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

168
Visualizações
Javascript newbie can't keystore.generate("EC", "P-256")

I'm pretty new to Javascript and Node. Using Jupyter Notebook I ran a subsection of this [SMART HEALTH CARD][1] to generate a key. I just took the "Creating the Signed Health Card" section and ran it in notebook. I get "{ keys: [] }" . When I run it from Node, I get nothing (no error and no JSON output). I am using MacOS Big Sur 11.6.2 & node 16.9.0 & node-jose 2.0.0

The actual subsection I ran is:

var jose = require('node-jose');

const keystore = jose.JWK.createKeyStore()

let signingKey;

keystore.generate("EC", "P-256").
then(function(result) {
  // {result} is a jose.JWK.Key
  signingKey = result;
});

keystore.toJSON(true);

When I added console.log(signingKey)to the generate function in Jupyter Notebook, I get the key so somehow the signingKey is not getting exported out of the generate function.

I've looked thru all the questions and at Node-Jose docs but can't figure it out. What is this clueless person missing?

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

0

The signingKey is a local variable within the generate function. All I need to do is add a return (signingkey) to the function and I have my key.

I'm sure there is a better answer but least I've learned a little about .then().

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