export type Hex = `0x${string}`; export type Address = `0x${string}`; export type VerifyMessageArgs = { address: Address; message: { raw: Hex; }; signature: Hex; }; export type VerifyMessageFn = (args: VerifyMessageArgs) => boolean | Promise; export type SetHeadersFn = (name: string, value: string) => void; export type VerifyRequestArgs = { request: Request; verifyMessage: VerifyMessageFn; nonceStore: NonceStore; policy?: VerifyPolicy; setHeaders?: SetHeadersFn; }; export type BindingMode = "request-bound" | "class-bound"; export type ReplayMode = "non-replayable" | "replayable"; export type ContentDigestMode = "auto" | "recompute" | "require" | "off"; export type SignOptions = { label?: string; binding?: BindingMode; replay?: ReplayMode; created?: number; expires?: number; ttlSeconds?: number; nonce?: string | (() => Promise); contentDigest?: ContentDigestMode; components?: string[]; }; export interface EthHttpSigner { address: Address; chainId: number; signMessage: (message: Uint8Array) => Promise; } export interface NonceStore { consume(key: string, ttlSeconds: number): Promise; } export type RoutePolicy = { methods?: string[]; replayable?: boolean; additionalRequestBoundComponents?: string[]; classBoundPolicies?: string[] | string[][]; }; export type RoutePolicyConfig = Record & { default?: RoutePolicy; }; export type VerifyPolicy = Omit & { label?: string; strictLabel?: boolean; replayableNotBefore?: (keyid: string) => number | null | undefined | Promise; replayableInvalidated?: (args: { keyid: string; signature: Hex; }) => boolean | Promise; maxSignatureVerifications?: number; now?: () => number; clockSkewSec?: number; maxValiditySec?: number; maxNonceWindowSec?: number; nonceKey?: (keyid: string, nonce: string) => string; }; export type ServerConfig = { max_validity_sec: number; route_policies?: RoutePolicyConfig; }; export type SignatureParams = { created: number; expires: number; keyid: string; nonce?: string; tag?: string; }; export type VerifyResult = { ok: true; address: Address; chainId: number; label: string; components: string[]; params: SignatureParams; replayable: boolean; binding: BindingMode; } | { ok: false; reason: VerifyFailReason; detail?: string; }; export type VerifyFailReason = "missing_headers" | "label_not_found" | "bad_signature_input" | "bad_signature" | "bad_keyid" | "bad_time" | "not_yet_valid" | "expired" | "validity_too_long" | "nonce_required" | "replayable_not_allowed" | "replayable_invalidation_required" | "replayable_not_before" | "replayable_invalidated" | "class_bound_not_allowed" | "not_request_bound" | "nonce_window_too_long" | "replay" | "digest_mismatch" | "digest_required" | "alg_not_allowed" | "bad_signature_bytes" | "bad_signature_check"; export type VerifierClientVerifyRequestArgs = { request: Request; policy?: VerifyPolicy; setHeaders?: SetHeadersFn; }; export type CreateVerifierClientArgs = { verifyMessage: VerifyMessageFn; nonceStore: NonceStore; defaults?: VerifyPolicy; }; export declare class Erc8128Error extends Error { code: "CRYPTO_UNAVAILABLE" | "INVALID_OPTIONS" | "UNSUPPORTED_REQUEST" | "BODY_READ_FAILED" | "DIGEST_REQUIRED" | "BAD_DERIVED_VALUE" | "BAD_HEADER_VALUE" | "PARSE_ERROR"; constructor(code: "CRYPTO_UNAVAILABLE" | "INVALID_OPTIONS" | "UNSUPPORTED_REQUEST" | "BODY_READ_FAILED" | "DIGEST_REQUIRED" | "BAD_DERIVED_VALUE" | "BAD_HEADER_VALUE" | "PARSE_ERROR", message: string); } export type AcceptSignatureRequestShape = Request | { hasQuery: boolean; hasBody: boolean; }; export type AcceptSignatureSignOptions = { binding: BindingMode; replay: ReplayMode; components: string[]; }; export type ParsedAcceptSignatureMember = { label: string; components: string[]; requiredParams: string[]; acceptSignatureValue: string; signOptions?: AcceptSignatureSignOptions; }; export type SelectAcceptSignatureRetryOptionsArgs = { members: Pick[]; requestShape: AcceptSignatureRequestShape; attemptedOptions?: Array | undefined>; }; export declare function parseAcceptSignatureHeader(headerValue: string, requestShape?: AcceptSignatureRequestShape): ParsedAcceptSignatureMember[]; export declare function normalizeAcceptSignatureSignOptions(options?: Partial): AcceptSignatureSignOptions; export declare function selectAcceptSignatureRetryOptions(args: SelectAcceptSignatureRetryOptionsArgs): AcceptSignatureSignOptions | null; export type DiscoveryDocumentConfig = { verificationEndpoint?: string; invalidationEndpoint?: string; maxValiditySec?: number; routePolicy?: Record & { default?: RoutePolicy; }; }; export type DiscoveryDocument = { max_validity_sec: number; verification_endpoint?: string; invalidation_endpoint?: string; route_policies?: RoutePolicyConfig; }; export declare function formatDiscoveryDocument(config: DiscoveryDocumentConfig): DiscoveryDocument; export type ParsedSignatureInputMember = { label: string; components: string[]; params: SignatureParams; signatureParamsValue: string; }; export declare function parseSignatureInputHeader(headerValue: string): ParsedSignatureInputMember[]; export declare function parseSignatureHeader(headerValue: string): Map; export type SelectedSignature = { label: string; components: string[]; params: { keyid: string; created: number; expires: number; nonce?: string; tag?: string; }; signatureParamsValue: string; sigB64: string; }; export declare function selectSignatureFromHeaders(args: { signatureInputHeader: string; signatureHeader: string; policy: Pick; }): { ok: true; selected: SelectedSignature[]; } | { ok: false; result: VerifyResult; }; export declare function formatKeyId(chainId: number, address: Address): string; export declare function parseKeyId(keyid: string): { chainId: number; address: Address; } | null; export declare function matchRoutePolicy(method: string, pathname: string, policies: RoutePolicyConfig | undefined): RoutePolicy | undefined; export type ResolvedPosture = { binding: BindingMode | undefined; replay: ReplayMode; components: string[] | undefined; }; export declare function resolvePosture(method: string, pathname: string, serverConfig: ServerConfig | null | undefined, mergedOptions: SignOptions & { replay: ReplayMode; }): ResolvedPosture; export declare function signRequest(input: RequestInfo, signer: EthHttpSigner, opts?: SignOptions): Promise; export declare function signRequest(input: RequestInfo, init: RequestInit | undefined, signer: EthHttpSigner, opts?: SignOptions): Promise; export declare function signedFetch(input: RequestInfo, signer: EthHttpSigner, opts?: SignOptions & { fetch?: typeof fetch; }): Promise; export declare function signedFetch(input: RequestInfo, init: RequestInit | undefined, signer: EthHttpSigner, opts?: SignOptions & { fetch?: typeof fetch; }): Promise; export type SignerClientOptions = Omit & { fetch?: typeof fetch; serverConfigs?: Record; preferReplayable?: boolean; }; export type FetchOptions = SignOptions & { fetch?: typeof fetch; }; export type SignerClient = { signRequest: { (input: RequestInfo, opts?: SignOptions): Promise; (input: RequestInfo, init: RequestInit | undefined, opts?: SignOptions): Promise; }; signedFetch: { (input: RequestInfo, opts?: FetchOptions): Promise; (input: RequestInfo, init: RequestInit | undefined, opts?: FetchOptions): Promise; }; fetch: { (input: RequestInfo, opts?: FetchOptions): Promise; (input: RequestInfo, init: RequestInit | undefined, opts?: FetchOptions): Promise; }; setServerConfig: (origin: string, config: ServerConfig | null) => void; }; export declare function createSignerClient(signer: EthHttpSigner, defaults?: SignerClientOptions): SignerClient; export type VerifierClientOptions = VerifyPolicy; export type VerifierClient = { verifyRequest: (args: VerifierClientVerifyRequestArgs) => Promise; }; export declare function createVerifierClient(args: CreateVerifierClientArgs): VerifierClient; export declare function verifyRequest(args: VerifyRequestArgs): Promise; export {};