Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!