Date.prototype.toISOString()
exactly and is sufficient for verification, since the signer already
turned every Date into its canonical string form before ever hashing
or signing it.
Two concrete cross-language pitfalls this module corrects for —
found empirically while writing it, not assumed:
- JSON.stringify’s default separators are compact (no space after ”,” or ”:”); Python’s json.dumps defaults to ”, ” and ”: ”. Left uncorrected, every object/array would serialize to different bytes in Python than in Node, and no signature would ever verify.
- JSON.stringify does not escape non-ASCII characters by default; Python’s json.dumps defaults to ensure_ascii=True, which \uXXXX- escapes them. Same effect: different bytes for any string containing non-ASCII content.