Reputation: 130
I have a use case where a peer must send a message and signature to another peer using WebRTC Data Channels. Unfortunately the signature generated using WebCrypto is an ArrayBuffer, meaning that when I use JSON.stringify() to send the object the signature is lost.
Is there a way to encode the ArrayBuffer signature that will enable me to transfer the stringifyed object over the Data Channel without compromising the signature on the receiving end?
Upvotes: 0
Views: 331
Reputation: 1856
Consider using https://github.com/dcodeIO/ProtoBuf.js/ and encoding the ASCII as binary.
Upvotes: 0
Reputation: 17360
Are you setting the datachannels binaryType to 'arraybuffer'? Then you should be able to transfer without using JSON.stringify.
Upvotes: 0