@genesislcap/foundation-auth 14.71.1-auth-mf.3 → 14.71.1-auth-mf.6

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 (71) hide show
  1. package/dist/dts/dto/EVENT_LOGIN_DETAILS_ACK.d.ts +7 -0
  2. package/dist/dts/dto/EVENT_LOGIN_DETAILS_ACK.d.ts.map +1 -0
  3. package/dist/dts/dto/index.d.ts +1 -0
  4. package/dist/dts/dto/index.d.ts.map +1 -1
  5. package/dist/dts/entity/index.d.ts +1 -0
  6. package/dist/dts/entity/index.d.ts.map +1 -1
  7. package/dist/dts/entity/loginDetailsAck.d.ts +7 -0
  8. package/dist/dts/entity/loginDetailsAck.d.ts.map +1 -0
  9. package/dist/dts/machine/machine.d.ts +12 -1
  10. package/dist/dts/machine/machine.d.ts.map +1 -1
  11. package/dist/dts/machine/types.d.ts +3 -5
  12. package/dist/dts/machine/types.d.ts.map +1 -1
  13. package/dist/dts/main/main.d.ts +14 -4
  14. package/dist/dts/main/main.d.ts.map +1 -1
  15. package/dist/dts/mapper/loginMapper.d.ts +16 -4
  16. package/dist/dts/mapper/loginMapper.d.ts.map +1 -1
  17. package/dist/dts/routes/base.d.ts +10 -17
  18. package/dist/dts/routes/base.d.ts.map +1 -1
  19. package/dist/dts/routes/config.d.ts.map +1 -1
  20. package/dist/dts/routes/login/login.d.ts +5 -5
  21. package/dist/dts/routes/login/login.d.ts.map +1 -1
  22. package/dist/dts/routes/login/login.template.d.ts.map +1 -1
  23. package/dist/dts/store/auth.d.ts +2 -1
  24. package/dist/dts/store/auth.d.ts.map +1 -1
  25. package/dist/dts/store/authFormEntry.d.ts +3 -0
  26. package/dist/dts/store/authFormEntry.d.ts.map +1 -1
  27. package/dist/esm/dto/EVENT_LOGIN_DETAILS_ACK.js +1 -0
  28. package/dist/esm/entity/index.js +1 -0
  29. package/dist/esm/entity/loginDetailsAck.js +1 -0
  30. package/dist/esm/machine/machine.js +135 -169
  31. package/dist/esm/main/main.js +42 -6
  32. package/dist/esm/mapper/loginMapper.js +17 -1
  33. package/dist/esm/routes/base.js +3 -34
  34. package/dist/esm/routes/config.js +0 -2
  35. package/dist/esm/routes/login/login.js +44 -61
  36. package/dist/esm/routes/login/login.template.js +20 -9
  37. package/dist/esm/store/auth.js +1 -0
  38. package/dist/esm/store/authFormEntry.js +1 -3
  39. package/dist/foundation-auth.api.json +550 -19
  40. package/dist/foundation-auth.d.ts +68 -27
  41. package/docs/api/foundation-auth.auth.loginwithcookies.md +15 -0
  42. package/docs/api/foundation-auth.auth.loginwithcredentials.md +22 -0
  43. package/docs/api/{foundation-auth.auth.store.md → foundation-auth.auth.logout.md} +7 -3
  44. package/docs/api/foundation-auth.auth.md +6 -4
  45. package/docs/api/foundation-auth.autheventmap.md +0 -1
  46. package/docs/api/foundation-auth.authformentryeventmap.md +1 -0
  47. package/docs/api/foundation-auth.authformentrystore.md +1 -0
  48. package/docs/api/foundation-auth.authformentrystore.onautofillform.md +22 -0
  49. package/docs/api/foundation-auth.authmachinecontext.authdto.md +1 -1
  50. package/docs/api/foundation-auth.authmachinecontext.authentity.md +1 -1
  51. package/docs/api/foundation-auth.authmachinecontext.credentials.md +1 -1
  52. package/docs/api/foundation-auth.authmachinecontext.md +2 -2
  53. package/docs/api/foundation-auth.authmachineevent.md +0 -2
  54. package/docs/api/foundation-auth.authstore.md +1 -0
  55. package/docs/api/foundation-auth.authstore.onlogindetails.md +22 -0
  56. package/docs/api/foundation-auth.defaultauthformentrystore.md +1 -0
  57. package/docs/api/foundation-auth.defaultauthformentrystore.onautofillform.md +11 -0
  58. package/docs/api/foundation-auth.defaultauthmachine.addloginevents.md +23 -0
  59. package/docs/api/foundation-auth.defaultauthmachine.createfetchmachineevent.md +23 -0
  60. package/docs/api/foundation-auth.defaultauthmachine.md +2 -0
  61. package/docs/api/foundation-auth.defaultauthstore.md +1 -0
  62. package/docs/api/foundation-auth.defaultauthstore.onlogindetails.md +11 -0
  63. package/docs/api/foundation-auth.event_login_details_ack.md +14 -0
  64. package/docs/api/foundation-auth.islogindetailsackdto.md +24 -0
  65. package/docs/api/foundation-auth.islogindetailsackentity.md +24 -0
  66. package/docs/api/foundation-auth.logindetailsack.md +14 -0
  67. package/docs/api/foundation-auth.logindto.md +2 -2
  68. package/docs/api/foundation-auth.loginentity.md +2 -2
  69. package/docs/api/foundation-auth.md +4 -0
  70. package/docs/api-report.md +54 -15
  71. package/package.json +11 -11
