refactor(javascript): group domain semantics and contracts (#907)

This commit is contained in:
ysopwnable
2026-10-07 17:16:58 +08:00
committed by GitHub
parent d5f28fb29c
commit f6a58f1062
253 changed files with 432 additions and 410 deletions
@@ -0,0 +1,17 @@
import { createHash } from "node:crypto";
import canonicalize from "canonicalize";
/** Canonically encode one export-shape comparison value. */
export const canonicalExportShapeValue = (value: unknown): string => {
const encoded = canonicalize(value);
if (encoded === undefined)
throw new TypeError(
"JavaScript export shape comparison could not canonicalize data",
);
return encoded;
};
/** Derive one deterministic SHA-256 comparison identifier component. */
export const digestExportShapeValue = (value: unknown): string =>
createHash("sha256").update(canonicalExportShapeValue(value)).digest("hex");