Checksum for document

As an exrra measure to ensure that all collaborative clients really have the same document, we stringify the document and create a checksum. This checksum is then sent to the server a few seconds after everyone has stopped typing. If one collaborator has a checksum than the others, that client requests a full copy from the server.

Unfortunately, json stringify outputs don’t need to be the same, and I recently found out that Firefox and Chrome produce slightly different outputs, which means that the checksums don’t match.

My question therefore: any good ideas of how to create a browser independent checksum from pm.mod.collab.versionDoc?

If you have two identical documents whose .toJSON() methods produce different JSON, that’s a bug, and I’d be interested in an example.

— Thinking about this a little more, I realized that attribute objects can originate with user code, and thus might end up with different property order for nodes with multiple attributes. Maybe use something like this project to compute the checksum?