@genesislcap/foundation-auth 14.71.1-auth-mf.16 → 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.
Files changed (63) hide show
  1. package/README.md +22 -16
  2. package/dist/dts/index.d.ts +0 -1
  3. package/dist/dts/index.d.ts.map +1 -1
  4. package/dist/dts/machine/machine.d.ts +3 -1
  5. package/dist/dts/machine/machine.d.ts.map +1 -1
  6. package/dist/dts/main/config.d.ts +15 -53
  7. package/dist/dts/main/config.d.ts.map +1 -1
  8. package/dist/dts/routes/base.d.ts +3 -3
  9. package/dist/dts/routes/base.d.ts.map +1 -1
  10. package/dist/dts/routes/index.d.ts +2 -0
  11. package/dist/dts/routes/index.d.ts.map +1 -1
  12. package/dist/dts/routes/logout/logout.d.ts.map +1 -1
  13. package/dist/dts/routes/routing.d.ts +66 -0
  14. package/dist/dts/routes/routing.d.ts.map +1 -0
  15. package/dist/dts/routes/types.d.ts +17 -0
  16. package/dist/dts/routes/types.d.ts.map +1 -1
  17. package/dist/dts/routes/utils.d.ts +30 -0
  18. package/dist/dts/routes/utils.d.ts.map +1 -0
  19. package/dist/esm/index.js +0 -1
  20. package/dist/esm/machine/machine.js +14 -11
  21. package/dist/esm/main/config.js +9 -53
  22. package/dist/esm/routes/base.js +5 -6
  23. package/dist/esm/routes/index.js +2 -0
  24. package/dist/esm/routes/login/login.template.js +3 -3
  25. package/dist/esm/routes/logout/logout.js +1 -3
  26. package/dist/esm/routes/protected/protected.js +1 -1
  27. package/dist/esm/routes/routing.js +51 -0
  28. package/dist/esm/routes/types.js +13 -1
  29. package/dist/esm/routes/utils.js +39 -0
  30. package/dist/foundation-auth.api.json +413 -285
  31. package/dist/foundation-auth.d.ts +110 -100
  32. package/docs/api/foundation-auth.authconfig.md +3 -3
  33. package/docs/api/foundation-auth.authconfig.omitroutes.md +1 -1
  34. package/docs/api/foundation-auth.authconfig.postloginredirect.md +16 -0
  35. package/docs/api/foundation-auth.authconfig.postlogoutredirect.md +16 -0
  36. package/docs/api/{foundation-auth.routes.md → foundation-auth.authroutes.md} +4 -3
  37. package/docs/api/foundation-auth.authrouting.getroutepath.md +13 -0
  38. package/docs/api/foundation-auth.authrouting.md +37 -0
  39. package/docs/api/foundation-auth.authrouting.navigateto.md +16 -0
  40. package/docs/api/foundation-auth.configure.md +5 -2
  41. package/docs/api/foundation-auth.defaultauthmachine._constructor_.md +2 -1
  42. package/docs/api/foundation-auth.defaultauthmachine.md +1 -1
  43. package/docs/api/foundation-auth.defaultauthrouting.getroutepath.md +24 -0
  44. package/docs/api/foundation-auth.defaultauthrouting.md +22 -0
  45. package/docs/api/foundation-auth.defaultauthrouting.navigateto.md +26 -0
  46. package/docs/api/foundation-auth.getauthrouting.md +32 -0
  47. package/docs/api/{foundation-auth.getsubroutepath.md → foundation-auth.getroutepath.md} +4 -4
  48. package/docs/api/foundation-auth.md +6 -6
  49. package/docs/api-report.md +57 -44
  50. package/package.json +31 -30
  51. package/dist/dts/logout/index.d.ts +0 -2
  52. package/dist/dts/logout/index.d.ts.map +0 -1
  53. package/dist/dts/logout/logout.d.ts +0 -61
  54. package/dist/dts/logout/logout.d.ts.map +0 -1
  55. package/dist/esm/logout/index.js +0 -1
  56. package/dist/esm/logout/logout.js +0 -52
  57. package/docs/api/foundation-auth.authconfig.defaultredirecturl.md +0 -18
  58. package/docs/api/foundation-auth.authconfig.routetourl.md +0 -18
  59. package/docs/api/foundation-auth.defaultlogoututility.md +0 -21
  60. package/docs/api/foundation-auth.defaultlogoututility.run.md +0 -16
  61. package/docs/api/foundation-auth.getlogoututility.md +0 -32
  62. package/docs/api/foundation-auth.logoututility.md +0 -36
  63. 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
- * `LogoutUtility`: A logout utility, which you can call `run()` on to trigger a logout.
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: 'Login',
80
- name: 'login',
81
- path: 'login', // < at what path should the micro frontend be accessed
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: 'login', // < important to match the route path
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 login
116
+ * Otherwise route them to auth
114
117
  */
