@genesislcap/foundation-login 14.70.4-es2021.1 → 14.70.4-test.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,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { FoundationRouter } from '@genesislcap/foundation-ui';
2
3
  import { logger } from '../utils';
3
4
  var ResourceType;
@@ -16,25 +17,29 @@ function loadZeroFallback() {
16
17
  /**
17
18
  * Granular
18
19
  */
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
- }
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
+ });
32
35
  }
33
- export async function loadRemotes(options) {
34
- const { registerZeroDesignSystem } = await loadZeroDesignSystem();
35
- return {
36
- ZeroDesignSystem: registerZeroDesignSystem(),
37
- };
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
+ });
38
43
  }
39
44
  /**
40
45
  * Ensure tree shaking doesn't remove these
@@ -151,8 +151,5 @@ 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, {
155
- ...defaultLoginConfig,
156
- ...config,
157
- }));
154
+ container.register(Registration.instance(LoginConfig, Object.assign(Object.assign({}, defaultLoginConfig), config)));
158
155
  }
@@ -38,12 +38,6 @@ export const definition = {
38
38
  */
39
39
  export const standaloneDefinition = {
40
40
  name: 'foundation-login',
41
- template: template({
42
- ...defaultTemplateOptions,
43
- provider: 'zero-design-system-provider',
44
- }),
45
- styles: styles({
46
- ...defaultTemplateOptions,
47
- provider: 'zero-design-system-provider',
48
- }),
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' })),
49
43
  };
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,11 +118,16 @@ let Login = class Login extends FASTElement {
118
118
  /**
119
119
  * @internal
120
120
  */
121
- async connectedCallback() {
122
- this.registerDIDependencies();
123
- super.connectedCallback();
124
- await this.registerCommonComponents();
125
- this.checkForSSOToken();
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
+ });
126
131
  }
127
132
  /**
128
133
  * Used to forward the user onto a logged-in session during an SSO journey
@@ -164,17 +169,19 @@ let Login = class Login extends FASTElement {
164
169
  * Called from the connectedCallback
165
170
  * @internal
166
171
  */
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;
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
+ });
178
185
  }
179
186
  /**
180
187
  * @internal
@@ -185,13 +192,7 @@ let Login = class Login extends FASTElement {
185
192
  * Register custom configs for core services. Note this can also be done via provideDesignSystem().register(...)
186
193
  * if preferred. Here for example mainly as this will mostly occur at an app level.
187
194
  */
188
- Registration.instance(ConnectConfig, {
189
- ...defaultConnectConfig,
190
- connect: {
191
- ...defaultConnectConfig.connect,
192
- heartbeatInterval: 12000,
193
- },
194
- }));
195
+ Registration.instance(ConnectConfig, Object.assign(Object.assign({}, defaultConnectConfig), { connect: Object.assign(Object.assign({}, defaultConnectConfig.connect), { heartbeatInterval: 12000 }) })));
195
196
  }
196
197
  };
