@genesislcap/foundation-auth 14.71.1-auth-mf.2 → 14.71.1-auth-mf.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/dto/EVENT_LOGIN_DETAILS_ACK.d.ts +7 -0
- package/dist/dts/dto/EVENT_LOGIN_DETAILS_ACK.d.ts.map +1 -0
- package/dist/dts/dto/index.d.ts +1 -0
- package/dist/dts/dto/index.d.ts.map +1 -1
- package/dist/dts/entity/index.d.ts +1 -0
- package/dist/dts/entity/index.d.ts.map +1 -1
- package/dist/dts/entity/loginDetailsAck.d.ts +7 -0
- package/dist/dts/entity/loginDetailsAck.d.ts.map +1 -0
- package/dist/dts/machine/machine.d.ts +12 -1
- package/dist/dts/machine/machine.d.ts.map +1 -1
- package/dist/dts/machine/types.d.ts +3 -5
- package/dist/dts/machine/types.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +14 -4
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/mapper/loginMapper.d.ts +16 -4
- package/dist/dts/mapper/loginMapper.d.ts.map +1 -1
- package/dist/dts/routes/base.d.ts +6 -15
- package/dist/dts/routes/base.d.ts.map +1 -1
- package/dist/dts/routes/config.d.ts.map +1 -1
- package/dist/dts/routes/login/login.d.ts +5 -5
- package/dist/dts/routes/login/login.d.ts.map +1 -1
- package/dist/dts/routes/login/login.template.d.ts.map +1 -1
- package/dist/dts/store/auth.d.ts +2 -1
- package/dist/dts/store/auth.d.ts.map +1 -1
- package/dist/dts/store/authFormEntry.d.ts +6 -0
- package/dist/dts/store/authFormEntry.d.ts.map +1 -1
- package/dist/esm/dto/EVENT_LOGIN_DETAILS_ACK.js +1 -0
- package/dist/esm/entity/index.js +1 -0
- package/dist/esm/entity/loginDetailsAck.js +1 -0
- package/dist/esm/machine/machine.js +135 -169
- package/dist/esm/main/main.js +42 -6
- package/dist/esm/mapper/loginMapper.js +17 -1
- package/dist/esm/routes/base.js +3 -30
- package/dist/esm/routes/config.js +0 -2
- package/dist/esm/routes/login/login.js +46 -63
- package/dist/esm/routes/login/login.template.js +4 -5
- package/dist/esm/store/auth.js +1 -0
- package/dist/esm/store/authFormEntry.js +39 -27
- package/dist/foundation-auth.api.json +648 -45
- package/dist/foundation-auth.d.ts +67 -26
- package/docs/api/foundation-auth.auth.loginwithcookies.md +15 -0
- package/docs/api/foundation-auth.auth.loginwithcredentials.md +22 -0
- package/docs/api/{foundation-auth.auth.store.md → foundation-auth.auth.logout.md} +7 -3
- package/docs/api/foundation-auth.auth.md +6 -4
- package/docs/api/foundation-auth.autheventmap.md +0 -1
- package/docs/api/foundation-auth.authformentryeventmap.md +1 -0
- package/docs/api/foundation-auth.authformentrystore.md +2 -0
- package/docs/api/foundation-auth.authformentrystore.onautofillform.md +22 -0
- package/docs/api/foundation-auth.authformentrystore.orgusername.md +11 -0
- package/docs/api/foundation-auth.authmachinecontext.authdto.md +1 -1
- package/docs/api/foundation-auth.authmachinecontext.authentity.md +1 -1
- package/docs/api/foundation-auth.authmachinecontext.credentials.md +1 -1
- package/docs/api/foundation-auth.authmachinecontext.md +2 -2
- package/docs/api/foundation-auth.authmachineevent.md +0 -2
- package/docs/api/foundation-auth.authstore.md +1 -0
- package/docs/api/foundation-auth.authstore.onlogindetails.md +22 -0
- package/docs/api/foundation-auth.defaultauthformentrystore._constructor_.md +13 -0
- package/docs/api/foundation-auth.defaultauthformentrystore.md +8 -0
- package/docs/api/foundation-auth.defaultauthformentrystore.onautofillform.md +11 -0
- package/docs/api/foundation-auth.defaultauthformentrystore.orgusername.md +11 -0
- package/docs/api/foundation-auth.defaultauthmachine.addloginevents.md +23 -0
- package/docs/api/foundation-auth.defaultauthmachine.createfetchmachineevent.md +23 -0
- package/docs/api/foundation-auth.defaultauthmachine.md +2 -0
- package/docs/api/foundation-auth.defaultauthstore.md +1 -0
- package/docs/api/foundation-auth.defaultauthstore.onlogindetails.md +11 -0
- package/docs/api/foundation-auth.event_login_details_ack.md +14 -0
- package/docs/api/foundation-auth.islogindetailsackdto.md +24 -0
- package/docs/api/foundation-auth.islogindetailsackentity.md +24 -0
- package/docs/api/foundation-auth.logindetailsack.md +14 -0
- package/docs/api/foundation-auth.logindto.md +2 -2
- package/docs/api/foundation-auth.loginentity.md +2 -2
- package/docs/api/foundation-auth.md +4 -0
- package/docs/api-report.md +59 -13
- package/package.json +11 -11
|
@@ -11,58 +11,47 @@ let Login = class Login extends BaseRoute {
|
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.idps = [];
|
|
13
13
|
this.selectedIDP = '';
|
|
14
|
-
this.ssoToggled = false;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
/**
|
|
21
|
-
* Retaining the logic that logs authenticated users out when this route is visited for now.
|
|
22
|
-
* TODO: Revisit as shouldn't load mf if logged in already.
|
|
23
|
-
*/
|
|
24
|
-
if (this.user.isAuthenticated()) {
|
|
25
|
-
this.logout();
|
|
26
|
-
}
|
|
27
|
-
if (this.config.autoAuth && this.user.isAnonymous()) {
|
|
28
|
-
this.automaticLogin();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger.debug(e);
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
this.addStoreBindings();
|
|
36
18
|
}
|
|
19
|
+
enter(phase) {
|
|
20
|
+
super.enter(phase);
|
|
21
|
+
/**
|
|
22
|
+
* Retaining the logic that logs authenticated users out when this route is visited for now.
|
|
23
|
+
* TODO: Revisit as shouldn't load mf if logged in already.
|
|
24
|
+
*/
|
|
25
|
+
if (this.user.isAuthenticated()) {
|
|
26
|
+
this.logout();
|
|
27
|
+
}
|
|
28
|
+
if (this.config.autoAuth) {
|
|
29
|
+
this.automaticLogin();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// TODO: Move the auto login logic up a level
|
|
37
33
|
automaticLogin() {
|
|
38
34
|
/**
|
|
39
35
|
* Login preference flow taken from @genesislcap/foundation-auth.
|
|
40
36
|
* We should sit down with Jose and team to cross check this. Reference code is bit hard to follow in places.
|
|
41
37
|
*/
|
|
42
38
|
const cm = this.credentialManager;
|
|
43
|
-
const refreshCredentials = cm.createRefreshCredentials();
|
|
39
|
+
const refreshCredentials = cm.createRefreshCredentials(); // < refresh can likely go
|
|
44
40
|
if (cm.validateRefreshCredentials(refreshCredentials)) {
|
|
45
41
|
logger.debug(`Attempting to login with refresh credentials.`);
|
|
46
42
|
// TODO: These may need to invoke different events on the machine.
|
|
47
43
|
this.login(refreshCredentials);
|
|
48
44
|
return;
|
|
49
45
|
}
|
|
50
|
-
if (this.ssoToggled) {
|
|
51
|
-
|
|
52
|
-
if (cm.validateSSOCredentials(ssoCredentials)) {
|
|
53
|
-
logger.debug(`Attempting to login with SSO.`);
|
|
54
|
-
// TODO: These may need to invoke different events on the machine.
|
|
55
|
-
this.login(ssoCredentials);
|
|
56
|
-
this.credentialManager.removeSSOToken(); // < sso tokens can only be used once, remove after login attempt
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
46
|
+
if (!this.store.formEntry.ssoToggled) {
|
|
47
|
+
this.$emit('auth-autofill-form');
|
|
59
48
|
}
|
|
60
49
|
this.attemptBasicLogin();
|
|
61
50
|
}
|
|
62
51
|
attemptBasicLogin() {
|
|
63
52
|
const basicCredentials = this.credentialManager.createBasicCredentials({
|
|
64
|
-
username: this.
|
|
65
|
-
password: this.password,
|
|
53
|
+
username: this.store.formEntry.username,
|
|
54
|
+
password: this.store.formEntry.password,
|
|
66
55
|
});
|
|
67
56
|
if (!this.credentialManager.validateBasicCredentials(basicCredentials)) {
|
|
68
57
|
logger.debug(`Basic credentials appear invalid, aborting login attempt.`);
|
|
@@ -71,27 +60,29 @@ let Login = class Login extends BaseRoute {
|
|
|
71
60
|
logger.debug(`Attempting to login with basic credentials.`);
|
|
72
61
|
this.login(basicCredentials);
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
63
|
+
addStoreBindings() {
|
|
64
|
+
this.store.formEntry.binding((x) => x.ssoToggled, (value) => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
this.clearError();
|
|
67
|
+
if (value) {
|
|
68
|
+
const path = `${(_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.identityProvidersPath) !== null && _b !== void 0 ? _b : 'sso/list'}`;
|
|
69
|
+
fetchIDPs(path)
|
|
70
|
+
.then((idps) => {
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
logger.debug('fetched IDPs', idps);
|
|
73
|
+
// it no longer throws, check for 'error' manually
|
|
74
|
+
if (!idps.length || (idps.length === 1 && ((_a = idps[0]) === null || _a === void 0 ? void 0 : _a.id) === 'error')) {
|
|
75
|
+
this.setError('Failed to fetch identity providers.');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Move to store of keep local?
|
|
79
|
+
this.idps = idps;
|
|
80
|
+
this.selectedIDP = (_c = (_b = this.idps) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.catch(() => this.setError('Failed to fetch identity providers.'));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
95
86
|
}
|
|
96
87
|
get selectedIDPName() {
|
|
97
88
|
return this.selectedIDP ? ` - ${this.selectedIDP}` : '';
|
|
@@ -161,18 +152,13 @@ let Login = class Login extends BaseRoute {
|
|
|
161
152
|
type: 'closeSocket',
|
|
162
153
|
});
|
|
163
154
|
}
|
|
164
|
-
onRefreshTest() {
|
|
165
|
-
this.$emit('auth-machine-event', {
|
|
166
|
-
type: 'refresh',
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
155
|
onLoginDetailsTest() {
|
|
170
156
|
this.$emit('auth-machine-event', {
|
|
171
157
|
type: 'login-details',
|
|
172
158
|
});
|
|
173
159
|
}
|
|
174
160
|
get submitDisabled() {
|
|
175
|
-
return this.authMachine.hasTag('pending');
|
|
161
|
+
return false; // this.authMachine.hasTag('pending'); // disable for now
|
|
176
162
|
}
|
|
177
163
|
};
|
|
178
164
|
__decorate([
|
|
@@ -181,9 +167,6 @@ __decorate([
|
|
|
181
167
|
__decorate([
|
|
182
168
|
observable
|
|
183
169
|
], Login.prototype, "selectedIDP", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
observable
|
|
186
|
-
], Login.prototype, "ssoToggled", void 0);
|
|
187
170
|
__decorate([
|
|
188
171
|
volatile
|
|
189
172
|
], Login.prototype, "selectedIDPName", null);
|
|
@@ -2,7 +2,7 @@ import { sync } from '@genesislcap/foundation-utils';
|
|
|
2
2
|
import { html, repeat, when } from '@microsoft/fast-element';
|
|
3
3
|
import { organisationField, passwordField, showPasswordsCheckbox, usernameField, submitButton, } from '../base';
|
|
4
4
|
const regularLogin = html `
|
|
5
|
-
${when((login) => !login.ssoToggled, html `
|
|
5
|
+
${when((login) => !login.store.formEntry.ssoToggled, html `
|
|
6
6
|
${organisationField()} ${usernameField()} ${passwordField()}
|
|
7
7
|
<span class="case-warning">*Fields are case-sensitive</span>
|
|
8
8
|
${showPasswordsCheckbox()}
|
|
@@ -42,7 +42,6 @@ const regularLogin = html `
|
|
|
42
42
|
<a class="link-url" @click=${(x) => x.logout()}>Logout Test</a>
|
|
43
43
|
<a class="link-url" @click=${(x) => x.onOpenSocketTest()}>Socket Open Test</a>
|
|
44
44
|
<a class="link-url" @click=${(x) => x.onCloseSocketTest()}>Socket Close Test</a>
|
|
45
|
-
<a class="link-url" @click=${(x) => x.onRefreshTest()}>Refresh Test</a>
|
|
46
45
|
<a class="link-url" @click=${(x) => x.onLoginDetailsTest()}>Login Details Test</a>
|
|
47
46
|
<pre>context: ${(x) => JSON.stringify(x.authMachine.errors.messages)}</pre>
|
|
48
47
|
${when((x) => !!x.authMachine.errors.size, html `
|
|
@@ -64,7 +63,7 @@ const regularLogin = html `
|
|
|
64
63
|
`)}
|
|
65
64
|
`;
|
|
66
65
|
const ssoLogin = html `
|
|
67
|
-
${when((login) => login.ssoToggled, html `
|
|
66
|
+
${when((login) => login.store.formEntry.ssoToggled, html `
|
|
68
67
|
<div class="sso">
|
|
69
68
|
<span class="form-title">Providers</span>
|
|
70
69
|
<zero-select
|
|
@@ -121,11 +120,11 @@ export const LoginTemplate = html `
|
|
|
121
120
|
${regularLogin} ${ssoLogin}
|
|
122
121
|
${when((x) => x.config.sso, html `
|
|
123
122
|
<zero-checkbox
|
|
124
|
-
?checked="${sync((x) => x.ssoToggled, 'boolean')}"
|
|
123
|
+
?checked="${sync((x) => x.store.formEntry.ssoToggled, 'boolean')}"
|
|
125
124
|
name="sso-toggle"
|
|
126
125
|
data-test-id="sso-toggle"
|
|
127
126
|
>
|
|
128
|
-
${(x) =>
|
|
127
|
+
${(x) => x.store.formEntry.ssoToggled ? 'SSO Enabled' + x.selectedIDPName : 'Enable SSO?'}
|
|
129
128
|
</zero-checkbox>
|
|
130
129
|
`)}
|
|
131
130
|
<auth-message
|
package/dist/esm/store/auth.js
CHANGED
|
@@ -20,6 +20,7 @@ let DefaultAuthStore = class DefaultAuthStore extends AbstractStoreRoot {
|
|
|
20
20
|
credentials,
|
|
21
21
|
},
|
|
22
22
|
}));
|
|
23
|
+
this.onLoginDetails = this.createListener('auth-login-details', () => this.authMachine.send({ type: 'login-details' }));
|
|
23
24
|
this.onLogout = this.createListener('auth-logout', () => this.authMachine.send({ type: 'logout' }));
|
|
24
25
|
}
|
|
25
26
|
get isPending() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
import { CredentialManager } from '@genesislcap/foundation-comms';
|
|
2
|
+
import { CredentialManager, credentialSeparator } from '@genesislcap/foundation-comms';
|
|
3
3
|
import { AbstractStore, registerStore } from '@genesislcap/foundation-store';
|
|
4
|
-
import { observable } from '@microsoft/fast-element';
|
|
4
|
+
import { observable, volatile } from '@microsoft/fast-element';
|
|
5
5
|
import { AuthConfig } from '../main';
|
|
6
6
|
import { logger } from '../utils';
|
|
7
7
|
/**
|
|
@@ -9,8 +9,14 @@ import { logger } from '../utils';
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export class DefaultAuthFormEntryStore extends AbstractStore {
|
|
12
|
+
get orgUsername() {
|
|
13
|
+
return this.config.fields.organisation && this.organisation.trim() !== ''
|
|
14
|
+
? `${this.username.trim()}:${this.organisation.trim()}`
|
|
15
|
+
: this.username.trim();
|
|
16
|
+
}
|
|
12
17
|
constructor() {
|
|
13
|
-
|
|
18
|
+
var _a, _b;
|
|
19
|
+
super();
|
|
14
20
|
this.host = '';
|
|
15
21
|
this.organisation = '';
|
|
16
22
|
this.username = '';
|
|
@@ -33,8 +39,11 @@ export class DefaultAuthFormEntryStore extends AbstractStore {
|
|
|
33
39
|
this.onPasswordChanged = this.createListener('auth-password-changed', (detail) => (this.commit.password = detail));
|
|
34
40
|
this.onPassword2Changed = this.createListener('auth-password2-changed', (detail) => (this.commit.password2 = detail));
|
|
35
41
|
this.onShowPasswordsChanged = this.createListener('auth-showPasswords-changed', (detail) => (this.commit.showPasswords = detail));
|
|
42
|
+
this.onAutofillForm = this.createListener('auth-autofill-form', () => this.autofill());
|
|
43
|
+
this.ssoToggled = (_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.toggled) !== null && _b !== void 0 ? _b : false;
|
|
36
44
|
}
|
|
37
45
|
autofill() {
|
|
46
|
+
var _a, _b, _c;
|
|
38
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
48
|
let credentialData;
|
|
40
49
|
try {
|
|
@@ -43,30 +52,30 @@ export class DefaultAuthFormEntryStore extends AbstractStore {
|
|
|
43
52
|
* Neptune was using cookies directly. To provide them with a seamless upgrade, we should load from cookies if the
|
|
44
53
|
* container is empty. These stored cookies become irrelevant after their first login in the new system.
|
|
45
54
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
const containerData = yield this.credentialManager.getCredentialsFromContainer();
|
|
56
|
+
const cookieData = yield this.credentialManager.getCredentialsFromCookie();
|
|
57
|
+
const [normalisedData, canRemoveCookie] = this.credentialManager.normaliseLegacyCredentialData(containerData, cookieData);
|
|
58
|
+
if (cookieData && canRemoveCookie) {
|
|
59
|
+
/**
|
|
60
|
+
* Upgrade path: They have chosen a profile from the container, yet also have a cookie... it's safe to remove the cookie.
|
|
61
|
+
*/
|
|
62
|
+
this.credentialManager.removeCookie();
|
|
63
|
+
}
|
|
64
|
+
credentialData = normalisedData;
|
|
65
|
+
if (credentialData) {
|
|
66
|
+
const passwordCredentials = credentialData;
|
|
67
|
+
this.username = (_a = passwordCredentials.name) !== null && _a !== void 0 ? _a : '';
|
|
68
|
+
this.password = (_b = passwordCredentials.password) !== null && _b !== void 0 ? _b : '';
|
|
69
|
+
if (this.config.fields.organisation) {
|
|
70
|
+
const combinedCompIdUsername = (_c = passwordCredentials.id) !== null && _c !== void 0 ? _c : '';
|
|
71
|
+
const valueParts = combinedCompIdUsername.split(credentialSeparator);
|
|
72
|
+
const orgIdx = valueParts.length === 2 ? 1 : 0;
|
|
73
|
+
const proposedOrganisation = valueParts[orgIdx];
|
|
74
|
+
if (proposedOrganisation !== this.username) {
|
|
75
|
+
this.organisation = proposedOrganisation;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
80
|
catch (err) {
|
|
72
81
|
logger.error('An error occurred attempting to get and autofill from stored credentials.', err);
|
|
@@ -129,6 +138,9 @@ __decorate([
|
|
|
129
138
|
__decorate([
|
|
130
139
|
observable
|
|
131
140
|
], DefaultAuthFormEntryStore.prototype, "termsAgreed", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
volatile
|
|
143
|
+
], DefaultAuthFormEntryStore.prototype, "orgUsername", null);
|
|
132
144
|
/**
|
|
133
145
|
* DI key of the store.
|
|
134
146
|
* @internal
|