cyberphone / json-canonicalization

JSON Canonicalization Scheme (JCS)
Other
98 stars 23 forks source link

[JavaScript] Canonicalize incorrectly serialises undefined values. #10

Closed yacinehmito closed 3 years ago

yacinehmito commented 4 years ago

When using the JS implementation of json-canonicalize v1.0.3 on the object { foo: undefined }, we get the string {"foo":undefined}.

This is incorrect. Indeed, the result of JSON.stringify({ foo: undefined }) is {}, not {"foo":undefined}.

It might be worth adding to the test suite. I am willing to do it myself, but only if I first receive approval.

cyberphone commented 4 years ago

You are perfectly right, I obviously did not consider the undefined case. I will talk to the person maintaining the NPM version (https://www.npmjs.com/package/canonicalize) and see what he thinks about this. I just got this from another person who also have taken on this stuff: https://github.com/Arxcis/identity-wallet/blob/master/lib/canonicalize.mjs