197
198
  __decorate([
@@ -220,14 +221,13 @@ export { Login };
220
221
  * customise the MF for their needs via define.ts.
221
222
  */
222
223
  let LoginHosted = class LoginHosted extends Login {
223
- async registerCommonComponents() {
224
- this.ready = true;
224
+ registerCommonComponents() {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ this.ready = true;
227
+ });
225
228
  }
226
229
  };
227
230
  LoginHosted = __decorate([
228
- customElement({
229
- ...definition,
230
- name: `${definition.name}-hosted`,
231
- })
231
+ customElement(Object.assign(Object.assign({}, definition), { name: `${definition.name}-hosted` }))
232
232
  ], LoginHosted);
233
233
  export { LoginHosted };
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,8 +52,9 @@ export class BaseRoute extends ConfigHostElement {
52
52
  this.onNavigate = (path) => Route.path.push(path);
53
53
  }
54
54
  connectedCallback() {
55
+ var _a;
55
56
  super.connectedCallback();
56
- this.host = this.session.getSessionStorageItem('hostUrl') ?? hostUrl;
57
+ this.host = (_a = this.session.getSessionStorageItem('hostUrl')) !== null && _a !== void 0 ? _a : hostUrl;
57
58
  /**
58
59
  * Fill with default values from config / env vars if needed.
59
60
  * For now using CredentialManager based auto-filling.
@@ -64,16 +65,20 @@ export class BaseRoute extends ConfigHostElement {
64
65
  // this.email = this.config.fields.email?.value;
65
66
  // this.password = this.config.fields.password?.value;
66
67
  }
67
- async onSubmit() {
68
- this.isSubmitting = true;
69
- this.clearError();
70
- await this.ensureConnection();
68
+ onSubmit() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ this.isSubmitting = true;
71
+ this.clearError();
72
+ yield this.ensureConnection();
73
+ });
71
74
  }
72
- async ensureConnection() {
73
- if (this.connect.isConnected) {
74
- return true;
75
- }
76
- return this.connect.connect(this.host);
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
+ });
77
82
  }
78
83
  setError(message) {
79
84
  this.message = message;
@@ -96,42 +101,45 @@ export class BaseRoute extends ConfigHostElement {
96
101
  this.onBack();
97
102
  }, delay);
98
103
  }
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) {
104
+ autofill() {
105
+ var _a, _b, _c;
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ let credentialData;
108
+ try {
111
109
  /**
112
- * Upgrade path: They have chosen a profile from the container, yet also have a cookie... it's safe to remove the cookie.
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.
113
113
  */
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;
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
+ }
127
135
  }
128
136
  }
129
137
  }
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);
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
+ });
135
143
  }
136
144
  storeCredentials(password = this.password) {
137
145
  this.credentialManager.storeCredentials({
@@ -140,17 +148,19 @@ export class BaseRoute extends ConfigHostElement {
140
148
  password,
141
149
  });
142
150
  }
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();
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
+ });
154
164
  }
155
165
  }
156
166
  __decorate([
@@ -217,11 +227,11 @@ export const configurableTextField = (name, type, autofocus = false, autocomplet
217
227
  ?autofocus="${() => autofocus}"
218
228
  ?required="${() => required}"
219
229
  ${autocomplete ? `autocomplete="${autocomplete}"` : ''}
220
- data-test-id="${testIdOverride ?? fieldName}"
230
+ data-test-id="${testIdOverride !== null && testIdOverride !== void 0 ? testIdOverride : fieldName}"
221
231
  class="${className}"
222
232
  >
223
233
  <span class="form-title">
224
- ${(x) => labelOverride ?? x.config.fields[fieldName].label}
234
+ ${(x) => labelOverride !== null && labelOverride !== void 0 ? labelOverride : x.config.fields[fieldName].label}
225
235
  </span>
226
236
  </zero-text-field>
227
237
  `)}
@@ -244,7 +254,7 @@ export const organisationField = () => html `
244
254
  ?required="${(x) => (x.config.fields.organisation.required === false ? false : true)}"
245
255
  >
246
256
  <span class="form-title">
247
- ${(x) => x.config.fields.organisation.label ?? 'Organisation'}
257
+ ${(x) => { var _a; return (_a = x.config.fields.organisation.label) !== null && _a !== void 0 ? _a : 'Organisation'; }}
248
258
  </span>
249
259
  </zero-text-field>
250
260
  `)}
@@ -266,7 +276,7 @@ export const usernameField = () => html `
266
276
  title="${(x) => x.config.fields.username.title}"
267
277
  required
268
278
  >
269
- <span class="form-title">${(x) => x.config.fields.username.label ?? 'Username'}</span>
279
+ <span class="form-title">${(x) => { var _a; return (_a = x.config.fields.username.label) !== null && _a !== void 0 ? _a : 'Username'; }}</span>
270
280
  </zero-text-field>
271
281
  `;
272
282
  /**
@@ -283,7 +293,7 @@ export const emailField = () => html `
283
293
  :value="${sync((x) => x.email)}"
284
294
  required
285
295
  >
286
- <span class="form-title">${(x) => x.config.fields.email.label ?? 'Email'}</span>
296
+ <span class="form-title">${(x) => { var _a; return (_a = x.config.fields.email.label) !== null && _a !== void 0 ? _a : 'Email'; }}</span>
287
297
  </zero-text-field>
288
298
  `)}
289
299
  `;
@@ -300,7 +310,7 @@ export const passwordField = (label) => html `
300
310
  :value="${sync((x) => x.password)}"
301
311
  required
302
312
  >
303
- <span class="form-title">${(x) => label ?? x.config.fields.password.label ?? 'Password'}</span>
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>
304
314
  </zero-text-field>
305
315
  `;
306
316
  const password2FieldMeta = {
@@ -1,4 +1,4 @@
1
- import { __decorate, __param } from "tslib";
1
+ import { __awaiter, __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: async (phase) => {
120
+ navigate: (phase) => __awaiter(this, void 0, void 0, function* () {
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 && (await auth.reAuthFromSession())) {
144
+ if (this.loginConfig.autoAuth && (yield 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 { __decorate } from "tslib";
1
+ import { __awaiter, __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,19 +6,29 @@ 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
- async connectedCallback() {
10
- super.connectedCallback();
11
- await this.autofill();
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
+ });
12
17
  }
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.');
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
+ });
22
32
  }
23
33
  };
24
34
  ForgotPassword = __decorate([
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,40 +20,50 @@ let LoginForm = class LoginForm extends BaseRoute {
20
20
  this.convertHostUrl();
21
21
  };
22
22
  }
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
- }
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
+ });
34
40
  }
35
- async enter() {
36
- DOM.queueUpdate(async () => {
37
- try {
38
- if (!this.connect.isConnected && this.config.autoConnect) {
39
- await this.toggleConnection();
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
+ }
40
51
  }
41
- if (!this.auth.isLoggedIn && this.config.autoAuth) {
42
- this.attemptLoginWhenConnected();
52
+ catch (e) {
53
+ logger.debug(e);
43
54
  }
44
- }
45
- catch (e) {
46
- logger.debug(e);
47
- }
55
+ }));
48
56
  });
