@grandlinex/kernel 0.31.0 → 0.32.0
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/CHANGELOG.md +6 -0
- package/dist/cjs/actions/GetTokenAction.js +1 -1
- package/dist/cjs/classes/BaseAuthProvider.d.ts +2 -2
- package/dist/cjs/classes/BaseAuthProvider.js +1 -1
- package/dist/cjs/classes/timing/ServerTiming.js +1 -1
- package/dist/cjs/lib/express.d.ts +1 -1
- package/dist/cjs/lib/index.d.ts +1 -1
- package/dist/cjs/modules/crypto/CryptoClient.d.ts +1 -1
- package/dist/cjs/modules/crypto/CryptoClient.js +3 -3
- package/dist/mjs/actions/GetTokenAction.js +1 -1
- package/dist/mjs/classes/BaseAuthProvider.d.ts +2 -2
- package/dist/mjs/classes/BaseAuthProvider.js +1 -1
- package/dist/mjs/classes/timing/ServerTiming.js +1 -1
- package/dist/mjs/lib/express.d.ts +1 -1
- package/dist/mjs/lib/index.d.ts +1 -1
- package/dist/mjs/modules/crypto/CryptoClient.d.ts +1 -1
- package/dist/mjs/modules/crypto/CryptoClient.js +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [v0.31.1] - 2023-07-07
|
|
5
|
+
### Added
|
|
6
|
+
- @/token pass the token body to jwt generator function
|
|
7
|
+
### Fixed
|
|
8
|
+
- Deal with code smells
|
|
9
|
+
|
|
4
10
|
## [v0.31.0] - 2023-07-06
|
|
5
11
|
### Added
|
|
6
12
|
- JTW Token now can be extended with custom payload
|
|
@@ -13,11 +13,11 @@ export interface IAuthProvider<T extends JwtExtend> {
|
|
|
13
13
|
authorizeToken(userid: string, token: string, requestType: string): Promise<AuthResult>;
|
|
14
14
|
validateAccess(token: JwtToken<T>, requestType: string): Promise<boolean>;
|
|
15
15
|
bearerTokenValidation(req: XRequest): Promise<JwtToken<T> | number>;
|
|
16
|
-
jwtAddData(token: JwtToken<T>): Promise<JwtToken<T>>;
|
|
16
|
+
jwtAddData(token: JwtToken<T>, extend?: Record<string, any>): Promise<JwtToken<T>>;
|
|
17
17
|
}
|
|
18
18
|
export default abstract class BaseAuthProvider<T extends JwtExtend = JwtExtend> implements IAuthProvider<T> {
|
|
19
19
|
abstract authorizeToken(username: string, token: string, requestType: string): Promise<AuthResult>;
|
|
20
20
|
abstract validateAccess(token: JwtToken<T>, requestType: string): Promise<boolean>;
|
|
21
21
|
abstract bearerTokenValidation(req: XRequest): Promise<JwtToken<T> | number>;
|
|
22
|
-
jwtAddData(token: JwtToken<T>): Promise<JwtToken<T>>;
|
|
22
|
+
jwtAddData(token: JwtToken<T>, extend?: Record<string, any>): Promise<JwtToken<T>>;
|
|
23
23
|
}
|
package/dist/cjs/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ICClient<T extends JwtExtend = JwtExtend> extends ICoreCClient
|
|
|
8
8
|
setAuthProvider(provider: IAuthProvider<T>): boolean;
|
|
9
9
|
jwtVerifyAccessToken(token: string): Promise<JwtToken<T> | number>;
|
|
10
10
|
jwtDecodeAccessToken(token: string): jwt.JwtPayload | null;
|
|
11
|
-
jwtGenerateAccessToken(data: JwtToken<T>, expire?: string | number): Promise<string>;
|
|
11
|
+
jwtGenerateAccessToken(data: JwtToken<T>, extend?: Record<string, any>, expire?: string | number): Promise<string>;
|
|
12
12
|
apiTokenValidation(username: string, token: string, requestType: string): Promise<{
|
|
13
13
|
valid: boolean;
|
|
14
14
|
userId: string | null;
|
|
@@ -10,7 +10,7 @@ export default class CryptoClient<T extends JwtExtend = JwtExtend> extends CoreC
|
|
|
10
10
|
setAuthProvider(provider: IAuthProvider<T>): boolean;
|
|
11
11
|
jwtVerifyAccessToken(token: string): Promise<JwtToken<T> | number>;
|
|
12
12
|
jwtDecodeAccessToken(token: string): JwtToken<T> | null;
|
|
13
|
-
jwtGenerateAccessToken(data: JwtToken<T>, expire?: string | number): Promise<string>;
|
|
13
|
+
jwtGenerateAccessToken(data: JwtToken<T>, extend?: Record<string, any>, expire?: string | number): Promise<string>;
|
|
14
14
|
apiTokenValidation(username: string, token: string, requestType: string): Promise<{
|
|
15
15
|
valid: boolean;
|
|
16
16
|
userId: string | null;
|
|
@@ -59,10 +59,10 @@ class CryptoClient extends core_1.CoreCryptoClient {
|
|
|
59
59
|
const mod = jwt.default || jwt;
|
|
60
60
|
return mod.decode(token, { json: true });
|
|
61
61
|
}
|
|
62
|
-
async jwtGenerateAccessToken(data, expire) {
|
|
62
|
+
async jwtGenerateAccessToken(data, extend, expire) {
|
|
63
63
|
let sData;
|
|
64
64
|
if (this.authProvider) {
|
|
65
|
-
sData = await this.authProvider.jwtAddData(data);
|
|
65
|
+
sData = await this.authProvider.jwtAddData(data, extend);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
68
|
sData = data;
|
|
@@ -103,7 +103,7 @@ class CryptoClient extends core_1.CoreCryptoClient {
|
|
|
103
103
|
return this.authProvider.bearerTokenValidation(req);
|
|
104
104
|
}
|
|
105
105
|
const authHeader = req.headers.authorization;
|
|
106
|
-
const token = authHeader
|
|
106
|
+
const token = authHeader?.split(' ')?.[1];
|
|
107
107
|
if (!token) {
|
|
108
108
|
return 401;
|
|
109
109
|
}
|
|
@@ -13,11 +13,11 @@ export interface IAuthProvider<T extends JwtExtend> {
|
|
|
13
13
|
authorizeToken(userid: string, token: string, requestType: string): Promise<AuthResult>;
|
|
14
14
|
validateAccess(token: JwtToken<T>, requestType: string): Promise<boolean>;
|
|
15
15
|
bearerTokenValidation(req: XRequest): Promise<JwtToken<T> | number>;
|
|
16
|
-
jwtAddData(token: JwtToken<T>): Promise<JwtToken<T>>;
|
|
16
|
+
jwtAddData(token: JwtToken<T>, extend?: Record<string, any>): Promise<JwtToken<T>>;
|
|
17
17
|
}
|
|
18
18
|
export default abstract class BaseAuthProvider<T extends JwtExtend = JwtExtend> implements IAuthProvider<T> {
|
|
19
19
|
abstract authorizeToken(username: string, token: string, requestType: string): Promise<AuthResult>;
|
|
20
20
|
abstract validateAccess(token: JwtToken<T>, requestType: string): Promise<boolean>;
|
|
21
21
|
abstract bearerTokenValidation(req: XRequest): Promise<JwtToken<T> | number>;
|
|
22
|
-
jwtAddData(token: JwtToken<T>): Promise<JwtToken<T>>;
|
|
22
|
+
jwtAddData(token: JwtToken<T>, extend?: Record<string, any>): Promise<JwtToken<T>>;
|
|
23
23
|
}
|
package/dist/mjs/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ICClient<T extends JwtExtend = JwtExtend> extends ICoreCClient
|
|
|
8
8
|
setAuthProvider(provider: IAuthProvider<T>): boolean;
|
|
9
9
|
jwtVerifyAccessToken(token: string): Promise<JwtToken<T> | number>;
|
|
10
10
|
jwtDecodeAccessToken(token: string): jwt.JwtPayload | null;
|
|
11
|
-
jwtGenerateAccessToken(data: JwtToken<T>, expire?: string | number): Promise<string>;
|
|
11
|
+
jwtGenerateAccessToken(data: JwtToken<T>, extend?: Record<string, any>, expire?: string | number): Promise<string>;
|
|
12
12
|
apiTokenValidation(username: string, token: string, requestType: string): Promise<{
|
|
13
13
|
valid: boolean;
|
|
14
14
|
userId: string | null;
|
|
@@ -10,7 +10,7 @@ export default class CryptoClient<T extends JwtExtend = JwtExtend> extends CoreC
|
|
|
10
10
|
setAuthProvider(provider: IAuthProvider<T>): boolean;
|
|
11
11
|
jwtVerifyAccessToken(token: string): Promise<JwtToken<T> | number>;
|
|
12
12
|
jwtDecodeAccessToken(token: string): JwtToken<T> | null;
|
|
13
|
-
jwtGenerateAccessToken(data: JwtToken<T>, expire?: string | number): Promise<string>;
|
|
13
|
+
jwtGenerateAccessToken(data: JwtToken<T>, extend?: Record<string, any>, expire?: string | number): Promise<string>;
|
|
14
14
|
apiTokenValidation(username: string, token: string, requestType: string): Promise<{
|
|
15
15
|
valid: boolean;
|
|
16
16
|
userId: string | null;
|
|
@@ -34,10 +34,10 @@ export default class CryptoClient extends CoreCryptoClient {
|
|
|
34
34
|
const mod = jwt.default || jwt;
|
|
35
35
|
return mod.decode(token, { json: true });
|
|
36
36
|
}
|
|
37
|
-
async jwtGenerateAccessToken(data, expire) {
|
|
37
|
+
async jwtGenerateAccessToken(data, extend, expire) {
|
|
38
38
|
let sData;
|
|
39
39
|
if (this.authProvider) {
|
|
40
|
-
sData = await this.authProvider.jwtAddData(data);
|
|
40
|
+
sData = await this.authProvider.jwtAddData(data, extend);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
sData = data;
|
|
@@ -78,7 +78,7 @@ export default class CryptoClient extends CoreCryptoClient {
|
|
|
78
78
|
return this.authProvider.bearerTokenValidation(req);
|
|
79
79
|
}
|
|
80
80
|
const authHeader = req.headers.authorization;
|
|
81
|
-
const token = authHeader
|
|
81
|
+
const token = authHeader?.split(' ')?.[1];
|
|
82
82
|
if (!token) {
|
|
83
83
|
return 401;
|
|
84
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grandlinex/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "GrandLineX is an out-of-the-box server framework on top of ExpressJs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "BSD-3-Clause",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@grandlinex/core": "0.
|
|
49
|
+
"@grandlinex/core": "0.32.0",
|
|
50
50
|
"axios": "1.4.0",
|
|
51
51
|
"body-parser": "1.20.2",
|
|
52
52
|
"express": "4.18.2",
|