feat: add optional bearer token support for webhook subscriptions
Token is stored in the DB but never returned in API responses (write-only). fireWebhooks() sends Authorization: Bearer <token> header when present.
This commit is contained in:
@@ -43,13 +43,13 @@ router.post("/notes/feed", async (ctx) => {
|
||||
router.post("/:did/webhooks", async (ctx) => {
|
||||
const { did } = ctx.params;
|
||||
const body = await ctx.request.body.json();
|
||||
const { method, url } = body ?? {};
|
||||
const { method, url, token } = body ?? {};
|
||||
if (!method || !url) {
|
||||
ctx.response.status = 400;
|
||||
ctx.response.body = { error: "method and url are required" };
|
||||
return;
|
||||
}
|
||||
const subscription = addWebhookSubscription({ did, method, url });
|
||||
const subscription = addWebhookSubscription({ did, method, url, token });
|
||||
ctx.response.status = 201;
|
||||
ctx.response.body = subscription;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user