115
118
  phase.cancel(() => {
116
119
  this.user.trackPath();
117
- Route.name.replace(phase.router, 'login');
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
- LogoutUtility is a singleton. You can access it via the DI container.
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 { LogoutUtility } from '@genesislcap/foundation-auth/logout';
140
+ import { AuthRouting } from '@genesislcap/foundation-auth';
138
141
  ...
139
- @LogoutUtility private logout: LogoutUtility;
142
+ @AuthRouting private authRouting: AuthRouting;
140
143
  ...
141
- this.logout.run();
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 { getLogoutUtility, LogoutUtility } from '@genesislcap/foundation-auth/logout';
150
+ import { getAuthRouting } from '@genesislcap/foundation-auth';
147
151
  ...
148
- private logout: LogoutUtility = getLogoutUtility();
152
+ private authRouting = getAuthRouting();
149
153
  ...
150
- this.logout.run();
154
+ this.authRouting.navigateTo('logout');
151
155
  ```
152
156
 
153
- See the [LogoutUtility API Docs](./docs/api/foundation-auth.logoututility.md) for more information.
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
 
@@ -2,7 +2,6 @@ export * from './env';
2
2
  export * from './credential';
3
3
  export * from './dto';
4
4
  export * from './entity';
5
- export * from './logout';
6
5
  export * from './machine';
7
6
  export * from './main';
8
7
  export * from './mapper';
@@ -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,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"}
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
- constructor(user: User, fetchMachine: FetchMachine, cm: CredentialManager, uuid: UUID, messageMapper: AuthMessageMapper, config: AuthConfig);
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,EAAmB,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EACL,iBAAiB,EAQlB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM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E,GAAG,KAAK,GAAG,iBAAiB;IAgB3E,SAAS,CAAC,YAAY;;;;;;;;;;;;;;;;;MAiBnB;IAEH,SAAS,CAAC,SAAS;;;MAGhB;CACJ;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,mEAA0E,CAAC"}
@@ -1,39 +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 'request-account': "request-account";
8
- readonly 'reset-password': "reset-password";
9
- readonly 'forgot-password': "forgot-password";
10
- readonly verify: "verify";
11
- readonly protected: "protected";
12
- readonly 'not-found': "not-found";
13
- };
14
- /**
15
- * @public
16
- */
17
- export type Routes = (typeof Routes)[keyof typeof Routes];
18
- /**
19
- * A utility to check if a pathname is a route of this micro frontend.
20
- *
21
- * @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
22
- *
23
- * @public
24
- * @privateRemarks
25
- * I've just put this util in for now given there's some app level direction code in place which needs review.
26
- */
27
- export declare function isMFRoute(pathname?: string): boolean;
28
- /**
29
- * A utility to get a sub route path taking the host path into account.
30
- *
31
- * @param routeName - The route name.
32
- * @param hostPath - The host path.
33
- *
34
- * @public
35
- */
36
- export declare function getSubRoutePath(routeName: Routes | string, hostPath?: string): string;
2
+ import type { AuthRoutes } from '../routes/types';
37
3
  /**
38
4
  * @public
39
5
  * Could be expanded to allow field ViewTemplates.
@@ -147,7 +113,7 @@ export interface AuthConfig {
147
113
  * omitRoutes: ['request-account'],
148
114
  * ```
149
115
  */
150
- omitRoutes: Exclude<Routes, 'login' | 'not-found'>[];
116
+ omitRoutes: Exclude<AuthRoutes, 'login' | 'not-found'>[];
151
117
  /**
152
118
  * Map of configuration for each of the primary form fields.
153
119
  *
@@ -162,13 +128,6 @@ export interface AuthConfig {
162
128
  * Used to help resolve internal route links. Defaults to an empty string.
163
129
  */
164
130
  hostPath: string;
165
- /**
166
- * The default URL to route the user to after a successful login.
167
- *
168
- * @remarks
169
- * User.lastPath() is any trumps this value.
170
- */
171
- defaultRedirectUrl: string;
172
131
  /**
173
132
  * The forgot password return URL which is used in the email template.
174
133
  */
@@ -183,16 +142,16 @@ export interface AuthConfig {
183
142
  */
184
143
  omitRedirectUrls: string[];
185
144
  /**
186
- * The routing method called post login and logout.
187
- *
188
145
  * @remarks
189
- * By default, we use the FASTRouter which internally invokes the native History APIs. The post login url is the last
190
- * url visited by the user by default or undefined. The post logout url is a slash `/` by default. When overriding
191
- * this, you should include some protection and may want to ignore when the URL is equal to the current url.
192
- *
193
- * @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.
194
148
  */
195
- routeToUrl: (url: string | undefined) => void;
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;
196
155
  /**
197
156
  * SSO configuration.
198
157
  *
@@ -243,17 +202,20 @@ export declare const AuthConfig: import("@microsoft/fast-foundation").InterfaceS
243
202
  *
244
203
  * @example Configuring auth on lazy load
245
204
  * ```ts
205
+ * title: 'Authenticate',
246
206
  * name: 'auth',
247
207
  * path: 'auth',
248
- * title: 'Authenticate',
249
208
  * element: async () => {
250
209
  * const { configure, Auth } = await import('@genesislcap/foundation-auth');
251
210
  * configure({
252
211
  * hostPath: 'auth',
253
- * defaultRedirectUrl: 'dashboard',
254
212
  * omitRoutes: ['request-account'],
255
213
  * logo: myCompanyLogo,
256
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
+ * },
257
219
  * });
258
220
  * return Auth;
259
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;;GAEG;AACH,eAAO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B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,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, Routes } from '../main/config';
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,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;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;;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,4 +1,6 @@
1
1
  export * from './base';
2
2
  export * from './config';
3
+ export * from './routing';
3
4
  export * from './types';
5
+ export * from './utils';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -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;IAML,MAAM;CAGP"}
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
@@ -2,7 +2,6 @@ export * from './env';
2
2
  export * from './credential';
3
3
  export * from './dto';
4
4
  export * from './entity';
5
- export * from './logout';
6
5
  export * from './machine';
7
6
  export * from './main';
8
7
  export * from './mapper';
@@ -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, getSubRoutePath } from '../main/config';
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', 'routeToRedirectUrl'],
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: 'feedbackDelay',
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
- 'routeToHostUrl',
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: 'routeToResetUrl',
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
- routeToRedirectUrl: () => this.config.routeToUrl(this.user.lastPath() || this.config.defaultRedirectUrl),
546
- routeToRootUrl: () => this.config.routeToUrl('/'),
547
- routeToHostUrl: () => this.config.routeToUrl(`/${this.config.hostPath}`),
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
  /**
@@ -1,46 +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
- 'request-account': 'request-account',
12
- 'reset-password': 'reset-password',
13
- 'forgot-password': 'forgot-password',
14
- verify: 'verify',
15
- protected: 'protected',
16
- 'not-found': 'not-found',
17
- };
18
- /**
19
- * A utility to check if a pathname is a route of this micro frontend.
20
- *
21
- * @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
22
- *
23
- * @public
24
- * @privateRemarks
25
- * I've just put this util in for now given there's some app level direction code in place which needs review.
26
- */
27
- export function isMFRoute(pathname = location.pathname) {
28
- const valueParts = pathname.split('/');
29
- const routeIdx = pathname.charAt(0) === '/' ? 1 : 0;
30
- const route = valueParts[routeIdx];
31
- return !!Routes[route];
32
- }
33
- /**
34
- * A utility to get a sub route path taking the host path into account.
35
- *
36
- * @param routeName - The route name.
37
- * @param hostPath - The host path.
38
- *
39
- * @public
40
- */
41
- export function getSubRoutePath(routeName, hostPath = '') {
42
- return hostPath !== '' ? `${hostPath}/${routeName}` : routeName;
43
- }
5
+ import { getRoutePath, navigateTo } from '../routes/utils';
44
6
  /**
45
7
  * Default AuthConfig DI implementation.
46
8
  * @public
@@ -71,19 +33,10 @@ export const defaultAuthConfig = {
71
33
  },
72
34
  },
73
35
  hostPath: '',
74
- defaultRedirectUrl: '/protected',
75
- forgotPasswordReturnUrl: `${location.protocol}//${location.host}/${getSubRoutePath('reset-password')}`,
36
+ forgotPasswordReturnUrl: `${location.protocol}//${location.host}/${getRoutePath('reset-password')}`,
76
37
  omitRedirectUrls: ['/not-found', '/not-permitted'],
77
- routeToUrl: (url) => {
78
- if (!!url && url !== Route.path.current) {
79
- /**
80
- * Uses the FASTRouter by default, however, host apps may override to integrate with their router of choice.
81
- * The FASTRouter invokes the History API and triggers a NavigationMessage to drive the view change.
82
- * TODO: We will need to test how unknown app level routers react to this default when not overriding.
83
- */
84
- Route.path.push(url);
85
- }
86
- },
38
+ postLoginRedirect: () => navigateTo('protected'),
39
+ postLogoutRedirect: () => navigateTo('/'),
87
40
  sso: {
88
41
  identityProvidersPath: 'gwf/sso/list',
89
42
  },
@@ -107,17 +60,20 @@ export const AuthConfig = DI.createInterface((x) => x.instance(defaultAuthConfig
107
60
  *
108
61
  * @example Configuring auth on lazy load
109
62
  * ```ts
63
+ * title: 'Authenticate',
110
64
  * name: 'auth',
111
65
  * path: 'auth',
112
- * title: 'Authenticate',
113
66
  * element: async () => {
114
67
  * const { configure, Auth } = await import('@genesislcap/foundation-auth');
115
68
  * configure({
116
69
  * hostPath: 'auth',
117
- * defaultRedirectUrl: 'dashboard',
118
70
  * omitRoutes: ['request-account'],
119
71
  * logo: myCompanyLogo,
120
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
+ * },
121
77
  * });
122
78
  * return Auth;
123
79
  * },