admin管理员组文章数量:1279176
I'm integrating NetSuite with custom serverless application running on AWS. The application uses AWS Cognito for authentication. I received NodeJS code from application developer and I was refactoring it to run in NetSuite using SuiteScript 2.1 moduled. I hit a brick wall when I got to HMACs.
I'm trying to implement following line which uses NodeJS crypto
package const kDate = crypto.createHmac('sha256', Buffer.from('AWS4' + key, 'utf8')).update(dateStamp).digest();
SuiteScript code looks like this:
let _sKey = https.createSecretKey({
encoding: https.Encoding.UTF_8,
secret: ('AWS4' + key)
});
let _kDate = crypto.createHmac({
algorithm: crypto.HashAlg.SHA256,
key: _sKey
});
_kDate.update({
input: dateStamp
});
const kDate = _kDate.digest({outputEncoding: encode.Encoding.UTF_8});
Explaination SuiteScript crypto.createHmac() inside N/crypto requires crypto.SecretKey object as parameter. SuiteScript crypto.createSecretKey() method only accepts reference to credential-holding UI element or its guid and does not accept string. I found https.createSecretKey() method inside N/https module which accepts sting. This allowed me to create HMAC, update it but when I call digest() method, I get following error: "name":"AN_ERROR_OCCURRED_WHILE_DECRYPT_PASSWORDGUID","message":"An error occurred while decrypting a credential."
This would indicate that credential-holding UI element is still at play and although HMAC created, I still can't perform hashing.
Does anyone have any experience with this type of implementation?
Alternatively, have you performed M2M authentication between NetSuite and AWS using Cognito and M2M authentication or do you know a good case study you can refer me to?
本文标签: suitescriptIntegrating NetSuite with AWS Cognito serviceStack Overflow
版权声明:本文标题:suitescript - Integrating NetSuite with AWS Cognito service - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741246608a2364996.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论