feat: rotate signed Memos webhooks

This commit is contained in:
2026-07-19 05:55:43 +08:00
parent 2af99a4b43
commit e9190da834
4 changed files with 20 additions and 6 deletions
+4
View File
@@ -10,6 +10,10 @@ export async function createUserWebhook(baseUrl: string, token: string, userName
const user = userName.split("/").at(-1); if (!user) throw new Error("Invalid Memos user");
return (await request(`${base(baseUrl)}/users/${encodeURIComponent(user)}/webhooks`, token, { method: "POST", body: JSON.stringify(webhook) })).json() as Promise<{ name: string }>;
}
export async function deleteUserWebhook(baseUrl: string, token: string, userName: string, webhookName: string) {
const user = userName.split("/").at(-1), webhook = webhookName.split("/").at(-1); if (!user || !webhook) throw new Error("Invalid Memos webhook");
await request(`${base(baseUrl)}/users/${encodeURIComponent(user)}/webhooks/${encodeURIComponent(webhook)}`, token, { method: "DELETE" });
}
export async function verifyMemos(baseUrl: string, token: string) { await request(`${base(baseUrl)}/memos?pageSize=1`, token); }
export async function getMemosIdentity(baseUrl: string, token: string) {
let user: MemosIdentity;