Skip to content

Commit a5ceaf8

Browse files
rodrigokggazzo
andauthored
fix: handling of special characters on canonical json (#282)
Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz>
1 parent 9b5c9df commit a5ceaf8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/core/src/utils/signJson.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ export async function verifySignaturesFromRemote<
172172
return true;
173173
}
174174

175+
/**
176+
* @deprecated Use encodeCanonicalJsonCrypto instead
177+
*/
175178
export function encodeCanonicalJson(value: unknown): string {
176179
if (value === null || typeof value !== 'object') {
177180
// Handle primitive types and null
178-
if (typeof value === 'string') {
179-
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
180-
}
181-
return String(value);
181+
return JSON.stringify(value);
182182
}
183183

184184
if (Array.isArray(value)) {

0 commit comments

Comments
 (0)