@hemia/jwt-manager 0.0.2 → 0.0.3
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.
|
@@ -5912,33 +5912,33 @@ class JwtManager extends Mixin {
|
|
|
5912
5912
|
throw new Error("JWT secret key is required.");
|
|
5913
5913
|
}
|
|
5914
5914
|
}
|
|
5915
|
-
createToken(payload, expiresIn, options) {
|
|
5916
|
-
return this.createBasicToken(payload, 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 }));
|
|
5915
|
+
createToken(payload, secretKey, expiresIn, options) {
|
|
5916
|
+
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 }));
|
|
5917
5917
|
}
|
|
5918
5918
|
createTokenWithSecret(payload, secretKey, expiresIn, options) {
|
|
5919
5919
|
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 }));
|
|
5920
5920
|
}
|
|
5921
|
-
createCleanCredentialsToken(operative = Operatives.CATALOG, expiresIn) {
|
|
5921
|
+
createCleanCredentialsToken(operative = Operatives.CATALOG, secretKey, expiresIn) {
|
|
5922
5922
|
const payload = { accessType: operative };
|
|
5923
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5923
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5924
5924
|
}
|
|
5925
|
-
getTokenWithoutKey(payload, expiresIn, options) {
|
|
5926
|
-
return this.createToken(payload, expiresIn, options);
|
|
5925
|
+
getTokenWithoutKey(payload, secretKey, expiresIn, options) {
|
|
5926
|
+
return this.createToken(payload, secretKey, expiresIn, options);
|
|
5927
5927
|
}
|
|
5928
5928
|
getTokenWithKey(payload, secretKey, expiresIn, options) {
|
|
5929
5929
|
return this.createTokenWithSecret(payload, secretKey, expiresIn, options);
|
|
5930
5930
|
}
|
|
5931
|
-
getTokenCleanCredentials(operative = Operatives.CATALOG, expiresIn) {
|
|
5932
|
-
return this.createCleanCredentialsToken(operative, expiresIn);
|
|
5931
|
+
getTokenCleanCredentials(operative = Operatives.CATALOG, secretKey, expiresIn) {
|
|
5932
|
+
return this.createCleanCredentialsToken(operative, secretKey, expiresIn);
|
|
5933
5933
|
}
|
|
5934
|
-
createIdToken(claims, expiresIn) {
|
|
5934
|
+
createIdToken(claims, secretKey, expiresIn) {
|
|
5935
5935
|
if (!claims.sub) {
|
|
5936
5936
|
throw new Error('sub (subject) claim is required for ID tokens');
|
|
5937
5937
|
}
|
|
5938
5938
|
const payload = Object.assign(Object.assign({}, claims), { iss: this._issuer, aud: this._audience, iat: Math.floor(Date.now() / 1000) });
|
|
5939
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn, { issuer: this._issuer, audience: this._audience });
|
|
5939
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, { issuer: this._issuer, audience: this._audience });
|
|
5940
5940
|
}
|
|
5941
|
-
createAccessToken(sub, scopes, expiresIn) {
|
|
5941
|
+
createAccessToken(sub, scopes, secretKey, expiresIn) {
|
|
5942
5942
|
const payload = {
|
|
5943
5943
|
sub,
|
|
5944
5944
|
scope: scopes.join(' '),
|
|
@@ -5946,9 +5946,9 @@ class JwtManager extends Mixin {
|
|
|
5946
5946
|
aud: this._audience,
|
|
5947
5947
|
iat: Math.floor(Date.now() / 1000),
|
|
5948
5948
|
};
|
|
5949
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || '15m', { issuer: this._issuer, audience: this._audience });
|
|
5949
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '15m', { issuer: this._issuer, audience: this._audience });
|
|
5950
5950
|
}
|
|
5951
|
-
createRefreshToken(sub, expiresIn) {
|
|
5951
|
+
createRefreshToken(sub, secretKey, expiresIn) {
|
|
5952
5952
|
const payload = {
|
|
5953
5953
|
sub,
|
|
5954
5954
|
type: 'refresh',
|
|
@@ -5956,7 +5956,7 @@ class JwtManager extends Mixin {
|
|
|
5956
5956
|
aud: this._audience,
|
|
5957
5957
|
iat: Math.floor(Date.now() / 1000),
|
|
5958
5958
|
};
|
|
5959
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || '30d', {
|
|
5959
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '30d', {
|
|
5960
5960
|
issuer: this._issuer,
|
|
5961
5961
|
audience: this._audience,
|
|
5962
5962
|
jwtid: this.generateJti()
|
|
@@ -5914,33 +5914,33 @@ class JwtManager extends Mixin {
|
|
|
5914
5914
|
throw new Error("JWT secret key is required.");
|
|
5915
5915
|
}
|
|
5916
5916
|
}
|
|
5917
|
-
createToken(payload, expiresIn, options) {
|
|
5918
|
-
return this.createBasicToken(payload, 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 }));
|
|
5917
|
+
createToken(payload, secretKey, expiresIn, options) {
|
|
5918
|
+
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 }));
|
|
5919
5919
|
}
|
|
5920
5920
|
createTokenWithSecret(payload, secretKey, expiresIn, options) {
|
|
5921
5921
|
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 }));
|
|
5922
5922
|
}
|
|
5923
|
-
createCleanCredentialsToken(operative = exports.Operatives.CATALOG, expiresIn) {
|
|
5923
|
+
createCleanCredentialsToken(operative = exports.Operatives.CATALOG, secretKey, expiresIn) {
|
|
5924
5924
|
const payload = { accessType: operative };
|
|
5925
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5925
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn);
|
|
5926
5926
|
}
|
|
5927
|
-
getTokenWithoutKey(payload, expiresIn, options) {
|
|
5928
|
-
return this.createToken(payload, expiresIn, options);
|
|
5927
|
+
getTokenWithoutKey(payload, secretKey, expiresIn, options) {
|
|
5928
|
+
return this.createToken(payload, secretKey, expiresIn, options);
|
|
5929
5929
|
}
|
|
5930
5930
|
getTokenWithKey(payload, secretKey, expiresIn, options) {
|
|
5931
5931
|
return this.createTokenWithSecret(payload, secretKey, expiresIn, options);
|
|
5932
5932
|
}
|
|
5933
|
-
getTokenCleanCredentials(operative = exports.Operatives.CATALOG, expiresIn) {
|
|
5934
|
-
return this.createCleanCredentialsToken(operative, expiresIn);
|
|
5933
|
+
getTokenCleanCredentials(operative = exports.Operatives.CATALOG, secretKey, expiresIn) {
|
|
5934
|
+
return this.createCleanCredentialsToken(operative, secretKey, expiresIn);
|
|
5935
5935
|
}
|
|
5936
|
-
createIdToken(claims, expiresIn) {
|
|
5936
|
+
createIdToken(claims, secretKey, expiresIn) {
|
|
5937
5937
|
if (!claims.sub) {
|
|
5938
5938
|
throw new Error('sub (subject) claim is required for ID tokens');
|
|
5939
5939
|
}
|
|
5940
5940
|
const payload = Object.assign(Object.assign({}, claims), { iss: this._issuer, aud: this._audience, iat: Math.floor(Date.now() / 1000) });
|
|
5941
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn, { issuer: this._issuer, audience: this._audience });
|
|
5941
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || jwtConfig.expiresIn, { issuer: this._issuer, audience: this._audience });
|
|
5942
5942
|
}
|
|
5943
|
-
createAccessToken(sub, scopes, expiresIn) {
|
|
5943
|
+
createAccessToken(sub, scopes, secretKey, expiresIn) {
|
|
5944
5944
|
const payload = {
|
|
5945
5945
|
sub,
|
|
5946
5946
|
scope: scopes.join(' '),
|
|
@@ -5948,9 +5948,9 @@ class JwtManager extends Mixin {
|
|
|
5948
5948
|
aud: this._audience,
|
|
5949
5949
|
iat: Math.floor(Date.now() / 1000),
|
|
5950
5950
|
};
|
|
5951
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || '15m', { issuer: this._issuer, audience: this._audience });
|
|
5951
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '15m', { issuer: this._issuer, audience: this._audience });
|
|
5952
5952
|
}
|
|
5953
|
-
createRefreshToken(sub, expiresIn) {
|
|
5953
|
+
createRefreshToken(sub, secretKey, expiresIn) {
|
|
5954
5954
|
const payload = {
|
|
5955
5955
|
sub,
|
|
5956
5956
|
type: 'refresh',
|
|
@@ -5958,7 +5958,7 @@ class JwtManager extends Mixin {
|
|
|
5958
5958
|
aud: this._audience,
|
|
5959
5959
|
iat: Math.floor(Date.now() / 1000),
|
|
5960
5960
|
};
|
|
5961
|
-
return this.createBasicToken(payload, this._secretKey, expiresIn || '30d', {
|
|
5961
|
+
return this.createBasicToken(payload, secretKey || this._secretKey, expiresIn || '30d', {
|
|
5962
5962
|
issuer: this._issuer,
|
|
5963
5963
|
audience: this._audience,
|
|
5964
5964
|
jwtid: this.generateJti()
|
|
@@ -8,15 +8,15 @@ export declare class JwtManager extends Mixin {
|
|
|
8
8
|
private _issuer;
|
|
9
9
|
private _audience;
|
|
10
10
|
constructor();
|
|
11
|
-
createToken(payload: object, expiresIn?: string | number, options?: SignOptions): string;
|
|
11
|
+
createToken(payload: object, secretKey?: string, expiresIn?: string | number, options?: SignOptions): string;
|
|
12
12
|
createTokenWithSecret(payload: object, secretKey: string, expiresIn?: string | number, options?: SignOptions): string;
|
|
13
|
-
createCleanCredentialsToken(operative?: Operatives, expiresIn?: string | number): string;
|
|
14
|
-
getTokenWithoutKey(payload: object, expiresIn?: string | number, options?: SignOptions): string;
|
|
13
|
+
createCleanCredentialsToken(operative?: Operatives, secretKey?: string, expiresIn?: string | number): string;
|
|
14
|
+
getTokenWithoutKey(payload: object, secretKey?: string, expiresIn?: string | number, options?: SignOptions): string;
|
|
15
15
|
getTokenWithKey(payload: object, secretKey: string, expiresIn?: string | number, options?: SignOptions): string;
|
|
16
|
-
getTokenCleanCredentials(operative?: Operatives, expiresIn?: string | number): string;
|
|
17
|
-
createIdToken(claims: StandardClaims, expiresIn?: string | number): string;
|
|
18
|
-
createAccessToken(sub: string, scopes: string[], expiresIn?: string | number): string;
|
|
19
|
-
createRefreshToken(sub: string, expiresIn?: string | number): string;
|
|
16
|
+
getTokenCleanCredentials(operative?: Operatives, secretKey?: string, expiresIn?: string | number): string;
|
|
17
|
+
createIdToken(claims: StandardClaims, secretKey?: string, expiresIn?: string | number): string;
|
|
18
|
+
createAccessToken(sub: string, scopes: string[], secretKey?: string, expiresIn?: string | number): string;
|
|
19
|
+
createRefreshToken(sub: string, secretKey?: string, expiresIn?: string | number): string;
|
|
20
20
|
verify(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
|
|
21
21
|
verifyDetailed(token: string, secretKey?: string, options?: VerifyOptions): TokenValidationResult;
|
|
22
22
|
validateToken(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
|
package/package.json
CHANGED