/** Type declarations for the single-file Node verification SDK. */

export declare class HookgetVerificationError extends Error {
  readonly reason:
    | 'missing_headers'
    | 'bad_timestamp'
    | 'timestamp_out_of_tolerance'
    | 'no_matching_signature';
  constructor(reason: string, message: string);
}

export interface VerifyOptions {
  /** Replay window in seconds. Defaults to 300. */
  toleranceSeconds?: number;
  /** Unix seconds. Present so tests do not have to sleep. */
  now?: number;
}

export interface Verified {
  id: string;
  timestamp: number;
}

export declare function sign(
  secret: string,
  id: string,
  timestamp: number,
  body: string,
): string;

export declare function verify(
  secrets: string | readonly string[],
  headers: Record<string, string | string[] | undefined>,
  body: string | Uint8Array,
  opts?: VerifyOptions,
): Verified;

export declare function isValid(
  secrets: string | readonly string[],
  headers: Record<string, string | string[] | undefined>,
  body: string | Uint8Array,
  opts?: VerifyOptions,
): boolean;
