Nour
06/11/2025, 10:32 AMCeligo AI
06/11/2025, 10:33 AMAI generated answer (using internal Slack threads):The HMAC object is empty because the
crypto.createHmac
function in NetSuite's SuiteScript expects a secret key that is stored in NetSuite's secrets management, not a dynamically computed key.
In the context of AWS4 authentication, the secret key is not static but is dynamically generated based on elements of the request (like date, service name, etc.). This is why the HMAC object is empty when you try to use crypto.createHmac
with a dynamically computed key.
Here is an example of how you can generate the AWS signature using CryptoJS:
javascript
function getAWSSignatureKey(key, dateStamp, regionName, serviceName) {
var kDate = CryptoJS.HmacSHA256(dateStamp, "AWS4" + key);
var kRegion = CryptoJS.HmacSHA256(regionName, kDate);
var kService = CryptoJS.HmacSHA256(serviceName, kRegion);
var kSigning = CryptoJS.HmacSHA256("aws4_request", kService);
return kSigning;
}
And here is how you can call this function:
javascript
var signing_key = CryptoJS.getAWSSignatureKey(secret_key, datestamp, region, service);
var signingsha256Data = CryptoJS.createHmacSHA256Crypto(string_to_sign, signing_key)
var signature = CryptoJS.HmacSHA256ToHexCrypto(signingsha256Data);
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
06/11/2025, 10:33 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836892843
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829264939
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825475395
Celigo AI
06/11/2025, 10:33 AM