import { a as StandardSchemaProps, i as ParseResult, n as JsonSchema, o as ValidBrand, t as Id } from "./types-hGBnCpJj.mjs"; //#region src/codecs/digest/key.d.ts /** Wire encoding for digest operator key material (not Crockford base32). */ type DigestKeyFormat = "hex" | "base64url"; declare const digestKeyBrand: unique symbol; /** * Opaque imported handle for one operator Digest key. * * Holds a single HMAC-SHA-256 key derived via HKDF under the domain-separation * label `@smonn/ids/digest/hmac`. The underlying `webcrypto.CryptoKey` is held internally and * never exposed to callers. Obtain handles via {@link importDigestKey} and pass * them to `createDigestId` as the `key` option. * * Unlike the other keyed codecs, the Digest codec holds exactly one key — there * is no keyring. Re-keying is a deliberate, breaking operator action (every ID * changes), never an in-band rotation. * * Distinct from the **Opaque key**, **Wrapping key**, and **Signing key** — the * same raw bytes imported as a `DigestKey` are cryptographically independent of * any other codec's key. */ type DigestKey = { readonly [digestKeyBrand]: "DigestKey"; }; /** * Import raw operator key material into a {@link DigestKey} handle. * * Derives a single HMAC-SHA-256 key via HKDF under the domain-separation label * `@smonn/ids/digest/hmac`. Accepts 16, 24, or 32 bytes. To store or transport key * material, use {@link encodeDigestKey} / {@link decodeDigestKey} * (`"hex"` or `"base64url"` — not Crockford base32). * * @param bytes - 16, 24, or 32 raw key bytes. * @throws {IdsError} `invalid_key_length` if `bytes.length` is not 16, 24, or 32. */ declare function importDigestKey(bytes: Uint8Array): Promise; /** * Encode raw digest operator key material for storage in env vars or secret managers. * * Supports `"hex"` (lowercase) and `"base64url"`. Output round-trips through * {@link decodeDigestKey} back to the original bytes. * * @throws {IdsError} `invalid_key_format` if `format` is not `"hex"` or `"base64url"`. * @throws {IdsError} `invalid_key_length` if `bytes.length` is not 16, 24, or 32. */ declare function encodeDigestKey(bytes: Uint8Array, format: DigestKeyFormat): string; /** * Decode key material emitted by {@link encodeDigestKey} back to raw bytes. * * The result can be passed directly to {@link importDigestKey}. * * @throws {IdsError} `invalid_key_format` if `format` is not `"hex"` or `"base64url"`. * @throws {IdsError} `invalid_key_encoding` if the string is malformed for its format. * @throws {IdsError} `invalid_key_length` if the decoded bytes are not 16, 24, or 32 bytes. */ declare function decodeDigestKey(encoded: string, format: DigestKeyFormat): Uint8Array; //#endregion //#region src/codecs/digest/index.d.ts /** * Configuration options for a Digest codec instance. */ type DigestOptions = { /** * Non-secret, required namespace. The same material under a different * `ns` yields a different ID, so one key can serve multiple unlinkable namespaces. * Must be non-empty and not whitespace-only. */ ns: string; /** * Single operator digest key. The Digest codec holds exactly one key — there * is no keyring. Re-keying is a deliberate, breaking operator action. */ key: DigestKey; /** If true, silences the duplicate-brand warning in non-production environments. */ allowDuplicateBrand?: boolean; }; /** * Codec returned by {@link createDigestId}. * * Maps caller **material** to a stable public ID under one **Digest key**: * the same material always yields the same ID, and the material cannot be * recovered from the ID (**equality leakage** is the intended property). * * - `digest` is async (WebCrypto HMAC). * - `is`, `parse`, `safeParse`, `toJsonSchema`, and `~standard` are synchronous * and require no key material — they validate prefix and base32 shape only. * - There is no reverse method (`unwrap`, `verify`, `extractTimestamp`) — the * codec is one-way by definition. */ type DigestCodec = { /** * Digest `material` into a stable canonical {@link Id}. * * The same `(brand, ns, key, material)` tuple always returns the same ID. * Strings are UTF-8 encoded; byte arrays are used as-is. */ digest(material: string | Uint8Array): Promise>; /** Strict type guard: `true` only for already-canonical `Id` strings. */ is(value: unknown): value is Id; /** Normalise to canonical form, or throw on parse failure. */ parse(value: unknown): Id; /** Normalise to canonical form, or return `{ ok: false, error }`. */ safeParse(value: unknown): ParseResult; /** JSON Schema for the canonical wire form (`pattern` is canonical-only). */ toJsonSchema(): JsonSchema; /** Standard Schema validate entry point. */ readonly "~standard": StandardSchemaProps; /** * Converts a trusted `Id` to an RFC 9562 canonical (lowercase, hyphenated) * UUID string by reinterpreting the 16-byte payload verbatim. Total — cannot fail. * Returns a plain `string` (brand is shed). See ADR-0024. */ toUUID(id: Id): string; /** * Parses a UUID string into an `Id`. Accepts case-insensitive `8-4-4-4-12` * hyphenated form only. Throws `IdsError` with `code: "invalid_id"` on bad input. * See ADR-0024. */ fromUUID(value: string): Id; /** * Non-throwing UUID parse. Returns `{ ok: true, id }` or * `{ ok: false, error: "not_string" | "invalid_uuid" }`. See ADR-0024. */ safeFromUUID(value: unknown): ParseResult; }; /** * Construct a {@link DigestCodec} for `brand`. * * `opts.ns` is the required namespace — the same material under a * different `ns` yields a different ID. `opts.key` is the single operator * Digest key; there is no keyring. * * @example * ```ts * const key = await importDigestKey(new Uint8Array(32)); * const idk = createDigestId("idk", { ns: "checkout", key }); * * const id = await idk.digest("order-123"); // Id<"idk"> * idk.is(id); // true * ``` */ declare function createDigestId(brand: Brand & ValidBrand, opts: DigestOptions): DigestCodec; //#endregion export { DigestCodec, type DigestKey, type DigestKeyFormat, DigestOptions, createDigestId, decodeDigestKey, encodeDigestKey, importDigestKey }; //# sourceMappingURL=digest.d.mts.map