@theventures/caret
Version:
Unofficial Node.js API client for the Caret HTTP API
24 lines • 1 kB
TypeScript
import type { WebhookEventMap, WebhookEventType } from "../types/webhooks.js";
export interface VerifyRequestResult<T extends WebhookEventType = WebhookEventType> {
isValid: boolean;
data?: WebhookEventMap[T];
error?: string;
}
export declare class WebhookVerifier {
private secret;
constructor(secret?: string);
/**
* Verify a webhook signature using HMAC-SHA256
* @param payload - The webhook payload (request body)
* @param signature - The signature from X-Caret-Signature header
* @returns true if the signature is valid
*/
verify(payload: string | Buffer, signature: string): boolean;
/**
* Verify a webhook request and parse the typed data
* @param request - The incoming Request object
* @returns Object containing isValid flag and parsed typed data if valid
*/
verifyRequest<T extends WebhookEventType = WebhookEventType>(request: Request): Promise<VerifyRequestResult<T>>;
}
//# sourceMappingURL=verifier.d.ts.map