import type { BillingWebhookEvent } from "@autlantic/payments-recurring-core"; import { BILLING_WEBHOOK_SIGNATURE_HEADER } from "@autlantic/payments-recurring-core"; export { BILLING_WEBHOOK_SIGNATURE_HEADER }; /** Default skew for timestamped webhook signatures (5 minutes). */ export declare const BILLING_WEBHOOK_TOLERANCE_SEC = 300; export type WebhookVerifyFailureReason = "missing_header" | "empty_secret" | "length_mismatch" | "invalid_signature" | "compare_error" | "timestamp_expired" | "timestamp_invalid" | "legacy_signature_rejected"; export type WebhookVerifyResult = { ok: true; } | { ok: false; reason: WebhookVerifyFailureReason; }; export type WebhookParseFailureReason = "invalid_json" | "missing_fields"; export type WebhookParseResult = { ok: true; event: BillingWebhookEvent; } | { ok: false; reason: WebhookParseFailureReason; }; /** * Sign webhook body. Emits Stripe-style `t=,v1=` where * hmac = HMAC-SHA256(secret, `${t}.${rawBody}`). */ export declare function signBillingWebhookBody(secret: string, rawBody: string, timestampSec?: number): string; export declare function signBillingWebhook(secret: string, event: BillingWebhookEvent): { body: string; signature: string; }; /** * Verify webhook HMAC. Prefer {@link verifyBillingWebhookDetailed} when you need * a failure reason for logs / metrics. * * Argument order: `(secret, rawBody, signatureHeader)`. * Accepts timestamped `t=…,v1=…` and legacy raw hex (backward compatible). */ export declare function verifyBillingWebhook(secret: string, rawBody: string, signatureHeader: string | null | undefined, options?: { toleranceSec?: number; nowSec?: number; }): boolean; /** Same as {@link verifyBillingWebhook}, with structured failure reasons. */ export declare function verifyBillingWebhookDetailed(secret: string, rawBody: string, signatureHeader: string | null | undefined, options?: { toleranceSec?: number; nowSec?: number; }): WebhookVerifyResult; /** * Throw {@link AutlanticBillingError} when verification fails. * Useful in Express / Next route handlers. */ export declare function assertBillingWebhook(secret: string, rawBody: string, signatureHeader: string | null | undefined): void; export declare function parseBillingWebhookEvent(rawBody: string): BillingWebhookEvent | null; /** Parse webhook JSON with a structured failure reason. */ export declare function parseBillingWebhookEventDetailed(rawBody: string): WebhookParseResult; //# sourceMappingURL=webhook.d.ts.map