chore(scripts): add list and delete commands to manage-webhooks
`deno task webhooks list` prints the authenticated DID's subscriptions (id, url, method, verb). `deno task webhooks delete --id <id>` removes a single one — pair with `list` to pick which to drop instead of nuking everything via delete-all.
This commit is contained in:
@@ -18,6 +18,10 @@ Usage:
|
||||
[--method POST] \\
|
||||
[--token <outbound-bearer>]
|
||||
|
||||
deno task webhooks list
|
||||
|
||||
deno task webhooks delete --id <id>
|
||||
|
||||
deno task webhooks delete-all
|
||||
|
||||
Inputs (env or flag, env preferred):
|
||||
@@ -150,6 +154,32 @@ const main = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "list") {
|
||||
const res = await fetch(`${api}/${session.did}/webhooks`, {
|
||||
headers: { "Authorization": `Bearer ${session.accessJwt}` },
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`list failed (${res.status}): ${await res.text()}`);
|
||||
Deno.exit(1);
|
||||
}
|
||||
console.log(JSON.stringify(await res.json(), null, 2));
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "delete") {
|
||||
const id = flags.id ?? die("--id is required for delete");
|
||||
const res = await fetch(`${api}/${session.did}/webhooks/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { "Authorization": `Bearer ${session.accessJwt}` },
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`delete failed (${res.status}): ${await res.text()}`);
|
||||
Deno.exit(1);
|
||||
}
|
||||
console.log(`[done] webhook ${id} deleted`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "delete-all") {
|
||||
const res = await fetch(`${api}/${session.did}/webhooks`, {
|
||||
method: "DELETE",
|
||||
|
||||
Reference in New Issue
Block a user