49
57
  }
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);
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
+ }
65
+ return this.connect.connect(this.host);
66
+ });
57
67
  }
58
68
  attemptLoginWhenConnected() {
59
69
  this.connect.isConnectedSubject.subscribe((isConnected) => {
@@ -95,14 +105,16 @@ let LoginForm = class LoginForm extends BaseRoute {
95
105
  this.login(basicCredentials);
96
106
  }
97
107
  ssoToggledChanged() {
108
+ var _a, _b;
98
109
  this.clearError();
99
110
  if (this.ssoToggled) {
100
- const path = `${this.config.sso?.identityProvidersPath ?? 'sso/list'}`;
111
+ const path = `${(_b = (_a = this.config.sso) === null || _a === void 0 ? void 0 : _a.identityProvidersPath) !== null && _b !== void 0 ? _b : 'sso/list'}`;
101
112
  fetchIDPs(path)
102
113
  .then((idps) => {
114
+ var _a, _b;
103
115
  logger.debug('fetched IDPs', idps);
104
116
  this.idps = idps;
105
- this.selectedIDP = this?.idps?.[0]?.id;
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;
106
118
  })
107
119
  .catch(() => this.setError('Failed to fetch identity providers.'));
108
120
  }
@@ -128,54 +140,64 @@ let LoginForm = class LoginForm extends BaseRoute {
128
140
  }
129
141
  }
130
142
  convertHostUrl() {
131
- if (this.connect?.httpMode() && this.host?.startsWith('ws')) {
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'))) {
132
145
  this.host = this.host.replace('ws', 'http');
133
146
  }
134
- else if (!this.connect?.httpMode() && this.host?.startsWith('http')) {
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'))) {
135
148
  this.host = this.host.replace('http', 'ws');
136
149
  }
137
150
  }
138
- async onHostSubmit() {
139
- await this.toggleConnection();
151
+ onHostSubmit() {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ yield this.toggleConnection();
154
+ });
140
155
  }
141
- async onLoginSubmit() {
142
- await super.onSubmit();
143
- DOM.queueUpdate(() => {
144
- this.attemptBasicLogin();
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
+ });
145
165
  });
146
166
  }
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.');
152
- }
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
+ 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;
167
179
  }
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.');
180
+ Route.path.push(url);
181
+ }
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());
172
196
  return;
173
197
  }
174
- this.setError(err.message + err.getMessageError());
175
- return;
198
+ this.setError(err.message);
176
199
  }
