UNPKG

@owlrelay/webhook

Version:

OwlRelay Webhook utilities

47 lines (41 loc) 1.08 kB
import { Fetch } from 'ofetch'; declare function signBody({ bodyBuffer, secret, }: { bodyBuffer: ArrayBuffer; secret: string; }): Promise<{ signature: string; }>; declare function verifySignature({ bodyBuffer, signature: base64Signature, secret, }: { bodyBuffer: ArrayBuffer; signature: string; secret: string; }): Promise<boolean>; type Address = { address?: string; name?: string; }; type Email = { from: Address; to?: Address[]; cc?: Address[]; subject?: string; text?: string; html?: string; attachments?: { filename: string | null; mimeType: string; content: ArrayBuffer | string; }[]; }; declare function triggerWebhook({ email, webhookUrl, webhookSecret, httpClient, }: { email: Email; webhookUrl: string; webhookSecret?: string | null; httpClient?: Fetch; }): Promise<Response>; declare function serializeEmailForWebhook({ email }: { email: Email; }): { body: FormData; }; export { serializeEmailForWebhook, signBody, triggerWebhook, verifySignature };