jose-node-esm-runtime
Advanced tools
Comparing version 4.6.2 to 4.7.0
@@ -18,11 +18,16 @@ import fetchJwks from '../runtime/fetch_jwks.js'; | ||
typeof (options === null || options === void 0 ? void 0 : options.cooldownDuration) === 'number' ? options === null || options === void 0 ? void 0 : options.cooldownDuration : 30000; | ||
this._cacheMaxAge = typeof (options === null || options === void 0 ? void 0 : options.cacheMaxAge) === 'number' ? options === null || options === void 0 ? void 0 : options.cacheMaxAge : 600000; | ||
} | ||
coolingDown() { | ||
if (!this._cooldownStarted) { | ||
return false; | ||
} | ||
return Date.now() < this._cooldownStarted + this._cooldownDuration; | ||
return typeof this._jwksTimestamp === 'number' | ||
? Date.now() < this._jwksTimestamp + this._cooldownDuration | ||
: false; | ||
} | ||
fresh() { | ||
return typeof this._jwksTimestamp === 'number' | ||
? Date.now() < this._jwksTimestamp + this._cacheMaxAge | ||
: false; | ||
} | ||
async getKey(protectedHeader, token) { | ||
if (!this._jwks) { | ||
if (!this._jwks || !this.fresh()) { | ||
await this.reload(); | ||
@@ -64,3 +69,3 @@ } | ||
this._jwks = { keys: json.keys }; | ||
this._cooldownStarted = Date.now(); | ||
this._jwksTimestamp = Date.now(); | ||
this._pendingFetch = undefined; | ||
@@ -67,0 +72,0 @@ }) |
@@ -7,20 +7,29 @@ import type { JWSHeaderParameters, FlattenedJWSInput, GetKeyFunction } from '../types'; | ||
/** | ||
* Timeout (in milliseconds) for the HTTP request. When reached the request will be | ||
* aborted and the verification will fail. Default is 5000. | ||
* Timeout (in milliseconds) for the HTTP request. When reached the request | ||
* will be aborted and the verification will fail. Default is 5000 (5 | ||
* seconds). | ||
*/ | ||
timeoutDuration?: number; | ||
/** | ||
* Duration (in milliseconds) for which no more HTTP requests will be triggered | ||
* after a previous successful fetch. Default is 30000. | ||
* Duration (in milliseconds) for which no more HTTP requests will be | ||
* triggered after a previous successful fetch. Default is 30000 (30 seconds). | ||
*/ | ||
cooldownDuration?: number; | ||
/** | ||
* An instance of [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | ||
* or [https.Agent](https://nodejs.org/api/https.html#https_class_https_agent) to pass | ||
* to the [http.get](https://nodejs.org/api/http.html#http_http_get_options_callback) | ||
* or [https.get](https://nodejs.org/api/https.html#https_https_get_options_callback) | ||
* method's options. Use when behind an http(s) proxy. | ||
* This is a Node.js runtime specific option, it is ignored | ||
* when used outside of Node.js runtime. | ||
* Maximum time (in milliseconds) between successful HTTP requests. Default is | ||
* 600000 (10 minutes). | ||
*/ | ||
cacheMaxAge?: number | typeof Infinity; | ||
/** | ||
* An instance of | ||
* [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) or | ||
* [https.Agent](https://nodejs.org/api/https.html#https_class_https_agent) to | ||
* pass to the | ||
* [http.get](https://nodejs.org/api/http.html#http_http_get_options_callback) | ||
* or | ||
* [https.get](https://nodejs.org/api/https.html#https_https_get_options_callback) | ||
* method's options. Use when behind an http(s) proxy. This is a Node.js | ||
* runtime specific option, it is ignored when used outside of Node.js | ||
* runtime. | ||
*/ | ||
agent?: any; | ||
@@ -27,0 +36,0 @@ } |
{ | ||
"name": "jose-node-esm-runtime", | ||
"version": "4.6.2", | ||
"version": "4.7.0", | ||
"homepage": "https://github.com/panva/jose", | ||
@@ -5,0 +5,0 @@ "repository": "panva/jose", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231415
6143