@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.
- 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 -53
- 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 -53
- 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 -100
- 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} +4 -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 -44
- 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/dist/esm/routes/base.js
CHANGED
|
@@ -3,13 +3,13 @@ import { createInputEmitter, createSelectEmitter, EventEmitter, targetChecked, }
|
|
|
3
3
|
import { SecondaryRapidColorHEX } from '@genesislcap/foundation-zero';
|
|
4
4
|
import { attr, css, customElement, FASTElement, html, observable, when, } from '@microsoft/fast-element';
|
|
5
5
|
import { Container } from '@microsoft/fast-foundation';
|
|
6
|
-
import { Route } from '@microsoft/fast-router';
|
|
7
6
|
import { classNames } from '@microsoft/fast-web-utilities';
|
|
8
7
|
import { CredentialManager } from '../credential';
|
|
9
8
|
import { AuthConfig, defaultAuthConfig } from '../main/config';
|
|
10
9
|
import { AuthStore } from '../store';
|
|
11
10
|
import { User } from '../user';
|
|
12
11
|
import { logger } from '../utils';
|
|
12
|
+
import { AuthRouting } from './routing';
|
|
13
13
|
/**
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
@@ -49,8 +49,7 @@ export class BaseRoute extends ConfigHostElement {
|
|
|
49
49
|
*/
|
|
50
50
|
this.message = '';
|
|
51
51
|
this.hasErrors = false;
|
|
52
|
-
this.onBack = () => this.
|
|
53
|
-
this.onNavigate = (path) => Route.path.push(path);
|
|
52
|
+
this.onBack = () => this.routing.navigateTo('/');
|
|
54
53
|
}
|
|
55
54
|
connectedCallback() {
|
|
56
55
|
super.connectedCallback();
|
|
@@ -64,9 +63,6 @@ export class BaseRoute extends ConfigHostElement {
|
|
|
64
63
|
clearError() {
|
|
65
64
|
logger.warn('base clearError callers need updating...');
|
|
66
65
|
}
|
|
67
|
-
getSubRoutePath(routeName) {
|
|
68
|
-
return this.config.hostPath !== '' ? `${this.config.hostPath}/${routeName}` : routeName;
|
|
69
|
-
}
|
|
70
66
|
attemptAutofill() {
|
|
71
67
|
if (!this.store.formEntry.ssoToggled &&
|
|
72
68
|
!this.store.formEntry.username &&
|
|
@@ -78,6 +74,9 @@ export class BaseRoute extends ConfigHostElement {
|
|
|
78
74
|
__decorate([
|
|
79
75
|
AuthStore
|
|
80
76
|
], BaseRoute.prototype, "store", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
AuthRouting
|
|
79
|
+
], BaseRoute.prototype, "routing", void 0);
|
|
81
80
|
__decorate([
|
|
82
81
|
User
|
|
83
82
|
], BaseRoute.prototype, "user", void 0);
|
package/dist/esm/routes/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const regularLogin = html `
|
|
|
13
13
|
${when((x) => !x.config.omitRoutes.includes('forgot-password'), html `
|
|
14
14
|
<a
|
|
15
15
|
class="link-url"
|
|
16
|
-
@click=${(x) => x.
|
|
16
|
+
@click=${(x) => x.routing.navigateTo(`forgot-password`)}
|
|
17
17
|
data-test-id="forgot-password"
|
|
18
18
|
>
|
|
19
19
|
Forgot Password?
|
|
@@ -22,7 +22,7 @@ const regularLogin = html `
|
|
|
22
22
|
${when((x) => !x.config.omitRoutes.includes('reset-password'), html `
|
|
23
23
|
<a
|
|
24
24
|
class="link-url"
|
|
25
|
-
@click=${(x) => x.
|
|
25
|
+
@click=${(x) => x.routing.navigateTo(`reset-password`)}
|
|
26
26
|
data-test-id="reset-password"
|
|
27
27
|
>
|
|
28
28
|
Change Password
|
|
@@ -33,7 +33,7 @@ const regularLogin = html `
|
|
|
33
33
|
${when((x) => !x.config.omitRoutes.includes('request-account'), html `
|
|
34
34
|
<a
|
|
35
35
|
class="link-url"
|
|
36
|
-
@click=${(x) => x.
|
|
36
|
+
@click=${(x) => x.routing.navigateTo(`request-account`)}
|
|
37
37
|
data-test-id="request-account"
|
|
38
38
|
>
|
|
39
39
|
Request Account
|
|
@@ -5,9 +5,7 @@ import { LogoutStyles as styles } from './logout.styles';
|
|
|
5
5
|
import { LogoutTemplate as template } from './logout.template';
|
|
6
6
|
let Logout = class Logout extends BaseRoute {
|
|
7
7
|
enter() {
|
|
8
|
-
|
|
9
|
-
this.logout();
|
|
10
|
-
}
|
|
8
|
+
this.logout();
|
|
11
9
|
}
|
|
12
10
|
logout() {
|
|
13
11
|
this.$emit('auth-logout');
|
|
@@ -7,7 +7,7 @@ import { BaseRoute } from '../base';
|
|
|
7
7
|
import { ProtectedTemplate as template } from './protected.template';
|
|
8
8
|
let Protected = class Protected extends BaseRoute {
|
|
9
9
|
onLogout() {
|
|
10
|
-
this
|
|
10
|
+
this.routing.navigateTo('logout');
|
|
11
11
|
}
|
|
12
12
|
onOpenSocketTest() {
|
|
13
13
|
this.connect.connect(SOCKET_URL);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { DI } from '@microsoft/fast-foundation';
|
|
3
|
+
import { AuthConfig } from '../main/config';
|
|
4
|
+
import { getRoutePath, navigateTo } from './utils';
|
|
5
|
+
/**
|
|
6
|
+
* Default AuthRouting.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class DefaultAuthRouting {
|
|
11
|
+
/** {@inheritDoc AuthRouting.navigateTo} */
|
|
12
|
+
navigateTo(route) {
|
|
13
|
+
navigateTo(this.getRoutePath(route));
|
|
14
|
+
}
|
|
15
|
+
/** {@inheritDoc AuthRouting.getRoutePath} */
|
|
16
|
+
getRoutePath(route) {
|
|
17
|
+
return getRoutePath(route, this.config.hostPath);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
AuthConfig
|
|
22
|
+
], DefaultAuthRouting.prototype, "config", void 0);
|
|
23
|
+
/**
|
|
24
|
+
* AuthRouting DI key.
|
|
25
|
+
*
|
|
26
|
+
* @privateRemarks
|
|
27
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const AuthRouting = DI.createInterface((x) => x.singleton(DefaultAuthRouting));
|
|
32
|
+
/**
|
|
33
|
+
* Gets AuthRouting from the DI container.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* A utility method for host applications that are not using decorators or the DI container.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { getAuthRouting } from '@genesislcap/foundation-auth';
|
|
41
|
+
* ...
|
|
42
|
+
* private authRouting = getAuthRouting();
|
|
43
|
+
* ...
|
|
44
|
+
* this.authRouting.navigateTo('logout');
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export function getAuthRouting() {
|
|
50
|
+
return DI.getOrCreateDOMContainer().get(AuthRouting);
|
|
51
|
+
}
|
package/dist/esm/routes/types.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export const AuthRoutes = {
|
|
5
|
+
login: 'login',
|
|
6
|
+
logout: 'logout',
|
|
7
|
+
'request-account': 'request-account',
|
|
8
|
+
'reset-password': 'reset-password',
|
|
9
|
+
'forgot-password': 'forgot-password',
|
|
10
|
+
verify: 'verify',
|
|
11
|
+
protected: 'protected',
|
|
12
|
+
'not-found': 'not-found',
|
|
13
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Route } from '@microsoft/fast-router';
|
|
2
|
+
import { AuthRoutes } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A utility to check if a pathname is a route of this micro frontend.
|
|
5
|
+
*
|
|
6
|
+
* @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @privateRemarks
|
|
10
|
+
* I've just put this util in for now given there's some app level direction code in place which needs review.
|
|
11
|
+
*/
|
|
12
|
+
export function isMFRoute(pathname = location.pathname) {
|
|
13
|
+
const valueParts = pathname.split('/');
|
|
14
|
+
const routeIdx = pathname.charAt(0) === '/' ? 1 : 0;
|
|
15
|
+
const route = valueParts[routeIdx];
|
|
16
|
+
return !!AuthRoutes[route];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @remarks
|
|
20
|
+
* Uses the `FASTRouter`.
|
|
21
|
+
*
|
|
22
|
+
* @param route - An auth route including query params if required, ie. `reset-password?expired`.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export function navigateTo(route) {
|
|
27
|
+
Route.path.push(route);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A utility to get a sub route path taking the host path into account.
|
|
31
|
+
*
|
|
32
|
+
* @param route - An auth route.
|
|
33
|
+
* @param hostPath - The host path.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export function getRoutePath(route, hostPath = '') {
|
|
38
|
+
return hostPath ? `${hostPath}/${route}` : route;
|
|
39
|
+
}
|