@genesislcap/foundation-auth 14.71.1-auth-mf.17 → 14.71.1-auth-mf.18
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/README.md +22 -16
- package/dist/dts/index.d.ts +0 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/machine/machine.d.ts +3 -1
- package/dist/dts/machine/machine.d.ts.map +1 -1
- package/dist/dts/main/config.d.ts +15 -54
- package/dist/dts/main/config.d.ts.map +1 -1
- package/dist/dts/routes/base.d.ts +3 -3
- package/dist/dts/routes/base.d.ts.map +1 -1
- package/dist/dts/routes/index.d.ts +2 -0
- package/dist/dts/routes/index.d.ts.map +1 -1
- package/dist/dts/routes/logout/logout.d.ts.map +1 -1
- package/dist/dts/routes/routing.d.ts +66 -0
- package/dist/dts/routes/routing.d.ts.map +1 -0
- package/dist/dts/routes/types.d.ts +17 -0
- package/dist/dts/routes/types.d.ts.map +1 -1
- package/dist/dts/routes/utils.d.ts +30 -0
- package/dist/dts/routes/utils.d.ts.map +1 -0
- package/dist/esm/index.js +0 -1
- package/dist/esm/machine/machine.js +14 -11
- package/dist/esm/main/config.js +9 -54
- package/dist/esm/routes/base.js +5 -6
- package/dist/esm/routes/index.js +2 -0
- package/dist/esm/routes/login/login.template.js +3 -3
- package/dist/esm/routes/logout/logout.js +1 -3
- package/dist/esm/routes/protected/protected.js +1 -1
- package/dist/esm/routes/routing.js +51 -0
- package/dist/esm/routes/types.js +13 -1
- package/dist/esm/routes/utils.js +39 -0
- package/dist/foundation-auth.api.json +413 -285
- package/dist/foundation-auth.d.ts +110 -101
- package/docs/api/foundation-auth.authconfig.md +3 -3
- package/docs/api/foundation-auth.authconfig.omitroutes.md +1 -1
- package/docs/api/foundation-auth.authconfig.postloginredirect.md +16 -0
- package/docs/api/foundation-auth.authconfig.postlogoutredirect.md +16 -0
- package/docs/api/{foundation-auth.routes.md → foundation-auth.authroutes.md} +3 -3
- package/docs/api/foundation-auth.authrouting.getroutepath.md +13 -0
- package/docs/api/foundation-auth.authrouting.md +37 -0
- package/docs/api/foundation-auth.authrouting.navigateto.md +16 -0
- package/docs/api/foundation-auth.configure.md +5 -2
- package/docs/api/foundation-auth.defaultauthmachine._constructor_.md +2 -1
- package/docs/api/foundation-auth.defaultauthmachine.md +1 -1
- package/docs/api/foundation-auth.defaultauthrouting.getroutepath.md +24 -0
- package/docs/api/foundation-auth.defaultauthrouting.md +22 -0
- package/docs/api/foundation-auth.defaultauthrouting.navigateto.md +26 -0
- package/docs/api/foundation-auth.getauthrouting.md +32 -0
- package/docs/api/{foundation-auth.getsubroutepath.md → foundation-auth.getroutepath.md} +4 -4
- package/docs/api/foundation-auth.md +6 -6
- package/docs/api-report.md +57 -45
- package/package.json +31 -30
- package/dist/dts/logout/index.d.ts +0 -2
- package/dist/dts/logout/index.d.ts.map +0 -1
- package/dist/dts/logout/logout.d.ts +0 -61
- package/dist/dts/logout/logout.d.ts.map +0 -1
- package/dist/esm/logout/index.js +0 -1
- package/dist/esm/logout/logout.js +0 -52
- package/docs/api/foundation-auth.authconfig.defaultredirecturl.md +0 -18
- package/docs/api/foundation-auth.authconfig.routetourl.md +0 -18
- package/docs/api/foundation-auth.defaultlogoututility.md +0 -21
- package/docs/api/foundation-auth.defaultlogoututility.run.md +0 -16
- package/docs/api/foundation-auth.getlogoututility.md +0 -32
- package/docs/api/foundation-auth.logoututility.md +0 -36
- package/docs/api/foundation-auth.logoututility.run.md +0 -15
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ not limited to:
|
|
|
11
11
|
* `AuthStore`: An auth based `foundation-store`.
|
|
12
12
|
* `AuthMachine`: An auth based `foundation-state-machine` covering the various auth workflows.
|
|
13
13
|
* `AuthMessageMapper`: The auth message dto to entity mapper.
|
|
14
|
-
* `
|
|
14
|
+
* `AuthRouting`: A routing utility, which you can call `navigateTo(...)` to navigate to internal routes.
|
|
15
15
|
* Various UI components / screens.
|
|
16
16
|
|
|
17
17
|
In most cases, developers simply import both the `User` and `Auth` micro frontend, and use the `configure` export token
|
|
@@ -76,17 +76,20 @@ See the [User API Docs](./docs/api/foundation-auth.user.md) for more information
|
|
|
76
76
|
Here we are lazy loading the micro frontend when the route is accessed.
|
|
77
77
|
```ts
|
|
78
78
|
{
|
|
79
|
-
title: '
|
|
80
|
-
name: '
|
|
81
|
-
path: '
|
|
79
|
+
title: 'Authenticate',
|
|
80
|
+
name: 'auth',
|
|
81
|
+
path: 'auth', // < at what path should the micro frontend be accessed
|
|
82
82
|
element: async () => {
|
|
83
83
|
const { Auth, configure } = await import('@genesislcap/foundation-auth');
|
|
84
84
|
configure({
|
|
85
85
|
omitRoutes: ['request-account'],
|
|
86
|
-
hostPath: '
|
|
87
|
-
defaultRedirectUrl: 'my-dashboard',
|
|
86
|
+
hostPath: 'auth', // < important to match the route path
|
|
88
87
|
logo: myLogo,
|
|
89
88
|
background: myBG,
|
|
89
|
+
postLoginRedirect: () => {
|
|
90
|
+
// You could inspect the user here and route them based on various conditions.
|
|
91
|
+
Route.path.push('my-dashboard');
|
|
92
|
+
},
|
|
90
93
|
});
|
|
91
94
|
return Auth;
|
|
92
95
|
},
|
|
@@ -110,11 +113,11 @@ this.contributors.push({
|
|
|
110
113
|
return;
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
113
|
-
* Otherwise route them to
|
|
116
|
+
* Otherwise route them to auth
|
|
114
117
|
*/
|
|
115
118
|
phase.cancel(() => {
|
|
116
119
|
this.user.trackPath();
|
|
117
|
-
Route.name.replace(phase.router, '
|
|
120
|
+
Route.name.replace(phase.router, 'auth');
|
|
118
121
|
});
|
|
119
122
|
},
|
|
120
123
|
});
|
|
@@ -132,25 +135,28 @@ this.connect.connect(SOCKET_URL);
|
|
|
132
135
|
```
|
|
133
136
|
|
|
134
137
|
### Logging out
|
|
135
|
-
|
|
138
|
+
You can logout by navigating to the logout route. You can access the `AuthRouting` singleton via the DI container.
|
|
136
139
|
```ts
|
|
137
|
-
import {
|
|
140
|
+
import { AuthRouting } from '@genesislcap/foundation-auth';
|
|
138
141
|
...
|
|
139
|
-
@
|
|
142
|
+
@AuthRouting private authRouting: AuthRouting;
|
|
140
143
|
...
|
|
141
|
-
this.
|
|
144
|
+
this.authRouting.navigateTo('logout');
|
|
142
145
|
```
|
|
143
146
|
|
|
144
147
|
...or via a utility if your app is not using decorators or the DI container.
|
|
148
|
+
|
|
145
149
|
```ts
|
|
146
|
-
import {
|
|
150
|
+
import { getAuthRouting } from '@genesislcap/foundation-auth';
|
|
147
151
|
...
|
|
148
|
-
private
|
|
152
|
+
private authRouting = getAuthRouting();
|
|
149
153
|
...
|
|
150
|
-
this.
|
|
154
|
+
this.authRouting.navigateTo('logout');
|
|
151
155
|
```
|
|
152
156
|
|
|
153
|
-
|
|
157
|
+
You can use `AuthRouting` to navigate to other routes, like change password etc.
|
|
158
|
+
|
|
159
|
+
See the [AuthRouting API Docs](./docs/api/foundation-auth.authrouting.md) for more information.
|
|
154
160
|
|
|
155
161
|
## [API Docs](./docs/api/index.md)
|
|
156
162
|
|
package/dist/dts/index.d.ts
CHANGED
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -4,6 +4,7 @@ import type { InterpreterOptions } from 'xstate';
|
|
|
4
4
|
import { CredentialManager } from '../credential';
|
|
5
5
|
import { AuthConfig } from '../main/config';
|
|
6
6
|
import { AuthMessageMapper } from '../mapper';
|
|
7
|
+
import { AuthRouting } from '../routes/routing';
|
|
7
8
|
import { User } from '../user';
|
|
8
9
|
import type { AuthMachineContext, AuthMachineEvent, LoginParams, QueryParams } from './types';
|
|
9
10
|
/**
|
|
@@ -23,7 +24,8 @@ export declare class DefaultAuthMachine extends AbstractMachine<AuthMachineConte
|
|
|
23
24
|
private uuid;
|
|
24
25
|
private messageMapper;
|
|
25
26
|
private config;
|
|
26
|
-
|
|
27
|
+
private routing;
|
|
28
|
+
constructor(user: User, fetchMachine: FetchMachine, cm: CredentialManager, uuid: UUID, messageMapper: AuthMessageMapper, config: AuthConfig, routing: AuthRouting);
|
|
27
29
|
start(options?: InterpreterOptions<typeof this.machine>): void;
|
|
28
30
|
/**
|
|
29
31
|
* AuthMachine is a singleton.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/machine/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,YAAY,EACZ,iBAAiB,EAMjB,OAAO,EAER,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAEL,iBAAiB,EAIlB,MAAM,eAAe,CAAC;AAWvB,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/machine/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,YAAY,EACZ,iBAAiB,EAMjB,OAAO,EAER,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM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G,KAAK,GAAG,iBAAiB;IAgB3E,SAAS,CAAC,YAAY;;;;;;;;;;;;;;;;;MAiBnB;IAEH,SAAS,CAAC,SAAS;;;MAGhB;CACJ;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,mEAA0E,CAAC"}
|
|
@@ -1,40 +1,5 @@
|
|
|
1
1
|
import { ElementStyles } from '@microsoft/fast-element';
|
|
2
|
-
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare const Routes: {
|
|
6
|
-
readonly login: "login";
|
|
7
|
-
readonly logout: "logout";
|
|
8
|
-
readonly 'request-account': "request-account";
|
|
9
|
-
readonly 'reset-password': "reset-password";
|
|
10
|
-
readonly 'forgot-password': "forgot-password";
|
|
11
|
-
readonly verify: "verify";
|
|
12
|
-
readonly protected: "protected";
|
|
13
|
-
readonly 'not-found': "not-found";
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export type Routes = (typeof Routes)[keyof typeof Routes];
|
|
19
|
-
/**
|
|
20
|
-
* A utility to check if a pathname is a route of this micro frontend.
|
|
21
|
-
*
|
|
22
|
-
* @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
* @privateRemarks
|
|
26
|
-
* I've just put this util in for now given there's some app level direction code in place which needs review.
|
|
27
|
-
*/
|
|
28
|
-
export declare function isMFRoute(pathname?: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* A utility to get a sub route path taking the host path into account.
|
|
31
|
-
*
|
|
32
|
-
* @param routeName - The route name.
|
|
33
|
-
* @param hostPath - The host path.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export declare function getSubRoutePath(routeName: Routes | string, hostPath?: string): string;
|
|
2
|
+
import type { AuthRoutes } from '../routes/types';
|
|
38
3
|
/**
|
|
39
4
|
* @public
|
|
40
5
|
* Could be expanded to allow field ViewTemplates.
|
|
@@ -148,7 +113,7 @@ export interface AuthConfig {
|
|
|
148
113
|
* omitRoutes: ['request-account'],
|
|
149
114
|
* ```
|
|
150
115
|
*/
|
|
151
|
-
omitRoutes: Exclude<
|
|
116
|
+
omitRoutes: Exclude<AuthRoutes, 'login' | 'not-found'>[];
|
|
152
117
|
/**
|
|
153
118
|
* Map of configuration for each of the primary form fields.
|
|
154
119
|
*
|
|
@@ -163,13 +128,6 @@ export interface AuthConfig {
|
|
|
163
128
|
* Used to help resolve internal route links. Defaults to an empty string.
|
|
164
129
|
*/
|
|
165
130
|
hostPath: string;
|
|
166
|
-
/**
|
|
167
|
-
* The default URL to route the user to after a successful login.
|
|
168
|
-
*
|
|
169
|
-
* @remarks
|
|
170
|
-
* User.lastPath() is any trumps this value.
|
|
171
|
-
*/
|
|
172
|
-
defaultRedirectUrl: string;
|
|
173
131
|
/**
|
|
174
132
|
* The forgot password return URL which is used in the email template.
|
|
175
133
|
*/
|
|
@@ -184,16 +142,16 @@ export interface AuthConfig {
|
|
|
184
142
|
*/
|
|
185
143
|
omitRedirectUrls: string[];
|
|
186
144
|
/**
|
|
187
|
-
* The routing method called post login and logout.
|
|
188
|
-
*
|
|
189
145
|
* @remarks
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* this, you should include some protection and may want to ignore when the URL is equal to the current url.
|
|
193
|
-
*
|
|
194
|
-
* @param url - The url to route to or undefined.
|
|
146
|
+
* Called after a successful login and should be overridden by host. User.lastPath() can be used to trump static
|
|
147
|
+
* values when required.
|
|
195
148
|
*/
|
|
196
|
-
|
|
149
|
+
postLoginRedirect: () => void;
|
|
150
|
+
/**
|
|
151
|
+
* @remarks
|
|
152
|
+
* Called after a successful logout. Routes to back to the login form by default.
|
|
153
|
+
*/
|
|
154
|
+
postLogoutRedirect: () => void;
|
|
197
155
|
/**
|
|
198
156
|
* SSO configuration.
|
|
199
157
|
*
|
|
@@ -244,17 +202,20 @@ export declare const AuthConfig: import("@microsoft/fast-foundation").InterfaceS
|
|
|
244
202
|
*
|
|
245
203
|
* @example Configuring auth on lazy load
|
|
246
204
|
* ```ts
|
|
205
|
+
* title: 'Authenticate',
|
|
247
206
|
* name: 'auth',
|
|
248
207
|
* path: 'auth',
|
|
249
|
-
* title: 'Authenticate',
|
|
250
208
|
* element: async () => {
|
|
251
209
|
* const { configure, Auth } = await import('@genesislcap/foundation-auth');
|
|
252
210
|
* configure({
|
|
253
211
|
* hostPath: 'auth',
|
|
254
|
-
* defaultRedirectUrl: 'dashboard',
|
|
255
212
|
* omitRoutes: ['request-account'],
|
|
256
213
|
* logo: myCompanyLogo,
|
|
257
214
|
* background: myAuthBG,
|
|
215
|
+
* postLoginRedirect: () => {
|
|
216
|
+
* // You could inspect the user here and route them based on various conditions.
|
|
217
|
+
* Route.path.push('dashboard');
|
|
218
|
+
* },
|
|
258
219
|
* });
|
|
259
220
|
* return Auth;
|
|
260
221
|
* },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/main/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/main/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,c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,EAAE,UAoC/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,kEAAuE,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,QAOpD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Binding } from '@microsoft/fast-element';
|
|
2
2
|
import { Container } from '@microsoft/fast-foundation';
|
|
3
3
|
import { CredentialManager } from '../credential';
|
|
4
|
-
import { AuthConfig
|
|
4
|
+
import { AuthConfig } from '../main/config';
|
|
5
5
|
import { AuthEventMap, AuthFormEntryEventMap, AuthStore } from '../store';
|
|
6
6
|
import { User } from '../user';
|
|
7
|
+
import { AuthRouting } from './routing';
|
|
7
8
|
type EventMap = AuthEventMap & AuthFormEntryEventMap & {};
|
|
8
9
|
/**
|
|
9
10
|
* @internal
|
|
@@ -350,6 +351,7 @@ export declare class ConfigHostElement extends ConfigHostElement_base implements
|
|
|
350
351
|
*/
|
|
351
352
|
export declare class BaseRoute extends ConfigHostElement {
|
|
352
353
|
store: AuthStore;
|
|
354
|
+
routing: AuthRouting;
|
|
353
355
|
user: User;
|
|
354
356
|
credentialManager: CredentialManager;
|
|
355
357
|
/**
|
|
@@ -360,9 +362,7 @@ export declare class BaseRoute extends ConfigHostElement {
|
|
|
360
362
|
connectedCallback(): void;
|
|
361
363
|
setError(message: string): void;
|
|
362
364
|
clearError(): void;
|
|
363
|
-
getSubRoutePath(routeName: Routes | string): string;
|
|
364
365
|
onBack: () => void;
|
|
365
|
-
onNavigate: (path: string) => void;
|
|
366
366
|
attemptAutofill(): void;
|
|
367
367
|
}
|
|
368
368
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/routes/base.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,OAAO,EAOR,MAAM,yBAAyB,CAAC;AACjC,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B,MAAM,EAAE,UAAU,CAAC;IAE/B,iBAAiB;CAMlB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,iBAAiB;IACnC,KAAK,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACE,iBAAiB,EAAG,iBAAiB,CAAC;IAEzD;;OAEG;IACS,OAAO,EAAE,MAAM,CAAM;IACrB,SAAS,EAAE,OAAO,CAAS;IAEvC,iBAAiB;IAMjB,QAAQ,CAAC,OAAO,EAAE,MAAM;IAKxB,UAAU;IAIV,MAAM,aAAsC;IAE5C,eAAe,IAAI,IAAI;CASxB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,mFAsB7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,mFAiBzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,mFAkBtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,gCAAiC,MAAM,2DAahE,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,cAAc,8BAA+B,KAAK,GAAG,cAAc,2DAgB/E,CAAC;AAgGF;;GAEG;AACH,eAAO,MAAM,UAAU,kCAAmC,OAAO,2DAUhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,gCAChB,MAAM,eACD,MAAM,aACR,OAAO,2DAWlB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,mFASjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/logout/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,qBAKa,MAAO,SAAQ,SAAS;IACnC,KAAK;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/logout/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,qBAKa,MAAO,SAAQ,SAAS;IACnC,KAAK;IAIL,MAAM;CAGP"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AuthRoutes } from './types';
|
|
2
|
+
import { getRoutePath, navigateTo } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* AuthRouting interface.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A utility to navigate to a sub route of the auth micro frontend without needing to know the full path in advance.
|
|
8
|
+
*
|
|
9
|
+
* @example Import the utility into any component or logic you wish to invoke from.
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { AuthRouting } from '@genesislcap/foundation-auth';
|
|
12
|
+
* ...
|
|
13
|
+
* @AuthRouting private authRouting: AuthRouting;
|
|
14
|
+
* ...
|
|
15
|
+
* this.authRouting.navigateTo('logout');
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthRouting {
|
|
21
|
+
/** {@inheritDoc navigateTo} */
|
|
22
|
+
navigateTo: typeof navigateTo;
|
|
23
|
+
/** {@inheritDoc getRoutePath} */
|
|
24
|
+
getRoutePath: typeof getRoutePath;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Default AuthRouting.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare class DefaultAuthRouting implements AuthRouting {
|
|
32
|
+
/** @internal */
|
|
33
|
+
private config;
|
|
34
|
+
/** {@inheritDoc AuthRouting.navigateTo} */
|
|
35
|
+
navigateTo(route: AuthRoutes | string): void;
|
|
36
|
+
/** {@inheritDoc AuthRouting.getRoutePath} */
|
|
37
|
+
getRoutePath(route: AuthRoutes | string): string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* AuthRouting DI key.
|
|
41
|
+
*
|
|
42
|
+
* @privateRemarks
|
|
43
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export declare const AuthRouting: import("@microsoft/fast-foundation").InterfaceSymbol<AuthRouting>;
|
|
48
|
+
/**
|
|
49
|
+
* Gets AuthRouting from the DI container.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* A utility method for host applications that are not using decorators or the DI container.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { getAuthRouting } from '@genesislcap/foundation-auth';
|
|
57
|
+
* ...
|
|
58
|
+
* private authRouting = getAuthRouting();
|
|
59
|
+
* ...
|
|
60
|
+
* this.authRouting.navigateTo('logout');
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare function getAuthRouting(): AuthRouting;
|
|
66
|
+
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/routes/routing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,iCAAiC;IACjC,YAAY,EAAE,OAAO,YAAY,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD,gBAAgB;IACJ,OAAO,CAAC,MAAM,CAAa;IAEvC,2CAA2C;IAC3C,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;IAIrC,6CAA6C;IAC7C,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;CAGxC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,mEAA0E,CAAC;AAEnG;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
|
|
@@ -26,4 +26,21 @@ export interface IDPResponse {
|
|
|
26
26
|
ID: string;
|
|
27
27
|
TYPE: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare const AuthRoutes: {
|
|
33
|
+
readonly login: "login";
|
|
34
|
+
readonly logout: "logout";
|
|
35
|
+
readonly 'request-account': "request-account";
|
|
36
|
+
readonly 'reset-password': "reset-password";
|
|
37
|
+
readonly 'forgot-password': "forgot-password";
|
|
38
|
+
readonly verify: "verify";
|
|
39
|
+
readonly protected: "protected";
|
|
40
|
+
readonly 'not-found': "not-found";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export type AuthRoutes = (typeof AuthRoutes)[keyof typeof AuthRoutes];
|
|
29
46
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/routes/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/routes/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;CASb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AuthRoutes } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A utility to check if a pathname is a route of this micro frontend.
|
|
4
|
+
*
|
|
5
|
+
* @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @privateRemarks
|
|
9
|
+
* I've just put this util in for now given there's some app level direction code in place which needs review.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isMFRoute(pathname?: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @remarks
|
|
14
|
+
* Uses the `FASTRouter`.
|
|
15
|
+
*
|
|
16
|
+
* @param route - An auth route including query params if required, ie. `reset-password?expired`.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function navigateTo(route: AuthRoutes | string): void;
|
|
21
|
+
/**
|
|
22
|
+
* A utility to get a sub route path taking the host path into account.
|
|
23
|
+
*
|
|
24
|
+
* @param route - An auth route.
|
|
25
|
+
* @param hostPath - The host path.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function getRoutePath(route: AuthRoutes | string, hostPath?: string): string;
|
|
30
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/routes/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,GAAE,MAA0B,GAAG,OAAO,CAKvE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,QAEpD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM,CAEtF"}
|
package/dist/esm/index.js
CHANGED
|
@@ -6,8 +6,9 @@ import { and, assign, createMachine, fromPromise, not, or, raise, sendTo } from
|
|
|
6
6
|
import { CredentialManager, CredentialType, } from '../credential';
|
|
7
7
|
import { MESSAGE_TYPE } from '../dto';
|
|
8
8
|
import { LOGIN_DETAILS_URL, LOGIN_URL, LOGOUT_URL, FORGOT_PASSWORD_URL, CHANGE_PASSWORD_URL, RESET_PASSWORD_URL, } from '../env';
|
|
9
|
-
import { AuthConfig
|
|
9
|
+
import { AuthConfig } from '../main/config';
|
|
10
10
|
import { AuthMessageMapper, createHTTPHeadersFromDTO, isLoginAckEntity, isLoginDetailsAckEntity, isLoginNackEntity, isLogoutAckEntity, isLogoutNackEntity, isNackDTO, } from '../mapper';
|
|
11
|
+
import { AuthRouting } from '../routes/routing';
|
|
11
12
|
import { User } from '../user';
|
|
12
13
|
import { logger } from '../utils';
|
|
13
14
|
import { defaultAuthMachineContext, isLoginParams, isQueryParams } from './types';
|
|
@@ -16,7 +17,7 @@ import { defaultAuthMachineContext, isLoginParams, isQueryParams } from './types
|
|
|
16
17
|
* @public
|
|
17
18
|
*/
|
|
18
19
|
let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
19
|
-
constructor(user, fetchMachine, cm, uuid, messageMapper, config) {
|
|
20
|
+
constructor(user, fetchMachine, cm, uuid, messageMapper, config, routing) {
|
|
20
21
|
super();
|
|
21
22
|
this.user = user;
|
|
22
23
|
this.fetchMachine = fetchMachine;
|
|
@@ -24,6 +25,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
24
25
|
this.uuid = uuid;
|
|
25
26
|
this.messageMapper = messageMapper;
|
|
26
27
|
this.config = config;
|
|
28
|
+
this.routing = routing;
|
|
27
29
|
this.onIdleEvents = () => ({
|
|
28
30
|
login: {
|
|
29
31
|
actions: ['resetContext', 'setParams'],
|
|
@@ -160,7 +162,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
160
162
|
meta: {
|
|
161
163
|
content: 'Logged in.',
|
|
162
164
|
},
|
|
163
|
-
entry: ['storeBasicCredentials', 'loggedInCallback', '
|
|
165
|
+
entry: ['storeBasicCredentials', 'loggedInCallback', 'postLoginRedirect'],
|
|
164
166
|
on: {
|
|
165
167
|
logout: {
|
|
166
168
|
target: '#authMachine.loggingOut',
|
|
@@ -183,7 +185,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
183
185
|
},
|
|
184
186
|
entry: [
|
|
185
187
|
sendTo('logoutFetcher', this.createFetchMachineEvent(LOGOUT_URL), {
|
|
186
|
-
delay: '
|
|
188
|
+
delay: 'logoutFeedbackDelay',
|
|
187
189
|
}),
|
|
188
190
|
],
|
|
189
191
|
},
|
|
@@ -193,7 +195,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
193
195
|
'unsetUser',
|
|
194
196
|
'preventSilentAccess',
|
|
195
197
|
'loggedOutCallback',
|
|
196
|
-
'
|
|
198
|
+
'postLogoutRedirect',
|
|
197
199
|
'openOIDCLogoutPage',
|
|
198
200
|
],
|
|
199
201
|
on: this.onIdleEvents(),
|
|
@@ -435,7 +437,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
435
437
|
},
|
|
436
438
|
after: {
|
|
437
439
|
feedbackDelay: {
|
|
438
|
-
actions: '
|
|
440
|
+
actions: 'resetPasswordRedirect',
|
|
439
441
|
target: '#authMachine.idle',
|
|
440
442
|
},
|
|
441
443
|
},
|
|
@@ -542,10 +544,9 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
542
544
|
this.cm.storeCredentials(data);
|
|
543
545
|
}
|
|
544
546
|
},
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
routeToResetUrl: () => this.config.routeToUrl(getSubRoutePath('reset-password?expired', this.config.hostPath)),
|
|
547
|
+
postLoginRedirect: this.config.postLoginRedirect,
|
|
548
|
+
postLogoutRedirect: this.config.postLogoutRedirect,
|
|
549
|
+
resetPasswordRedirect: () => this.routing.navigateTo('reset-password?expired'),
|
|
549
550
|
/**
|
|
550
551
|
* loggedInCallback.
|
|
551
552
|
* @remarks
|
|
@@ -608,6 +609,7 @@ let DefaultAuthMachine = class DefaultAuthMachine extends AbstractMachine {
|
|
|
608
609
|
},
|
|
609
610
|
delays: {
|
|
610
611
|
feedbackDelay: this.config.feedbackDelay,
|
|
612
|
+
logoutFeedbackDelay: 1000,
|
|
611
613
|
},
|
|
612
614
|
});
|
|
613
615
|
this.start();
|
|
@@ -672,7 +674,8 @@ DefaultAuthMachine = __decorate([
|
|
|
672
674
|
__param(2, CredentialManager),
|
|
673
675
|
__param(3, UUID),
|
|
674
676
|
__param(4, AuthMessageMapper),
|
|
675
|
-
__param(5, AuthConfig)
|
|
677
|
+
__param(5, AuthConfig),
|
|
678
|
+
__param(6, AuthRouting)
|
|
676
679
|
], DefaultAuthMachine);
|
|
677
680
|
export { DefaultAuthMachine };
|
|
678
681
|
/**
|
package/dist/esm/main/config.js
CHANGED
|
@@ -1,47 +1,8 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
2
|
import { DI, Registration } from '@microsoft/fast-foundation';
|
|
3
|
-
import { Route } from '@microsoft/fast-router';
|
|
4
3
|
import defaultBackgroundSrc from '../assets/bg.jpg';
|
|
5
4
|
import defaultLogoSrc from '../assets/genesis-logo-light.svg';
|
|
6
|
-
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const Routes = {
|
|
10
|
-
login: 'login',
|
|
11
|
-
logout: 'logout',
|
|
12
|
-
'request-account': 'request-account',
|
|
13
|
-
'reset-password': 'reset-password',
|
|
14
|
-
'forgot-password': 'forgot-password',
|
|
15
|
-
verify: 'verify',
|
|
16
|
-
protected: 'protected',
|
|
17
|
-
'not-found': 'not-found',
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A utility to check if a pathname is a route of this micro frontend.
|
|
21
|
-
*
|
|
22
|
-
* @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
* @privateRemarks
|
|
26
|
-
* I've just put this util in for now given there's some app level direction code in place which needs review.
|
|
27
|
-
*/
|
|
28
|
-
export function isMFRoute(pathname = location.pathname) {
|
|
29
|
-
const valueParts = pathname.split('/');
|
|
30
|
-
const routeIdx = pathname.charAt(0) === '/' ? 1 : 0;
|
|
31
|
-
const route = valueParts[routeIdx];
|
|
32
|
-
return !!Routes[route];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A utility to get a sub route path taking the host path into account.
|
|
36
|
-
*
|
|
37
|
-
* @param routeName - The route name.
|
|
38
|
-
* @param hostPath - The host path.
|
|
39
|
-
*
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
export function getSubRoutePath(routeName, hostPath = '') {
|
|
43
|
-
return hostPath !== '' ? `${hostPath}/${routeName}` : routeName;
|
|
44
|
-
}
|
|
5
|
+
import { getRoutePath, navigateTo } from '../routes/utils';
|
|
45
6
|
/**
|
|
46
7
|
* Default AuthConfig DI implementation.
|
|
47
8
|
* @public
|
|
@@ -72,19 +33,10 @@ export const defaultAuthConfig = {
|
|
|
72
33
|
},
|
|
73
34
|
},
|
|
74
35
|
hostPath: '',
|
|
75
|
-
|
|
76
|
-
forgotPasswordReturnUrl: `${location.protocol}//${location.host}/${getSubRoutePath('reset-password')}`,
|
|
36
|
+
forgotPasswordReturnUrl: `${location.protocol}//${location.host}/${getRoutePath('reset-password')}`,
|
|
77
37
|
omitRedirectUrls: ['/not-found', '/not-permitted'],
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Uses the FASTRouter by default, however, host apps may override to integrate with their router of choice.
|
|
82
|
-
* The FASTRouter invokes the History API and triggers a NavigationMessage to drive the view change.
|
|
83
|
-
* TODO: We will need to test how unknown app level routers react to this default when not overriding.
|
|
84
|
-
*/
|
|
85
|
-
Route.path.push(url);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
38
|
+
postLoginRedirect: () => navigateTo('protected'),
|
|
39
|
+
postLogoutRedirect: () => navigateTo('/'),
|
|
88
40
|
sso: {
|
|
89
41
|
identityProvidersPath: 'gwf/sso/list',
|
|
90
42
|
},
|
|
@@ -108,17 +60,20 @@ export const AuthConfig = DI.createInterface((x) => x.instance(defaultAuthConfig
|
|
|
108
60
|
*
|
|
109
61
|
* @example Configuring auth on lazy load
|
|
110
62
|
* ```ts
|
|
63
|
+
* title: 'Authenticate',
|
|
111
64
|
* name: 'auth',
|
|
112
65
|
* path: 'auth',
|
|
113
|
-
* title: 'Authenticate',
|
|
114
66
|
* element: async () => {
|
|
115
67
|
* const { configure, Auth } = await import('@genesislcap/foundation-auth');
|
|
116
68
|
* configure({
|
|
117
69
|
* hostPath: 'auth',
|
|
118
|
-
* defaultRedirectUrl: 'dashboard',
|
|
119
70
|
* omitRoutes: ['request-account'],
|
|
120
71
|
* logo: myCompanyLogo,
|
|
121
72
|
* background: myAuthBG,
|
|
73
|
+
* postLoginRedirect: () => {
|
|
74
|
+
* // You could inspect the user here and route them based on various conditions.
|
|
75
|
+
* Route.path.push('dashboard');
|
|
76
|
+
* },
|
|
122
77
|
* });
|
|
123
78
|
* return Auth;
|
|
124
79
|
* },
|