@@ -11,51 +11,40 @@ 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
- enter() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
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
- const ssoCredentials = cm.createSSOCredentials();
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
  }
@@ -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
- // TODO: Sync the SSO changes from login here.
75
- ssoToggledChanged() {
76
- var _a, _b;
77
- this.clearError();
78
- if (this.ssoToggled) {
79
- const path = `${(_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.identityProvidersPath) !== null && _b !== void 0 ? _b : 'sso/list'}`;
80
- fetchIDPs(path)
81
- .then((idps) => {
82
- var _a, _b, _c;
83
- logger.debug('fetched IDPs', idps);
84
- // it no longer throws, check for 'error' manually
85
- if (!idps.length || (idps.length === 1 && ((_a = idps[0]) === null || _a === void 0 ? void 0 : _a.id) === 'error')) {
86
- this.setError('Failed to fetch identity providers.');
87
- }
88
- else {
89
- this.idps = idps;
90
- this.selectedIDP = (_c = (_b = this.idps) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id;
91
- }
92
- })
93
- .catch(() => this.setError('Failed to fetch identity providers.'));
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,15 +42,26 @@ 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
- <pre>context: ${(x) => JSON.stringify(x.authMachine.errors.messages)}</pre>
48
- ${when((x) => !!x.authMachine.errors.size, html `
49
- <span>${(x) => x.authMachine.errors.messages}</span>
46
+ <pre>snapshot: ${(x) => JSON.stringify(x.store.authMachine.snapshot)}</pre>
47
+ <pre>state: ${(x) => JSON.stringify(x.store.authMachine.state)}</pre>
48
+ <pre>context: ${(x) => JSON.stringify(x.store.authMachine.errors.messages)}</pre>
49
+ <pre>meta: ${(x) => JSON.stringify(x.store.authMachine.getMetaValuesByKey())}</pre>
50
+ ${when((x) => !!x.store.authMachine.errors.size, html `
51
+ <span>${(x) => x.store.authMachine.errors.messages}</span>
50
52
  `)}
51
- ${when((x) => x.authMachine.hasTag('pending'), html `
53
+ ${when((x) => x.store.authMachine.hasTag('pending'), html `
52
54
  <h4>PENDING...</h4>
53
55
  `)}
56
+ ${when((x) => x.store.authMachine.matches('loggedOut'), html `
57
+ <h4>loggedOut...</h4>
58
+ `)}
59
+ ${when((x) => x.store.authMachine.matches('idle'), html `
60
+ <h4>idle...</h4>
61
+ `)}
62
+ ${when((x) => x.store.authMachine.matches('authCheck'), html `
63
+ <h4>authCheck...</h4>
64
+ `)}
54
65
  </div>
55
66
  </div>
56
67
  </div>
@@ -64,7 +75,7 @@ const regularLogin = html `
64
75
  `)}
65
76
  `;
66
77
  const ssoLogin = html `
67
- ${when((login) => login.ssoToggled, html `
78
+ ${when((login) => login.store.formEntry.ssoToggled, html `
68
79
  <div class="sso">
69
80
  <span class="form-title">Providers</span>
70
81
  <zero-select
@@ -121,11 +132,11 @@ export const LoginTemplate = html `
121
132
  ${regularLogin} ${ssoLogin}
122
133
  ${when((x) => x.config.sso, html `
123
134
  <zero-checkbox
124
- ?checked="${sync((x) => x.ssoToggled, 'boolean')}"
135
+ ?checked="${sync((x) => x.store.formEntry.ssoToggled, 'boolean')}"
125
136
  name="sso-toggle"
126
137
  data-test-id="sso-toggle"
127
138
  >
128
- ${(x) => (x.ssoToggled ? 'SSO Enabled' + x.selectedIDPName : 'Enable SSO?')}
139
+ ${(x) => x.store.formEntry.ssoToggled ? 'SSO Enabled' + x.selectedIDPName : 'Enable SSO?'}
129
140
  </zero-checkbox>
130
141
  `)}
131
142
  <auth-message
@@ -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() {
@@ -39,10 +39,8 @@ export class DefaultAuthFormEntryStore extends AbstractStore {
39
39
  this.onPasswordChanged = this.createListener('auth-password-changed', (detail) => (this.commit.password = detail));
40
40
  this.onPassword2Changed = this.createListener('auth-password2-changed', (detail) => (this.commit.password2 = detail));
41
41
  this.onShowPasswordsChanged = this.createListener('auth-showPasswords-changed', (detail) => (this.commit.showPasswords = detail));
42
+ this.onAutofillForm = this.createListener('auth-autofill-form', () => this.autofill());
42
43
  this.ssoToggled = (_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.toggled) !== null && _b !== void 0 ? _b : false;
43
- if (!this.ssoToggled) {
44
- this.autofill();
45
- }
46
44
  }
47
45
  autofill() {
48
46
  var _a, _b, _c;