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] \\
|
[--method POST] \\
|
||||||
[--token <outbound-bearer>]
|
[--token <outbound-bearer>]
|
||||||
|
|
||||||
|
deno task webhooks list
|
||||||
|
|
||||||
|
deno task webhooks delete --id <id>
|
||||||
|
|
||||||
deno task webhooks delete-all
|
deno task webhooks delete-all
|
||||||
|
|
||||||
Inputs (env or flag, env preferred):
|
Inputs (env or flag, env preferred):
|
||||||
@@ -150,6 +154,32 @@ const main = async () => {
|
|||||||
return;
|
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") {
|
if (command === "delete-all") {
|
||||||
const res = await fetch(`${api}/${session.did}/webhooks`, {
|
const res = await fetch(`${api}/${session.did}/webhooks`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
|
|||||||
Reference in New Issue
Block a user