autobahn-js icon indicating copy to clipboard operation
autobahn-js copied to clipboard

Binary object to Base64 support

Open ecorm opened this issue 9 years ago • 5 comments

Does autobahn-js support conversion of binary objects to Base64, as per section 14 of the WAMP spec?

If a Base64 string were manually constructed with a leading '\0', and passed as an RPC argument, would it break Autobahn|JS?

ecorm avatar Mar 18 '16 19:03 ecorm

This isn't implemented yet. But since the refactoring of serializers, this could now be done at one place:

https://github.com/crossbario/autobahn-js/blob/master/package/lib/serializer.js#L22

JSON.stringify and JSON.parse don't know about the WAMP binary conversion thing, so that code needs to be expanded:

  • serialize needs to walk over the obj looking for binaries and replace those with the string encoding as per WAMP spec before putting the obj into JSON.serialize
  • unserialize needs to walk over the unserialized payload coming out of JSON.parse after unserialization, and replace strings that start with \ 0 with a decoded binary

oberstet avatar Mar 19 '16 10:03 oberstet

In fact, we've just recently implemented this in AutobahnPython and Crossbar.io. Which finally allows to fix this here too, since we can now test the feature.

oberstet avatar Apr 20 '17 19:04 oberstet

Would it make sense to be able to configure base64 as a serializer for the REST bridge? This seems like it would be handy because unless I am missing something, a method written to return some binary can currently not be called via REST bridge, only over websocket.

chrisbarber avatar May 12 '17 21:05 chrisbarber

@chrisbarber yes, that would make sense: https://github.com/crossbario/crossbar/issues/1079

When this is done, then AB JS needs bits too.

But the issue here is to add support for transparent binaries over JSON in AB JS over regular transports (WebSocket/RawSocket) ..

oberstet avatar May 14 '17 15:05 oberstet

there now is CI test coverage for binary payloads via https://github.com/crossbario/autobahn-js/blob/master/test/test_binary.js

to activate the tests for json, uncomment this: https://github.com/crossbario/autobahn-js/blob/caa775adbdecfe835a294b721f990e558009f87f/test/test.js#L60

oberstet avatar May 19 '19 08:05 oberstet