vona-module-a-user 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/.metadata/index.d.ts +8 -13
- package/dist/bean/{bean.roleInner.d.ts → bean.role.d.ts} +3 -3
- package/dist/bean/{bean.userInner.d.ts → bean.user.d.ts} +3 -3
- package/dist/config/config.d.ts +2 -3
- package/dist/index.js +56 -124
- package/dist/lib/auth.d.ts +1 -3
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/user.d.ts +1 -11
- package/dist/types/auth.d.ts +8 -6
- package/dist/types/role.d.ts +1 -4
- package/dist/types/user.d.ts +7 -10
- package/package.json +1 -1
- package/dist/bean/bean.authInner.d.ts +0 -7
- package/dist/lib/role.d.ts +0 -5
|
@@ -37,36 +37,31 @@ declare module 'vona-module-a-user' {
|
|
|
37
37
|
}
|
|
38
38
|
/** guard: end */
|
|
39
39
|
/** bean: begin */
|
|
40
|
-
export * from '../bean/bean.authInner.ts';
|
|
41
40
|
export * from '../bean/bean.passport.ts';
|
|
42
|
-
export * from '../bean/bean.
|
|
43
|
-
export * from '../bean/bean.
|
|
41
|
+
export * from '../bean/bean.role.ts';
|
|
42
|
+
export * from '../bean/bean.user.ts';
|
|
44
43
|
import 'vona';
|
|
45
44
|
declare module 'vona' {
|
|
46
45
|
}
|
|
47
46
|
declare module 'vona-module-a-user' {
|
|
48
|
-
interface BeanAuthInner {
|
|
49
|
-
}
|
|
50
47
|
interface BeanPassport {
|
|
51
48
|
}
|
|
52
|
-
interface
|
|
49
|
+
interface BeanRole {
|
|
53
50
|
}
|
|
54
|
-
interface
|
|
51
|
+
interface BeanUser {
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
/** bean: end */
|
|
58
55
|
/** bean: begin */
|
|
59
|
-
import type { BeanAuthInner } from '../bean/bean.authInner.ts';
|
|
60
56
|
import type { BeanPassport } from '../bean/bean.passport.ts';
|
|
61
|
-
import type {
|
|
62
|
-
import type {
|
|
57
|
+
import type { BeanRole } from '../bean/bean.role.ts';
|
|
58
|
+
import type { BeanUser } from '../bean/bean.user.ts';
|
|
63
59
|
import 'vona';
|
|
64
60
|
declare module 'vona' {
|
|
65
61
|
interface IBeanRecordGlobal {
|
|
66
|
-
'authInner': BeanAuthInner;
|
|
67
62
|
'passport': BeanPassport;
|
|
68
|
-
'
|
|
69
|
-
'
|
|
63
|
+
'role': BeanRole;
|
|
64
|
+
'user': BeanUser;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
/** bean: end */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
2
|
import type { IRoleBase } from '../types/role.ts';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
|
-
export declare class
|
|
5
|
-
private
|
|
6
|
-
private get
|
|
4
|
+
export declare class BeanRole extends BeanBase {
|
|
5
|
+
private _roleAdapter;
|
|
6
|
+
private get roleAdapter();
|
|
7
7
|
findOneByName(name: string): Promise<IRoleBase | undefined>;
|
|
8
8
|
findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
|
|
9
9
|
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[] | undefined>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IAuthUserProfile } from '../types/authProfile.ts';
|
|
2
2
|
import type { IUserBase } from '../types/user.ts';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
|
-
export declare class
|
|
5
|
-
private
|
|
6
|
-
private get
|
|
4
|
+
export declare class BeanUser extends BeanBase {
|
|
5
|
+
private _userAdapter;
|
|
6
|
+
private get userAdapter();
|
|
7
7
|
activate(user: IUserBase): Promise<void>;
|
|
8
8
|
register(user: Partial<IUserBase>, confirmed?: boolean): Promise<IUserBase>;
|
|
9
9
|
registerByProfile(profile: IAuthUserProfile): Promise<IUserBase>;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -11,9 +11,8 @@ export declare function config(_app: VonaApplication): {
|
|
|
11
11
|
adapter: {
|
|
12
12
|
authToken: keyof IServiceRecord;
|
|
13
13
|
passport: keyof IServiceRecord;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
roleInner: keyof IServiceRecord;
|
|
14
|
+
user: keyof IServiceRecord;
|
|
15
|
+
role: keyof IServiceRecord;
|
|
17
16
|
};
|
|
18
17
|
payloadData: {
|
|
19
18
|
fields: {
|
package/dist/index.js
CHANGED
|
@@ -5,15 +5,15 @@ import { Bean, Service, Scope } from 'vona-module-a-bean';
|
|
|
5
5
|
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
6
6
|
import { Meta } from 'vona-module-a-meta';
|
|
7
7
|
|
|
8
|
-
var _dec$
|
|
9
|
-
let GuardPassport = (_dec$
|
|
8
|
+
var _dec$e, _dec2$e, _class$e;
|
|
9
|
+
let GuardPassport = (_dec$e = Guard({
|
|
10
10
|
global: true,
|
|
11
11
|
public: false,
|
|
12
12
|
activated: true,
|
|
13
13
|
checkAuthToken: true
|
|
14
|
-
}), _dec2$
|
|
14
|
+
}), _dec2$e = BeanInfo({
|
|
15
15
|
module: "a-user"
|
|
16
|
-
}), _dec$
|
|
16
|
+
}), _dec$e(_class$e = _dec2$e(_class$e = class GuardPassport extends BeanBase {
|
|
17
17
|
async execute(options, next) {
|
|
18
18
|
// auth token
|
|
19
19
|
if (!this.bean.passport.getCurrent()) {
|
|
@@ -47,119 +47,48 @@ let GuardPassport = (_dec$f = Guard({
|
|
|
47
47
|
// next
|
|
48
48
|
return next();
|
|
49
49
|
}
|
|
50
|
-
}) || _class$
|
|
51
|
-
|
|
52
|
-
let __roleAdapter;
|
|
53
|
-
function setRoleAdapter(roleAdapter) {
|
|
54
|
-
__roleAdapter = roleAdapter;
|
|
55
|
-
}
|
|
56
|
-
function $getRoleId(role) {
|
|
57
|
-
return __roleAdapter.getRoleId(role);
|
|
58
|
-
}
|
|
59
|
-
function $getRoleName(role) {
|
|
60
|
-
return __roleAdapter.getRoleName(role);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let __userAdapter;
|
|
64
|
-
function setUserAdapter(userAdapter) {
|
|
65
|
-
__userAdapter = userAdapter;
|
|
66
|
-
}
|
|
67
|
-
function $getUserId(user) {
|
|
68
|
-
return __userAdapter.getUserId(user);
|
|
69
|
-
}
|
|
70
|
-
function $getUserName(user) {
|
|
71
|
-
return __userAdapter.getUserName(user);
|
|
72
|
-
}
|
|
73
|
-
function $getUserAvatar(user) {
|
|
74
|
-
return __userAdapter.getUserAvatar(user);
|
|
75
|
-
}
|
|
76
|
-
function $getUserEmail(user) {
|
|
77
|
-
return __userAdapter.getUserEmail(user);
|
|
78
|
-
}
|
|
79
|
-
function $getUserMobile(user) {
|
|
80
|
-
return __userAdapter.getUserMobile(user);
|
|
81
|
-
}
|
|
82
|
-
function $getUserActivated(user) {
|
|
83
|
-
return __userAdapter.getUserActivated(user);
|
|
84
|
-
}
|
|
85
|
-
function $getUserLocale(user) {
|
|
86
|
-
return __userAdapter.getUserLocale(user);
|
|
87
|
-
}
|
|
88
|
-
function $getUserAnonymous(user) {
|
|
89
|
-
return __userAdapter.getUserAnonymous(user);
|
|
90
|
-
}
|
|
91
|
-
function $getUserIdSystem(_userName, userId) {
|
|
92
|
-
return userId;
|
|
93
|
-
}
|
|
50
|
+
}) || _class$e) || _class$e);
|
|
94
51
|
|
|
95
|
-
var _dec$
|
|
96
|
-
let GuardRoleName = (_dec$
|
|
52
|
+
var _dec$d, _dec2$d, _class$d;
|
|
53
|
+
let GuardRoleName = (_dec$d = Guard({
|
|
97
54
|
passWhenMatched: true
|
|
98
|
-
}), _dec2$
|
|
55
|
+
}), _dec2$d = BeanInfo({
|
|
99
56
|
module: "a-user"
|
|
100
|
-
}), _dec$
|
|
57
|
+
}), _dec$d(_class$d = _dec2$d(_class$d = class GuardRoleName extends BeanBase {
|
|
101
58
|
async execute(options, next) {
|
|
102
59
|
if (!options.name) return this.app.throw(403);
|
|
103
60
|
const user = this.bean.passport.getCurrentUser();
|
|
104
|
-
if (!user ||
|
|
61
|
+
if (!user || user.anonymous) return this.app.throw(403);
|
|
105
62
|
const roles = this.bean.passport.getCurrentRoles();
|
|
106
63
|
if (!roles) return this.app.throw(403);
|
|
107
|
-
const roleNames = roles?.map(item =>
|
|
64
|
+
const roleNames = roles?.map(item => item.name);
|
|
108
65
|
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
109
66
|
if (!roleNames.some(roleName => optionsName.includes(roleName))) return this.app.throw(403);
|
|
110
67
|
if (options.passWhenMatched) return true;
|
|
111
68
|
// next
|
|
112
69
|
return next();
|
|
113
70
|
}
|
|
114
|
-
}) || _class$
|
|
71
|
+
}) || _class$d) || _class$d);
|
|
115
72
|
|
|
116
|
-
var _dec$
|
|
117
|
-
let GuardUserName = (_dec$
|
|
73
|
+
var _dec$c, _dec2$c, _class$c;
|
|
74
|
+
let GuardUserName = (_dec$c = Guard({
|
|
118
75
|
passWhenMatched: true
|
|
119
|
-
}), _dec2$
|
|
76
|
+
}), _dec2$c = BeanInfo({
|
|
120
77
|
module: "a-user"
|
|
121
|
-
}), _dec$
|
|
78
|
+
}), _dec$c(_class$c = _dec2$c(_class$c = class GuardUserName extends BeanBase {
|
|
122
79
|
async execute(options, next) {
|
|
123
80
|
if (!options.name) return this.app.throw(403);
|
|
124
81
|
const user = this.bean.passport.getCurrentUser();
|
|
125
|
-
if (!user ||
|
|
126
|
-
const userName =
|
|
82
|
+
if (!user || user.anonymous) return this.app.throw(403);
|
|
83
|
+
const userName = user.name;
|
|
127
84
|
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
128
85
|
if (!optionsName.includes(userName)) return this.app.throw(403);
|
|
129
86
|
if (options.passWhenMatched) return true;
|
|
130
87
|
// next
|
|
131
88
|
return next();
|
|
132
89
|
}
|
|
133
|
-
}) || _class$d) || _class$d);
|
|
134
|
-
|
|
135
|
-
var _dec$c, _dec2$c, _class$c;
|
|
136
|
-
let BeanAuthInner = (_dec$c = Bean(), _dec2$c = BeanInfo({
|
|
137
|
-
module: "a-user"
|
|
138
|
-
}), _dec$c(_class$c = _dec2$c(_class$c = class BeanAuthInner extends BeanBase {
|
|
139
|
-
constructor(...args) {
|
|
140
|
-
super(...args);
|
|
141
|
-
this._authInnerAdapter = void 0;
|
|
142
|
-
}
|
|
143
|
-
get authInnerAdapter() {
|
|
144
|
-
if (!this._authInnerAdapter) {
|
|
145
|
-
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.authInner, 'service');
|
|
146
|
-
this._authInnerAdapter = this.bean._getBean(beanFullName);
|
|
147
|
-
}
|
|
148
|
-
return this._authInnerAdapter;
|
|
149
|
-
}
|
|
150
|
-
async findOne(auth) {
|
|
151
|
-
if (String(auth.id).charAt(0) === '-') return auth;
|
|
152
|
-
return await this.authInnerAdapter.findOne(auth);
|
|
153
|
-
}
|
|
154
90
|
}) || _class$c) || _class$c);
|
|
155
91
|
|
|
156
|
-
let __authAdapter;
|
|
157
|
-
function setAuthAdapter(authAdapter) {
|
|
158
|
-
__authAdapter = authAdapter;
|
|
159
|
-
}
|
|
160
|
-
function $getAuthId(user) {
|
|
161
|
-
return __authAdapter.getAuthId(user);
|
|
162
|
-
}
|
|
163
92
|
function $getAuthIdSystem(_authName, authId) {
|
|
164
93
|
return authId;
|
|
165
94
|
}
|
|
@@ -190,11 +119,11 @@ let BeanPassport = (_dec$b = Bean(), _dec2$b = BeanInfo({
|
|
|
190
119
|
}
|
|
191
120
|
get isAuthenticated() {
|
|
192
121
|
const user = this.getCurrentUser();
|
|
193
|
-
return !!user &&
|
|
122
|
+
return !!user && !user.anonymous;
|
|
194
123
|
}
|
|
195
124
|
get isActivated() {
|
|
196
125
|
const user = this.getCurrentUser();
|
|
197
|
-
return !!user &&
|
|
126
|
+
return !!user && !!user.activated;
|
|
198
127
|
}
|
|
199
128
|
async isAdmin() {
|
|
200
129
|
const passport = this.getCurrent();
|
|
@@ -240,7 +169,7 @@ let BeanPassport = (_dec$b = Bean(), _dec2$b = BeanInfo({
|
|
|
240
169
|
await this.setCurrent(undefined);
|
|
241
170
|
}
|
|
242
171
|
async signinSystem(authName, authId, name, options) {
|
|
243
|
-
const user = await this.bean.
|
|
172
|
+
const user = await this.bean.user.findOneByName(name ?? 'admin');
|
|
244
173
|
if (!user) return this.app.throw(401);
|
|
245
174
|
const auth = {
|
|
246
175
|
id: $getAuthIdSystem(authName, authId)
|
|
@@ -263,7 +192,7 @@ let BeanPassport = (_dec$b = Bean(), _dec2$b = BeanInfo({
|
|
|
263
192
|
await this.setCurrent(passport);
|
|
264
193
|
}
|
|
265
194
|
async createUserAnonymous() {
|
|
266
|
-
const userAnonymous = await this.bean.
|
|
195
|
+
const userAnonymous = await this.bean.user.createAnonymous();
|
|
267
196
|
// event
|
|
268
197
|
await this.scope.event.createUserAnonymous.emit(userAnonymous);
|
|
269
198
|
// ok
|
|
@@ -376,49 +305,49 @@ let BeanPassport = (_dec$b = Bean(), _dec2$b = BeanInfo({
|
|
|
376
305
|
}) || _class$b) || _class$b);
|
|
377
306
|
|
|
378
307
|
var _dec$a, _dec2$a, _class$a;
|
|
379
|
-
let
|
|
308
|
+
let BeanRole = (_dec$a = Bean(), _dec2$a = BeanInfo({
|
|
380
309
|
module: "a-user"
|
|
381
|
-
}), _dec$a(_class$a = _dec2$a(_class$a = class
|
|
310
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class BeanRole extends BeanBase {
|
|
382
311
|
constructor(...args) {
|
|
383
312
|
super(...args);
|
|
384
|
-
this.
|
|
313
|
+
this._roleAdapter = void 0;
|
|
385
314
|
}
|
|
386
|
-
get
|
|
387
|
-
if (!this.
|
|
388
|
-
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.
|
|
389
|
-
this.
|
|
315
|
+
get roleAdapter() {
|
|
316
|
+
if (!this._roleAdapter) {
|
|
317
|
+
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.role, 'service');
|
|
318
|
+
this._roleAdapter = this.bean._getBean(beanFullName);
|
|
390
319
|
}
|
|
391
|
-
return this.
|
|
320
|
+
return this._roleAdapter;
|
|
392
321
|
}
|
|
393
322
|
findOneByName(name) {
|
|
394
|
-
return this.
|
|
323
|
+
return this.roleAdapter.findOneByName(name);
|
|
395
324
|
}
|
|
396
325
|
findOne(role) {
|
|
397
|
-
return this.
|
|
326
|
+
return this.roleAdapter.findOne(role);
|
|
398
327
|
}
|
|
399
328
|
findAllByUserId(userId) {
|
|
400
|
-
return this.
|
|
329
|
+
return this.roleAdapter.findAllByUserId(userId);
|
|
401
330
|
}
|
|
402
331
|
}) || _class$a) || _class$a);
|
|
403
332
|
|
|
404
333
|
var _dec$9, _dec2$9, _class$9;
|
|
405
|
-
let
|
|
334
|
+
let BeanUser = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
406
335
|
module: "a-user"
|
|
407
|
-
}), _dec$9(_class$9 = _dec2$9(_class$9 = class
|
|
336
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = class BeanUser extends BeanBase {
|
|
408
337
|
constructor(...args) {
|
|
409
338
|
super(...args);
|
|
410
|
-
this.
|
|
339
|
+
this._userAdapter = void 0;
|
|
411
340
|
}
|
|
412
|
-
get
|
|
413
|
-
if (!this.
|
|
414
|
-
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.
|
|
415
|
-
this.
|
|
341
|
+
get userAdapter() {
|
|
342
|
+
if (!this._userAdapter) {
|
|
343
|
+
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.user, 'service');
|
|
344
|
+
this._userAdapter = this.bean._getBean(beanFullName);
|
|
416
345
|
}
|
|
417
|
-
return this.
|
|
346
|
+
return this._userAdapter;
|
|
418
347
|
}
|
|
419
348
|
async activate(user) {
|
|
420
349
|
await this.scope.event.activate.emit(user, async user => {
|
|
421
|
-
await this.
|
|
350
|
+
await this.userAdapter.setActivated(user.id, true);
|
|
422
351
|
});
|
|
423
352
|
}
|
|
424
353
|
async register(user, confirmed) {
|
|
@@ -431,7 +360,7 @@ let BeanUserInner = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
431
360
|
};
|
|
432
361
|
return await this.scope.event.register.emit(data, async data => {
|
|
433
362
|
// user
|
|
434
|
-
const userNew = await this.
|
|
363
|
+
const userNew = await this.userAdapter.create(data.user);
|
|
435
364
|
if (data.autoActivate) {
|
|
436
365
|
await this.activate(userNew);
|
|
437
366
|
}
|
|
@@ -439,23 +368,23 @@ let BeanUserInner = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
439
368
|
});
|
|
440
369
|
}
|
|
441
370
|
async registerByProfile(profile) {
|
|
442
|
-
const user = await this.
|
|
371
|
+
const user = await this.userAdapter.userOfProfile(profile);
|
|
443
372
|
return await this.register(user, profile.confirmed);
|
|
444
373
|
}
|
|
445
374
|
createAnonymous() {
|
|
446
|
-
return this.
|
|
375
|
+
return this.userAdapter.createAnonymous();
|
|
447
376
|
}
|
|
448
377
|
findOneByName(name) {
|
|
449
|
-
return this.
|
|
378
|
+
return this.userAdapter.findOneByName(name);
|
|
450
379
|
}
|
|
451
380
|
findOne(user) {
|
|
452
|
-
return this.
|
|
381
|
+
return this.userAdapter.findOne(user);
|
|
453
382
|
}
|
|
454
383
|
update(user) {
|
|
455
|
-
return this.
|
|
384
|
+
return this.userAdapter.update(user);
|
|
456
385
|
}
|
|
457
386
|
remove(user) {
|
|
458
|
-
return this.
|
|
387
|
+
return this.userAdapter.remove(user);
|
|
459
388
|
}
|
|
460
389
|
}) || _class$9) || _class$9);
|
|
461
390
|
|
|
@@ -613,9 +542,8 @@ function config(_app) {
|
|
|
613
542
|
adapter: {
|
|
614
543
|
authToken: 'a-user:authTokenAdapter',
|
|
615
544
|
passport: 'home-user:passportAdapter',
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
roleInner: 'home-user:roleInnerAdapter'
|
|
545
|
+
user: 'home-user:userAdapter',
|
|
546
|
+
role: 'home-user:roleAdapter'
|
|
619
547
|
},
|
|
620
548
|
payloadData: {
|
|
621
549
|
fields: {
|
|
@@ -668,4 +596,8 @@ const Passport = {
|
|
|
668
596
|
admin: Admin
|
|
669
597
|
};
|
|
670
598
|
|
|
671
|
-
|
|
599
|
+
function $getUserIdSystem(_userName, userId) {
|
|
600
|
+
return userId;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export { $getAuthIdSystem, $getUserIdSystem, BeanPassport, BeanRole, BeanUser, EventActivate, EventCreateUserAnonymous, EventRegister, EventSignin, EventSignout, GuardPassport, GuardRoleName, GuardUserName, MetaPrintTip, Passport, ScopeModuleAUser, ServiceAuthTokenAdapter, ServiceRedisToken, config };
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function setAuthAdapter(authAdapter: IAuthAdapter): void;
|
|
4
|
-
export declare function $getAuthId(user: IAuthBase): TableIdentity;
|
|
2
|
+
import type { IAuthIdRecord } from '../types/auth.ts';
|
|
5
3
|
export declare function $getAuthIdSystem<K extends keyof IAuthIdRecord>(_authName: IAuthIdRecord[K], authId: K): TableIdentity;
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/user.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
|
-
import type {
|
|
3
|
-
import type { IUserAdapter, IUserBase, IUserIdRecord } from '../types/user.ts';
|
|
4
|
-
export declare function setUserAdapter(userAdapter: IUserAdapter): void;
|
|
5
|
-
export declare function $getUserId(user: IUserBase): TableIdentity;
|
|
6
|
-
export declare function $getUserName(user: IUserBase): string;
|
|
7
|
-
export declare function $getUserAvatar(user: IUserBase): string | undefined;
|
|
8
|
-
export declare function $getUserEmail(user: IUserBase): string | undefined;
|
|
9
|
-
export declare function $getUserMobile(user: IUserBase): string | undefined;
|
|
10
|
-
export declare function $getUserActivated(user: IUserBase): boolean;
|
|
11
|
-
export declare function $getUserLocale(user: IUserBase): keyof ILocaleInfos | undefined;
|
|
12
|
-
export declare function $getUserAnonymous(user: IUserBase): boolean;
|
|
2
|
+
import type { IUserIdRecord } from '../types/user.ts';
|
|
13
3
|
export declare function $getUserIdSystem<K extends keyof IUserIdRecord>(_userName: IUserIdRecord[K], userId: K): TableIdentity;
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IAuthProviderRecord } from 'vona-module-a-auth';
|
|
2
3
|
export interface IAuthIdRecord {
|
|
3
4
|
'-1': 'dev';
|
|
4
5
|
'-10000': 'mock';
|
|
5
6
|
}
|
|
6
|
-
export interface
|
|
7
|
+
export interface IAuthProviderBase {
|
|
7
8
|
id: TableIdentity;
|
|
9
|
+
providerName: keyof IAuthProviderRecord;
|
|
10
|
+
clientName: string;
|
|
8
11
|
}
|
|
9
|
-
export interface
|
|
10
|
-
|
|
12
|
+
export interface IAuthBase {
|
|
13
|
+
id: TableIdentity;
|
|
14
|
+
profileId?: string;
|
|
15
|
+
authProvider?: IAuthProviderBase;
|
|
11
16
|
}
|
|
12
17
|
export type TypeAuthToken = 'recreate' | 'refresh' | 'nochange';
|
|
13
18
|
export interface ISigninOptions {
|
|
14
19
|
/** default: refresh */
|
|
15
20
|
authToken?: TypeAuthToken;
|
|
16
21
|
}
|
|
17
|
-
export interface IAuthInnerAdapter {
|
|
18
|
-
findOne(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
|
|
19
|
-
}
|
package/dist/types/role.d.ts
CHANGED
|
@@ -6,12 +6,9 @@ export interface IRoleIdRecord {
|
|
|
6
6
|
}
|
|
7
7
|
export interface IRoleBase {
|
|
8
8
|
id: TableIdentity;
|
|
9
|
+
name: string;
|
|
9
10
|
}
|
|
10
11
|
export interface IRoleAdapter {
|
|
11
|
-
getRoleId(role: IRoleBase): TableIdentity;
|
|
12
|
-
getRoleName(role: IRoleBase): string;
|
|
13
|
-
}
|
|
14
|
-
export interface IRoleInnerAdapter {
|
|
15
12
|
findOneByName(name: string): Promise<IRoleBase | undefined>;
|
|
16
13
|
findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
|
|
17
14
|
findAllByUserId(userId: TableIdentity): Promise<IRoleBase[] | undefined>;
|
package/dist/types/user.d.ts
CHANGED
|
@@ -9,18 +9,15 @@ export interface IUserIdRecord {
|
|
|
9
9
|
}
|
|
10
10
|
export interface IUserBase {
|
|
11
11
|
id: TableIdentity;
|
|
12
|
+
name: string;
|
|
13
|
+
avatar?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
mobile?: string;
|
|
16
|
+
activated?: boolean;
|
|
17
|
+
locale?: keyof ILocaleInfos | undefined;
|
|
18
|
+
anonymous?: boolean;
|
|
12
19
|
}
|
|
13
20
|
export interface IUserAdapter {
|
|
14
|
-
getUserId(user: IUserBase): TableIdentity;
|
|
15
|
-
getUserName(user: IUserBase): string;
|
|
16
|
-
getUserAvatar(user: IUserBase): string | undefined;
|
|
17
|
-
getUserEmail(user: IUserBase): string | undefined;
|
|
18
|
-
getUserMobile(user: IUserBase): string | undefined;
|
|
19
|
-
getUserActivated(user: IUserBase): boolean;
|
|
20
|
-
getUserLocale(user: IUserBase): keyof ILocaleInfos | undefined;
|
|
21
|
-
getUserAnonymous(user: IUserBase): boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface IUserInnerAdapter {
|
|
24
21
|
create(user: Partial<IUserBase>): Promise<IUserBase>;
|
|
25
22
|
userOfProfile(profile: IAuthUserProfile): Promise<IUserBase>;
|
|
26
23
|
createAnonymous(): Promise<IUserBase>;
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { IAuthBase } from '../types/auth.ts';
|
|
2
|
-
import { BeanBase } from 'vona';
|
|
3
|
-
export declare class BeanAuthInner extends BeanBase {
|
|
4
|
-
private _authInnerAdapter;
|
|
5
|
-
private get authInnerAdapter();
|
|
6
|
-
findOne(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
|
|
7
|
-
}
|
package/dist/lib/role.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TableIdentity } from 'table-identity';
|
|
2
|
-
import type { IRoleAdapter, IRoleBase } from '../types/role.ts';
|
|
3
|
-
export declare function setRoleAdapter(roleAdapter: IRoleAdapter): void;
|
|
4
|
-
export declare function $getRoleId(role: IRoleBase): TableIdentity;
|
|
5
|
-
export declare function $getRoleName(role: IRoleBase): string;
|