Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported key type when trying to import a key set #367

Open
kaihendry opened this issue Mar 30, 2022 · 0 comments
Open

unsupported key type when trying to import a key set #367

kaihendry opened this issue Mar 30, 2022 · 0 comments

Comments

@kaihendry
Copy link

Imagine the following code:

"use strict";
const axios = require("axios");
const jose = require("node-jose");

async function working(url) {
  const jwksResponse = await axios.get(url);
  // do i need to iterate through the keys?
  return await jose.JWK.createKeyStore().add(jwksResponse.data.keys[0], "jwk");
}

async function notWorking(url) {
  const jwksResponse = await axios.get(url);
  return await jose.JWK.createKeyStore().add(jwksResponse.data, "jwk");
}

async function main() {
  const publicKeyStore = await working(
    "https://login.microsoftonline.com/common/discovery/v2.0/keys"
  );

  console.log(publicKeyStore);
  publicKeyStore = await notWorking(
    "https://login.microsoftonline.com/common/discovery/v2.0/keys"
  );
}

main();

My expectation was:

  1. Maybe a convenience function to fetch the keys
  2. A way for all the keys to be added without iterating through the retrieved keys

Am I missing something please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant