Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

565
Visualizações
How to write java script in nifi to decrypt jwt token using Apache NiFi. How to use ExecuteScript processor

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:

  1. Failed to process session due to javax.script.ScriptException: :13:6 Expected ; but found function async function decryptJWE(jweToken) Failed to process session due to javax.script.ScriptException: :13: expected operand but found const

please help me. thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda