ZodString import type {Blake3Hash} from '@fuzdev/fuz_util/hash_schemas.js'; Zod schema for a BLAKE3 hex hash — 64 lowercase hex characters (256-bit output).
Hash vocabulary — schemas, patterns, and guards, with no hashing.
This module is deliberately WASM-free. hash_blake3.ts and fact_hash.ts
import @fuzdev/blake3_wasm and kick off its initialization at module
scope, so importing either one to reach a validator drags the WASM binary
into the bundle and fetches it at page load. Client code that only needs to
*validate* a hash — action specs, wire schemas, cell payload shapes —
imports from here and pays nothing.
The hashing functions live next door: hash_blake3 in hash_blake3.ts,
the fact_hash_* producers in fact_hash.ts.
6 declarations
ZodString import type {Blake3Hash} from '@fuzdev/fuz_util/hash_schemas.js'; Zod schema for a BLAKE3 hex hash — 64 lowercase hex characters (256-bit output).
RegExp import {FACT_HASH_PATTERN} from '@fuzdev/fuz_util/hash_schemas.js'; Pattern for detecting a fact hash anywhere in text.
Has the global flag because the primary use is String.matchAll over
cell data / fact bytes. Callers that only need to validate a single
known string should use is_fact_hash instead — RegExp.test mutates
lastIndex on global patterns.
The trailing (?=blake3:|[^0-9a-f]|$) lookahead enforces a right
boundary so a 64-hex digest is matched only when it actually *ends*:
followed by a non-hex char, the end of string, or the start of another
blake3: ref. This rejects malformed over-long runs (blake3: + 65+
hex) rather than silently truncating them to a different valid-shaped
hash, while still matching two refs concatenated with no separator
(the blake3: alternative is needed because the prefix itself begins
with the hex char b). A bare (?![0-9a-f]) would instead drop the
first of two glued refs.
"blake3:" import {FACT_HASH_PREFIX} from '@fuzdev/fuz_util/hash_schemas.js'; Algorithm prefix on every fact hash. The colon is the separator.
string & $brand<"FactHash"> import type {FactHash} from '@fuzdev/fuz_util/hash_schemas.js'; z.infer<typeof FactHashSchema>[key: number]type string
$ZodBranded<ZodString, "FactHash", "out"> import {FactHashSchema} from '@fuzdev/fuz_util/hash_schemas.js'; Wire-form schema for a blake3:-prefixed fact hash. Branded so the
type system distinguishes a fact hash from any other string,
mirroring Uuid (id.ts). Construct only via fact_hash_bytes /
fact_hash_stream / FactHashSchema.parse(s) — direct string literals
don't satisfy the brand.
Both client-side (cell payloads) and server-side (DB-row hashes) consumers reuse this same schema.
(s: string): s is string & $brand<"FactHash"> import {is_fact_hash} from '@fuzdev/fuz_util/hash_schemas.js'; Type guard. Useful when receiving a hash from an external boundary —
narrows string to FactHash without going through Zod.
sstringboolean