vona-module-a-jwt 5.0.23 → 5.0.25
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/config/config.d.ts +2 -2
- package/dist/index.js +9 -6
- package/dist/types/jwt.d.ts +5 -3
- package/package.json +3 -2
package/dist/config/config.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { VonaApplication } from 'vona';
|
|
1
|
+
import type { VonaApplication, VonaConfigEnv } from 'vona';
|
|
2
2
|
import type { ConfigJwt } from '../types/jwt.ts';
|
|
3
|
-
export declare function config(
|
|
3
|
+
export declare function config(_app: VonaApplication, env: VonaConfigEnv): ConfigJwt;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { BeanInfo, BeanBase, deepExtend, cast, BeanScopeBase } from 'vona';
|
|
|
2
2
|
import ms from 'ms';
|
|
3
3
|
import { Service, Bean, Scope } from 'vona-module-a-bean';
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
|
-
import { Api } from 'vona-module-a-
|
|
5
|
+
import { Api } from 'vona-module-a-openapiutils';
|
|
6
6
|
import { Dto } from 'vona-module-a-web';
|
|
7
7
|
|
|
8
8
|
var _dec$4, _dec2$4, _class$4;
|
|
@@ -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
|
|
@@ -210,7 +210,7 @@ let DtoJwtToken = (_dec$1 = Dto(), _dec2$1 = BeanInfo({
|
|
|
210
210
|
initializer: null
|
|
211
211
|
}), _class2)) || _class$1) || _class$1);
|
|
212
212
|
|
|
213
|
-
function config(
|
|
213
|
+
function config(_app, env) {
|
|
214
214
|
return {
|
|
215
215
|
field: {
|
|
216
216
|
payload: {
|
|
@@ -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
|
}
|
|
@@ -234,7 +234,10 @@ function config(app) {
|
|
|
234
234
|
base: {
|
|
235
235
|
secret: undefined,
|
|
236
236
|
signOptions: {
|
|
237
|
-
issuer:
|
|
237
|
+
issuer: env.APP_NAME
|
|
238
|
+
},
|
|
239
|
+
verifyOptions: {
|
|
240
|
+
issuer: 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.25",
|
|
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
|
},
|