// Admin: list every webhook subscription via the Remanso API. Requires the // authenticated DID to be in the server-side ADMIN_DIDS allowlist. // // deno task webhooks:all // // Inputs (env or flag, env preferred): // ATPROTO_HANDLE / --handle e.g. alice.eurosky.social // ATPROTO_APP_PASSWORD / --app-password app password (NOT your account password) // REMANSO_API / --api default: https://api.remanso.space const HELP = ` Usage: deno task webhooks:all Inputs (env or flag, env preferred): ATPROTO_HANDLE / --handle your AT Protocol handle ATPROTO_APP_PASSWORD / --app-password app password (NOT your account password) REMANSO_API / --api default: https://api.remanso.space `; import { parseArgs, sessionFromFlagsOrEnv } from "./_atproto-session.ts"; const die = (msg: string): never => { console.error(`error: ${msg}`); console.error(HELP); Deno.exit(1); }; const main = async () => { const flags = parseArgs(Deno.args); if (flags.help === "true" || flags.h === "true") { console.log(HELP); Deno.exit(0); } const { session, api } = await sessionFromFlagsOrEnv(flags).catch( (e: Error) => die(e.message), ); const res = await fetch(`${api}/admin/webhooks`, { headers: { "Authorization": `Bearer ${session.accessJwt}` }, }); if (!res.ok) { console.error(`list-all failed (${res.status}): ${await res.text()}`); Deno.exit(1); } const rows = await res.json(); console.log(JSON.stringify(rows, null, 2)); console.error(`[done] ${rows.length} subscription(s) at ${api}`); }; await main();