177
- this.setError(err.message);
178
- }
200
+ });
179
201
  }
180
202
  get connectActionText() {
181
203
  return this.connect.isConnected ? 'Disconnect' : 'Connect';
@@ -1,16 +1,18 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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
- async onLogout() {
8
- const result = await this.auth.logout();
9
- if (!result.success) {
10
- return;
11
- }
12
- await this.credentialManager.preventSilentAccess();
13
- this.onNavigate('/');
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
+ });
14
16
  }
15
17
  };
16
18
  Protected = __decorate([
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,9 +9,14 @@ let RequestAccount = class RequestAccount extends BaseRoute {
9
9
  super(...arguments);
10
10
  this.termsAgreed = false;
11
11
  }
12
- async onSubmit() {
13
- logger.debug('request account submission');
14
- await super.onSubmit();
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
+ });
15
20
  }
16
21
  };
17
22
  __decorate([
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,33 +10,49 @@ let ResetPassword = class ResetPassword extends BaseRoute {
10
10
  this.hasPasswordExpired = false;
11
11
  this.passwordResetToken = '';
12
12
  }
13
- async connectedCallback() {
14
- super.connectedCallback();
15
- await this.autofill();
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
+ });
16
21
  }
17
- async enter(phase) {
18
- this.hasPasswordExpired = !!phase.route.queryParams.expired;
19
- this.passwordResetToken = phase.route.queryParams.password;
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
+ });
20
27
  }
21
- async onSubmit() {
22
- await super.onSubmit();
23
- this.passwordResetToken
24
- ? await this.onForgotPasswordWorkflow()
25
- : await this.onChangePasswordWorkflow();
26
- this.isSubmitting = false;
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
+ });
27
39
  }
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);
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
+ });
33
47
  });
34
48
  }
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);
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
+ });
40
56
  });
41
57
  }
42
58
  get headingText() {
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,9 +9,14 @@ let Verify = class Verify extends BaseRoute {
9
9
  super(...arguments);
10
10
  this.code = '';
11
11
  }
12
- async onSubmit() {
13
- logger.debug('2FA verify submission');
14
- await super.onSubmit();
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
+ });
15
20
  }
16
21
  };
17
22
  __decorate([
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { API_HOST } from '@genesislcap/foundation-utils';
2
3
  import { logger } from './logger';
3
4
  /**
@@ -29,7 +30,7 @@ export const getSSOLoginURL = (idp, path = '/login?idp=', host = API_HOST) => {
29
30
  *
30
31
  * @public
31
32
  */
32
- export const fetchIDPs = async (path = 'sso/list', host = API_HOST) => {
33
+ export const fetchIDPs = (path = 'sso/list', host = API_HOST) => __awaiter(void 0, void 0, void 0, function* () {
33
34
  const IDP_ENDPOINT = getIPDEndpoint(path, host);
34
35
  return fetch(IDP_ENDPOINT)
35
36
  .then((res) => {
@@ -46,4 +47,4 @@ export const fetchIDPs = async (path = 'sso/list', host = API_HOST) => {
46
47
  logger.error('Failed to fetch identity providers.');
47
48
  return [{ id: 'error', type: null, description: 'Failed to fetch providers.' }];
48
49
  });
49
- };
50
+ });
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.4-es2021.1",
4
+ "version": "14.70.4-test.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.4-es2021.1",
53
- "@genesislcap/genx": "14.70.4-es2021.1",
52
+ "@genesislcap/foundation-testing": "14.70.4-test.1",
53
+ "@genesislcap/genx": "14.70.4-test.1",
54
54
  "rimraf": "^3.0.2"
55
55
  },
56
56
  "dependencies": {
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",
57
+ "@genesislcap/foundation-comms": "14.70.4-test.1",
58
+ "@genesislcap/foundation-ui": "14.70.4-test.1",
59
+ "@genesislcap/foundation-utils": "14.70.4-test.1",
60
+ "@genesislcap/foundation-zero": "14.70.4-test.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": "5d0d8ee36cfd068cfc6211033b326d0a978cfc05"
77
+ "gitHead": "2414c66a7a84c61343d756e240cb4140d82f1311"
78
78
  }