jose
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -9,2 +9,8 @@ import fetchJwks from '../runtime/fetch_jwks.js'; | ||
} | ||
let USER_AGENT; | ||
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) { | ||
const NAME = 'jose'; | ||
const VERSION = 'v5.0.2'; | ||
USER_AGENT = `${NAME}/${VERSION}`; | ||
} | ||
class RemoteJWKSet extends LocalJWKSet { | ||
@@ -56,2 +62,7 @@ constructor(url, options) { | ||
} | ||
const headers = new Headers(this._options.headers); | ||
if (USER_AGENT && !headers.has('User-Agent')) { | ||
headers.set('User-Agent', USER_AGENT); | ||
this._options.headers = Object.fromEntries(headers.entries()); | ||
} | ||
this._pendingFetch || (this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options) | ||
@@ -58,0 +69,0 @@ .then((json) => { |
@@ -12,2 +12,8 @@ "use strict"; | ||
} | ||
let USER_AGENT; | ||
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) { | ||
const NAME = 'jose'; | ||
const VERSION = 'v5.0.2'; | ||
USER_AGENT = `${NAME}/${VERSION}`; | ||
} | ||
class RemoteJWKSet extends local_js_1.LocalJWKSet { | ||
@@ -66,2 +72,7 @@ _url; | ||
} | ||
const headers = new Headers(this._options.headers); | ||
if (USER_AGENT && !headers.has('User-Agent')) { | ||
headers.set('User-Agent', USER_AGENT); | ||
this._options.headers = Object.fromEntries(headers.entries()); | ||
} | ||
this._pendingFetch ||= (0, fetch_jwks_js_1.default)(this._url, this._timeoutDuration, this._options) | ||
@@ -68,0 +79,0 @@ .then((json) => { |
@@ -9,2 +9,8 @@ import fetchJwks from '../runtime/fetch_jwks.js'; | ||
} | ||
let USER_AGENT; | ||
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) { | ||
const NAME = 'jose'; | ||
const VERSION = 'v5.0.2'; | ||
USER_AGENT = `${NAME}/${VERSION}`; | ||
} | ||
class RemoteJWKSet extends LocalJWKSet { | ||
@@ -63,2 +69,7 @@ _url; | ||
} | ||
const headers = new Headers(this._options.headers); | ||
if (USER_AGENT && !headers.has('User-Agent')) { | ||
headers.set('User-Agent', USER_AGENT); | ||
this._options.headers = Object.fromEntries(headers.entries()); | ||
} | ||
this._pendingFetch ||= fetchJwks(this._url, this._timeoutDuration, this._options) | ||
@@ -65,0 +76,0 @@ .then((json) => { |
@@ -12,4 +12,4 @@ import type { KeyLike, JWSHeaderParameters, JSONWebKeySet, FlattenedJWSInput } from '../types'; | ||
/** | ||
* Returns a function that resolves to a key object from a locally stored, or otherwise available, | ||
* JSON Web Key Set. | ||
* Returns a function that resolves a JWS JOSE Header to a public key object from a locally stored, | ||
* or otherwise available, JSON Web Key Set. | ||
* | ||
@@ -25,4 +25,7 @@ * It uses the "alg" (JWS Algorithm) Header Parameter to determine the right JWK "kty" (Key Type), | ||
* | ||
* Note: The function's purpose is to resolve public keys used for verifying signatures and will not | ||
* work for public encryption keys. | ||
* | ||
* @param jwks JSON Web Key Set formatted object. | ||
*/ | ||
export declare function createLocalJWKSet<KeyLikeType extends KeyLike = KeyLike>(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<KeyLikeType>; |
@@ -28,10 +28,14 @@ import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput } from '../types'; | ||
agent?: any; | ||
/** Optional headers to be sent with the HTTP request. */ | ||
/** | ||
* Headers to be sent with the HTTP request. Default is that `User-Agent: jose/v${version}` header | ||
* is added unless the runtime is a browser in which adding an explicit headers fetch | ||
* configuration would cause an unnecessary CORS preflight request. | ||
*/ | ||
headers?: Record<string, string>; | ||
} | ||
/** | ||
* Returns a function that resolves to a key object downloaded from a remote endpoint returning a | ||
* JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC jwks_uri. The JSON Web Key Set is | ||
* fetched when no key matches the selection process but only as frequently as the | ||
* `cooldownDuration` option allows to prevent abuse. | ||
* Returns a function that resolves a JWS JOSE Header to a public key object downloaded from a | ||
* remote endpoint returning a JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC | ||
* jwks_uri. The JSON Web Key Set is fetched when no key matches the selection process but only as | ||
* frequently as the `cooldownDuration` option allows to prevent abuse. | ||
* | ||
@@ -47,2 +51,5 @@ * It uses the "alg" (JWS Algorithm) Header Parameter to determine the right JWK "kty" (Key Type), | ||
* | ||
* Note: The function's purpose is to resolve public keys used for verifying signatures and will not | ||
* work for public encryption keys. | ||
* | ||
* @param url URL to fetch the JSON Web Key Set from. | ||
@@ -49,0 +56,0 @@ * @param options Options for the remote JSON Web Key Set. |
{ | ||
"name": "jose", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
497298
12335