vona-module-a-user 5.0.19 → 5.0.20
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/.metadata/index.d.ts +36 -0
- package/dist/bean/bean.passport.d.ts +4 -3
- package/dist/bean/bean.roleInner.d.ts +2 -2
- package/dist/index.js +17 -6
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/role.d.ts +1 -1
- package/dist/lib/user.d.ts +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/role.d.ts +2 -2
- package/dist/types/user.d.ts +1 -1
- package/package.json +1 -1
|
@@ -18,10 +18,22 @@ declare module 'vona-module-a-aspect' {
|
|
|
18
18
|
declare module 'vona-module-a-user' {
|
|
19
19
|
interface GuardPassport {
|
|
20
20
|
}
|
|
21
|
+
interface GuardPassport {
|
|
22
|
+
get $beanFullName(): 'a-user.guard.passport';
|
|
23
|
+
get $onionName(): 'a-user:passport';
|
|
24
|
+
}
|
|
21
25
|
interface GuardRoleName {
|
|
22
26
|
}
|
|
27
|
+
interface GuardRoleName {
|
|
28
|
+
get $beanFullName(): 'a-user.guard.roleName';
|
|
29
|
+
get $onionName(): 'a-user:roleName';
|
|
30
|
+
}
|
|
23
31
|
interface GuardUserName {
|
|
24
32
|
}
|
|
33
|
+
interface GuardUserName {
|
|
34
|
+
get $beanFullName(): 'a-user.guard.userName';
|
|
35
|
+
get $onionName(): 'a-user:userName';
|
|
36
|
+
}
|
|
25
37
|
}
|
|
26
38
|
/** guard: end */
|
|
27
39
|
/** bean: begin */
|
|
@@ -71,7 +83,15 @@ declare module 'vona-module-a-bean' {
|
|
|
71
83
|
declare module 'vona-module-a-user' {
|
|
72
84
|
interface ServiceAuthTokenAdapter {
|
|
73
85
|
}
|
|
86
|
+
interface ServiceAuthTokenAdapter {
|
|
87
|
+
get $beanFullName(): 'a-user.service.authTokenAdapter';
|
|
88
|
+
get $onionName(): 'a-user:authTokenAdapter';
|
|
89
|
+
}
|
|
90
|
+
interface ServiceRedisToken {
|
|
91
|
+
}
|
|
74
92
|
interface ServiceRedisToken {
|
|
93
|
+
get $beanFullName(): 'a-user.service.redisToken';
|
|
94
|
+
get $onionName(): 'a-user:redisToken';
|
|
75
95
|
}
|
|
76
96
|
}
|
|
77
97
|
/** service: end */
|
|
@@ -102,10 +122,22 @@ declare module 'vona' {
|
|
|
102
122
|
declare module 'vona-module-a-user' {
|
|
103
123
|
interface EventCreateUserAnonymous {
|
|
104
124
|
}
|
|
125
|
+
interface EventCreateUserAnonymous {
|
|
126
|
+
get $beanFullName(): 'a-user.event.createUserAnonymous';
|
|
127
|
+
get $onionName(): 'a-user:createUserAnonymous';
|
|
128
|
+
}
|
|
129
|
+
interface EventSignin {
|
|
130
|
+
}
|
|
105
131
|
interface EventSignin {
|
|
132
|
+
get $beanFullName(): 'a-user.event.signin';
|
|
133
|
+
get $onionName(): 'a-user:signin';
|
|
106
134
|
}
|
|
107
135
|
interface EventSignout {
|
|
108
136
|
}
|
|
137
|
+
interface EventSignout {
|
|
138
|
+
get $beanFullName(): 'a-user.event.signout';
|
|
139
|
+
get $onionName(): 'a-user:signout';
|
|
140
|
+
}
|
|
109
141
|
}
|
|
110
142
|
/** event: end */
|
|
111
143
|
/** event: begin */
|
|
@@ -142,6 +174,10 @@ declare module 'vona' {
|
|
|
142
174
|
declare module 'vona-module-a-user' {
|
|
143
175
|
interface MetaPrintTip {
|
|
144
176
|
}
|
|
177
|
+
interface MetaPrintTip {
|
|
178
|
+
get $beanFullName(): 'a-user.meta.printTip';
|
|
179
|
+
get $onionName(): 'a-user:printTip';
|
|
180
|
+
}
|
|
145
181
|
}
|
|
146
182
|
/** meta: end */
|
|
147
183
|
/** config: begin */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IJwtClientRecord, IJwtSignOptions, IJwtToken, IPayloadDataBase } from 'vona-module-a-jwt';
|
|
1
|
+
import type { IJwtClientRecord, IJwtSignOptions, IJwtToken, IJwtVerifyOptions, IPayloadDataBase } from 'vona-module-a-jwt';
|
|
2
2
|
import type { IAuthBase, IAuthIdRecord, ISigninOptions } from '../types/auth.ts';
|
|
3
3
|
import type { IPassportBase } from '../types/passport.ts';
|
|
4
4
|
import type { IRoleBase } from '../types/role.ts';
|
|
@@ -24,11 +24,12 @@ export declare class BeanPassport extends BeanBase {
|
|
|
24
24
|
signinWithAnonymous(): Promise<void>;
|
|
25
25
|
createUserAnonymous(): Promise<IUserBase>;
|
|
26
26
|
kickOut(user: IUserBase): Promise<void>;
|
|
27
|
-
checkAuthToken(accessToken?: string, clientName?: keyof IJwtClientRecord): Promise<IPayloadDataBase | undefined>;
|
|
27
|
+
checkAuthToken(accessToken?: string, clientName?: keyof IJwtClientRecord, options?: IJwtVerifyOptions): Promise<IPayloadDataBase | undefined>;
|
|
28
28
|
refreshAuthToken(refreshToken: string): Promise<IJwtToken>;
|
|
29
29
|
createTempAuthToken(options?: IJwtSignOptions): Promise<string>;
|
|
30
30
|
createOauthAuthToken(options?: IJwtSignOptions): Promise<string>;
|
|
31
|
-
createOauthCode(
|
|
31
|
+
createOauthCode(options?: IJwtSignOptions): Promise<string>;
|
|
32
|
+
createOauthCodeFromOauthAuthToken(accessToken: string, options?: IJwtSignOptions): Promise<string>;
|
|
32
33
|
createAuthTokenFromOauthCode(code: string): Promise<IJwtToken>;
|
|
33
34
|
private _passportSerialize;
|
|
34
35
|
private _handlePayloadData;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { IRoleBase } from '../types/role.ts';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
export declare class BeanRoleInner extends BeanBase {
|
|
@@ -6,5 +6,5 @@ export declare class BeanRoleInner extends BeanBase {
|
|
|
6
6
|
private get roleInnerAdapter();
|
|
7
7
|
findOneByName(name: string): Promise<IRoleBase | undefined>;
|
|
8
8
|
findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
|
|
9
|
-
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[]>;
|
|
9
|
+
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[] | undefined>;
|
|
10
10
|
}
|
package/dist/index.js
CHANGED
|
@@ -250,10 +250,10 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
250
250
|
async kickOut(user) {
|
|
251
251
|
await this.authTokenAdapter.removeAll(user);
|
|
252
252
|
}
|
|
253
|
-
async checkAuthToken(accessToken, clientName) {
|
|
253
|
+
async checkAuthToken(accessToken, clientName, options) {
|
|
254
254
|
clientName = clientName ?? 'access';
|
|
255
255
|
const [payloadData, err] = await catchError(() => {
|
|
256
|
-
return this.bean.jwt.get(clientName).verify(accessToken);
|
|
256
|
+
return this.bean.jwt.get(clientName).verify(accessToken, options);
|
|
257
257
|
});
|
|
258
258
|
if (err) {
|
|
259
259
|
if (['access', 'refresh'].includes(clientName)) {
|
|
@@ -292,7 +292,7 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
292
292
|
authToken: 'nochange'
|
|
293
293
|
});
|
|
294
294
|
// jwt token
|
|
295
|
-
return await this.bean.jwt.
|
|
295
|
+
return await this.bean.jwt.createTempAuthToken(payloadData, options);
|
|
296
296
|
}
|
|
297
297
|
async createOauthAuthToken(options) {
|
|
298
298
|
// current
|
|
@@ -303,13 +303,24 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
303
303
|
authToken: 'nochange'
|
|
304
304
|
});
|
|
305
305
|
// jwt token
|
|
306
|
-
return await this.bean.jwt.
|
|
306
|
+
return await this.bean.jwt.createOauthAuthToken(payloadData, options);
|
|
307
307
|
}
|
|
308
|
-
async createOauthCode(
|
|
308
|
+
async createOauthCode(options) {
|
|
309
|
+
// current
|
|
310
|
+
const passport = this.getCurrent();
|
|
311
|
+
if (!passport) return this.app.throw(401);
|
|
312
|
+
// payloadData
|
|
313
|
+
const payloadData = await this._passportSerialize(passport, {
|
|
314
|
+
authToken: 'nochange'
|
|
315
|
+
});
|
|
316
|
+
// code
|
|
317
|
+
return await this.bean.jwt.createOauthCode(payloadData, options);
|
|
318
|
+
}
|
|
319
|
+
async createOauthCodeFromOauthAuthToken(accessToken, options) {
|
|
309
320
|
// payloadData
|
|
310
321
|
const payloadData = await this.bean.jwt.get('access').verify(accessToken);
|
|
311
322
|
if (!payloadData) return this.app.throw(401);
|
|
312
|
-
//
|
|
323
|
+
// code
|
|
313
324
|
return await this.bean.jwt.createOauthCode(payloadData, options);
|
|
314
325
|
}
|
|
315
326
|
async createAuthTokenFromOauthCode(code) {
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { IAuthAdapter, IAuthBase, IAuthIdRecord } from '../types/auth.ts';
|
|
3
3
|
export declare function setAuthAdapter(authAdapter: IAuthAdapter): void;
|
|
4
4
|
export declare function $getAuthId(user: IAuthBase): TableIdentity;
|
package/dist/lib/role.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { IRoleAdapter, IRoleBase } from '../types/role.ts';
|
|
3
3
|
export declare function setRoleAdapter(roleAdapter: IRoleAdapter): void;
|
|
4
4
|
export declare function $getRoleId(role: IRoleBase): TableIdentity;
|
package/dist/lib/user.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ILocaleInfos } from 'vona';
|
|
2
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
2
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
3
3
|
import type { IUserAdapter, IUserBase, IUserIdRecord } from '../types/user.ts';
|
|
4
4
|
export declare function setUserAdapter(userAdapter: IUserAdapter): void;
|
|
5
5
|
export declare function $getUserId(user: IUserBase): TableIdentity;
|
package/dist/types/auth.d.ts
CHANGED
package/dist/types/role.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
export interface IRoleNameRecord {
|
|
3
3
|
admin: never;
|
|
4
4
|
}
|
|
@@ -14,5 +14,5 @@ export interface IRoleAdapter {
|
|
|
14
14
|
export interface IRoleInnerAdapter {
|
|
15
15
|
findOneByName(name: string): Promise<IRoleBase | undefined>;
|
|
16
16
|
findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
|
|
17
|
-
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[]>;
|
|
17
|
+
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[] | undefined>;
|
|
18
18
|
}
|
package/dist/types/user.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ILocaleInfos } from 'vona';
|
|
2
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
2
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
3
3
|
import type { IAuthUserProfile } from './authProfile.ts';
|
|
4
4
|
export interface IUserNameRecord {
|
|
5
5
|
admin: never;
|