mirror your GitHub repos to tangled.org automatically
1import { enqueue } from '~~/server/utils/queue'
2import { requireSession } from '~~/server/utils/server-session'
3
4/**
5 * Enqueue an SSH key rotation for the current `(did, installationId)`.
6 *
7 * The actual rotation runs in the worker: delete the existing
8 * `sh.tangled.publicKey` PDS record, drop the local row, generate a fresh
9 * keypair, publish the new public half. Doing this via the queue (rather
10 * than inline like the signup path) means a slow PDS doesn't tie up the
11 * request and we get retry semantics for free.
12 */
13export default defineEventHandler(async event => {
14 const session = await requireSession(event)
15 const row = await enqueue('atproto.publish-pubkey', {
16 did: session.did,
17 installationId: session.installationId,
18 force: true,
19 })
20 return { jobId: row?.id ?? null }
21})