@hemia/jwt-manager 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,11 +8,6 @@ var jwtConfig = {
|
|
|
8
8
|
cleanCredentialSecret: 'clean-credential-secret-key',
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
var Operatives;
|
|
12
|
-
(function (Operatives) {
|
|
13
|
-
Operatives["CATALOG"] = "catalog";
|
|
14
|
-
})(Operatives || (Operatives = {}));
|
|
15
|
-
|
|
16
11
|
function getDefaultExportFromCjs (x) {
|
|
17
12
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
18
13
|
}
|
|
@@ -2124,46 +2119,55 @@ const coerce$1 = (version, options) => {
|
|
|
2124
2119
|
};
|
|
2125
2120
|
var coerce_1 = coerce$1;
|
|
2126
2121
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
this.max = 1000;
|
|
2130
|
-
this.map = new Map();
|
|
2131
|
-
}
|
|
2122
|
+
var lrucache;
|
|
2123
|
+
var hasRequiredLrucache;
|
|
2132
2124
|
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
return undefined
|
|
2137
|
-
} else {
|
|
2138
|
-
// Remove the key from the map and add it to the end
|
|
2139
|
-
this.map.delete(key);
|
|
2140
|
-
this.map.set(key, value);
|
|
2141
|
-
return value
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2125
|
+
function requireLrucache () {
|
|
2126
|
+
if (hasRequiredLrucache) return lrucache;
|
|
2127
|
+
hasRequiredLrucache = 1;
|
|
2144
2128
|
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2129
|
+
class LRUCache {
|
|
2130
|
+
constructor () {
|
|
2131
|
+
this.max = 1000;
|
|
2132
|
+
this.map = new Map();
|
|
2133
|
+
}
|
|
2148
2134
|
|
|
2149
|
-
|
|
2150
|
-
|
|
2135
|
+
get (key) {
|
|
2136
|
+
const value = this.map.get(key);
|
|
2137
|
+
if (value === undefined) {
|
|
2138
|
+
return undefined
|
|
2139
|
+
} else {
|
|
2140
|
+
// Remove the key from the map and add it to the end
|
|
2141
|
+
this.map.delete(key);
|
|
2142
|
+
this.map.set(key, value);
|
|
2143
|
+
return value
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2151
2146
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
const firstKey = this.map.keys().next().value;
|
|
2156
|
-
this.delete(firstKey);
|
|
2157
|
-
}
|
|
2147
|
+
delete (key) {
|
|
2148
|
+
return this.map.delete(key)
|
|
2149
|
+
}
|
|
2158
2150
|
|
|
2159
|
-
|
|
2160
|
-
|
|
2151
|
+
set (key, value) {
|
|
2152
|
+
const deleted = this.delete(key);
|
|
2161
2153
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2154
|
+
if (!deleted && value !== undefined) {
|
|
2155
|
+
// If cache is full, delete the least recently used item
|
|
2156
|
+
if (this.map.size >= this.max) {
|
|
2157
|
+
const firstKey = this.map.keys().next().value;
|
|
2158
|
+
this.delete(firstKey);
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
this.map.set(key, value);
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
return this
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2165
2167
|
|
|
2166
|
-
|
|
2168
|
+
lrucache = LRUCache;
|
|
2169
|
+
return lrucache;
|
|
2170
|
+
}
|
|
2167
2171
|
|
|
2168
2172
|
var range;
|
|
2169
2173
|
var hasRequiredRange;
|
|
@@ -2386,7 +2390,7 @@ function requireRange () {
|
|
|
2386
2390
|
|
|
2387
2391
|
range = Range;
|
|
2388
2392
|
|
|
2389
|
-
const LRU =
|
|
2393
|
+
const LRU = requireLrucache();
|
|
2390
2394
|
const cache = new LRU();
|
|
2391
2395
|
|
|
2392
2396
|
const parseOptions = parseOptions_1;
|
|
@@ -5815,7 +5819,7 @@ var jwt = /*@__PURE__*/getDefaultExportFromCjs(jsonwebtoken);
|
|
|
5815
5819
|
|
|
5816
5820
|
class Mixin {
|
|
5817
5821
|
createBasicToken(payload, secret, expiresIn, options) {
|
|
5818
|
-
const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn, issuer:
|
|
5822
|
+
const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn, issuer: options === null || options === void 0 ? void 0 : options.issuer, audience: options === null || options === void 0 ? void 0 : options.audience, algorithm: (options === null || options === void 0 ? void 0 : options.algorithm) || 'HS256' });
|
|
5819
5823
|
return jwt.sign(payload, secret, finalOptions);
|
|
5820
5824
|
}
|
|
5821
5825
|
validateTokenBase(token, secretKey, options) {
|
|
@@ -5891,61 +5895,50 @@ class Mixin {
|
|
|
5891
5895
|
}
|
|
5892
5896
|
|
|
5893
5897
|
class JwtManager extends Mixin {
|
|
5894
|
-
constructor() {
|
|
5898
|
+
constructor(issuer, audience) {
|
|
5895
5899
|
super();
|
|
5896
5900
|
this._secretKey = '';
|
|
5897
5901
|
this._issuer = '';
|
|
5898
5902
|
this._audience = '';
|
|
5899
5903
|
this._secretKey = process.env.JWT_SECRET || jwtConfig.cleanCredentialSecret;
|
|
5900
|
-
this._issuer = process.env.JWT_ISSUER || 'hemia-app';
|
|
5901
|
-
this._audience = process.env.JWT_AUDIENCE || 'hemia-api';
|
|
5904
|
+
this._issuer = issuer || process.env.JWT_ISSUER || 'hemia-app';
|
|
5905
|
+
this._audience = audience || process.env.JWT_AUDIENCE || 'hemia-api';
|
|
5902
5906
|
if (!this._secretKey) {
|
|
5903
5907
|
throw new Error("JWT secret key is required.");
|
|
5904
5908
|
}
|
|
5905
5909
|
}
|
|
5906
|
-
|
|
5907
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5908
|
-
}
|
|
5909
|
-
createTokenWithSecret(payload, secretKey, expiresIn, options) {
|
|
5910
|
-
return this.createBasicToken(payload, secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5911
|
-
}
|
|
5912
|
-
createCleanCredentialsToken(operative = Operatives.CATALOG, secretKey, expiresIn, customClaims) {
|
|
5913
|
-
const payload = Object.assign({ accessType: operative }, customClaims);
|
|
5914
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5915
|
-
}
|
|
5916
|
-
getTokenWithoutKey(payload, secretKey, expiresIn, options) {
|
|
5917
|
-
return this.createToken(payload, secretKey, expiresIn, options);
|
|
5918
|
-
}
|
|
5919
|
-
getTokenWithKey(payload, secretKey, expiresIn, options) {
|
|
5920
|
-
return this.createTokenWithSecret(payload, secretKey, expiresIn, options);
|
|
5921
|
-
}
|
|
5922
|
-
getTokenCleanCredentials(operative = Operatives.CATALOG, secretKey, expiresIn) {
|
|
5923
|
-
return this.createCleanCredentialsToken(operative, secretKey, expiresIn);
|
|
5924
|
-
}
|
|
5925
|
-
createIdToken(claims, secretKey, expiresIn, customClaims) {
|
|
5910
|
+
createIdToken(claims, options = {}, customClaims) {
|
|
5926
5911
|
if (!claims.sub) {
|
|
5927
5912
|
throw new Error('sub (subject) claim is required for ID tokens');
|
|
5928
5913
|
}
|
|
5929
5914
|
const payload = Object.assign(Object.assign(Object.assign({}, claims), { iat: Math.floor(Date.now() / 1000) }), customClaims);
|
|
5930
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, {
|
|
5915
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || jwtConfig.expiresIn, {
|
|
5916
|
+
issuer: options.issuer || this._issuer,
|
|
5917
|
+
audience: options.clientID
|
|
5918
|
+
});
|
|
5931
5919
|
}
|
|
5932
|
-
createAccessToken(sub, scopes,
|
|
5920
|
+
createAccessToken(sub, scopes, options = {}, customClaims) {
|
|
5933
5921
|
const payload = Object.assign({ sub, scope: scopes.join(' '), iat: Math.floor(Date.now() / 1000) }, customClaims);
|
|
5934
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '15m', {
|
|
5922
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || '15m', {
|
|
5923
|
+
issuer: options.issuer || this._issuer,
|
|
5924
|
+
audience: options.audience || this._audience,
|
|
5925
|
+
algorithm: 'HS256'
|
|
5926
|
+
});
|
|
5935
5927
|
}
|
|
5936
|
-
createRefreshToken(sub,
|
|
5928
|
+
createRefreshToken(sub, options = {}, customClaims) {
|
|
5937
5929
|
const payload = Object.assign({ sub, type: 'refresh', iat: Math.floor(Date.now() / 1000) }, customClaims);
|
|
5938
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '30d', {
|
|
5939
|
-
issuer: this._issuer,
|
|
5940
|
-
audience: this._audience,
|
|
5930
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || '30d', {
|
|
5931
|
+
issuer: options.issuer || this._issuer,
|
|
5932
|
+
audience: options.audience || this._audience,
|
|
5933
|
+
algorithm: 'HS256',
|
|
5941
5934
|
jwtid: this.generateJti()
|
|
5942
5935
|
});
|
|
5943
5936
|
}
|
|
5944
5937
|
verify(token, secretKey, options) {
|
|
5945
|
-
return this.validateTokenBase(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5938
|
+
return this.validateTokenBase(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience, algorithms: ['HS256'] }));
|
|
5946
5939
|
}
|
|
5947
5940
|
verifyDetailed(token, secretKey, options) {
|
|
5948
|
-
return super.validateTokenDetailed(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5941
|
+
return super.validateTokenDetailed(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience, algorithms: ['HS256'] }));
|
|
5949
5942
|
}
|
|
5950
5943
|
validateToken(token, secretKey, options) {
|
|
5951
5944
|
return this.verify(token, secretKey, options);
|
|
@@ -6004,6 +5997,11 @@ class JwtManager extends Mixin {
|
|
|
6004
5997
|
}
|
|
6005
5998
|
}
|
|
6006
5999
|
|
|
6000
|
+
var Operatives;
|
|
6001
|
+
(function (Operatives) {
|
|
6002
|
+
Operatives["CATALOG"] = "catalog";
|
|
6003
|
+
})(Operatives || (Operatives = {}));
|
|
6004
|
+
|
|
6007
6005
|
var TokenType;
|
|
6008
6006
|
(function (TokenType) {
|
|
6009
6007
|
TokenType["ID_TOKEN"] = "id_token";
|
|
@@ -10,11 +10,6 @@ var jwtConfig = {
|
|
|
10
10
|
cleanCredentialSecret: 'clean-credential-secret-key',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
exports.Operatives = void 0;
|
|
14
|
-
(function (Operatives) {
|
|
15
|
-
Operatives["CATALOG"] = "catalog";
|
|
16
|
-
})(exports.Operatives || (exports.Operatives = {}));
|
|
17
|
-
|
|
18
13
|
function getDefaultExportFromCjs (x) {
|
|
19
14
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
20
15
|
}
|
|
@@ -2126,46 +2121,55 @@ const coerce$1 = (version, options) => {
|
|
|
2126
2121
|
};
|
|
2127
2122
|
var coerce_1 = coerce$1;
|
|
2128
2123
|
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
this.max = 1000;
|
|
2132
|
-
this.map = new Map();
|
|
2133
|
-
}
|
|
2124
|
+
var lrucache;
|
|
2125
|
+
var hasRequiredLrucache;
|
|
2134
2126
|
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
return undefined
|
|
2139
|
-
} else {
|
|
2140
|
-
// Remove the key from the map and add it to the end
|
|
2141
|
-
this.map.delete(key);
|
|
2142
|
-
this.map.set(key, value);
|
|
2143
|
-
return value
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2127
|
+
function requireLrucache () {
|
|
2128
|
+
if (hasRequiredLrucache) return lrucache;
|
|
2129
|
+
hasRequiredLrucache = 1;
|
|
2146
2130
|
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2131
|
+
class LRUCache {
|
|
2132
|
+
constructor () {
|
|
2133
|
+
this.max = 1000;
|
|
2134
|
+
this.map = new Map();
|
|
2135
|
+
}
|
|
2150
2136
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2137
|
+
get (key) {
|
|
2138
|
+
const value = this.map.get(key);
|
|
2139
|
+
if (value === undefined) {
|
|
2140
|
+
return undefined
|
|
2141
|
+
} else {
|
|
2142
|
+
// Remove the key from the map and add it to the end
|
|
2143
|
+
this.map.delete(key);
|
|
2144
|
+
this.map.set(key, value);
|
|
2145
|
+
return value
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2153
2148
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
const firstKey = this.map.keys().next().value;
|
|
2158
|
-
this.delete(firstKey);
|
|
2159
|
-
}
|
|
2149
|
+
delete (key) {
|
|
2150
|
+
return this.map.delete(key)
|
|
2151
|
+
}
|
|
2160
2152
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2153
|
+
set (key, value) {
|
|
2154
|
+
const deleted = this.delete(key);
|
|
2163
2155
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2156
|
+
if (!deleted && value !== undefined) {
|
|
2157
|
+
// If cache is full, delete the least recently used item
|
|
2158
|
+
if (this.map.size >= this.max) {
|
|
2159
|
+
const firstKey = this.map.keys().next().value;
|
|
2160
|
+
this.delete(firstKey);
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
this.map.set(key, value);
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
return this
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2167
2169
|
|
|
2168
|
-
|
|
2170
|
+
lrucache = LRUCache;
|
|
2171
|
+
return lrucache;
|
|
2172
|
+
}
|
|
2169
2173
|
|
|
2170
2174
|
var range;
|
|
2171
2175
|
var hasRequiredRange;
|
|
@@ -2388,7 +2392,7 @@ function requireRange () {
|
|
|
2388
2392
|
|
|
2389
2393
|
range = Range;
|
|
2390
2394
|
|
|
2391
|
-
const LRU =
|
|
2395
|
+
const LRU = requireLrucache();
|
|
2392
2396
|
const cache = new LRU();
|
|
2393
2397
|
|
|
2394
2398
|
const parseOptions = parseOptions_1;
|
|
@@ -5817,7 +5821,7 @@ var jwt = /*@__PURE__*/getDefaultExportFromCjs(jsonwebtoken);
|
|
|
5817
5821
|
|
|
5818
5822
|
class Mixin {
|
|
5819
5823
|
createBasicToken(payload, secret, expiresIn, options) {
|
|
5820
|
-
const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn, issuer:
|
|
5824
|
+
const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn, issuer: options === null || options === void 0 ? void 0 : options.issuer, audience: options === null || options === void 0 ? void 0 : options.audience, algorithm: (options === null || options === void 0 ? void 0 : options.algorithm) || 'HS256' });
|
|
5821
5825
|
return jwt.sign(payload, secret, finalOptions);
|
|
5822
5826
|
}
|
|
5823
5827
|
validateTokenBase(token, secretKey, options) {
|
|
@@ -5893,61 +5897,50 @@ class Mixin {
|
|
|
5893
5897
|
}
|
|
5894
5898
|
|
|
5895
5899
|
class JwtManager extends Mixin {
|
|
5896
|
-
constructor() {
|
|
5900
|
+
constructor(issuer, audience) {
|
|
5897
5901
|
super();
|
|
5898
5902
|
this._secretKey = '';
|
|
5899
5903
|
this._issuer = '';
|
|
5900
5904
|
this._audience = '';
|
|
5901
5905
|
this._secretKey = process.env.JWT_SECRET || jwtConfig.cleanCredentialSecret;
|
|
5902
|
-
this._issuer = process.env.JWT_ISSUER || 'hemia-app';
|
|
5903
|
-
this._audience = process.env.JWT_AUDIENCE || 'hemia-api';
|
|
5906
|
+
this._issuer = issuer || process.env.JWT_ISSUER || 'hemia-app';
|
|
5907
|
+
this._audience = audience || process.env.JWT_AUDIENCE || 'hemia-api';
|
|
5904
5908
|
if (!this._secretKey) {
|
|
5905
5909
|
throw new Error("JWT secret key is required.");
|
|
5906
5910
|
}
|
|
5907
5911
|
}
|
|
5908
|
-
|
|
5909
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5910
|
-
}
|
|
5911
|
-
createTokenWithSecret(payload, secretKey, expiresIn, options) {
|
|
5912
|
-
return this.createBasicToken(payload, secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5913
|
-
}
|
|
5914
|
-
createCleanCredentialsToken(operative = exports.Operatives.CATALOG, secretKey, expiresIn, customClaims) {
|
|
5915
|
-
const payload = Object.assign({ accessType: operative }, customClaims);
|
|
5916
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5917
|
-
}
|
|
5918
|
-
getTokenWithoutKey(payload, secretKey, expiresIn, options) {
|
|
5919
|
-
return this.createToken(payload, secretKey, expiresIn, options);
|
|
5920
|
-
}
|
|
5921
|
-
getTokenWithKey(payload, secretKey, expiresIn, options) {
|
|
5922
|
-
return this.createTokenWithSecret(payload, secretKey, expiresIn, options);
|
|
5923
|
-
}
|
|
5924
|
-
getTokenCleanCredentials(operative = exports.Operatives.CATALOG, secretKey, expiresIn) {
|
|
5925
|
-
return this.createCleanCredentialsToken(operative, secretKey, expiresIn);
|
|
5926
|
-
}
|
|
5927
|
-
createIdToken(claims, secretKey, expiresIn, customClaims) {
|
|
5912
|
+
createIdToken(claims, options = {}, customClaims) {
|
|
5928
5913
|
if (!claims.sub) {
|
|
5929
5914
|
throw new Error('sub (subject) claim is required for ID tokens');
|
|
5930
5915
|
}
|
|
5931
5916
|
const payload = Object.assign(Object.assign(Object.assign({}, claims), { iat: Math.floor(Date.now() / 1000) }), customClaims);
|
|
5932
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, {
|
|
5917
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || jwtConfig.expiresIn, {
|
|
5918
|
+
issuer: options.issuer || this._issuer,
|
|
5919
|
+
audience: options.clientID
|
|
5920
|
+
});
|
|
5933
5921
|
}
|
|
5934
|
-
createAccessToken(sub, scopes,
|
|
5922
|
+
createAccessToken(sub, scopes, options = {}, customClaims) {
|
|
5935
5923
|
const payload = Object.assign({ sub, scope: scopes.join(' '), iat: Math.floor(Date.now() / 1000) }, customClaims);
|
|
5936
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '15m', {
|
|
5924
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || '15m', {
|
|
5925
|
+
issuer: options.issuer || this._issuer,
|
|
5926
|
+
audience: options.audience || this._audience,
|
|
5927
|
+
algorithm: 'HS256'
|
|
5928
|
+
});
|
|
5937
5929
|
}
|
|
5938
|
-
createRefreshToken(sub,
|
|
5930
|
+
createRefreshToken(sub, options = {}, customClaims) {
|
|
5939
5931
|
const payload = Object.assign({ sub, type: 'refresh', iat: Math.floor(Date.now() / 1000) }, customClaims);
|
|
5940
|
-
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '30d', {
|
|
5941
|
-
issuer: this._issuer,
|
|
5942
|
-
audience: this._audience,
|
|
5932
|
+
return this.createBasicToken(payload, options.secretKey || this._secretKey, options.expiresIn || '30d', {
|
|
5933
|
+
issuer: options.issuer || this._issuer,
|
|
5934
|
+
audience: options.audience || this._audience,
|
|
5935
|
+
algorithm: 'HS256',
|
|
5943
5936
|
jwtid: this.generateJti()
|
|
5944
5937
|
});
|
|
5945
5938
|
}
|
|
5946
5939
|
verify(token, secretKey, options) {
|
|
5947
|
-
return this.validateTokenBase(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5940
|
+
return this.validateTokenBase(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience, algorithms: ['HS256'] }));
|
|
5948
5941
|
}
|
|
5949
5942
|
verifyDetailed(token, secretKey, options) {
|
|
5950
|
-
return super.validateTokenDetailed(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
|
|
5943
|
+
return super.validateTokenDetailed(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience, algorithms: ['HS256'] }));
|
|
5951
5944
|
}
|
|
5952
5945
|
validateToken(token, secretKey, options) {
|
|
5953
5946
|
return this.verify(token, secretKey, options);
|
|
@@ -6006,6 +5999,11 @@ class JwtManager extends Mixin {
|
|
|
6006
5999
|
}
|
|
6007
6000
|
}
|
|
6008
6001
|
|
|
6002
|
+
exports.Operatives = void 0;
|
|
6003
|
+
(function (Operatives) {
|
|
6004
|
+
Operatives["CATALOG"] = "catalog";
|
|
6005
|
+
})(exports.Operatives || (exports.Operatives = {}));
|
|
6006
|
+
|
|
6009
6007
|
exports.TokenType = void 0;
|
|
6010
6008
|
(function (TokenType) {
|
|
6011
6009
|
TokenType["ID_TOKEN"] = "id_token";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Operatives } from '../Enums/Enums';
|
|
1
|
+
import { JwtPayload, VerifyOptions } from 'jsonwebtoken';
|
|
3
2
|
import { Mixin } from '../mixin/jwt.mixin';
|
|
4
3
|
import { StandardClaims } from '../interfaces/oidc-claims';
|
|
5
4
|
import { TokenValidationResult } from '../types/token-validation';
|
|
@@ -7,16 +6,25 @@ export declare class JwtManager extends Mixin {
|
|
|
7
6
|
private _secretKey;
|
|
8
7
|
private _issuer;
|
|
9
8
|
private _audience;
|
|
10
|
-
constructor();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
constructor(issuer?: string, audience?: string);
|
|
10
|
+
createIdToken(claims: StandardClaims, options?: {
|
|
11
|
+
clientID?: string;
|
|
12
|
+
issuer?: string;
|
|
13
|
+
expiresIn?: string | number;
|
|
14
|
+
secretKey?: string;
|
|
15
|
+
}, customClaims?: object): string;
|
|
16
|
+
createAccessToken(sub: string, scopes: string[], options?: {
|
|
17
|
+
audience?: string;
|
|
18
|
+
issuer?: string;
|
|
19
|
+
expiresIn?: string | number;
|
|
20
|
+
secretKey?: string;
|
|
21
|
+
}, customClaims?: object): string;
|
|
22
|
+
createRefreshToken(sub: string, options?: {
|
|
23
|
+
audience?: string;
|
|
24
|
+
issuer?: string;
|
|
25
|
+
expiresIn?: string | number;
|
|
26
|
+
secretKey?: string;
|
|
27
|
+
}, customClaims?: object): string;
|
|
20
28
|
verify(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
|
|
21
29
|
verifyDetailed(token: string, secretKey?: string, options?: VerifyOptions): TokenValidationResult;
|
|
22
30
|
validateToken(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
|
package/package.json
CHANGED