open-agreements
Version:
Open-source legal template filling CLI and library
29 lines • 1.4 kB
TypeScript
/**
* Compute a portable content fingerprint for a paragraph's raw visible text.
*
* Algorithm: `sha256:nfkc:` + first 32 hex chars of
* `sha256( stripInvisibles(NFKC(text)).replace(/\s+/g, " ").trim() )`.
*
* Order matters:
* 1. NFKC first so compatibility whitespace (NBSP, ideographic space) is
* normalized to ASCII space and ligatures/full-width Latin decompose.
* 2. Strip Cf-category invisibles (soft hyphen, ZWJ, ZWNJ, LRM/RLM, bidi
* controls, variation selectors, BOM) so byte-level round-trip noise
* doesn't change the hash without changing the visible glyphs.
* 3. Whitespace collapse + trim.
*
* Case is preserved — citation systems need to distinguish "Section 5" from
* "section 5". Curly quotes / en-dashes / ellipses are NOT folded to ASCII;
* legal practice distinguishes them.
*
* The output is read-only metadata, not an edit anchor. Edit tools accept only
* `_bk_*` paragraph IDs.
*
* The 128-bit truncation (32 hex) is collision-safe at any realistic
* citation-corpus scale; the `sha256:nfkc:` prefix reserves space for future
* algorithm bumps (e.g. `sha256:nfkc-strip:`). Consumers SHOULD store and
* compare the full prefixed string so an algorithm bump cleanly invalidates
* old hashes.
*/
export declare function computeContentFingerprint(rawVisibleText: string): string;
//# sourceMappingURL=content_fingerprint.d.ts.map