Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/openconditions-contrib-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"check-types": "tsc --noEmit"
},
"dependencies": {
"canonicalize": "3.0.0"
"canonicalize": "4.0.0"
},
"devDependencies": {
"@types/node": "^26.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ describe("cross-repo conformance", () => {
it("canonicalClaimBytes matches the pinned RFC 8785 hex", () => {
expect(toHex(canonicalClaimBytes(FIXED_CLAIM))).toBe(PINNED_CLAIM_HEX);
});

it("rejects invalid Unicode through the public TypeError contract", () => {
expect(() => canonicalClaimBytes({ note: "\ud800" })).toThrow(TypeError);
});
});

describe("round-trip signing", () => {
Expand Down
7 changes: 5 additions & 2 deletions packages/openconditions-contrib-client/src/jcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const encoder = new TextEncoder();
* `canonicalize` package (the JCS reference implementation, EXACT version
* @openconditions/contrib-core uses); nothing here is hand-rolled.
*
* @throws TypeError when the value contains a non-finite number, is nested too
* deeply to canonicalize, or is not JSON-serializable at all
* @throws TypeError when the value contains a non-finite number or lone
* surrogate, is nested too deeply to canonicalize, or is not JSON-serializable at all
* (undefined, function, symbol); Error on a circular reference.
*/
export function canonicalClaimBytes(claim: unknown): Uint8Array<ArrayBuffer> {
Expand All @@ -30,6 +30,9 @@ export function canonicalClaimBytes(claim: unknown): Uint8Array<ArrayBuffer> {
if (err instanceof Error && /NaN|Infinity/.test(err.message)) {
throw new TypeError("canonicalClaimBytes: non-finite number in value");
}
if (err instanceof Error && /Lone surrogate/.test(err.message)) {
throw new TypeError("canonicalClaimBytes: lone surrogate in value");
}
throw err;
}
if (text === undefined) {
Expand Down
11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.