Skip to content

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

Open
@kaihendry

Description

@kaihendry

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions