@everymatrix/user-login 1.94.20 → 1.94.22

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.
@@ -3,8 +3,7 @@ import { getTranslations, translate } from "../../utils/locale.utils";
3
3
  import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
4
4
  import { getSlottedElement } from "../../../../../../../../libs/common/src/utils/index";
5
5
  import { dispatchCustomEvent } from "../../../../../../../../libs/custom-events/src/index";
6
- import { createRecaptcha, createTurnstile, } from "../../../../../../../../libs/common/src/captcha/index";
7
- import { CAPTCHA_CONTAINER_SLOT } from "../../utils/utils";
6
+ import { createRecaptcha, createTurnstile, RECAPTCHA_TOKEN_RESPONSE_HEADER, TURNSTILE_TOKEN_RESPONSE_HEADER, TURNSTILE_IS_VISIBLE_HEADER, CAPTCHA_CONTAINER_SLOT, } from "../../../../../../../../libs/common/src/captcha/index";
8
7
  import "../../../../../../../libs/vaadin-facade/index";
9
8
  export class UserLogin {
10
9
  constructor() {
@@ -48,7 +47,7 @@ export class UserLogin {
48
47
  * Login API call for Gm 1.7
49
48
  */
50
49
  this.userLoginGm17 = async () => {
51
- var _a, _b, _c;
50
+ var _a, _b, _c, _d, _e;
52
51
  let headers = {
53
52
  'Content-Type': 'application/json'
54
53
  };
@@ -60,11 +59,13 @@ export class UserLogin {
60
59
  let token;
61
60
  if (typeof ((_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.ensureToken) === "function") {
62
61
  token = await ((_c = (_b = this.captchaInstance) === null || _b === void 0 ? void 0 : _b.ensureToken) === null || _c === void 0 ? void 0 : _c.call(_b));
62
+ headers[TURNSTILE_TOKEN_RESPONSE_HEADER] = token !== null && token !== void 0 ? token : "";
63
+ headers[TURNSTILE_IS_VISIBLE_HEADER] = "false";
63
64
  }
64
65
  else {
65
66
  token = this.captchaToken;
67
+ headers[RECAPTCHA_TOKEN_RESPONSE_HEADER] = token !== null && token !== void 0 ? token : "";
66
68
  }
67
- headers['cf-captcha-response'] = token !== null && token !== void 0 ? token : "";
68
69
  }
69
70
  const options = {
70
71
  method: 'POST',
@@ -93,6 +94,7 @@ export class UserLogin {
93
94
  }
94
95
  finally {
95
96
  this.isLoginLoading = false;
97
+ (_e = (_d = this.captchaInstance) === null || _d === void 0 ? void 0 : _d.reset) === null || _e === void 0 ? void 0 : _e.call(_d);
96
98
  }
97
99
  };
98
100
  /**
@@ -155,15 +157,17 @@ export class UserLogin {
155
157
  try {
156
158
  const turnstileToken = await ((_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.ensureToken) === null || _b === void 0 ? void 0 : _b.call(_a));
157
159
  if (turnstileToken) {
158
- headers.append('cf-captcha-response', turnstileToken);
159
- headers.append('cfCaptchaIsVisible', 'false');
160
+ headers.append(TURNSTILE_TOKEN_RESPONSE_HEADER, turnstileToken);
161
+ headers.append(TURNSTILE_IS_VISIBLE_HEADER, 'false');
160
162
  }
161
163
  }
162
164
  catch (error) {
163
165
  this.hasError = true;
164
- this.errorMessage = translate('genericError', this.lang) || `${error}`;
165
- this.sendErrorNotification(this.errorMessage);
166
166
  this.isLoginLoading = false;
167
+ if (error !== null) {
168
+ this.errorMessage = translate('genericError', this.lang) || `${error}`;
169
+ this.sendErrorNotification(this.errorMessage);
170
+ }
167
171
  return;
168
172
  }
169
173
  }
@@ -228,7 +232,9 @@ export class UserLogin {
228
232
  this.sendErrorNotification(this.errorMessage);
229
233
  })
230
234
  .finally(() => {
235
+ var _a, _b;
231
236
  this.isLoginLoading = false;
237
+ (_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.reset) === null || _b === void 0 ? void 0 : _b.call(_a);
232
238
  });
233
239
  };
234
240
  /**
@@ -349,8 +355,6 @@ export class UserLogin {
349
355
  this.biometricactionmode = 'switch';
350
356
  this.isFromLogin = true;
351
357
  this.turnstileSiteKey = undefined;
352
- this.turnstileEnableFallback = false;
353
- this.turnstileRetryCount = undefined;
354
358
  this.userNameEmail = '';
355
359
  this.userPassword = '';
356
360
  this.isValidUserEmail = true;
@@ -366,7 +370,6 @@ export class UserLogin {
366
370
  this.isLoginLoading = false;
367
371
  this.isNativeApp = false;
368
372
  this.biometricsLoaded = false;
369
- this.isTurnstileLoading = false;
370
373
  }
371
374
  /**
372
375
  * Watch for changes in the translation URL and fetch new translations
@@ -467,7 +470,6 @@ export class UserLogin {
467
470
  isEnabled: true,
468
471
  provider: "cloudflare",
469
472
  siteKey: this.turnstileSiteKey,
470
- enableFallback: this.turnstileEnableFallback
471
473
  });
472
474
  }
473
475
  }
@@ -500,8 +502,7 @@ export class UserLogin {
500
502
  });
501
503
  }
502
504
  async initializeCaptcha({ provider, siteKey, enableFallback }) {
503
- const slotElement = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
504
- this.captchaContainerEl = slotElement;
505
+ const captchaContainerEl = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
505
506
  const captchaCreator = {
506
507
  "google": createRecaptcha,
507
508
  "cloudflare": createTurnstile
@@ -512,7 +513,7 @@ export class UserLogin {
512
513
  enableFallback,
513
514
  callback: provider === "google" ? (token) => { this.captchaToken = token; } : undefined
514
515
  });
515
- await this.captchaInstance.render(this.captchaContainerEl);
516
+ await this.captchaInstance.render(captchaContainerEl);
516
517
  }
517
518
  /**
518
519
  * Lifecycle method: Clean up event listeners when the component is removed
@@ -522,7 +523,8 @@ export class UserLogin {
522
523
  this.stylingSubscription && this.stylingSubscription.unsubscribe();
523
524
  window.removeEventListener('LoginCredentials', this.autofillCredentialsHandler);
524
525
  window.removeEventListener('message', this.messageHandler);
525
- (_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
526
+ if (this.turnstileSiteKey)
527
+ (_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
526
528
  }
527
529
  /**
528
530
  * Send error notification as a post message
@@ -604,7 +606,7 @@ export class UserLogin {
604
606
  * Render function
605
607
  */
606
608
  render() {
607
- return (h("section", { key: 'c72b94ac2e6cde988ae4798402680a527e4a004e', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: '36c64bfcc9d5e19ae7b22d50638bf3c720167606', name: CAPTCHA_CONTAINER_SLOT })));
609
+ return (h("section", { key: 'd53f60a484827fbb28b2ec8a907ac21e0781427a', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: '8b42ec462b580ffb0d1448bbe185febada0bcd22', name: CAPTCHA_CONTAINER_SLOT })));
608
610
  }
609
611
  static get is() { return "user-login"; }
610
612
  static get encapsulation() { return "shadow"; }
@@ -1012,41 +1014,6 @@ export class UserLogin {
1012
1014
  },
1013
1015
  "attribute": "turnstile-site-key",
1014
1016
  "reflect": false
1015
- },
1016
- "turnstileEnableFallback": {
1017
- "type": "boolean",
1018
- "mutable": false,
1019
- "complexType": {
1020
- "original": "boolean",
1021
- "resolved": "boolean",
1022
- "references": {}
1023
- },
1024
- "required": false,
1025
- "optional": true,
1026
- "docs": {
1027
- "tags": [],
1028
- "text": "Enable Turnstile fallback behavior."
1029
- },
1030
- "attribute": "turnstile-enable-fallback",
1031
- "reflect": false,
1032
- "defaultValue": "false"
1033
- },
1034
- "turnstileRetryCount": {
1035
- "type": "number",
1036
- "mutable": false,
1037
- "complexType": {
1038
- "original": "number",
1039
- "resolved": "number",
1040
- "references": {}
1041
- },
1042
- "required": false,
1043
- "optional": true,
1044
- "docs": {
1045
- "tags": [],
1046
- "text": "Number of retry attempts for Turnstile."
1047
- },
1048
- "attribute": "turnstile-retry-count",
1049
- "reflect": false
1050
1017
  }
1051
1018
  };
1052
1019
  }
@@ -1066,8 +1033,7 @@ export class UserLogin {
1066
1033
  "phoneCodes": {},
1067
1034
  "isLoginLoading": {},
1068
1035
  "isNativeApp": {},
1069
- "biometricsLoaded": {},
1070
- "isTurnstileLoading": {}
1036
+ "biometricsLoaded": {}
1071
1037
  };
1072
1038
  }
1073
1039
  static get methods() {
@@ -1,4 +1,3 @@
1
1
  export function format(first, middle, last) {
2
2
  return ((first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : ''));
3
3
  }
4
- export const CAPTCHA_CONTAINER_SLOT = "captchaContainer";
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["user-login",[[1,"user-login",{"endpoint":[513],"minPassLength":[514,"min-pass-length"],"lang":[1537],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"passwordReset":[513,"password-reset"],"userEmailRegex":[513,"user-email-regex"],"userEmailRegexOptions":[513,"user-email-regex-options"],"userPhoneRegex":[513,"user-phone-regex"],"userPhoneRegexOptions":[513,"user-phone-regex-options"],"passwordRegex":[513,"password-regex"],"passwordRegexOptions":[513,"password-regex-options"],"version":[513],"loginByPhoneNumber":[513,"login-by-phone-number"],"defaultPrefix":[513,"default-prefix"],"isPrefixEditable":[513,"is-prefix-editable"],"mbSource":[513,"mb-source"],"biometricEnabled":[513,"biometric-enabled"],"biometricactionmode":[1],"isFromLogin":[4,"is-from-login"],"turnstileSiteKey":[1,"turnstile-site-key"],"turnstileEnableFallback":[4,"turnstile-enable-fallback"],"turnstileRetryCount":[2,"turnstile-retry-count"],"userNameEmail":[32],"userPassword":[32],"isValidUserEmail":[32],"userPhone":[32],"userPrefix":[32],"isValidPassword":[32],"isValidUserPhone":[32],"isPasswordVisible":[32],"errorMessage":[32],"errorForFields":[32],"hasError":[32],"phoneCodes":[32],"isLoginLoading":[32],"isNativeApp":[32],"biometricsLoaded":[32],"isTurnstileLoading":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
8
+ return bootstrapLazy([["user-login",[[1,"user-login",{"endpoint":[513],"minPassLength":[514,"min-pass-length"],"lang":[1537],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"passwordReset":[513,"password-reset"],"userEmailRegex":[513,"user-email-regex"],"userEmailRegexOptions":[513,"user-email-regex-options"],"userPhoneRegex":[513,"user-phone-regex"],"userPhoneRegexOptions":[513,"user-phone-regex-options"],"passwordRegex":[513,"password-regex"],"passwordRegexOptions":[513,"password-regex-options"],"version":[513],"loginByPhoneNumber":[513,"login-by-phone-number"],"defaultPrefix":[513,"default-prefix"],"isPrefixEditable":[513,"is-prefix-editable"],"mbSource":[513,"mb-source"],"biometricEnabled":[513,"biometric-enabled"],"biometricactionmode":[1],"isFromLogin":[4,"is-from-login"],"turnstileSiteKey":[1,"turnstile-site-key"],"userNameEmail":[32],"userPassword":[32],"isValidUserEmail":[32],"userPhone":[32],"userPrefix":[32],"isValidPassword":[32],"isValidUserPhone":[32],"isPasswordVisible":[32],"errorMessage":[32],"errorForFields":[32],"hasError":[32],"phoneCodes":[32],"isLoginLoading":[32],"isNativeApp":[32],"biometricsLoaded":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };