How can I use crypto-js library of Node.js in servicenow.

ravigupta
Mega Contributor

I would like to integrate the AWS Lex with servicenow. Lex requires signature to be created first and this can be created by Crypto-js library of Node.js. 

How can I access the crypto-js function in servicenow.

 

I would like to use the below Node.js code in servicenow.

var crypto = require("crypto-js"); function getSignatureKey(Crypto, key, dateStamp, regionName, serviceName) { var kDate = Crypto.HmacSHA256(dateStamp, "AWS4" + key); var kRegion = Crypto.HmacSHA256(regionName, kDate); var kService = Crypto.HmacSHA256(serviceName, kRegion); var kSigning = Crypto.HmacSHA256("aws4_request", kService); return kSigning; }

Below is the URL which shows the Node.js code.

https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-javascript

Thank you

Ravi Gupta

 

3 REPLIES 3

Jace Benson
Mega Sage

It's a bit of a pain.  You can do it.  Josh Nerius has a video about making crypto-js work with webpack.

https://youtu.be/BUKF2eKL8Gk?t=693

SanjivMeher
Kilo Patron
Kilo Patron

Hi Ravi,

 

Did you manage to get this working. I laos want to use crypto to sign using rsa-sha1 algorithm. But getting too many errors when I try to use the script


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

I was not able to complete this task.

 

Regards,

Ravi  Gupta