export type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;

export interface VerifyWebhookOptions {
  /** The RAW request body (string or bytes), before JSON parsing. */
  body: string | Uint8Array | ArrayBuffer;
  headers: WebhookHeaders;
  secret?: string;
  /** Several secrets while you rotate one. */
  secrets?: string[];
  /** Default 300 seconds. */
  toleranceSeconds?: number;
  now?: number;
}

export declare class WebhookVerificationError extends Error {
  readonly code: "missing_headers" | "stale_timestamp" | "bad_signature";
}

export declare function verifyWebhook(options: VerifyWebhookOptions): Promise<{ webhookId: string | null; timestamp: number }>;
export declare function parseWebhook<T = unknown>(options: VerifyWebhookOptions): Promise<{ webhookId: string | null; timestamp: number; payload: T }>;
