Using jsonwebtoken npm module in Apigee Edge 4.15.04.00

We are using jsonwebtoken to create signed JWT tokens. The node app works using nodejs but when deploying to Edge ver 4.15.04.00 we get

Script execution failed: Object  of type class io.apigee.trireme.core.modules.Buffer$BufferImpl expected:
at  crypto.js:416\n  at  sign (/organization/environment/api/node_modules/jwa/index.js:54)\n  at  jwsSign
(/organization/environment/api/node_modules/jws/lib/sign-stream.js:23)\n                               at
/organization/environment/api/node_modules/jsonwebtoken/sign.js:144\n                                  at
/organization/environment/api/controllers/appController.js:104\n                                          at
/organization/environment/api/node_modules/xml2js/lib/xml2js.js:484\n   at   emit   (events.js:95)\n   at
/organization/environment/api/node_modules/xml2js/lib/xml2js.js:445\n               at               emit
(/organization/environment/api/node_modules/xml2js/node_modules/sax/lib/sax.js:639)\n     at     emitNode
(/organization/environment/api/node_modules/xml2js/node_modules/sax/lib/sax.js:644)\n     at     closeTag
(/organization/environment/api/node_modules/xml2js/node_modules/sax/lib/sax.js:903)\n       at      write
(/organization/environment/api/node_modules/xml2js/node_modules/sax/lib/sax.js:1447)\n                 at
/organization/environment/api/node_modules/xml2js/lib/xml2js.js:503\n                                  at
/organization/environment/api/node_modules/xml2js/lib/xml2js.js:7\n                                    at
/organization/environment/api/node_modules/xml2js/lib/xml2js.js:535\n         at         callback
(/organization/environment/api/controllers/appController.js:91)\n  at /node_modules/request/request.js:122\n
at  emit   (events.js:98)\n  at  /node_modules/request/request.js:888\n  at   emit  (events.js:117)\n  at
/node_modules/request/request.js:839\n   at  emit   (events.js:117)\n  at   _stream_readable.js:943\n  at
_tickDomainCallback (trireme.js:491)\n at _tickFromSpinner (trireme.js:422)\n",


On the supported list of npm modules - http://docs.apigee.com/api-services/content/understanding-edge-support-nodejs-modules I see crypto npm module is supported. Anyone else tried using jsonwebtoken in Edge?

0 3 418
3 REPLIES 3

Hi @vineet Bhatia,

Could you please check if your version of json web token?

For 2.*.* Node version required is >= 4.

Since supported version of node in APIGEE is 0.10.32

You'll have to install 1.6.3 version of JWT.

let us know how it works if you downgrade jwt to 1.6.3

Thanks!

@Mohammed Zuber

Thanks for the suggestion. I did not know this. I notice though that according to jsonwebtoken's NPM page, there is no such version as "1.6.3." There is 1.1.2 and then the very next version is 2.0.

Did you mean 1.1.2, or were you under the impression that a version 1.6.3 exists?

Not applicable

@Chris Covney and @Vineet Bhatia - I'm using 5.7.0 and it works fine. Although my proxies run on a more recent version of Edge. However, since Trireme version shouldn't be too different from yours, I wonder if your issue is rather an issue with a too old version of jsonwebtoken. My suggestion then, give it a try to a more recent version.