import { type KeyObject } from "node:crypto"; import { SDJwtInstance, type Signer, type Verifier, type KbVerifier, type SdJwtPayload } from "@sd-jwt/core"; import { type PublicJwkP256 } from "./keys.js"; /** The hash algorithm we emit. `_sd_alg` records it; verification follows the token's. */ export declare const SD_HASH_ALG = "sha-256"; /** The package's SD-JWT hasher — one copy, shared with the intent-sign rail and its simulated * wallet, so every side hashes identically (a drift here reads as a bad signature). */ export declare const hasher: (data: string | ArrayBuffer, alg: string) => Uint8Array; /** ES256 signer over a P-256 key. `ieee-p1363` is the raw r‖s encoding JWS requires — node's * default for EC is DER, which would produce signatures no JWS verifier accepts. */ export declare function es256Signer(privateKey: KeyObject): Signer; /** * The package's one ES256 JWS check: the AP2 mandates, and the intent-sign rail's credential and * key binding, all verify through this function. * * It takes a `KeyObject` rather than a JWK so a caller holding a key that came from somewhere * other than a JWK (an X.509 certificate in a credential's `x5c`, say) can share it without a * round trip through JWK, which would quietly mangle any key that is not EC P-256. * * Any malformed input verifies as FALSE, never as a thrown error a caller might catch and treat * as "inconclusive". */ export declare function es256Verify(publicKey: KeyObject, data: string, sig: string): boolean; /** {@link es256Verify} against a known public JWK, in the shape @sd-jwt/core wants. */ export declare function es256Verifier(publicJwk: PublicJwkP256): Verifier; /** * Key-binding verifier: checks the KB-JWT against the key the mandate's OWN `cnf` names. * * This is the whole point of key binding — the holder's signature is checked against the * key the issuer committed to, not against a key supplied alongside the signature. A * mandate with no `cnf` cannot have a valid KB-JWT, and says so rather than passing. */ export declare const cnfKbVerifier: KbVerifier; export interface SdJwtOptions { /** Present ⇒ this instance can issue. */ privateKey?: KeyObject; /** Present ⇒ this instance can verify an issuer signature. */ publicJwk?: PublicJwkP256; /** The same, for a key that did not arrive as a JWK — a certificate's, or a chain link's. */ publicKey?: KeyObject; /** Present ⇒ this instance can append a key-bound delegation hop. */ holderKey?: KeyObject; } /** Build an SD-JWT instance wired to this package's crypto. */ export declare function sdJwtInstance(opts: SdJwtOptions): SDJwtInstance; /** * `sd_hash` over a compact SD-JWT — the digest a Payment Mandate's `transaction_id` and a * Checkout Mandate's `checkout_hash` carry. * * AP2 requires the algorithm to match the token's own `_sd_alg` when present, else * sha-256 (the same agility #146 established on the dc-payment rail). `alg` is the IANA * name; callers read it off the decoded token rather than assuming. */ export declare function digestToken(token: string, alg?: string): string; /** What a `@sd-jwt/core` failure was about, read from its message. */ export type LibraryRefusalCode = "expired" | "not-yet-valid" | "disclosure" | "malformed" | "signature"; /** * Name a `@sd-jwt/core` failure. The library reports every failure as one exception type, so the * message is all there is. `verifyMandate` and the chain verifier both read it through here, and * `sdjwt.test.ts` pins one real failure per message, so a library upgrade that rewords one turns a * test red instead of silently changing the code a caller switches on. Unknown messages fall to * `signature` — a refusal, never a pass. */ export declare function libraryRefusal(message: string): LibraryRefusalCode;