Skip to content

The open source coding agent.

TypeScript

wip: share

Frank075ef0fa34a6
diff --git a/infra/app.ts b/infra/app.ts
index 15187920880..7215995badd 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 74ca22faf5f..572ac3cabda 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({})