Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tomasholderness/d4e6af89ab910284ccc4f09c09fd9755 to your computer and use it in GitHub Desktop.

Select an option

Save tomasholderness/d4e6af89ab910284ccc4f09c09fd9755 to your computer and use it in GitHub Desktop.
aws-cognito-rsa
// Library
var jwkToPem = require('jwk-to-pem');
// Paste your JWK here
var key='{"alg":"RS256","e":"","kid":"","kty":"RSA","n":"","use":"sig"}';
// Parse the key
key = JSON.parse(key);
// Convert to RSA Public Key (.pem)
var jwk = {kty: key.kty, n: key.n, e: key.e};
// Print to console
console.log(jwk);
@matthewberryman
Copy link

Last few lines should be

// Convert to RSA Public Key (.pem)
var jwk = {kty: key.kty, n: key.n, e: key.e},
pem = jwkToPem(jwk);

// Print to console
console.log(pem);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment