Thanks for your help @raucao. I have a POST/RESP with SAFE Launcher telling me I’m unauthorized (which is good atm) For the record I was able to get rs to include libsodium
and request
from node.js (also had to add bops
for node.js Buffer support).
What I did…
cd ~/src/rs.js
npm install -g browserify
bower install libsodium.js
npm install bops request
browserify -r bops -o lib/bops.js
browserify -r request -o lib/request.js
Then add the following paths to components.json in two places as noted above:
bower_components/libsodium.js/dist/browsers/combined/sodium.min.js
lib/bops.js
lib/request.js
In my code I used the Object “libsodium” or “var nacl = libsodium” (for code that was written expecting it as ‘nacl’). And to get the request and buffer objects:
binary = require('bops');
HttpRequest = require('request');
Then…
// Converting assymetric public key to base64 string
// WAS publicKey: Buffer(assymetricKeys.publicKey).toString('base64'),
publicKey: binary.to(assymetricKeys.publicKey,'base64'),
// Converting nonce to base64 string
// WAS: nonce: new Buffer(nonce).toString('base64'),
nonce: binary.to(nonce,'base64'),
etc
Bops is a portability layer for Buffer (a node.js API that is not portable): https://github.com/chrisdickinson/bops
When I have things working we can look at stripping out the extras.