/** Identifies the app being attested. */ export interface AppInfo { /** Apple App ID in the format `TEAMID.bundleId`. */ appId: string; /** Set to `true` when verifying attestations from the development environment. */ developmentEnv?: boolean; } /** Successful attestation verification result. */ export interface AttestationResult { /** PEM-encoded ECDSA P-256 public key extracted from the attestation. */ publicKeyPem: string; /** Raw App Attest receipt bytes for server-side refresh. */ receipt: Uint8Array; /** Initial sign count (always `0` for attestation). */ signCount: number; } /** Options for {@linkcode verifyAttestation}. */ export interface VerifyAttestationOptions { /** Override date for certificate chain validation (for testing with expired certs). */ checkDate?: Date; } /** * Minimal CBOR decoder for Apple App Attest attestation objects. * * Apple's CBOR encoding of the attestation object contains a receipt field whose * byte-string length header is sometimes incorrect (overstated by ~21 bytes). * Standard CBOR libraries (cborg) fail to decode this. We use a strict * structural parser for the known attestation object layout: * { "fmt": text, "attStmt": { "x5c": [bstr, ...], "receipt": bstr }, "authData": bstr } * * The parser walks the maps entry by entry with bounds-checked headers, * accepting keys in any order and rejecting duplicates, unknown keys, * indefinite lengths, and trailing bytes. The single tolerated * malformation is the overstated receipt length, repaired in one * documented code path ({@linkcode readReceiptWithRepair}). */ export interface AttestationCbor { fmt: string; attStmt: { x5c: Uint8Array[]; receipt: Uint8Array; }; authData: Uint8Array; } /** * Decode an Apple App Attest attestation object from raw CBOR bytes. * * Strict structural walk: the top-level map must contain exactly * fmt/attStmt/authData (any order) and attStmt exactly x5c/receipt (any * order); duplicate keys, unknown keys, indefinite lengths, and trailing * bytes are rejected. The single tolerated malformation is Apple's * overstated receipt length — see {@linkcode readReceiptWithRepair}. * * @throws {AttestationError} with code `INVALID_FORMAT` if the data is not * a valid attestation CBOR structure. */ export declare function decodeAttestationCbor(data: Uint8Array): AttestationCbor; /** * Verify an Apple App Attest attestation. * * Implements the full server-side verification described in * [Apple's documentation](https://developer.apple.com/documentation/devicecheck/validating_apps_that_connect_to_your_server): * CBOR decode, certificate chain validation, nonce check, key extraction, * AAGUID check, and credential ID verification. * * **Important:** The `clientDataHash` parameter corresponds to Apple's * `clientDataHash` argument on `DCAppAttestService.attestKey(_:clientDataHash:)`. * Most client SDKs (Expo's `attestKeyAsync`, native wrappers) hash the * caller's challenge with SHA-256 before passing to Apple. If you are using * the {@linkcode withAttestation} middleware, this hashing is handled * automatically. If calling `verifyAttestation` directly, you must pass * `SHA-256(challenge)` — not the raw challenge — as `clientDataHash`. * * @throws {AttestationError} If any verification step fails. */ export declare function verifyAttestation(appInfo: AppInfo, keyId: string, clientDataHash: Uint8Array | string, attestation: Uint8Array | string, options?: VerifyAttestationOptions): Promise;