hmacSHA256(Hex decimal hash) signature generation with CryptoJS in servicenow

dayalsingh
Kilo Explorer

Hello Guys,

-1

I am using cryptoJS Lib for generating Hex HMACSHA256 signature for AWS4 request.Its working fine in custom application scope but in sn_capi scope throws me error undefined properties.

gist.github.com/igable/4bdcd90f78a8b2b07581 ..I have used this cryptojs file in the above link in my servicenow "script include" which is in sn_capi/cloud API scope when i hit this code with command var CryptoJS = new sn_capi.Crypto().CryptoJS; var kRegion = CryptoJS.HmacSHA256('regionName', 'kDate'); gs.info(kRegion); to get the hash i gets an error "undefined properties" at lines 1,8,50,149,186 but this works fine in custom application scope.I am able  to generate hash value in custom application scope but fails in sn_capi scope.Can anyone guide me on this.

Hey @dave.slusher can you guide me on this.

@Chuck Tomasi @Pradeep Sharma @Brad Tilton 
@Mark Stanger 
@Anurag Tripathi 
@josh.nerius 
@Göran Lundqvist 

 

11 REPLIES 11

Miguel Donayre
ServiceNow Employee
ServiceNow Employee

Hello @dayalsingh 

I have a similar set up as well. Can you check to see if your Script Include is Accessible from "All application scopes"?

 

find_real_file.png

 

Thank you for your reply @Miguel Donayre ,I already have accessible from as "all application scope".I can see that your key master is custom application scope.Its working fine for me as well in custom application scope but giving error in sn_capi(cloud api) scope.

@dayalsingh 

I am using mine in the global scope and it works just fine for me.

here is how i am call that same line you are 

var kRegion = x_snc_key_master.CryptoJS.HmacSHA256(region, kDate); 

find_real_file.png

I had to sit in a custom scope application in order for it to work. It couldn't get it to work when I placed it inside any SN scope application. I don't know if there was a way or not but the only way I got it to work was with a custom application.