mirror of
https://github.com/hanzoai/node-jwks-rsa.git
synced 2026-09-24 17:00:54 +00:00
22 lines
415 B
JavaScript
22 lines
415 B
JavaScript
const nock = require('nock');
|
|
const jose2 = require('jose2');
|
|
|
|
function jwksEndpoint(host, certs) {
|
|
return nock(host)
|
|
.get('/.well-known/jwks.json')
|
|
.reply(200, {
|
|
keys: certs.map(cert => {
|
|
const parsed = jose2.JWK.asKey(cert.pub).toJWK();
|
|
return {
|
|
...parsed,
|
|
use: 'sig',
|
|
kid: cert.kid
|
|
};
|
|
})
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
jwksEndpoint
|
|
};
|