UNPKG

1.42 kBTypeScriptView Raw
1import { createEventHandler } from "./event-handler/index.js";
2import type { EmitterWebhookEvent, EmitterWebhookEventName, HandlerFunction, RemoveHandlerFunction, Options, WebhookError, WebhookEventHandlerError, EmitterWebhookEventWithStringPayloadAndSignature } from "./types.js";
3export { createNodeMiddleware } from "./middleware/node/index.js";
4export { emitterEventNames } from "./generated/webhook-names.js";
5declare class Webhooks<TTransformed = unknown> {
6 sign: (payload: string) => Promise<string>;
7 verify: (eventPayload: string, signature: string) => Promise<boolean>;
8 on: <E extends EmitterWebhookEventName>(event: E | E[], callback: HandlerFunction<E, TTransformed>) => void;
9 onAny: (callback: (event: TTransformed extends unknown ? EmitterWebhookEvent : EmitterWebhookEvent & TTransformed) => any) => void;
10 onError: (callback: (event: WebhookEventHandlerError<TTransformed>) => any) => void;
11 removeListener: <E extends EmitterWebhookEventName | "*">(event: E | E[], callback: RemoveHandlerFunction<E, TTransformed>) => void;
12 receive: (event: EmitterWebhookEvent) => Promise<void>;
13 verifyAndReceive: (options: EmitterWebhookEventWithStringPayloadAndSignature) => Promise<void>;
14 constructor(options: Options<TTransformed> & {
15 secret: string;
16 });
17}
18export { createEventHandler, Webhooks, type EmitterWebhookEvent, type EmitterWebhookEventName, type WebhookError, };