From 075ef0fa34a6b5a423c1a1adc2eb546fab3f5212 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 20 Oct 2025 16:17:49 -0400 Subject: [PATCH] wip: share --- infra/app.ts | 3 ++- packages/function/src/api.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/infra/app.ts b/infra/app.ts index 15187920..7215995b 100644 --- a/infra/app.ts +++ b/infra/app.ts @@ -3,6 +3,7 @@ import { domain } from "./stage" const GITHUB_APP_ID = new sst.Secret("GITHUB_APP_ID") const GITHUB_APP_PRIVATE_KEY = new sst.Secret("GITHUB_APP_PRIVATE_KEY") export const EMAILOCTOPUS_API_KEY = new sst.Secret("EMAILOCTOPUS_API_KEY") +const ADMIN_SECRET = new sst.Secret("ADMIN_SECRET") const bucket = new sst.cloudflare.Bucket("Bucket") export const api = new sst.cloudflare.Worker("Api", { @@ -12,7 +13,7 @@ export const api = new sst.cloudflare.Worker("Api", { WEB_DOMAIN: domain, }, url: true, - link: [bucket, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY], + link: [bucket, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY, ADMIN_SECRET], transform: { worker: (args) => { args.logpush = true diff --git a/packages/function/src/api.ts b/packages/function/src/api.ts index 74ca22fa..572ac3ca 100644 --- a/packages/function/src/api.ts +++ b/packages/function/src/api.ts @@ -137,7 +137,11 @@ export default new Hono<{ Bindings: Env }>() return c.json({}) }) .post("/share_delete_admin", async (c) => { - const id = c.env.SYNC_SERVER.idFromName("oVF8Rsiv") + const body = await c.req.json<{ sessionShortName: string; adminSecret: string }>() + const sessionShortName = body.sessionShortName + const adminSecret = body.adminSecret + if (adminSecret !== Resource.ADMIN_SECRET.value) throw new Error("Invalid admin secret") + const id = c.env.SYNC_SERVER.idFromName(sessionShortName) const stub = c.env.SYNC_SERVER.get(id) await stub.clear() return c.json({})