Skip to content
Open
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
6 changes: 5 additions & 1 deletion conformance/golden/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ function stableStringify(value: unknown): string {
}

if (value && typeof value === 'object') {
// Sort by Unicode code point, never by locale: this string feeds the
// challenge-id HMAC, and localeCompare both diverges from the other
// SDKs (which sort by code point) and varies with the runtime's ICU
// data, making the reference id environment-dependent.
const entries = Object.entries(value as Record<string, unknown>).sort(([left], [right]) =>
left.localeCompare(right),
left < right ? -1 : left > right ? 1 : 0,
)
return `{${entries
.map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item)}`)
Expand Down
24 changes: 24 additions & 0 deletions conformance/vectors/challenge-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,30 @@
}
},
"expected": "WqQuVsD-d0Uij4uzx-W_MdUc4wo6wpIuvHNvPIw6G9M"
},
{
"name": "mixed_case_key_ordering",
"description": "Canonical request JSON must sort keys by Unicode code point (uppercase before lowercase), not locale collation",
"tags": [
"happy-path",
"canonicalization"
],
"input": {
"secretKey": "case-sensitive-key",
"realm": "api.example.com",
"method": "tempo",
"intent": "charge",
"request": {
"amount": "1000000",
"Currency": "USD",
"ZONE": "eu-1",
"network": {
"chainId": 42431,
"Layer": "L2"
}
}
},
"expected": "WXjRL_umEnaXW00KDPpLZrhhlolHNkHK_I5y-cIShdE"
}
]
}