refactor(domain): reuse canonical ordering and digest owners

This commit is contained in:
morluto
2026-10-22 14:04:28 +08:00
parent c537c52c96
commit 51be954c4b
6 changed files with 37 additions and 55 deletions
@@ -829,15 +829,6 @@ export const registrationKey = (
]),
]);
/** Sort values by a deterministic unique semantic key. */
export const sortedUnique = <Value>(
values: readonly Value[],
key: (value: Value) => string,
): Value[] =>
[...new Map(values.map((value) => [key(value), value])).values()].sort(
(left, right) => compareUnicodeCodePoints(key(left), key(right)),
);
/** Hash exact UTF-8 source text. */
export const sha256Text = (value: string): string =>
createHash("sha256").update(value).digest("hex");