@genesislcap/foundation-login 14.70.3 → 14.70.4-es2021.1

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.
@@ -1,4 +1,3 @@
1
- import { __awaiter } from "tslib";
2
1
  import { FoundationRouter } from '@genesislcap/foundation-ui';
3
2
  import { logger } from '../utils';
4
3
  var ResourceType;
@@ -17,29 +16,25 @@ function loadZeroFallback() {
17
16
  /**
18
17
  * Granular
19
18
  */
20
- function loadZeroDesignSystem() {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- let type = ResourceType.REMOTE;
23
- try {
24
- // @ts-ignore
25
- return yield import('foundationZero/ZeroDesignSystem');
26
- }
27
- catch (e) {
28
- type = ResourceType.LOCAL;
29
- return yield loadZeroFallback();
30
- }
31
- finally {
32
- logger.debug(`Using '${type}' version of foundationZero/ZeroDesignSystem`);
33
- }
34
- });
19
+ async function loadZeroDesignSystem() {
20
+ let type = ResourceType.REMOTE;
21
+ try {
22
+ // @ts-ignore
23
+ return await import('foundationZero/ZeroDesignSystem');
24
+ }
25
+ catch (e) {
26
+ type = ResourceType.LOCAL;
27
+ return await loadZeroFallback();
28
+ }
29
+ finally {
30
+ logger.debug(`Using '${type}' version of foundationZero/ZeroDesignSystem`);
31
+ }
35
32
  }
36
- export function loadRemotes(options) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const { registerZeroDesignSystem } = yield loadZeroDesignSystem();
39
- return {
40
- ZeroDesignSystem: registerZeroDesignSystem(),
41
- };
42
- });
33
+ export async function loadRemotes(options) {
34
+ const { registerZeroDesignSystem } = await loadZeroDesignSystem();
35
+ return {
36
+ ZeroDesignSystem: registerZeroDesignSystem(),
37
+ };
43
38
  }
44
39
  /**
45
40
  * Ensure tree shaking doesn't remove these
@@ -151,5 +151,8 @@ export const LoginConfig = DI.createInterface();
151
151
  * We can tailor the spreading logic after we put it to use. Keeping it simple for now.
152
152
  */
153
153
  export function configure(container, config) {
154
- container.register(Registration.instance(LoginConfig, Object.assign(Object.assign({}, defaultLoginConfig), config)));
154
+ container.register(Registration.instance(LoginConfig, {
155
+ ...defaultLoginConfig,
156
+ ...config,
157
+ }));
155
158
  }
@@ -38,6 +38,12 @@ export const definition = {
38
38
  */
39
39
  export const standaloneDefinition = {
40
40
  name: 'foundation-login',
41
- template: template(Object.assign(Object.assign({}, defaultTemplateOptions), { provider: 'zero-design-system-provider' })),
42
- styles: styles(Object.assign(Object.assign({}, defaultTemplateOptions), { provider: 'zero-design-system-provider' })),
41
+ template: template({
42
+ ...defaultTemplateOptions,
43
+ provider: 'zero-design-system-provider',
44
+ }),
45
+ styles: styles({
46
+ ...defaultTemplateOptions,
47
+ provider: 'zero-design-system-provider',
48
+ }),
43
49
  };
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { ConnectConfig, defaultConnectConfig, Session } from '@genesislcap/foundation-comms';
3
3
  import { customElement, FASTElement, observable } from '@microsoft/fast-element';
4
4
  import { Container, inject, Registration } from '@microsoft/fast-foundation';
@@ -118,16 +118,11 @@ let Login = class Login extends FASTElement {
118
118
  /**
119
119
  * @internal
120
120
  */
121
- connectedCallback() {
122
- const _super = Object.create(null, {
123
- connectedCallback: { get: () => super.connectedCallback }
124
- });
125
- return __awaiter(this, void 0, void 0, function* () {
126
- this.registerDIDependencies();
127
- _super.connectedCallback.call(this);
128
- yield this.registerCommonComponents();
129
- this.checkForSSOToken();
130
- });
121
+ async connectedCallback() {
122
+ this.registerDIDependencies();
123
+ super.connectedCallback();
124
+ await this.registerCommonComponents();
125
+ this.checkForSSOToken();
131
126
  }
132
127
  /**
133
128
  * Used to forward the user onto a logged-in session during an SSO journey
@@ -169,19 +164,17 @@ let Login = class Login extends FASTElement {
169
164
  * Called from the connectedCallback
170
165
  * @internal
171
166
  */
172
- registerCommonComponents() {
173
- return __awaiter(this, void 0, void 0, function* () {
174
- /**
175
- * Send event to indicate some async work is happening. Will be picked up by overlay micro frontend.
176
- */
177
- yield Components.loadRemotes({});
178
- /**
179
- * Simulate loading delay, TODO: Remove
180
- *
181
- * await new Promise(resolve => setTimeout(resolve, 3000));
182
- */
183
- this.ready = true;
184
- });
167
+ async registerCommonComponents() {
168
+ /**
169
+ * Send event to indicate some async work is happening. Will be picked up by overlay micro frontend.
170
+ */
171
+ await Components.loadRemotes({});
172
+ /**
173
+ * Simulate loading delay, TODO: Remove
174
+ *
175
+ * await new Promise(resolve => setTimeout(resolve, 3000));
176
+ */
177
+ this.ready = true;
185
178
  }
186
179
  /**
187
180
  * @internal
@@ -192,7 +185,13 @@ let Login = class Login extends FASTElement {
192
185
  * Register custom configs for core services. Note this can also be done via provideDesignSystem().register(...)
193
186
  * if preferred. Here for example mainly as this will mostly occur at an app level.
194
187
  */
195
- Registration.instance(ConnectConfig, Object.assign(Object.assign({}, defaultConnectConfig), { connect: Object.assign(Object.assign({}, defaultConnectConfig.connect), { heartbeatInterval: 12000 }) })));
188
+ Registration.instance(ConnectConfig, {
189
+ ...defaultConnectConfig,
190
+ connect: {
191
+ ...defaultConnectConfig.connect,
192
+ heartbeatInterval: 12000,
193
+ },
194
+ }));
196
195
  }
197
196
  };
198
197
  __decorate([
@@ -221,13 +220,14 @@ export { Login };
221
220
  * customise the MF for their needs via define.ts.
222
221
  */
223
222
  let LoginHosted = class LoginHosted extends Login {
224
- registerCommonComponents() {
225
- return __awaiter(this, void 0, void 0, function* () {
226
- this.ready = true;
227
- });
223
+ async registerCommonComponents() {
224
+ this.ready = true;
228
225
  }
229
226
  };
230
227
  LoginHosted = __decorate([
231
- customElement(Object.assign(Object.assign({}, definition), { name: `${definition.name}-hosted` }))
228
+ customElement({
229
+ ...definition,
230
+ name: `${definition.name}-hosted`,
231
+ })
232
232
  ], LoginHosted);
233
233
  export { LoginHosted };
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Auth, Connect, CredentialManager, credentialSeparator, MessageBuilder, Session, } from '@genesislcap/foundation-comms';
3
3
  import { sync } from '@genesislcap/foundation-utils';
4
4
  import { SecondaryRapidColorHEX } from '@genesislcap/foundation-zero';
@@ -52,9 +52,8 @@ export class BaseRoute extends ConfigHostElement {
52
52
  this.onNavigate = (path) => Route.path.push(path);
53
53
  }
54
54
  connectedCallback() {
55
- var _a;
56
55
  super.connectedCallback();
57
- this.host = (_a = this.session.getSessionStorageItem('hostUrl')) !== null && _a !== void 0 ? _a : hostUrl;
56
+ this.host = this.session.getSessionStorageItem('hostUrl') ?? hostUrl;
58
57
  /**
59
58
  * Fill with default values from config / env vars if needed.
60
59
  * For now using CredentialManager based auto-filling.
@@ -65,20 +64,16 @@ export class BaseRoute extends ConfigHostElement {
65
64
  // this.email = this.config.fields.email?.value;
66
65
  // this.password = this.config.fields.password?.value;
67
66
  }
68
- onSubmit() {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- this.isSubmitting = true;
71
- this.clearError();
72
- yield this.ensureConnection();
73
- });
67
+ async onSubmit() {
68
+ this.isSubmitting = true;
69
+ this.clearError();
70
+ await this.ensureConnection();
74
71
  }
75
- ensureConnection() {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- if (this.connect.isConnected) {
78
- return true;
79
- }
80
- return this.connect.connect(this.host);
81
- });
72
+ async ensureConnection() {
73
+ if (this.connect.isConnected) {
74
+ return true;
75
+ }
76
+ return this.connect.connect(this.host);
82
77
  }
83
78
  setError(message) {
84
79
  this.message = message;
@@ -101,45 +96,42 @@ export class BaseRoute extends ConfigHostElement {
101
96
  this.onBack();
102
97
  }, delay);
103
98
  }
104
- autofill() {
105
- var _a, _b, _c;
106
- return __awaiter(this, void 0, void 0, function* () {
107
- let credentialData;
108
- try {
99
+ async autofill() {
100
+ let credentialData;
101
+ try {
102
+ /**
103
+ * TODO: Revert back to `credentialManager.getCredentials()` after Neptune deployment.
104
+ * Neptune was using cookies directly. To provide them with a seamless upgrade, we should load from cookies if the
105
+ * container is empty. These stored cookies become irrelevant after their first login in the new system.
106
+ */
107
+ const containerData = await this.credentialManager.getCredentialsFromContainer();
108
+ const cookieData = await this.credentialManager.getCredentialsFromCookie();
109
+ const [normalisedData, canRemoveCookie] = this.credentialManager.normaliseLegacyCredentialData(containerData, cookieData);
110
+ if (cookieData && canRemoveCookie) {
109
111
  /**
110
- * TODO: Revert back to `credentialManager.getCredentials()` after Neptune deployment.
111
- * Neptune was using cookies directly. To provide them with a seamless upgrade, we should load from cookies if the
112
- * container is empty. These stored cookies become irrelevant after their first login in the new system.
112
+ * Upgrade path: They have chosen a profile from the container, yet also have a cookie... it's safe to remove the cookie.
113
113
  */
114
- const containerData = yield this.credentialManager.getCredentialsFromContainer();
115
- const cookieData = yield this.credentialManager.getCredentialsFromCookie();
116
- const [normalisedData, canRemoveCookie] = this.credentialManager.normaliseLegacyCredentialData(containerData, cookieData);
117
- if (cookieData && canRemoveCookie) {
118
- /**
119
- * Upgrade path: They have chosen a profile from the container, yet also have a cookie... it's safe to remove the cookie.
120
- */
121
- this.credentialManager.removeCookie();
122
- }
123
- credentialData = normalisedData;
124
- if (credentialData) {
125
- this.username = (_a = credentialData.name) !== null && _a !== void 0 ? _a : '';
126
- this.password = (_b = credentialData.password) !== null && _b !== void 0 ? _b : '';
127
- if (this.config.fields.organisation) {
128
- const combinedCompIdUsername = (_c = credentialData.id) !== null && _c !== void 0 ? _c : '';
129
- const valueParts = combinedCompIdUsername.split(credentialSeparator);
130
- const orgIdx = valueParts.length === 2 ? 1 : 0;
131
- const proposedOrganisation = valueParts[orgIdx];
132
- if (proposedOrganisation !== this.username) {
133
- this.organisation = proposedOrganisation;
134
- }
114
+ this.credentialManager.removeCookie();
115
+ }
116
+ credentialData = normalisedData;
117
+ if (credentialData) {
118
+ this.username = credentialData.name ?? '';
119
+ this.password = credentialData.password ?? '';
120
+ if (this.config.fields.organisation) {
121
+ const combinedCompIdUsername = credentialData.id ?? '';
122
+ const valueParts = combinedCompIdUsername.split(credentialSeparator);
123
+ const orgIdx = valueParts.length === 2 ? 1 : 0;
124
+ const proposedOrganisation = valueParts[orgIdx];
125
+ if (proposedOrganisation !== this.username) {
126
+ this.organisation = proposedOrganisation;
135
127
  }
136
128
  }
137
129
  }
138
- catch (err) {
139
- logger.error('An error occurred attempting to get and autofill from stored credentials.', err);
140
- }
141
- return Promise.resolve(!!credentialData);
142
- });
130
+ }
131
+ catch (err) {
132
+ logger.error('An error occurred attempting to get and autofill from stored credentials.', err);
133
+ }
134
+ return Promise.resolve(!!credentialData);
143
135
  }
144
136
  storeCredentials(password = this.password) {
145
137
  this.credentialManager.storeCredentials({
@@ -148,19 +140,17 @@ export class BaseRoute extends ConfigHostElement {
148
140
  password,
149
141
  });
150
142
  }
151
- sendMessage(message, successFeedback = '', successCallback) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- yield this.ensureConnection();
154
- this.clearError();
155
- const result = yield this.connect.send(message);
156
- if (result.ERROR) {
157
- this.setError(result.ERROR.map((error) => error.TEXT).toString());
158
- return;
159
- }
160
- this.message = successFeedback;
161
- successCallback && successCallback(result);
162
- this.queueOnBack();
163
- });
143
+ async sendMessage(message, successFeedback = '', successCallback) {
144
+ await this.ensureConnection();
145
+ this.clearError();
146
+ const result = await this.connect.send(message);
147
+ if (result.ERROR) {
148
+ this.setError(result.ERROR.map((error) => error.TEXT).toString());
149
+ return;
150
+ }
151
+ this.message = successFeedback;
152
+ successCallback && successCallback(result);
153
+ this.queueOnBack();
164
154
  }
