Description
Hi Roger, thanks for your work on macaroons! I'm trying to take a serialized macaroon generated via libmacaroons using python and verify it using a node app. I noticed you also helped with libmacaroons, so I was perhaps naively assuming they can work together in a decentralized system. Is there a way to do this? (Any "caveats" ? ;)
Using the python cli:
>>> import macaroons
>>> secret = 'this is our super secret key; only we should know it'
>>> public = 'we used our secret key'
>>> location = 'http://mybank/'
>>> M = macaroons.create(location, secret, public)
>>> M.serialize()
'MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo'
Using the nodejs cli:
> var Macaroon = require('macaroon');
> Macaroon
{ newMacaroon: [Function],
import: [Function],
export: [Function],
discharge: [Function] }
> Macaroon.import('MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo');
TypeError: Cannot read property 'replace' of undefined
I can just do this:
> m = Macaroon.import({'location': 'http://mybank/', 'identifier': 'we used our secret key', 'cid': 'account = 3735928559', 'signature': '1efe4763f290dbce0c1d08477367e11f4eee456a64933cf662d79772dbb82128'});
...but of course I don't want to pass that json-encoded string around. Is there a way to deserialize in nodejs a macaroon that was serialized using the python cli? Are there any usage examples out there? Thanks and regards