@genesislcap/foundation-user 14.176.1-alpha-6ef4895.0 → 14.177.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/dts/config.d.ts +54 -1
- package/dist/dts/config.d.ts.map +1 -1
- package/dist/dts/types.d.ts +12 -0
- package/dist/dts/types.d.ts.map +1 -1
- package/dist/dts/user.d.ts +43 -12
- package/dist/dts/user.d.ts.map +1 -1
- package/dist/esm/config.js +35 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/user.js +42 -10
- package/dist/foundation-user.api.json +368 -29
- package/dist/foundation-user.d.ts +114 -12
- package/docs/api/foundation-user.defaultuser.hasadminprofile.md +15 -0
- package/docs/api/foundation-user.defaultuser.md +3 -0
- package/docs/api/foundation-user.defaultuser.permissions.md +11 -0
- package/docs/api/foundation-user.defaultuser.profiles.md +11 -0
- package/docs/api/foundation-user.getuserchannel.md +39 -0
- package/docs/api/foundation-user.legacyuserapi.hasadminprofile.md +20 -0
- package/docs/api/foundation-user.legacyuserapi.md +30 -0
- package/docs/api/foundation-user.legacyuserapi.permissions.md +16 -0
- package/docs/api/foundation-user.legacyuserapi.profiles.md +16 -0
- package/docs/api/foundation-user.legacyuserapi.username.md +16 -0
- package/docs/api/foundation-user.md +5 -0
- package/docs/api/foundation-user.user.addauthenticationchangelistener.md +1 -3
- package/docs/api/foundation-user.user.md +2 -3
- package/docs/api/foundation-user.userchannel.md +33 -0
- package/docs/api/foundation-user.userchannelevents.md +17 -0
- package/docs/api/foundation-user.userchannelid.md +13 -0
- package/docs/api-report.md +44 -5
- package/package.json +12 -11
package/dist/dts/config.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { TypedBroadcastChannel } from '@genesislcap/foundation-broadcast-channel';
|
2
|
+
import { SetUserProperties, UserChannelEvents } from './types';
|
2
3
|
import type { User } from './user';
|
3
4
|
/**
|
4
5
|
* @internal
|
@@ -49,5 +50,57 @@ export declare const defaultUserConfig: UserConfig;
|
|
49
50
|
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
50
51
|
*/
|
51
52
|
export declare const UserConfig: import("@microsoft/fast-foundation").InterfaceSymbol<UserConfig>;
|
53
|
+
/**
|
54
|
+
* UserChannel DI interface.
|
55
|
+
* @example
|
56
|
+
* ```ts
|
57
|
+
* import { UserChannel } from '@genesislcap/foundation-user';
|
58
|
+
* ...
|
59
|
+
* @UserChannel protected channel: UserChannel;
|
60
|
+
* ...
|
61
|
+
* this.channel.onmessage = (e) => {
|
62
|
+
* if (this.channel.isMessageType('user-authentication-change', e)) {
|
63
|
+
* logger.debug('user-authentication-change', e.data.detail);
|
64
|
+
* return;
|
65
|
+
* }
|
66
|
+
* }
|
67
|
+
* ...
|
68
|
+
* this.channel.close();
|
69
|
+
* ```
|
70
|
+
* @public
|
71
|
+
*/
|
72
|
+
export interface UserChannel extends TypedBroadcastChannel<UserChannelEvents> {
|
73
|
+
}
|
74
|
+
/**
|
75
|
+
* UserChannel DI key.
|
76
|
+
* @internal
|
77
|
+
* @privateRemarks
|
78
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
79
|
+
*/
|
80
|
+
export declare const UserChannel: import("@microsoft/fast-foundation").InterfaceSymbol<TypedBroadcastChannel<UserChannelEvents>>;
|
81
|
+
/**
|
82
|
+
* Gets UserChannel from the DI container.
|
83
|
+
*
|
84
|
+
* @remarks
|
85
|
+
* A utility method for host applications that are not using decorators or the DI container.
|
86
|
+
*
|
87
|
+
* @example
|
88
|
+
* ```ts
|
89
|
+
* import { getUserChannel } from '@genesislcap/foundation-user';
|
90
|
+
* ...
|
91
|
+
* const channel = getUserChannel();
|
92
|
+
* ...
|
93
|
+
* channel.onmessage = (e) => {
|
94
|
+
* if (channel.isMessageType('user-authentication-change', e)) {
|
95
|
+
* logger.debug('user-authentication-change', e.data.detail);
|
96
|
+
* return;
|
97
|
+
* }
|
98
|
+
* }
|
99
|
+
* ...
|
100
|
+
* channel.close();
|
101
|
+
* ```
|
102
|
+
* @public
|
103
|
+
*/
|
104
|
+
export declare function getUserChannel(): UserChannel;
|
52
105
|
export {};
|
53
106
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/dts/config.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAiB,MAAM,SAAS,CAAC;AAC9E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,KAAK,aAAa,GAAG;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;CAAE,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,EAAE,CAAC;IAEjC;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAE9B;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAE3E;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UA0C/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,kEAAuE,CAAC;AAE/F;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAY,SAAQ,qBAAqB,CAAC,iBAAiB,CAAC;CAAG;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,gGAAkE,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
|
package/dist/dts/types.d.ts
CHANGED
@@ -12,6 +12,18 @@ export declare const UserAuthenticationChangeType = "user-authentication-change"
|
|
12
12
|
* @public
|
13
13
|
*/
|
14
14
|
export type UserAuthenticationChangeEvent = CustomEvent<boolean>;
|
15
|
+
/**
|
16
|
+
* UserChannelId.
|
17
|
+
* @public
|
18
|
+
*/
|
19
|
+
export declare const UserChannelId = "genesis-user";
|
20
|
+
/**
|
21
|
+
* UserChannelEvents.
|
22
|
+
* @public
|
23
|
+
*/
|
24
|
+
export type UserChannelEvents = {
|
25
|
+
[UserAuthenticationChangeType]: boolean;
|
26
|
+
};
|
15
27
|
/**
|
16
28
|
* UserPathHistory.
|
17
29
|
*
|
package/dist/dts/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,4BAA4B,+BAA+B,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAE/B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;OAGG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;IAElC;;OAEG;IACH,WAAW,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,YAAY,IAAI,IAAI,CAAC;IAErB;;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AAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAC7B"}
|
package/dist/dts/user.d.ts
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
import { Listener } from '@genesislcap/foundation-utils';
|
2
2
|
import { UserConfig } from './config';
|
3
3
|
import type { SetUserProperties, UserActionHistory, UserAuthenticationChangeEvent, UserPathHistory } from './types';
|
4
|
+
/**
|
5
|
+
* @remarks
|
6
|
+
* For backwards compatibility, will be removed in a future major release, likely v15.
|
7
|
+
*
|
8
|
+
* @public
|
9
|
+
*/
|
10
|
+
export interface LegacyUserAPI {
|
11
|
+
/**
|
12
|
+
* @deprecated - Use `userName` instead.
|
13
|
+
*/
|
14
|
+
readonly username: string;
|
15
|
+
/**
|
16
|
+
* @deprecated - Use `permission` instead.
|
17
|
+
*/
|
18
|
+
readonly permissions: string[];
|
19
|
+
/**
|
20
|
+
* @deprecated - Use `profile` instead.
|
21
|
+
*/
|
22
|
+
readonly profiles: string[];
|
23
|
+
/**
|
24
|
+
* @deprecated - Use `isAdmin` instead.
|
25
|
+
*/
|
26
|
+
hasAdminProfile(): boolean;
|
27
|
+
}
|
4
28
|
/**
|
5
29
|
* User interface.
|
6
30
|
*
|
7
31
|
* @remarks
|
8
32
|
* The user singleton, which always exists in either an anonymous or authenticated mode.
|
9
33
|
*
|
10
|
-
* @privateRemarks
|
11
|
-
* Provides `username` and `userName` for backwards compatability.
|
12
|
-
*
|
13
34
|
* @example
|
14
35
|
* ```ts
|
15
36
|
* import { User } from '@genesislcap/foundation-user';
|
@@ -19,7 +40,7 @@ import type { SetUserProperties, UserActionHistory, UserAuthenticationChangeEven
|
|
19
40
|
*
|
20
41
|
* @public
|
21
42
|
*/
|
22
|
-
export interface User extends UserPathHistory, UserActionHistory {
|
43
|
+
export interface User extends UserPathHistory, UserActionHistory, LegacyUserAPI {
|
23
44
|
readonly isAuthenticated: boolean;
|
24
45
|
readonly isAnonymous: boolean;
|
25
46
|
readonly userKVs: {
|
@@ -30,7 +51,6 @@ export interface User extends UserPathHistory, UserActionHistory {
|
|
30
51
|
readonly profile: string[];
|
31
52
|
readonly sourceRef: string;
|
32
53
|
readonly userName: string;
|
33
|
-
readonly username: string;
|
34
54
|
/**
|
35
55
|
* A structuredClone of the raw unmanaged properties used to set the user.
|
36
56
|
*
|
@@ -57,9 +77,7 @@ export interface User extends UserPathHistory, UserActionHistory {
|
|
57
77
|
/**
|
58
78
|
* @example
|
59
79
|
* ```ts
|
60
|
-
*
|
61
|
-
* ...
|
62
|
-
* const unsubscribe = this.user.addAuthenticationChangeListener((event: UserAuthenticationChangeEvent) => {
|
80
|
+
* const unsubscribe = this.user.addAuthenticationChangeListener((event) => {
|
63
81
|
* console.log('User authenticated?', event.detail);
|
64
82
|
* });
|
65
83
|
* ```
|
@@ -102,10 +120,6 @@ export declare class DefaultUser implements User {
|
|
102
120
|
set(properties: Partial<SetUserProperties>): User;
|
103
121
|
/** {@inheritDoc User.unset} */
|
104
122
|
unset(): User;
|
105
|
-
/** @internal */
|
106
|
-
protected userNameChanged(): void;
|
107
|
-
/** {@inheritDoc User.username} */
|
108
|
-
get username(): string;
|
109
123
|
/** {@inheritDoc User.isAnonymous} */
|
110
124
|
get isAnonymous(): boolean;
|
111
125
|
/** {@inheritDoc User.isAdmin} */
|
@@ -138,6 +152,23 @@ export declare class DefaultUser implements User {
|
|
138
152
|
addAuthenticationChangeListener(listener: Listener<UserAuthenticationChangeEvent>): () => void;
|
139
153
|
/** @internal */
|
140
154
|
protected isAuthenticatedChanged(): void;
|
155
|
+
/**
|
156
|
+
* Bridge legacy user apis below
|
157
|
+
*/
|
158
|
+
/** @internal */
|
159
|
+
protected userNameChanged(): void;
|
160
|
+
/** {@inheritDoc LegacyUserAPI.username} */
|
161
|
+
get username(): string;
|
162
|
+
/** @internal */
|
163
|
+
protected permissionChanged(): void;
|
164
|
+
/** {@inheritDoc LegacyUserAPI.permissions} */
|
165
|
+
get permissions(): string[];
|
166
|
+
/** @internal */
|
167
|
+
protected profileChanged(): void;
|
168
|
+
/** {@inheritDoc LegacyUserAPI.profiles} */
|
169
|
+
get profiles(): string[];
|
170
|
+
/** {@inheritDoc LegacyUserAPI.hasAdminProfile} */
|
171
|
+
hasAdminProfile(): boolean;
|
141
172
|
}
|
142
173
|
/**
|
143
174
|
* User DI key.
|
package/dist/dts/user.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzE,OAAO,
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzE,OAAO,EAAkB,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,eAAe,IAAI,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAK,SAAQ,eAAe,EAAE,iBAAiB,EAAE,aAAa;IAC7E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BAA+B,CAAC,QAAQ,EAAE,QAAQ,CAAC,6BAA6B,CAAC;IAIjF,gBAAgB;IAChB,SAAS,CAAC,sBAAsB;IAehC;;OAEG;IAEH,gBAAgB;IAChB,SAAS,CAAC,eAAe;IAIzB,2CAA2C;IAC3C,IAAI,QAAQ,WAGX;IAED,gBAAgB;IAChB,SAAS,CAAC,iBAAiB;IAI3B,8CAA8C;IAC9C,IAAI,WAAW,aAGd;IAED,gBAAgB;IAChB,SAAS,CAAC,cAAc;IAIxB,2CAA2C;IAC3C,IAAI,QAAQ,aAGX;IAED,kDAAkD;IAClD,eAAe;CAGhB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,4DAA4D,CAAC;AAE9E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAE9B"}
|
package/dist/esm/config.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
import { registerTypedBroadcastChannel, } from '@genesislcap/foundation-broadcast-channel';
|
1
2
|
import { DI } from '@microsoft/fast-foundation';
|
2
3
|
import { logger } from './logger';
|
4
|
+
import { UserChannelId } from './types';
|
3
5
|
/**
|
4
6
|
* Default UserConfig DI implementation.
|
5
7
|
* @public
|
@@ -55,3 +57,36 @@ export const defaultUserConfig = {
|
|
55
57
|
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
56
58
|
*/
|
57
59
|
export const UserConfig = DI.createInterface((x) => x.instance(defaultUserConfig));
|
60
|
+
/**
|
61
|
+
* UserChannel DI key.
|
62
|
+
* @internal
|
63
|
+
* @privateRemarks
|
64
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
65
|
+
*/
|
66
|
+
export const UserChannel = registerTypedBroadcastChannel(UserChannelId);
|
67
|
+
/**
|
68
|
+
* Gets UserChannel from the DI container.
|
69
|
+
*
|
70
|
+
* @remarks
|
71
|
+
* A utility method for host applications that are not using decorators or the DI container.
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* ```ts
|
75
|
+
* import { getUserChannel } from '@genesislcap/foundation-user';
|
76
|
+
* ...
|
77
|
+
* const channel = getUserChannel();
|
78
|
+
* ...
|
79
|
+
* channel.onmessage = (e) => {
|
80
|
+
* if (channel.isMessageType('user-authentication-change', e)) {
|
81
|
+
* logger.debug('user-authentication-change', e.data.detail);
|
82
|
+
* return;
|
83
|
+
* }
|
84
|
+
* }
|
85
|
+
* ...
|
86
|
+
* channel.close();
|
87
|
+
* ```
|
88
|
+
* @public
|
89
|
+
*/
|
90
|
+
export function getUserChannel() {
|
91
|
+
return DI.getOrCreateDOMContainer().get(UserChannel);
|
92
|
+
}
|
package/dist/esm/types.js
CHANGED
package/dist/esm/user.js
CHANGED
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
|
|
2
2
|
import { createObserver } from '@genesislcap/foundation-utils';
|
3
3
|
import { Observable, observable } from '@microsoft/fast-element';
|
4
4
|
import { DI } from '@microsoft/fast-foundation';
|
5
|
-
import { UserConfig } from './config';
|
5
|
+
import { getUserChannel, UserConfig } from './config';
|
6
6
|
import { UserAuthenticationChangeType } from './types';
|
7
7
|
/**
|
8
8
|
* Default User implementation.
|
@@ -27,15 +27,6 @@ export class DefaultUser {
|
|
27
27
|
unset() {
|
28
28
|
return this.config.unsetUser(this);
|
29
29
|
}
|
30
|
-
/** @internal */
|
31
|
-
userNameChanged() {
|
32
|
-
Observable.notify(this, 'username');
|
33
|
-
}
|
34
|
-
/** {@inheritDoc User.username} */
|
35
|
-
get username() {
|
36
|
-
Observable.track(this, 'username');
|
37
|
-
return this.userName;
|
38
|
-
}
|
39
30
|
/** {@inheritDoc User.isAnonymous} */
|
40
31
|
get isAnonymous() {
|
41
32
|
return !this.isAuthenticated;
|
@@ -118,6 +109,47 @@ export class DefaultUser {
|
|
118
109
|
(_a = this.authenticationChangeListeners) === null || _a === void 0 ? void 0 : _a.publish(new CustomEvent(UserAuthenticationChangeType, {
|
119
110
|
detail: this.isAuthenticated,
|
120
111
|
}));
|
112
|
+
/**
|
113
|
+
* Normally we'd inject channels, but in objects like User that will always exist (no destroy), the use of a channel
|
114
|
+
* may lead to tests failing to exit. Given authentication changes are infrequent, a temp channel poses less risk.
|
115
|
+
*/
|
116
|
+
const channel = getUserChannel();
|
117
|
+
channel.postMessage('user-authentication-change', this.isAuthenticated);
|
118
|
+
channel.close();
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* Bridge legacy user apis below
|
122
|
+
*/
|
123
|
+
/** @internal */
|
124
|
+
userNameChanged() {
|
125
|
+
Observable.notify(this, 'username');
|
126
|
+
}
|
127
|
+
/** {@inheritDoc LegacyUserAPI.username} */
|
128
|
+
get username() {
|
129
|
+
Observable.track(this, 'username');
|
130
|
+
return this.userName;
|
131
|
+
}
|
132
|
+
/** @internal */
|
133
|
+
permissionChanged() {
|
134
|
+
Observable.notify(this, 'permissions');
|
135
|
+
}
|
136
|
+
/** {@inheritDoc LegacyUserAPI.permissions} */
|
137
|
+
get permissions() {
|
138
|
+
Observable.track(this, 'permissions');
|
139
|
+
return this.permission;
|
140
|
+
}
|
141
|
+
/** @internal */
|
142
|
+
profileChanged() {
|
143
|
+
Observable.notify(this, 'profiles');
|
144
|
+
}
|
145
|
+
/** {@inheritDoc LegacyUserAPI.profiles} */
|
146
|
+
get profiles() {
|
147
|
+
Observable.track(this, 'profiles');
|
148
|
+
return this.profile;
|
149
|
+
}
|
150
|
+
/** {@inheritDoc LegacyUserAPI.hasAdminProfile} */
|
151
|
+
hasAdminProfile() {
|
152
|
+
return this.isAdmin();
|
121
153
|
}
|
122
154
|
}
|
123
155
|
__decorate([
|