165
155
  }
166
156
  __decorate([
@@ -227,11 +217,11 @@ export const configurableTextField = (name, type, autofocus = false, autocomplet
227
217
  ?autofocus="${() => autofocus}"
228
218
  ?required="${() => required}"
229
219
  ${autocomplete ? `autocomplete="${autocomplete}"` : ''}
230
- data-test-id="${testIdOverride !== null && testIdOverride !== void 0 ? testIdOverride : fieldName}"
220
+ data-test-id="${testIdOverride ?? fieldName}"
231
221
  class="${className}"
232
222
  >
233
223
  <span class="form-title">
234
- ${(x) => labelOverride !== null && labelOverride !== void 0 ? labelOverride : x.config.fields[fieldName].label}
224
+ ${(x) => labelOverride ?? x.config.fields[fieldName].label}
235
225
  </span>
236
226
  </zero-text-field>
237
227
  `)}
@@ -254,7 +244,7 @@ export const organisationField = () => html `
254
244
  ?required="${(x) => (x.config.fields.organisation.required === false ? false : true)}"
255
245
  >
256
246
  <span class="form-title">
257
- ${(x) => { var _a; return (_a = x.config.fields.organisation.label) !== null && _a !== void 0 ? _a : 'Organisation'; }}
247
+ ${(x) => x.config.fields.organisation.label ?? 'Organisation'}
258
248
  </span>
259
249
  </zero-text-field>
260
250
  `)}
@@ -276,7 +266,7 @@ export const usernameField = () => html `
276
266
  title="${(x) => x.config.fields.username.title}"
277
267
  required
278
268
  >
279
- <span class="form-title">${(x) => { var _a; return (_a = x.config.fields.username.label) !== null && _a !== void 0 ? _a : 'Username'; }}</span>
269
+ <span class="form-title">${(x) => x.config.fields.username.label ?? 'Username'}</span>
280
270
  </zero-text-field>
281
271
  `;
282
272
  /**
@@ -293,7 +283,7 @@ export const emailField = () => html `
293
283
  :value="${sync((x) => x.email)}"
294
284
  required
295
285
  >
296
- <span class="form-title">${(x) => { var _a; return (_a = x.config.fields.email.label) !== null && _a !== void 0 ? _a : 'Email'; }}</span>
286
+ <span class="form-title">${(x) => x.config.fields.email.label ?? 'Email'}</span>
297
287
  </zero-text-field>
298
288
  `)}
299
289
  `;
@@ -310,7 +300,7 @@ export const passwordField = (label) => html `
310
300
  :value="${sync((x) => x.password)}"
311
301
  required
312
302
  >
313
- <span class="form-title">${(x) => { var _a; return (_a = label !== null && label !== void 0 ? label : x.config.fields.password.label) !== null && _a !== void 0 ? _a : 'Password'; }}</span>
303
+ <span class="form-title">${(x) => label ?? x.config.fields.password.label ?? 'Password'}</span>
314
304
  </zero-text-field>
315
305
  `;
316
306
  const password2FieldMeta = {
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate, __param } from "tslib";
1
+ import { __decorate, __param } from "tslib";
2
2
  import { Auth, Session, FoundationAnalytics, FoundationAnalyticsEventType, } from '@genesislcap/foundation-comms';
3
3
  import { Container, optional } from '@microsoft/fast-foundation';
4
4
  import { RouterConfiguration, Route } from '@microsoft/fast-router';
@@ -117,7 +117,7 @@ let MainRouterConfig = class MainRouterConfig extends RouterConfiguration {
117
117
  * Example of a NavigationContributor
118
118
  */
119
119
  this.contributors.push({
120
- navigate: (phase) => __awaiter(this, void 0, void 0, function* () {
120
+ navigate: async (phase) => {
121
121
  const settings = phase.route.settings;
122
122
  /**
123
123
  * TODO: Centralise
@@ -141,7 +141,7 @@ let MainRouterConfig = class MainRouterConfig extends RouterConfiguration {
141
141
  /**
142
142
  * If allowAutoAuth and session is valid try to connect+auto-login
143
143
  */
144
- if (this.loginConfig.autoAuth && (yield auth.reAuthFromSession())) {
144
+ if (this.loginConfig.autoAuth && (await auth.reAuthFromSession())) {
145
145
  return;
146
146
  }
147
147
  /**
@@ -151,7 +151,7 @@ let MainRouterConfig = class MainRouterConfig extends RouterConfiguration {
151
151
  session.captureReturnUrl();
152
152
  Route.name.replace(phase.router, 'login');
153
153
  });
154
- }),
154
+ },
155
155
  });
156
156
  }
157
157
  construct(Type) {
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { customElement } from '@microsoft/fast-element';
3
3
  import { hostEnv } from '../../main/config';
4
4
  import { commonLoginRouteStyles } from '../../styles';
@@ -6,29 +6,19 @@ import { logger } from '../../utils';
6
6
  import { BaseRoute } from '../base';
7
7
  import { ForgotPasswordTemplate as template } from './forgot-password.template';
8
8
  let ForgotPassword = class ForgotPassword extends BaseRoute {
9
- connectedCallback() {
10
- const _super = Object.create(null, {
11
- connectedCallback: { get: () => super.connectedCallback }
12
- });
13
- return __awaiter(this, void 0, void 0, function* () {
14
- _super.connectedCallback.call(this);
15
- yield this.autofill();
16
- });
9
+ async connectedCallback() {
10
+ super.connectedCallback();
11
+ await this.autofill();
17
12
  }
18
- onSubmit() {
19
- const _super = Object.create(null, {
20
- onSubmit: { get: () => super.onSubmit }
21
- });
22
- return __awaiter(this, void 0, void 0, function* () {
23
- logger.debug('forgot password submission');
24
- yield _super.onSubmit.call(this);
25
- /**
26
- * Example url from email: https://public-foundation.genesislab.global/reset-password?password=nc_cbGrlgCkZeJHAF043oqEidnk
27
- */
28
- const returnUrl = `${location.protocol}//${hostEnv}/${this.getSubRoutePath('reset-password')}`;
29
- const message = this.messageBuilder.createForgotPasswordMessage(this.orgUsername, returnUrl);
30
- yield this.sendMessage(message, 'Please check your inbox for reset instructions.');
31
- });
13
+ async onSubmit() {
14
+ logger.debug('forgot password submission');
15
+ await super.onSubmit();
16
+ /**
17
+ * Example url from email: https://public-foundation.genesislab.global/reset-password?password=nc_cbGrlgCkZeJHAF043oqEidnk
18
+ */
19
+ const returnUrl = `${location.protocol}//${hostEnv}/${this.getSubRoutePath('reset-password')}`;
20
+ const message = this.messageBuilder.createForgotPasswordMessage(this.orgUsername, returnUrl);
21
+ await this.sendMessage(message, 'Please check your inbox for reset instructions.');
32
22
  }
33
23
  };
34
24
  ForgotPassword = __decorate([
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { AuthError } from '@genesislcap/foundation-comms';
3
3
  import { inIFrame, inSymphonyDesktop, openPopup } from '@genesislcap/foundation-utils';
4
4
  import { customElement, DOM, observable, volatile } from '@microsoft/fast-element';
@@ -20,51 +20,41 @@ let LoginForm = class LoginForm extends BaseRoute {
20
20
  this.convertHostUrl();
21
21
  };
22
22
  }
23
- connectedCallback() {
24
- const _super = Object.create(null, {
25
- connectedCallback: { get: () => super.connectedCallback }
26
- });
27
- var _a, _b;
28
- return __awaiter(this, void 0, void 0, function* () {
29
- _super.connectedCallback.call(this);
30
- this.ssoToggled = (_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.toggled) !== null && _b !== void 0 ? _b : false;
31
- if (this.connect.isConnected && this.auth.isLoggedIn) {
32
- yield this.credentialManager.preventSilentAccess();
33
- yield this.auth.logout();
34
- }
35
- this.convertHostUrl();
36
- if (!this.ssoToggled) {
37
- yield this.autofill();
38
- }
39
- });
23
+ async connectedCallback() {
24
+ super.connectedCallback();
25
+ this.ssoToggled = this.config.sso?.toggled ?? false;
26
+ if (this.connect.isConnected && this.auth.isLoggedIn) {
27
+ await this.credentialManager.preventSilentAccess();
28
+ await this.auth.logout();
29
+ }
30
+ this.convertHostUrl();
31
+ if (!this.ssoToggled) {
32
+ await this.autofill();
33
+ }
40
34
  }
41
- enter() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
44
- try {
45
- if (!this.connect.isConnected && this.config.autoConnect) {
46
- yield this.toggleConnection();
47
- }
48
- if (!this.auth.isLoggedIn && this.config.autoAuth) {
49
- this.attemptLoginWhenConnected();
50
- }
35
+ async enter() {
36
+ DOM.queueUpdate(async () => {
37
+ try {
38
+ if (!this.connect.isConnected && this.config.autoConnect) {
39
+ await this.toggleConnection();
51
40
  }
52
- catch (e) {
53
- logger.debug(e);
41
+ if (!this.auth.isLoggedIn && this.config.autoAuth) {
42
+ this.attemptLoginWhenConnected();
54
43
  }
55
- }));
56
- });
57
- }
58
- toggleConnection() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- if (this.connect.isConnected) {
61
- this.connect.disconnect();
62
- logger.debug(`Disconnected from ${this.host}`);
63
- return;
64
44
  }
65
- return this.connect.connect(this.host);
45
+ catch (e) {
46
+ logger.debug(e);
47
+ }
66
48
  });
67
49
  }
50
+ async toggleConnection() {
51
+ if (this.connect.isConnected) {
52
+ this.connect.disconnect();
53
+ logger.debug(`Disconnected from ${this.host}`);
54
+ return;
55
+ }
56
+ return this.connect.connect(this.host);
57
+ }
68
58
  attemptLoginWhenConnected() {
69
59
  this.connect.isConnectedSubject.subscribe((isConnected) => {
70
60
  if (isConnected) {
@@ -105,16 +95,14 @@ let LoginForm = class LoginForm extends BaseRoute {
105
95
  this.login(basicCredentials);
106
96
  }
107
97
  ssoToggledChanged() {
108
- var _a, _b;
109
98
  this.clearError();
110
99
  if (this.ssoToggled) {
111
- const path = `${(_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.identityProvidersPath) !== null && _b !== void 0 ? _b : 'sso/list'}`;
100
+ const path = `${this.config.sso?.identityProvidersPath ?? 'sso/list'}`;
112
101
  fetchIDPs(path)
113
102
  .then((idps) => {
114
- var _a, _b;
115
103
  logger.debug('fetched IDPs', idps);
116
104
  this.idps = idps;
117
- this.selectedIDP = (_b = (_a = this === null || this === void 0 ? void 0 : this.idps) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id;
105
+ this.selectedIDP = this?.idps?.[0]?.id;
118
106
  })
119
107
  .catch(() => this.setError('Failed to fetch identity providers.'));
120
108
  }
@@ -140,64 +128,54 @@ let LoginForm = class LoginForm extends BaseRoute {
140
128
  }
141
129
  }
142
130
  convertHostUrl() {
143
- var _a, _b, _c, _d;
144
- if (((_a = this.connect) === null || _a === void 0 ? void 0 : _a.httpMode()) && ((_b = this.host) === null || _b === void 0 ? void 0 : _b.startsWith('ws'))) {
131
+ if (this.connect?.httpMode() && this.host?.startsWith('ws')) {
145
132
  this.host = this.host.replace('ws', 'http');
146
133
  }
147
- else if (!((_c = this.connect) === null || _c === void 0 ? void 0 : _c.httpMode()) && ((_d = this.host) === null || _d === void 0 ? void 0 : _d.startsWith('http'))) {
134
+ else if (!this.connect?.httpMode() && this.host?.startsWith('http')) {
148
135
  this.host = this.host.replace('http', 'ws');
149
136
  }
150
137
  }
151
- onHostSubmit() {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- yield this.toggleConnection();
154
- });
138
+ async onHostSubmit() {
139
+ await this.toggleConnection();
155
140
  }
156
- onLoginSubmit() {
157
- const _super = Object.create(null, {
158
- onSubmit: { get: () => super.onSubmit }
159
- });
160
- return __awaiter(this, void 0, void 0, function* () {
161
- yield _super.onSubmit.call(this);
162
- DOM.queueUpdate(() => {
163
- this.attemptBasicLogin();
164
- });
141
+ async onLoginSubmit() {
142
+ await super.onSubmit();
143
+ DOM.queueUpdate(() => {
144
+ this.attemptBasicLogin();
165
145
  });
166
146
  }
167
- login(credentials) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- try {
170
- const { authToken } = yield this.auth.login(credentials);
171
- if (!authToken) {
172
- throw new Error('Unable to login. Try again later.');
173
- }
174
- this.storeCredentials();
175
- let url = this.config.defaultRedirectUrl;
176
- if (this.session.returnUrl &&
177
- !this.config.omitRedirectUrls.includes(this.session.returnUrl)) {
178
- url = this.session.returnUrl;
179
- }
180
- Route.path.push(url);
147
+ async login(credentials) {
148
+ try {
149
+ const { authToken } = await this.auth.login(credentials);
150
+ if (!authToken) {
151
+ throw new Error('Unable to login. Try again later.');
181
152
  }
182
- catch (err) {
183
- if (err instanceof AuthError) {
184
- if (err.hasPasswordExpiredError()) {
185
- this.storeCredentials();
186
- this.onNavigate(this.getSubRoutePath('reset-password?expired'));
187
- return;
188
- }
189
- if (this.config.fields.organisation &&
190
- this.config.fields.organisation.required !== false &&
191
- !this.organisation.length) {
192
- this.setError(err.message + 'Please fill in Comp Id.');
193
- return;
194
- }
195
- this.setError(err.message + err.getMessageError());
153
+ this.storeCredentials();
154
+ let url = this.config.defaultRedirectUrl;
155
+ if (this.session.returnUrl &&
156
+ !this.config.omitRedirectUrls.includes(this.session.returnUrl)) {
157
+ url = this.session.returnUrl;
158
+ }
159
+ Route.path.push(url);
160
+ }
161
+ catch (err) {
162
+ if (err instanceof AuthError) {
163
+ if (err.hasPasswordExpiredError()) {
164
+ this.storeCredentials();
165
+ this.onNavigate(this.getSubRoutePath('reset-password?expired'));
166
+ return;
167
+ }
168
+ if (this.config.fields.organisation &&
169
+ this.config.fields.organisation.required !== false &&
170
+ !this.organisation.length) {
171
+ this.setError(err.message + 'Please fill in Comp Id.');
196
172
  return;
197
173
  }
198
- this.setError(err.message);
174
+ this.setError(err.message + err.getMessageError());
175
+ return;
199
176
  }
200
- });
177
+ this.setError(err.message);
178
+ }
201
179
  }
202
180
  get connectActionText() {
203
181
  return this.connect.isConnected ? 'Disconnect' : 'Connect';
@@ -1,18 +1,16 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { customElement } from '@microsoft/fast-element';
3
3
  import { commonLoginRouteStyles } from '../../styles';
4
4
  import { BaseRoute } from '../base';
5
5
  import { ProtectedTemplate as template } from './protected.template';
6
6
  let Protected = class Protected extends BaseRoute {
7
- onLogout() {
8
- return __awaiter(this, void 0, void 0, function* () {
9
- const result = yield this.auth.logout();
10
- if (!result.success) {
11
- return;
12
- }
13
- yield this.credentialManager.preventSilentAccess();
14
- this.onNavigate('/');
15
- });
7
+ async onLogout() {
8
+ const result = await this.auth.logout();
9
+ if (!result.success) {
10
+ return;
11
+ }
12
+ await this.credentialManager.preventSilentAccess();
13
+ this.onNavigate('/');
16
14
  }
17
15
  };
18
16
  Protected = __decorate([
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { customElement, observable } from '@microsoft/fast-element';
3
3
  import { commonLoginRouteStyles } from '../../styles';
4
4
  import { logger } from '../../utils';
@@ -9,14 +9,9 @@ let RequestAccount = class RequestAccount extends BaseRoute {
9
9
  super(...arguments);
10
10
  this.termsAgreed = false;
11
11
  }
12
- onSubmit() {
13
- const _super = Object.create(null, {
14
- onSubmit: { get: () => super.onSubmit }
15
- });
16
- return __awaiter(this, void 0, void 0, function* () {
17
- logger.debug('request account submission');
18
- yield _super.onSubmit.call(this);
19
- });
12
+ async onSubmit() {
13
+ logger.debug('request account submission');
14
+ await super.onSubmit();
20
15
  }
21
16
  };
22
17
  __decorate([
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { customElement, observable, volatile } from '@microsoft/fast-element';
3
3
  import { commonLoginRouteStyles } from '../../styles';
4
4
  import { logger } from '../../utils';
@@ -10,49 +10,33 @@ let ResetPassword = class ResetPassword extends BaseRoute {
10
10
  this.hasPasswordExpired = false;
11
11
  this.passwordResetToken = '';
12
12
  }
13
- connectedCallback() {
14
- const _super = Object.create(null, {
15
- connectedCallback: { get: () => super.connectedCallback }
16
- });
17
- return __awaiter(this, void 0, void 0, function* () {
18
- _super.connectedCallback.call(this);
19
- yield this.autofill();
20
- });
13
+ async connectedCallback() {
14
+ super.connectedCallback();
15
+ await this.autofill();
21
16
  }
22
- enter(phase) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- this.hasPasswordExpired = !!phase.route.queryParams.expired;
25
- this.passwordResetToken = phase.route.queryParams.password;
26
- });
17
+ async enter(phase) {
18
+ this.hasPasswordExpired = !!phase.route.queryParams.expired;
19
+ this.passwordResetToken = phase.route.queryParams.password;
27
20
  }
28
- onSubmit() {
29
- const _super = Object.create(null, {
30
- onSubmit: { get: () => super.onSubmit }
31
- });
32
- return __awaiter(this, void 0, void 0, function* () {
33
- yield _super.onSubmit.call(this);
34
- this.passwordResetToken
35
- ? yield this.onForgotPasswordWorkflow()
36
- : yield this.onChangePasswordWorkflow();
37
- this.isSubmitting = false;
38
- });
21
+ async onSubmit() {
22
+ await super.onSubmit();
23
+ this.passwordResetToken
24
+ ? await this.onForgotPasswordWorkflow()
25
+ : await this.onChangePasswordWorkflow();
26
+ this.isSubmitting = false;
39
27
  }
40
- onForgotPasswordWorkflow() {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- logger.debug('forgot password submission');
43
- const message = this.messageBuilder.createForgotPasswordTokenMessage(this.orgUsername, this.passwordResetToken, this.password2);
44
- yield this.sendMessage(message, 'Password reset success.', () => {
45
- this.storeCredentials(this.password2);
46
- });
28
+ async onForgotPasswordWorkflow() {
29
+ logger.debug('forgot password submission');
30
+ const message = this.messageBuilder.createForgotPasswordTokenMessage(this.orgUsername, this.passwordResetToken, this.password2);
31
+ await this.sendMessage(message, 'Password reset success.', () => {
32
+ this.storeCredentials(this.password2);
47
33
  });
48
34
  }
49
- onChangePasswordWorkflow() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- logger.debug('change password submission');
52
- const message = this.messageBuilder.createChangePasswordMessage(this.orgUsername, this.password, this.password2);
53
- yield this.sendMessage(message, 'Password change success.', () => {
54
- this.storeCredentials(this.password2);
55
- });
35
+ async onChangePasswordWorkflow() {
36
+ logger.debug('change password submission');
37
+ const message = this.messageBuilder.createChangePasswordMessage(this.orgUsername, this.password, this.password2);
38
+ await this.sendMessage(message, 'Password change success.', () => {
39
+ this.storeCredentials(this.password2);
56
40
  });
57
41
  }
58
42
  get headingText() {
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { customElement, observable } from '@microsoft/fast-element';
3
3
  import { commonLoginRouteStyles } from '../../styles';
4
4
  import { logger } from '../../utils';
@@ -9,14 +9,9 @@ let Verify = class Verify extends BaseRoute {
9
9
  super(...arguments);
10
10
  this.code = '';
11
11
  }
12
- onSubmit() {
13
- const _super = Object.create(null, {
14
- onSubmit: { get: () => super.onSubmit }
15
- });
16
- return __awaiter(this, void 0, void 0, function* () {
17
- logger.debug('2FA verify submission');
18
- yield _super.onSubmit.call(this);
19
- });
12
+ async onSubmit() {
13
+ logger.debug('2FA verify submission');
14
+ await super.onSubmit();
20
15
  }
21
16
  };
22
17
  __decorate([
@@ -1,4 +1,3 @@
1
- import { __awaiter } from "tslib";
2
1
  import { API_HOST } from '@genesislcap/foundation-utils';
3
2
  import { logger } from './logger';
4
3
  /**
@@ -30,7 +29,7 @@ export const getSSOLoginURL = (idp, path = '/login?idp=', host = API_HOST) => {
30
29
  *
31
30
  * @public
32
31
  */
33
- export const fetchIDPs = (path = 'sso/list', host = API_HOST) => __awaiter(void 0, void 0, void 0, function* () {
32
+ export const fetchIDPs = async (path = 'sso/list', host = API_HOST) => {
34
33
  const IDP_ENDPOINT = getIPDEndpoint(path, host);
35
34
  return fetch(IDP_ENDPOINT)
36
35
  .then((res) => {
@@ -47,4 +46,4 @@ export const fetchIDPs = (path = 'sso/list', host = API_HOST) => __awaiter(void
47
46
  logger.error('Failed to fetch identity providers.');
48
47
  return [{ id: 'error', type: null, description: 'Failed to fetch providers.' }];
49
48
  });
50
- });
49
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-login",
3
3
  "description": "Genesis Foundation Login",
4
- "version": "14.70.3",
4
+ "version": "14.70.4-es2021.1",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/foundation-login.d.ts",
@@ -49,15 +49,15 @@
49
49
  "test:debug": "genx test --debug"
50
50
  },
51
51
  "devDependencies": {
52
- "@genesislcap/foundation-testing": "14.70.3",
53
- "@genesislcap/genx": "14.70.3",
52
+ "@genesislcap/foundation-testing": "14.70.4-es2021.1",
53
+ "@genesislcap/genx": "14.70.4-es2021.1",
54
54
  "rimraf": "^3.0.2"
55
55
  },
56
56
  "dependencies": {
57
- "@genesislcap/foundation-comms": "14.70.3",
58
- "@genesislcap/foundation-ui": "14.70.3",
59
- "@genesislcap/foundation-utils": "14.70.3",
60
- "@genesislcap/foundation-zero": "14.70.3",
57
+ "@genesislcap/foundation-comms": "14.70.4-es2021.1",
58
+ "@genesislcap/foundation-ui": "14.70.4-es2021.1",
59
+ "@genesislcap/foundation-utils": "14.70.4-es2021.1",
60
+ "@genesislcap/foundation-zero": "14.70.4-es2021.1",
61
61
  "@microsoft/fast-components": "^2.21.3",
62
62
  "@microsoft/fast-element": "^1.7.0",
63
63
  "@microsoft/fast-foundation": "^2.33.2",
@@ -74,5 +74,5 @@
74
74
  "access": "public"
75
75
  },
76
76
  "customElements": "dist/custom-elements.json",
77
- "gitHead": "2bd15e0c3928fa0fbfa60ccb7e4f89e956afda73"
77
+ "gitHead": "5d0d8ee36cfd068cfc6211033b326d0a978cfc05"
78
78
  }