Reputation:
I am new to NiFi and JavaScript. I am trying to decrypt the jwt token using executecommand processor. But failing to do so. I have attached my code. Can you please help me on the same. the library we are using here is node-jose:
flowFile = session.get();
if (flowFile != null)
{
var jweToken = flowFile.getAttribute('token')
var contentAlg = 'A256CBC-HS512';
const privKeyJwks = {"p:aaaaaabbbccccc,q:cddbcbvbvbmm"};
async function decryptJWE(jweToken) {
try {
// Decrypt JWE w/ private key
const privKey = await JWK.asKey(privKeyJwks);
return (await JWE.createDecrypt(privKey).decrypt(jweToken)).plaintext.toString();
flowFile = session.putAttribute(flowFile, 'token', 'jweToken')
} catch (e) {
console.error(e);
}
}
}
the errors I am getting:
please help me. thank you.
Upvotes: 0
Views: 509
Reputation: 10352
As far as I can find, Apache NiFi uses Nashorn as its JavaScript (ECMAScript, to be exact) implementation. According to the docs, Nashorn supports only ECMAScript 5.1; however, you're using async functions, which are supported only in ECMAScript 2017 and later.
The only way to go is to rewrite your script without using async functions.
Upvotes: 1