Socket
Socket
Sign inDemoInstall

jose

Package Overview
Dependencies
Maintainers
1
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jose - npm Package Compare versions

Comparing version 4.6.2 to 4.7.0

17

dist/browser/jwks/remote.js

@@ -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 @@ })

@@ -21,11 +21,16 @@ "use strict";

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();

@@ -67,3 +72,3 @@ }

this._jwks = { keys: json.keys };
this._cooldownStarted = Date.now();
this._jwksTimestamp = Date.now();
this._pendingFetch = undefined;

@@ -70,0 +75,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",
"version": "4.6.2",
"version": "4.7.0",
"description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS with no dependencies using runtime's native crypto",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc