@everymatrix/user-login 1.99.10 → 1.99.11

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.
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
8
8
  const defineCustomElements = async (win, options) => {
9
9
  if (typeof window === 'undefined') return undefined;
10
10
  await appGlobals.globalScripts();
11
- return index.bootstrapLazy([["user-login.cjs",[[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);
11
+ return index.bootstrapLazy([["user-login.cjs",[[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"],"useRegisPasswordCheck":[516,"use-regis-password-check"],"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],"registrationPasswordLoading":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"],"useRegisPasswordCheck":["loadRegistrationPasswordValidation"],"endpoint":["loadRegistrationPasswordValidation"]}]]]], options);
12
12
  };
13
13
 
14
14
  exports.setNonce = index.setNonce;
@@ -550,6 +550,57 @@ const dispatchCustomEvent = (type, data = {}) => {
550
550
  document.dispatchEvent(event);
551
551
  };
552
552
 
553
+ /** Loads the registration password field string validation, caller should handle fallback on failure. */
554
+ async function getRegistrationPasswordValidator(endpoint) {
555
+ var _a, _b, _c;
556
+ const url = new URL(`${endpoint}/v1/player/legislation/registration/config/`);
557
+ const response = await fetch(url.href, {
558
+ method: 'GET',
559
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' }
560
+ });
561
+ if (!response.ok) {
562
+ throw new Error(`HTTP error! Status: ${response.status}`);
563
+ }
564
+ const config = await response.json();
565
+ const validation = Array.isArray((_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.fields)
566
+ ? (_b = config.content.fields.find((field) => (field === null || field === void 0 ? void 0 : field.name) === 'Password')) === null || _b === void 0 ? void 0 : _b.validate
567
+ : null;
568
+ if (!validation || typeof validation.mandatory !== 'boolean' ||
569
+ (validation.type != null && validation.type !== 'string') ||
570
+ (validation.custom != null && !Array.isArray(validation.custom))) {
571
+ throw new Error('Registration password validation is missing or invalid.');
572
+ }
573
+ const { mandatory, minLength, maxLength } = validation;
574
+ for (const bound of [minLength, maxLength]) {
575
+ if (bound != null && (!Number.isInteger(bound) || bound < 0)) {
576
+ throw new Error('Registration password length bound is invalid.');
577
+ }
578
+ }
579
+ if (minLength != null && maxLength != null && minLength > maxLength) {
580
+ throw new Error('Registration password length bounds are inconsistent.');
581
+ }
582
+ const patterns = [];
583
+ for (const rule of (_c = validation.custom) !== null && _c !== void 0 ? _c : []) {
584
+ if (!rule || typeof rule.rule !== 'string') {
585
+ throw new Error('Registration password rule is invalid.');
586
+ }
587
+ if (rule.rule === 'regex') {
588
+ if (typeof rule.pattern !== 'string') {
589
+ throw new Error('Registration password regex pattern is invalid.');
590
+ }
591
+ patterns.push(new RegExp(rule.pattern));
592
+ }
593
+ }
594
+ return password => {
595
+ if (password.length === 0) {
596
+ return !mandatory;
597
+ }
598
+ return (minLength == null || password.length >= minLength) &&
599
+ (maxLength == null || password.length <= maxLength) &&
600
+ patterns.every(pattern => pattern.test(password));
601
+ };
602
+ }
603
+
553
604
  const SCRIPT_SRC$1 = 'https://www.google.com/recaptcha/api.js';
554
605
  const SCRIPT_LOAD_TIMEOUT_MS$1 = 5000;
555
606
  const RECAPTCHA_TOKEN_RESPONSE_HEADER = 'g-recaptcha-response';
@@ -7485,6 +7536,8 @@ const UserLogin = class {
7485
7536
  index.registerInstance(this, hostRef);
7486
7537
  this.errorCode = '';
7487
7538
  this.captchaInstance = null;
7539
+ this.registrationPasswordValidator = null;
7540
+ this.registrationPasswordRequest = 0;
7488
7541
  this.messageHandler = async (e) => {
7489
7542
  var _a;
7490
7543
  if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) === 'NativeAppReady') {
@@ -7794,6 +7847,13 @@ const UserLogin = class {
7794
7847
  regex = new RegExp(this.userPhoneRegex, this.userPhoneRegexOptions);
7795
7848
  return regex.test(input) && !!this.userPrefix;
7796
7849
  case 'password':
7850
+ if (this.useRegisPasswordCheck) {
7851
+ if (this.registrationPasswordLoading)
7852
+ return false;
7853
+ if (this.registrationPasswordValidator) {
7854
+ return this.registrationPasswordValidator(input);
7855
+ }
7856
+ }
7797
7857
  regex = new RegExp(this.passwordRegex, this.passwordRegexOptions);
7798
7858
  return regex.test(input);
7799
7859
  }
@@ -7823,6 +7883,7 @@ const UserLogin = class {
7823
7883
  this.userPhoneRegexOptions = '';
7824
7884
  this.passwordRegex = '';
7825
7885
  this.passwordRegexOptions = '';
7886
+ this.useRegisPasswordCheck = false;
7826
7887
  this.version = 'gm16';
7827
7888
  this.loginByPhoneNumber = 'false';
7828
7889
  this.defaultPrefix = undefined;
@@ -7847,6 +7908,7 @@ const UserLogin = class {
7847
7908
  this.isLoginLoading = false;
7848
7909
  this.isNativeApp = false;
7849
7910
  this.biometricsLoaded = false;
7911
+ this.registrationPasswordLoading = false;
7850
7912
  }
7851
7913
  /**
7852
7914
  * Watch for changes in the translation URL and fetch new translations
@@ -7888,6 +7950,9 @@ const UserLogin = class {
7888
7950
  */
7889
7951
  async componentWillLoad() {
7890
7952
  var _a, _b;
7953
+ if (this.useRegisPasswordCheck) {
7954
+ await this.loadRegistrationPasswordValidation();
7955
+ }
7891
7956
  if (this.loginByPhoneNumber === 'true') {
7892
7957
  if (this.defaultPrefix && this.isPrefixEditable === 'false') {
7893
7958
  this.phoneCodes = [{ label: this.defaultPrefix, value: this.defaultPrefix }];
@@ -7978,6 +8043,30 @@ const UserLogin = class {
7978
8043
  });
7979
8044
  });
7980
8045
  }
8046
+ async loadRegistrationPasswordValidation() {
8047
+ var _a;
8048
+ const request = ++this.registrationPasswordRequest;
8049
+ this.registrationPasswordValidator = null;
8050
+ this.registrationPasswordLoading = this.useRegisPasswordCheck;
8051
+ if (this.useRegisPasswordCheck) {
8052
+ try {
8053
+ const validator = await getRegistrationPasswordValidator(this.endpoint);
8054
+ if (request !== this.registrationPasswordRequest)
8055
+ return;
8056
+ this.registrationPasswordValidator = validator;
8057
+ }
8058
+ catch (error) {
8059
+ if (request !== this.registrationPasswordRequest)
8060
+ return;
8061
+ console.error('Error fetching registration password validation:', error);
8062
+ }
8063
+ }
8064
+ if (request !== this.registrationPasswordRequest)
8065
+ return;
8066
+ this.registrationPasswordLoading = false;
8067
+ this.isValidPassword = this.validate('password', this.userPassword);
8068
+ this.errorForFields = Object.assign(Object.assign({}, this.errorForFields), { password: !this.isValidPassword && this.userPassword.length > Number((_a = this.minPassLength) !== null && _a !== void 0 ? _a : 3) });
8069
+ }
7981
8070
  async initializeCaptcha({ provider, siteKey, enableFallback }) {
7982
8071
  const captchaContainerEl = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
7983
8072
  const captchaCreator = {
@@ -8058,6 +8147,7 @@ const UserLogin = class {
8058
8147
  !this.userPassword ||
8059
8148
  !this.isValidPassword ||
8060
8149
  this.isLoginLoading ||
8150
+ this.registrationPasswordLoading ||
8061
8151
  (this.version === 'gm17' && this.captchaInstance && !this.captchaToken));
8062
8152
  return isDisabled;
8063
8153
  }
@@ -8083,13 +8173,15 @@ const UserLogin = class {
8083
8173
  * Render function
8084
8174
  */
8085
8175
  render() {
8086
- return (index.h("section", { key: 'c5e52078e3e24ad5b931f5b48a9358c1f470313c', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), index.h("slot", { key: 'eac25bfc3f1c57a6ab24e7bf519ad7af5309c61d', name: CAPTCHA_CONTAINER_SLOT })));
8176
+ return (index.h("section", { key: 'b68862360fc82cbee468e48ddb6359f9e4974417', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), index.h("slot", { key: '9f5a57a674ffddc608234719d541e872e576e744', name: CAPTCHA_CONTAINER_SLOT })));
8087
8177
  }
8088
8178
  get host() { return index.getElement(this); }
8089
8179
  static get watchers() { return {
8090
8180
  "translationUrl": ["handleNewTranslations"],
8091
8181
  "clientStyling": ["handleClientStylingChange"],
8092
- "clientStylingUrl": ["handleClientStylingChangeURL"]
8182
+ "clientStylingUrl": ["handleClientStylingChangeURL"],
8183
+ "useRegisPasswordCheck": ["loadRegistrationPasswordValidation"],
8184
+ "endpoint": ["loadRegistrationPasswordValidation"]
8093
8185
  }; }
8094
8186
  };
8095
8187
  UserLogin.style = UserLoginStyle0;
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["user-login.cjs",[[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);
22
+ return index.bootstrapLazy([["user-login.cjs",[[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"],"useRegisPasswordCheck":[516,"use-regis-password-check"],"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],"registrationPasswordLoading":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"],"useRegisPasswordCheck":["loadRegistrationPasswordValidation"],"endpoint":["loadRegistrationPasswordValidation"]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -3,12 +3,15 @@ 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 { getRegistrationPasswordValidator } from "../../../../../../../../libs/common/src/password/index";
6
7
  import { createRecaptcha, createTurnstile, RECAPTCHA_TOKEN_RESPONSE_HEADER, TURNSTILE_TOKEN_RESPONSE_HEADER, TURNSTILE_IS_VISIBLE_HEADER, CAPTCHA_CONTAINER_SLOT, } from "../../../../../../../../libs/common/src/captcha/index";
7
8
  import "../../../../../../../libs/vaadin-facade/index";
8
9
  export class UserLogin {
9
10
  constructor() {
10
11
  this.errorCode = '';
11
12
  this.captchaInstance = null;
13
+ this.registrationPasswordValidator = null;
14
+ this.registrationPasswordRequest = 0;
12
15
  this.messageHandler = async (e) => {
13
16
  var _a;
14
17
  if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) === 'NativeAppReady') {
@@ -318,6 +321,13 @@ export class UserLogin {
318
321
  regex = new RegExp(this.userPhoneRegex, this.userPhoneRegexOptions);
319
322
  return regex.test(input) && !!this.userPrefix;
320
323
  case 'password':
324
+ if (this.useRegisPasswordCheck) {
325
+ if (this.registrationPasswordLoading)
326
+ return false;
327
+ if (this.registrationPasswordValidator) {
328
+ return this.registrationPasswordValidator(input);
329
+ }
330
+ }
321
331
  regex = new RegExp(this.passwordRegex, this.passwordRegexOptions);
322
332
  return regex.test(input);
323
333
  }
@@ -347,6 +357,7 @@ export class UserLogin {
347
357
  this.userPhoneRegexOptions = '';
348
358
  this.passwordRegex = '';
349
359
  this.passwordRegexOptions = '';
360
+ this.useRegisPasswordCheck = false;
350
361
  this.version = 'gm16';
351
362
  this.loginByPhoneNumber = 'false';
352
363
  this.defaultPrefix = undefined;
@@ -371,6 +382,7 @@ export class UserLogin {
371
382
  this.isLoginLoading = false;
372
383
  this.isNativeApp = false;
373
384
  this.biometricsLoaded = false;
385
+ this.registrationPasswordLoading = false;
374
386
  }
375
387
  /**
376
388
  * Watch for changes in the translation URL and fetch new translations
@@ -412,6 +424,9 @@ export class UserLogin {
412
424
  */
413
425
  async componentWillLoad() {
414
426
  var _a, _b;
427
+ if (this.useRegisPasswordCheck) {
428
+ await this.loadRegistrationPasswordValidation();
429
+ }
415
430
  if (this.loginByPhoneNumber === 'true') {
416
431
  if (this.defaultPrefix && this.isPrefixEditable === 'false') {
417
432
  this.phoneCodes = [{ label: this.defaultPrefix, value: this.defaultPrefix }];
@@ -502,6 +517,30 @@ export class UserLogin {
502
517
  });
503
518
  });
504
519
  }
520
+ async loadRegistrationPasswordValidation() {
521
+ var _a;
522
+ const request = ++this.registrationPasswordRequest;
523
+ this.registrationPasswordValidator = null;
524
+ this.registrationPasswordLoading = this.useRegisPasswordCheck;
525
+ if (this.useRegisPasswordCheck) {
526
+ try {
527
+ const validator = await getRegistrationPasswordValidator(this.endpoint);
528
+ if (request !== this.registrationPasswordRequest)
529
+ return;
530
+ this.registrationPasswordValidator = validator;
531
+ }
532
+ catch (error) {
533
+ if (request !== this.registrationPasswordRequest)
534
+ return;
535
+ console.error('Error fetching registration password validation:', error);
536
+ }
537
+ }
538
+ if (request !== this.registrationPasswordRequest)
539
+ return;
540
+ this.registrationPasswordLoading = false;
541
+ this.isValidPassword = this.validate('password', this.userPassword);
542
+ this.errorForFields = Object.assign(Object.assign({}, this.errorForFields), { password: !this.isValidPassword && this.userPassword.length > Number((_a = this.minPassLength) !== null && _a !== void 0 ? _a : 3) });
543
+ }
505
544
  async initializeCaptcha({ provider, siteKey, enableFallback }) {
506
545
  const captchaContainerEl = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
507
546
  const captchaCreator = {
@@ -582,6 +621,7 @@ export class UserLogin {
582
621
  !this.userPassword ||
583
622
  !this.isValidPassword ||
584
623
  this.isLoginLoading ||
624
+ this.registrationPasswordLoading ||
585
625
  (this.version === 'gm17' && this.captchaInstance && !this.captchaToken));
586
626
  return isDisabled;
587
627
  }
@@ -607,7 +647,7 @@ export class UserLogin {
607
647
  * Render function
608
648
  */
609
649
  render() {
610
- return (h("section", { key: 'c5e52078e3e24ad5b931f5b48a9358c1f470313c', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: 'eac25bfc3f1c57a6ab24e7bf519ad7af5309c61d', name: CAPTCHA_CONTAINER_SLOT })));
650
+ return (h("section", { key: 'b68862360fc82cbee468e48ddb6359f9e4974417', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: '9f5a57a674ffddc608234719d541e872e576e744', name: CAPTCHA_CONTAINER_SLOT })));
611
651
  }
612
652
  static get is() { return "user-login"; }
613
653
  static get encapsulation() { return "shadow"; }
@@ -857,6 +897,24 @@ export class UserLogin {
857
897
  "reflect": true,
858
898
  "defaultValue": "''"
859
899
  },
900
+ "useRegisPasswordCheck": {
901
+ "type": "boolean",
902
+ "mutable": false,
903
+ "complexType": {
904
+ "original": "boolean",
905
+ "resolved": "boolean",
906
+ "references": {}
907
+ },
908
+ "required": false,
909
+ "optional": false,
910
+ "docs": {
911
+ "tags": [],
912
+ "text": ""
913
+ },
914
+ "attribute": "use-regis-password-check",
915
+ "reflect": true,
916
+ "defaultValue": "false"
917
+ },
860
918
  "version": {
861
919
  "type": "string",
862
920
  "mutable": false,
@@ -1034,7 +1092,8 @@ export class UserLogin {
1034
1092
  "phoneCodes": {},
1035
1093
  "isLoginLoading": {},
1036
1094
  "isNativeApp": {},
1037
- "biometricsLoaded": {}
1095
+ "biometricsLoaded": {},
1096
+ "registrationPasswordLoading": {}
1038
1097
  };
1039
1098
  }
1040
1099
  static get methods() {
@@ -1078,6 +1137,12 @@ export class UserLogin {
1078
1137
  }, {
1079
1138
  "propName": "clientStylingUrl",
1080
1139
  "methodName": "handleClientStylingChangeURL"
1140
+ }, {
1141
+ "propName": "useRegisPasswordCheck",
1142
+ "methodName": "loadRegistrationPasswordValidation"
1143
+ }, {
1144
+ "propName": "endpoint",
1145
+ "methodName": "loadRegistrationPasswordValidation"
1081
1146
  }];
1082
1147
  }
1083
1148
  }
@@ -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"],"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);
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"],"useRegisPasswordCheck":[516,"use-regis-password-check"],"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],"registrationPasswordLoading":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"],"useRegisPasswordCheck":["loadRegistrationPasswordValidation"],"endpoint":["loadRegistrationPasswordValidation"]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };
@@ -546,6 +546,57 @@ const dispatchCustomEvent = (type, data = {}) => {
546
546
  document.dispatchEvent(event);
547
547
  };
548
548
 
549
+ /** Loads the registration password field string validation, caller should handle fallback on failure. */
550
+ async function getRegistrationPasswordValidator(endpoint) {
551
+ var _a, _b, _c;
552
+ const url = new URL(`${endpoint}/v1/player/legislation/registration/config/`);
553
+ const response = await fetch(url.href, {
554
+ method: 'GET',
555
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' }
556
+ });
557
+ if (!response.ok) {
558
+ throw new Error(`HTTP error! Status: ${response.status}`);
559
+ }
560
+ const config = await response.json();
561
+ const validation = Array.isArray((_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.fields)
562
+ ? (_b = config.content.fields.find((field) => (field === null || field === void 0 ? void 0 : field.name) === 'Password')) === null || _b === void 0 ? void 0 : _b.validate
563
+ : null;
564
+ if (!validation || typeof validation.mandatory !== 'boolean' ||
565
+ (validation.type != null && validation.type !== 'string') ||
566
+ (validation.custom != null && !Array.isArray(validation.custom))) {
567
+ throw new Error('Registration password validation is missing or invalid.');
568
+ }
569
+ const { mandatory, minLength, maxLength } = validation;
570
+ for (const bound of [minLength, maxLength]) {
571
+ if (bound != null && (!Number.isInteger(bound) || bound < 0)) {
572
+ throw new Error('Registration password length bound is invalid.');
573
+ }
574
+ }
575
+ if (minLength != null && maxLength != null && minLength > maxLength) {
576
+ throw new Error('Registration password length bounds are inconsistent.');
577
+ }
578
+ const patterns = [];
579
+ for (const rule of (_c = validation.custom) !== null && _c !== void 0 ? _c : []) {
580
+ if (!rule || typeof rule.rule !== 'string') {
581
+ throw new Error('Registration password rule is invalid.');
582
+ }
583
+ if (rule.rule === 'regex') {
584
+ if (typeof rule.pattern !== 'string') {
585
+ throw new Error('Registration password regex pattern is invalid.');
586
+ }
587
+ patterns.push(new RegExp(rule.pattern));
588
+ }
589
+ }
590
+ return password => {
591
+ if (password.length === 0) {
592
+ return !mandatory;
593
+ }
594
+ return (minLength == null || password.length >= minLength) &&
595
+ (maxLength == null || password.length <= maxLength) &&
596
+ patterns.every(pattern => pattern.test(password));
597
+ };
598
+ }
599
+
549
600
  const SCRIPT_SRC$1 = 'https://www.google.com/recaptcha/api.js';
550
601
  const SCRIPT_LOAD_TIMEOUT_MS$1 = 5000;
551
602
  const RECAPTCHA_TOKEN_RESPONSE_HEADER = 'g-recaptcha-response';
@@ -7481,6 +7532,8 @@ const UserLogin = class {
7481
7532
  registerInstance(this, hostRef);
7482
7533
  this.errorCode = '';
7483
7534
  this.captchaInstance = null;
7535
+ this.registrationPasswordValidator = null;
7536
+ this.registrationPasswordRequest = 0;
7484
7537
  this.messageHandler = async (e) => {
7485
7538
  var _a;
7486
7539
  if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) === 'NativeAppReady') {
@@ -7790,6 +7843,13 @@ const UserLogin = class {
7790
7843
  regex = new RegExp(this.userPhoneRegex, this.userPhoneRegexOptions);
7791
7844
  return regex.test(input) && !!this.userPrefix;
7792
7845
  case 'password':
7846
+ if (this.useRegisPasswordCheck) {
7847
+ if (this.registrationPasswordLoading)
7848
+ return false;
7849
+ if (this.registrationPasswordValidator) {
7850
+ return this.registrationPasswordValidator(input);
7851
+ }
7852
+ }
7793
7853
  regex = new RegExp(this.passwordRegex, this.passwordRegexOptions);
7794
7854
  return regex.test(input);
7795
7855
  }
@@ -7819,6 +7879,7 @@ const UserLogin = class {
7819
7879
  this.userPhoneRegexOptions = '';
7820
7880
  this.passwordRegex = '';
7821
7881
  this.passwordRegexOptions = '';
7882
+ this.useRegisPasswordCheck = false;
7822
7883
  this.version = 'gm16';
7823
7884
  this.loginByPhoneNumber = 'false';
7824
7885
  this.defaultPrefix = undefined;
@@ -7843,6 +7904,7 @@ const UserLogin = class {
7843
7904
  this.isLoginLoading = false;
7844
7905
  this.isNativeApp = false;
7845
7906
  this.biometricsLoaded = false;
7907
+ this.registrationPasswordLoading = false;
7846
7908
  }
7847
7909
  /**
7848
7910
  * Watch for changes in the translation URL and fetch new translations
@@ -7884,6 +7946,9 @@ const UserLogin = class {
7884
7946
  */
7885
7947
  async componentWillLoad() {
7886
7948
  var _a, _b;
7949
+ if (this.useRegisPasswordCheck) {
7950
+ await this.loadRegistrationPasswordValidation();
7951
+ }
7887
7952
  if (this.loginByPhoneNumber === 'true') {
7888
7953
  if (this.defaultPrefix && this.isPrefixEditable === 'false') {
7889
7954
  this.phoneCodes = [{ label: this.defaultPrefix, value: this.defaultPrefix }];
@@ -7974,6 +8039,30 @@ const UserLogin = class {
7974
8039
  });
7975
8040
  });
7976
8041
  }
8042
+ async loadRegistrationPasswordValidation() {
8043
+ var _a;
8044
+ const request = ++this.registrationPasswordRequest;
8045
+ this.registrationPasswordValidator = null;
8046
+ this.registrationPasswordLoading = this.useRegisPasswordCheck;
8047
+ if (this.useRegisPasswordCheck) {
8048
+ try {
8049
+ const validator = await getRegistrationPasswordValidator(this.endpoint);
8050
+ if (request !== this.registrationPasswordRequest)
8051
+ return;
8052
+ this.registrationPasswordValidator = validator;
8053
+ }
8054
+ catch (error) {
8055
+ if (request !== this.registrationPasswordRequest)
8056
+ return;
8057
+ console.error('Error fetching registration password validation:', error);
8058
+ }
8059
+ }
8060
+ if (request !== this.registrationPasswordRequest)
8061
+ return;
8062
+ this.registrationPasswordLoading = false;
8063
+ this.isValidPassword = this.validate('password', this.userPassword);
8064
+ this.errorForFields = Object.assign(Object.assign({}, this.errorForFields), { password: !this.isValidPassword && this.userPassword.length > Number((_a = this.minPassLength) !== null && _a !== void 0 ? _a : 3) });
8065
+ }
7977
8066
  async initializeCaptcha({ provider, siteKey, enableFallback }) {
7978
8067
  const captchaContainerEl = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
7979
8068
  const captchaCreator = {
@@ -8054,6 +8143,7 @@ const UserLogin = class {
8054
8143
  !this.userPassword ||
8055
8144
  !this.isValidPassword ||
8056
8145
  this.isLoginLoading ||
8146
+ this.registrationPasswordLoading ||
8057
8147
  (this.version === 'gm17' && this.captchaInstance && !this.captchaToken));
8058
8148
  return isDisabled;
8059
8149
  }
@@ -8079,13 +8169,15 @@ const UserLogin = class {
8079
8169
  * Render function
8080
8170
  */
8081
8171
  render() {
8082
- return (h("section", { key: 'c5e52078e3e24ad5b931f5b48a9358c1f470313c', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: 'eac25bfc3f1c57a6ab24e7bf519ad7af5309c61d', name: CAPTCHA_CONTAINER_SLOT })));
8172
+ return (h("section", { key: 'b68862360fc82cbee468e48ddb6359f9e4974417', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), h("slot", { key: '9f5a57a674ffddc608234719d541e872e576e744', name: CAPTCHA_CONTAINER_SLOT })));
8083
8173
  }
8084
8174
  get host() { return getElement(this); }
8085
8175
  static get watchers() { return {
8086
8176
  "translationUrl": ["handleNewTranslations"],
8087
8177
  "clientStyling": ["handleClientStylingChange"],
8088
- "clientStylingUrl": ["handleClientStylingChangeURL"]
8178
+ "clientStylingUrl": ["handleClientStylingChangeURL"],
8179
+ "useRegisPasswordCheck": ["loadRegistrationPasswordValidation"],
8180
+ "endpoint": ["loadRegistrationPasswordValidation"]
8089
8181
  }; }
8090
8182
  };
8091
8183
  UserLogin.style = UserLoginStyle0;
@@ -16,5 +16,5 @@ var patchBrowser = () => {
16
16
 
17
17
  patchBrowser().then(async (options) => {
18
18
  await globalScripts();
19
- 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);
19
+ 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"],"useRegisPasswordCheck":[516,"use-regis-password-check"],"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],"registrationPasswordLoading":[32],"autofillCredentials":[64]},null,{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"],"useRegisPasswordCheck":["loadRegistrationPasswordValidation"],"endpoint":["loadRegistrationPasswordValidation"]}]]]], options);
20
20
  });
@@ -0,0 +1,3 @@
1
+ export type RegistrationPasswordValidator = (password: string) => boolean;
2
+ /** Loads the registration password field string validation, caller should handle fallback on failure. */
3
+ export declare function getRegistrationPasswordValidator(endpoint: string): Promise<RegistrationPasswordValidator>;
@@ -54,6 +54,7 @@ export declare class UserLogin {
54
54
  * Regex options for password validation
55
55
  */
56
56
  passwordRegexOptions: string;
57
+ useRegisPasswordCheck: boolean;
57
58
  /**
58
59
  * Flag to determine if the component uses version 2 of the API
59
60
  */
@@ -110,12 +111,15 @@ export declare class UserLogin {
110
111
  isLoginLoading: boolean;
111
112
  isNativeApp: boolean;
112
113
  biometricsLoaded: boolean;
114
+ registrationPasswordLoading: boolean;
113
115
  host: HTMLElement;
114
116
  private errorCode;
115
117
  private stylingContainer?;
116
118
  private stylingSubscription;
117
119
  private captchaInstance;
118
120
  private captchaToken?;
121
+ private registrationPasswordValidator;
122
+ private registrationPasswordRequest;
119
123
  updateLoginCredentialsEvent?: CustomEvent;
120
124
  inputUserPhoneReference?: HTMLInputElement;
121
125
  /**
@@ -149,6 +153,7 @@ export declare class UserLogin {
149
153
  * @returns A Promise that resolves once the configuration is fetched and set.
150
154
  */
151
155
  getLoginConfig(): Promise<GM17CaptchaData>;
156
+ loadRegistrationPasswordValidation(): Promise<void>;
152
157
  private initializeCaptcha;
153
158
  private messageHandler;
154
159
  private checkNativeApp;
@@ -81,6 +81,7 @@ export namespace Components {
81
81
  * Cloudflare Turnstile site key. Acts as the enable/disable flag for Turnstile.
82
82
  */
83
83
  "turnstileSiteKey"?: string;
84
+ "useRegisPasswordCheck": boolean;
84
85
  /**
85
86
  * Regular expression for validating the user email
86
87
  */
@@ -184,6 +185,7 @@ declare namespace LocalJSX {
184
185
  * Cloudflare Turnstile site key. Acts as the enable/disable flag for Turnstile.
185
186
  */
186
187
  "turnstileSiteKey"?: string;
188
+ "useRegisPasswordCheck"?: boolean;
187
189
  /**
188
190
  * Regular expression for validating the user email
189
191
  */