Skip to content

DigestCodec

DigestCodec<Brand> = object

Defined in: src/codecs/digest/index.ts:57

Codec returned by 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.

Brand extends string

readonly ~standard: StandardSchemaProps<Brand>

Defined in: src/codecs/digest/index.ts:74

Standard Schema validate entry point.

digest(material): Promise<Id<Brand>>

Defined in: src/codecs/digest/index.ts:64

Digest material into a stable canonical Id.

The same (brand, ns, key, material) tuple always returns the same ID. Strings are UTF-8 encoded; byte arrays are used as-is.

string | Uint8Array<ArrayBufferLike>

Promise<Id<Brand>>


fromUUID(value): Id<Brand>

Defined in: src/codecs/digest/index.ts:86

Parses a UUID string into an Id<Brand>. Accepts case-insensitive 8-4-4-4-12 hyphenated form only. Throws IdsError with code: "invalid_id" on bad input. See ADR-0024.

string

Id<Brand>


is(value): value is Id<Brand>

Defined in: src/codecs/digest/index.ts:66

Strict type guard: true only for already-canonical Id<Brand> strings.

unknown

value is Id<Brand>


parse(value): Id<Brand>

Defined in: src/codecs/digest/index.ts:68

Normalise to canonical form, or throw on parse failure.

unknown

Id<Brand>


safeFromUUID(value): ParseResult<Brand>

Defined in: src/codecs/digest/index.ts:91

Non-throwing UUID parse. Returns { ok: true, id } or { ok: false, error: "not_string" | "invalid_uuid" }. See ADR-0024.

unknown

ParseResult<Brand>


safeParse(value): ParseResult<Brand>

Defined in: src/codecs/digest/index.ts:70

Normalise to canonical form, or return { ok: false, error }.

unknown

ParseResult<Brand>


toJsonSchema(): JsonSchema

Defined in: src/codecs/digest/index.ts:72

JSON Schema for the canonical wire form (pattern is canonical-only).

JsonSchema


toUUID(id): string

Defined in: src/codecs/digest/index.ts:80

Converts a trusted Id<Brand> 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.

Id<Brand>

string