vona-cli-set-api 1.0.107 → 1.0.111
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/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/.metadata/index.d.ts +7 -14
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/config/config.d.ts +0 -3
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/index.ts +7 -20
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/config/config.ts +0 -3
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/passportAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/authTokenAdapter.ts +0 -34
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/redisToken.ts +0 -63
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.111",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
32
32
|
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
33
33
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
34
|
-
"@cabloy/cli": "^3.0.
|
|
34
|
+
"@cabloy/cli": "^3.0.40",
|
|
35
35
|
"@cabloy/dotenv": "^1.1.10",
|
|
36
36
|
"@cabloy/extend": "^3.1.10",
|
|
37
|
-
"@cabloy/module-glob": "^5.2.
|
|
37
|
+
"@cabloy/module-glob": "^5.2.22",
|
|
38
38
|
"@cabloy/module-info": "^1.3.24",
|
|
39
39
|
"@cabloy/word-utils": "^2.0.1",
|
|
40
40
|
"@lcov-viewer/cli": "^1.3.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"urllib": "^4.6.11",
|
|
63
63
|
"uuid": "^11.1.0",
|
|
64
|
-
"vona-core": "^5.0.
|
|
64
|
+
"vona-core": "^5.0.36",
|
|
65
65
|
"why-is-node-running": "^3.2.2",
|
|
66
66
|
"yargs-parser": "^21.1.1"
|
|
67
67
|
},
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { IAuthTokenAdapter, IUserBase } from 'vona-module-a-user';
|
|
2
|
-
import type { IPayloadData } from '../types/passport.ts';
|
|
3
|
-
import { BeanBase, createHash, uuidv4 } from 'vona';
|
|
4
|
-
import { Service } from 'vona-module-a-bean';
|
|
5
|
-
|
|
6
|
-
@Service()
|
|
7
|
-
export class ServiceAuthTokenAdapter extends BeanBase implements IAuthTokenAdapter {
|
|
8
|
-
async create(payloadData: IPayloadData): Promise<IPayloadData> {
|
|
9
|
-
const token = (payloadData.authId.toString() === '-1') ? createHash(payloadData.authId.toString()) : uuidv4();
|
|
10
|
-
const payloadDataNew = Object.assign({}, payloadData, { token });
|
|
11
|
-
await this.scope.service.redisToken.create(payloadDataNew);
|
|
12
|
-
return payloadDataNew;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async retrieve(payloadData: IPayloadData): Promise<IPayloadData | undefined> {
|
|
16
|
-
return await this.scope.service.redisToken.retrieve(payloadData);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async verify(payloadData: IPayloadData): Promise<boolean> {
|
|
20
|
-
return await this.scope.service.redisToken.verify(payloadData);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async refresh(payloadData: IPayloadData): Promise<void> {
|
|
24
|
-
await this.scope.service.redisToken.refresh(payloadData);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async remove(payloadData: IPayloadData): Promise<void> {
|
|
28
|
-
await this.scope.service.redisToken.remove(payloadData);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async removeAll(user: IUserBase): Promise<void> {
|
|
32
|
-
await this.scope.service.redisToken.removeAll(user);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { IUserBase } from 'vona-module-a-user';
|
|
2
|
-
import type { IPayloadData } from '../types/passport.ts';
|
|
3
|
-
import { BeanBase } from 'vona';
|
|
4
|
-
import { Service } from 'vona-module-a-bean';
|
|
5
|
-
|
|
6
|
-
@Service()
|
|
7
|
-
export class ServiceRedisToken extends BeanBase {
|
|
8
|
-
private get redisAuth() {
|
|
9
|
-
return this.bean.redis.get('auth');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async verify(payloadData: IPayloadData) {
|
|
13
|
-
const payloadData2 = await this.retrieve(payloadData);
|
|
14
|
-
if (!payloadData2) return false;
|
|
15
|
-
if (payloadData2.token !== payloadData.token) return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async retrieve(payloadData: IPayloadData): Promise<IPayloadData | undefined> {
|
|
20
|
-
const key = this._getAuthRedisKey(payloadData);
|
|
21
|
-
if (!key) return;
|
|
22
|
-
const token = await this.redisAuth.get(key);
|
|
23
|
-
if (!token) return;
|
|
24
|
-
return { ...payloadData, token };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async create(payloadData: IPayloadData) {
|
|
28
|
-
const key = this._getAuthRedisKey(payloadData);
|
|
29
|
-
if (!key || !payloadData.token) return this.app.throw(401);
|
|
30
|
-
await this.redisAuth.set(key, payloadData.token, 'EX', this.scope.config.redisToken.maxAge);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async refresh(payloadData: IPayloadData) {
|
|
34
|
-
const key = this._getAuthRedisKey(payloadData);
|
|
35
|
-
if (!key) return this.app.throw(401);
|
|
36
|
-
await this.redisAuth.expire(key, this.scope.config.redisToken.maxAge);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async remove(payloadData: IPayloadData) {
|
|
40
|
-
const key = this._getAuthRedisKey(payloadData);
|
|
41
|
-
if (!key) return;
|
|
42
|
-
await this.redisAuth.del(key);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async removeAll(user: IUserBase) {
|
|
46
|
-
const keyPrefix = this.redisAuth.options.keyPrefix;
|
|
47
|
-
const keyPattern = this._getAuthRedisKeyPattern(user, keyPrefix);
|
|
48
|
-
const keys = await this.redisAuth.keys(keyPattern);
|
|
49
|
-
for (const fullKey of keys) {
|
|
50
|
-
const key = keyPrefix ? fullKey.substring(keyPrefix.length) : fullKey;
|
|
51
|
-
await this.redisAuth.del(key);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private _getAuthRedisKey(payloadData: IPayloadData) {
|
|
56
|
-
if (!this.ctx.instance) return;
|
|
57
|
-
return `authToken:${this.ctx.instance.id}:${payloadData.userId}:${payloadData.authId}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private _getAuthRedisKeyPattern(user: IUserBase, keyPrefix: string | undefined) {
|
|
61
|
-
return `${keyPrefix ?? ''}authToken:${this.ctx.instance.id}:${user.id}:*`;
|
|
62
|
-
}
|
|
63
|
-
}
|