Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda