From 6d6003da868974b5087ddc60304d11218a3db339 Mon Sep 17 00:00:00 2001 From: Dax Date: Sun, 18 Oct 2026 23:51:27 -0400 Subject: [PATCH] chore(function): remove legacy share write endpoints (#56939) --- .github/ISSUE_TEMPLATE/bug-report.yml | 6 +- infra/app.ts | 3 - packages/function/src/api.ts | 80 --------------------------- 3 files changed, 3 insertions(+), 86 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index da82bde2e12d..00f8fb63a935 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -41,9 +41,9 @@ body: - type: textarea id: screenshot-or-link attributes: - label: Screenshot and/or share link - description: Run `/share` to get a share link, or attach a screenshot - placeholder: Paste link or drag and drop screenshot here + label: Screenshot + description: Attach a screenshot or recording + placeholder: Drag and drop screenshot here validations: required: false diff --git a/infra/app.ts b/infra/app.ts index 5c2b51ac9981..2f18f68dbf17 100644 --- a/infra/app.ts +++ b/infra/app.ts @@ -13,9 +13,6 @@ const bucket = new sst.cloudflare.Bucket("Bucket") export const api = new sst.cloudflare.Worker("Api", { domain: `api.${domain}`, handler: "packages/function/src/api.ts", - environment: { - WEB_DOMAIN: domain, - }, url: true, link: [ bucket, diff --git a/packages/function/src/api.ts b/packages/function/src/api.ts index e57a567dca24..e5bbfd05313c 100644 --- a/packages/function/src/api.ts +++ b/packages/function/src/api.ts @@ -1,6 +1,5 @@ import { Hono } from "hono" import { DurableObject } from "cloudflare:workers" -import { randomUUID } from "node:crypto" import { jwtVerify, createRemoteJWKSet } from "jose" import { createAppAuth } from "@octokit/auth-app" import { Octokit } from "@octokit/rest" @@ -10,7 +9,6 @@ import { parseRepositoryClaim } from "./github" type Env = { SYNC_SERVER: DurableObjectNamespace Bucket: R2Bucket - WEB_DOMAIN: string } export class SyncServer extends DurableObject { @@ -43,40 +41,6 @@ export class SyncServer extends DurableObject { ws.close(code, "Durable Object is closing WebSocket") } - async publish(key: string, content: any) { - const sessionID = await this.getSessionID() - if ( - !key.startsWith(`session/info/${sessionID}`) && - !key.startsWith(`session/message/${sessionID}/`) && - !key.startsWith(`session/part/${sessionID}/`) - ) - return new Response("Error: Invalid key", { status: 400 }) - - // store message - await this.env.Bucket.put(`share/${key}.json`, JSON.stringify(content), { - httpMetadata: { - contentType: "application/json", - }, - }) - await this.ctx.storage.put(key, content) - const clients = this.ctx.getWebSockets() - console.log("SyncServer publish", key, "to", clients.length, "subscribers") - for (const client of clients) { - client.send(JSON.stringify({ key, content })) - } - } - - public async share(sessionID: string) { - let secret = await this.getSecret() - if (secret) return secret - secret = randomUUID() - - await this.ctx.storage.put("secret", secret) - await this.ctx.storage.put("sessionID", sessionID) - - return secret - } - public async getData() { const data = (await this.ctx.storage.list()) as Map return Array.from(data.entries()) @@ -84,14 +48,6 @@ export class SyncServer extends DurableObject { .map(([key, content]) => ({ key, content })) } - public async assertSecret(secret: string) { - if (secret !== (await this.getSecret())) throw new Error("Invalid secret") - } - - private async getSecret() { - return this.ctx.storage.get("secret") - } - private async getSessionID() { return this.ctx.storage.get("sessionID") } @@ -116,28 +72,6 @@ export class SyncServer extends DurableObject { export default new Hono<{ Bindings: Env }>() .get("/", (c) => c.text("Hello, world!")) - .post("/share_create", async (c) => { - const body = await c.req.json<{ sessionID: string }>() - const sessionID = body.sessionID - const short = SyncServer.shortName(sessionID) - const id = c.env.SYNC_SERVER.idFromName(short) - const stub = c.env.SYNC_SERVER.get(id) - const secret = await stub.share(sessionID) - return c.json({ - secret, - url: `https://${c.env.WEB_DOMAIN}/s/${short}`, - }) - }) - .post("/share_delete", async (c) => { - const body = await c.req.json<{ sessionID: string; secret: string }>() - const sessionID = body.sessionID - const secret = body.secret - const id = c.env.SYNC_SERVER.idFromName(SyncServer.shortName(sessionID)) - const stub = c.env.SYNC_SERVER.get(id) - await stub.assertSecret(secret) - await stub.clear() - return c.json({}) - }) .post("/share_delete_admin", async (c) => { const body = await c.req.json<{ sessionShortName: string; adminSecret: string }>() const sessionShortName = body.sessionShortName @@ -148,20 +82,6 @@ export default new Hono<{ Bindings: Env }>() await stub.clear() return c.json({}) }) - .post("/share_sync", async (c) => { - const body = await c.req.json<{ - sessionID: string - secret: string - key: string - content: any - }>() - const name = SyncServer.shortName(body.sessionID) - const id = c.env.SYNC_SERVER.idFromName(name) - const stub = c.env.SYNC_SERVER.get(id) - await stub.assertSecret(body.secret) - await stub.publish(body.key, body.content) - return c.json({}) - }) .get("/share_poll", async (c) => { const upgradeHeader = c.req.header("Upgrade") if (!upgradeHeader || upgradeHeader !== "websocket") {