vona-module-a-jwt 5.0.23 → 5.0.24
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.
- package/dist/index.js +6 -3
- package/dist/types/jwt.d.ts +5 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ let ServiceJwtClient = (_dec$4 = Service(), _dec2$4 = BeanInfo({
|
|
|
57
57
|
}
|
|
58
58
|
if (options?.temp) {
|
|
59
59
|
signOptions = Object.assign({}, signOptions, {
|
|
60
|
-
expiresIn: this.scope.config.
|
|
60
|
+
expiresIn: this.scope.config.tempAuthToken.signOptions.expiresIn
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
this._jwtInstance.sign(payload, this._clientOptions.secret, signOptions, (err, encoded) => {
|
|
@@ -70,7 +70,7 @@ let ServiceJwtClient = (_dec$4 = Service(), _dec2$4 = BeanInfo({
|
|
|
70
70
|
if (!token && this._clientName === 'access') token = this.scope.service.jwtExtract.fromAllWays();
|
|
71
71
|
if (!token) return undefined;
|
|
72
72
|
return new Promise((resolve, reject) => {
|
|
73
|
-
this._jwtInstance.verify(token, this._clientOptions.secret, this._clientOptions.
|
|
73
|
+
this._jwtInstance.verify(token, this._clientOptions.secret, this._clientOptions.verifyOptions, (err, decoded) => {
|
|
74
74
|
if (err) return reject(err);
|
|
75
75
|
const payload = cast(decoded);
|
|
76
76
|
// check field client
|
|
@@ -226,7 +226,7 @@ function config(app) {
|
|
|
226
226
|
cookie: 'token'
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
|
-
|
|
229
|
+
tempAuthToken: {
|
|
230
230
|
signOptions: {
|
|
231
231
|
expiresIn: 10 * 60
|
|
232
232
|
}
|
|
@@ -235,6 +235,9 @@ function config(app) {
|
|
|
235
235
|
secret: undefined,
|
|
236
236
|
signOptions: {
|
|
237
237
|
issuer: app.meta.env.APP_NAME
|
|
238
|
+
},
|
|
239
|
+
verifyOptions: {
|
|
240
|
+
issuer: app.meta.env.APP_NAME
|
|
238
241
|
}
|
|
239
242
|
},
|
|
240
243
|
clients: {
|
package/dist/types/jwt.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { SignOptions } from 'jsonwebtoken';
|
|
1
|
+
import type { SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
2
|
+
import type { StringValue } from 'ms';
|
|
2
3
|
export declare const ErrorMessageJwtExpired = "jwt expired";
|
|
3
4
|
export interface IJwtToken {
|
|
4
5
|
accessToken: string;
|
|
@@ -23,6 +24,7 @@ export interface IJwtVerifyOptions {
|
|
|
23
24
|
export interface IJwtClientOptions {
|
|
24
25
|
secret?: string;
|
|
25
26
|
signOptions: SignOptions;
|
|
27
|
+
verifyOptions?: VerifyOptions;
|
|
26
28
|
}
|
|
27
29
|
export interface ConfigJwt {
|
|
28
30
|
field: {
|
|
@@ -39,9 +41,9 @@ export interface ConfigJwt {
|
|
|
39
41
|
cookie: string;
|
|
40
42
|
};
|
|
41
43
|
};
|
|
42
|
-
|
|
44
|
+
tempAuthToken: {
|
|
43
45
|
signOptions: {
|
|
44
|
-
expiresIn: number;
|
|
46
|
+
expiresIn: StringValue | number;
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
49
|
base: IJwtClientOptions;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-jwt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.24",
|
|
5
5
|
"title": "a-jwt",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {}
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@types/jsonwebtoken": "9.0.
|
|
29
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
30
|
+
"@types/ms": "^2.1.0",
|
|
30
31
|
"jsonwebtoken": "^9.0.2",
|
|
31
32
|
"ms": "^2.1.3"
|
|
32
33
|
},
|