I need to change sha1.js library out of a 5 year o...
# suitescript
m
I need to change sha1.js library out of a 5 year old 1.0 script to support HMAC-SHA256. Does anyone have any guidance for me? Here's a code snippet. I tried changing the "1" to "256", but that caused "not found" errors. var oauth = OAuth({                             consumer: {                                           key: consumerkey,                                           secret: consumersecret                             },                             signature_method: 'HMAC-SHA1',                             hash_function: function(base_string, key) {                                           var enc=CryptoJS.HmacSHA1(base_string, key);                                                                               return CryptoJS.enc.Base64.stringify(enc);                             }              });
b
probably depends on where you got the library from
and if you were using a modular version
probably best to get a new version of crypto js
1
make sure to pay attention to the release notes, newer versions use the native crypto globals, which suitescript does not implement
m
Will those work with suitescript 1.0?
b
yes, assuming you grab an older version
m
Is there a way to download without using npm? The company that I work at has a very tight firewall.
b
your firewall is holding you back
facepalm 1
😅 1
npm is an essential tool for javascript
true news 2
s
crypto js 4.0.0 was where that breaking change was made, so earlier versions (like 3.3.0) should be the latest ones that will work
m
any clue on how to get the 3.3.0 version from jsDelivr?
n
@mikej We had to modify a script that NS professional services provided that used CryptoJS and SHA-1 recently
I just grabbed the relevant bits from the rollup: https://gist.github.com/drudge/dd335123cdf2e3ca71dee9d226b19a1e
👍 1
so then we changed from
CryptoJS.HmacSHA1
to
CryptoJS.HmacSHA256
I left both in the module though
m
thanks