@everymatrix/user-login 1.94.21 → 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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/user-login.cjs.entry.js +129 -211
- package/dist/cjs/user-login.cjs.js +1 -1
- package/dist/collection/components/user-login/user-login.js +20 -54
- package/dist/collection/utils/utils.js +0 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/user-login.entry.js +129 -211
- package/dist/esm/user-login.js +1 -1
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/user-login/.stencil/libs/common/src/captcha/google/index.d.ts +1 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/user-login/.stencil/libs/common/src/captcha/index.d.ts +5 -4
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/user-login/.stencil/libs/common/src/captcha/turnstile/index.d.ts +2 -38
- package/dist/types/components/user-login/user-login.d.ts +0 -10
- package/dist/types/components.d.ts +0 -16
- package/dist/types/utils/utils.d.ts +0 -1
- package/dist/user-login/user-login.entry.js +241 -241
- package/dist/user-login/user-login.esm.js +1 -1
- package/package.json +1 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -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"],"
|
|
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);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -514,11 +514,21 @@ const getSlottedElement = (host, slotName) => {
|
|
|
514
514
|
host.shadowRoot?.querySelector(`slot[name="${slotName}"]`)
|
|
515
515
|
);
|
|
516
516
|
|
|
517
|
-
if (!slot)
|
|
517
|
+
if (!slot) {
|
|
518
|
+
console.error(`[${host.tagName.toLowerCase()}] slot "${slotName}" not found.`);
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
518
521
|
|
|
519
|
-
|
|
522
|
+
const assignedElement = /** @type {HTMLElement | null} */ (
|
|
520
523
|
slot.assignedElements?.()[0] ?? null
|
|
521
524
|
);
|
|
525
|
+
|
|
526
|
+
if (!assignedElement) {
|
|
527
|
+
console.error( `[${host.tagName.toLowerCase()}] no element assigned to slot "${slotName}".`);
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return assignedElement;
|
|
522
532
|
};
|
|
523
533
|
|
|
524
534
|
/**
|
|
@@ -541,6 +551,8 @@ const dispatchCustomEvent = (type, data = {}) => {
|
|
|
541
551
|
};
|
|
542
552
|
|
|
543
553
|
const SCRIPT_SRC$1 = 'https://www.google.com/recaptcha/api.js';
|
|
554
|
+
const SCRIPT_LOAD_TIMEOUT_MS$1 = 5000;
|
|
555
|
+
const RECAPTCHA_TOKEN_RESPONSE_HEADER = 'g-recaptcha-response';
|
|
544
556
|
let scriptPromise$1 = null;
|
|
545
557
|
function loadRecaptcha() {
|
|
546
558
|
var _a;
|
|
@@ -557,11 +569,16 @@ function loadRecaptcha() {
|
|
|
557
569
|
script.async = true;
|
|
558
570
|
script.defer = true;
|
|
559
571
|
script.onload = () => {
|
|
572
|
+
const deadline = Date.now() + SCRIPT_LOAD_TIMEOUT_MS$1;
|
|
560
573
|
const check = () => {
|
|
561
574
|
var _a;
|
|
562
575
|
if ((_a = window.grecaptcha) === null || _a === void 0 ? void 0 : _a.render) {
|
|
563
576
|
resolve();
|
|
564
577
|
}
|
|
578
|
+
else if (Date.now() > deadline) {
|
|
579
|
+
scriptPromise$1 = null;
|
|
580
|
+
reject(new Error('[reCAPTCHA] timed out waiting for grecaptcha'));
|
|
581
|
+
}
|
|
565
582
|
else {
|
|
566
583
|
setTimeout(check, 50);
|
|
567
584
|
}
|
|
@@ -605,28 +622,37 @@ function createRecaptcha(options) {
|
|
|
605
622
|
}
|
|
606
623
|
|
|
607
624
|
const SCRIPT_SRC = 'https://challenges.cloudflare.com/turnstile/v0/api.js';
|
|
608
|
-
const RESET_COOL_DOWN_MS = 3000;
|
|
609
625
|
const RETRY_INTERVAL_MS = 3000;
|
|
610
626
|
const DEFAULT_RETRY_COUNT = 5;
|
|
627
|
+
const SCRIPT_LOAD_TIMEOUT_MS = 10000;
|
|
628
|
+
const TURNSTILE_TOKEN_EXPIRY_MS = 5 * 60 * 1000;
|
|
611
629
|
const DUMMY_TURNSTILE_RESPONSE = 'XXXX.DUMMY.TOKEN.XXXX';
|
|
612
|
-
|
|
630
|
+
const TURNSTILE_TOKEN_RESPONSE_HEADER = 'cf-captcha-response';
|
|
631
|
+
const TURNSTILE_IS_VISIBLE_HEADER = 'cfCaptchaIsVisible';
|
|
613
632
|
let scriptPromise = null;
|
|
614
633
|
function loadTurnstile() {
|
|
615
634
|
if (typeof window === 'undefined') {
|
|
616
635
|
return Promise.reject(new Error('[Turnstile] SSR'));
|
|
617
636
|
}
|
|
618
|
-
if (window.turnstile)
|
|
637
|
+
if (window.turnstile)
|
|
619
638
|
return Promise.resolve();
|
|
620
|
-
}
|
|
621
639
|
if (!scriptPromise) {
|
|
622
640
|
scriptPromise = new Promise((resolve, reject) => {
|
|
641
|
+
const timeout = setTimeout(() => {
|
|
642
|
+
scriptPromise = null;
|
|
643
|
+
reject(new Error('[Turnstile] script load timeout'));
|
|
644
|
+
}, SCRIPT_LOAD_TIMEOUT_MS);
|
|
623
645
|
const script = document.createElement('script');
|
|
624
646
|
script.src = SCRIPT_SRC;
|
|
625
647
|
script.async = true;
|
|
626
648
|
script.defer = true;
|
|
627
|
-
script.onload = () =>
|
|
649
|
+
script.onload = () => {
|
|
650
|
+
clearTimeout(timeout);
|
|
651
|
+
resolve();
|
|
652
|
+
};
|
|
628
653
|
script.onerror = () => {
|
|
629
|
-
|
|
654
|
+
clearTimeout(timeout);
|
|
655
|
+
scriptPromise = null;
|
|
630
656
|
reject(new Error('[Turnstile] script failed to load'));
|
|
631
657
|
};
|
|
632
658
|
document.head.appendChild(script);
|
|
@@ -634,159 +660,78 @@ function loadTurnstile() {
|
|
|
634
660
|
}
|
|
635
661
|
return scriptPromise;
|
|
636
662
|
}
|
|
637
|
-
/**
|
|
638
|
-
* Creates a self-contained Cloudflare Turnstile controller for use in any
|
|
639
|
-
* framework (Stencil, Vue, Svelte, vanilla TS). Mirrors the behavior of the
|
|
640
|
-
* React `useTurnstile` hook used in the Flash project.
|
|
641
|
-
*
|
|
642
|
-
* Typical lifecycle:
|
|
643
|
-
* 1. Call `render(containerEl)` in your mount/componentDidLoad — loads the
|
|
644
|
-
* script and renders an invisible widget.
|
|
645
|
-
* 2. On form submit, `await ensureToken()` to get (or obtain) a token.
|
|
646
|
-
* 3. Call `cleanup()` in your unmount/disconnectedCallback.
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* ```ts
|
|
650
|
-
* const turnstile = createTurnstile({
|
|
651
|
-
* siteKey: 'YOUR_SITE_KEY',
|
|
652
|
-
* action: 'login',
|
|
653
|
-
* onLoadingChange: (loading) => { this.isTurnstileLoading = loading; },
|
|
654
|
-
* });
|
|
655
|
-
*
|
|
656
|
-
* // in componentDidLoad
|
|
657
|
-
* await turnstile.render(this.turnstileContainerEl);
|
|
658
|
-
*
|
|
659
|
-
* // in handleSubmit
|
|
660
|
-
* const token = await turnstile.ensureToken();
|
|
661
|
-
* headers['X-Captcha-Response'] = token;
|
|
662
|
-
*
|
|
663
|
-
* // in disconnectedCallback
|
|
664
|
-
* turnstile.cleanup();
|
|
665
|
-
* ```
|
|
666
|
-
*/
|
|
667
663
|
function createTurnstile(options) {
|
|
668
664
|
const { siteKey, action, isEnabled = true, enableFallback = false, retryCount = DEFAULT_RETRY_COUNT } = options;
|
|
669
665
|
let token = null;
|
|
666
|
+
let tokenIssuedAt = 0;
|
|
670
667
|
let widgetId;
|
|
671
668
|
let container;
|
|
672
|
-
let
|
|
673
|
-
let currentPromise = null;
|
|
674
|
-
let shouldReset = false;
|
|
675
|
-
let lastResetAt = 0;
|
|
669
|
+
let isDestroyed = false;
|
|
676
670
|
let errorCount = 0;
|
|
671
|
+
let resolveToken = null;
|
|
672
|
+
let rejectToken = null;
|
|
677
673
|
function setToken(value) {
|
|
678
674
|
var _a;
|
|
679
675
|
token = value;
|
|
676
|
+
if (value)
|
|
677
|
+
tokenIssuedAt = Date.now();
|
|
680
678
|
(_a = options.onTokenChange) === null || _a === void 0 ? void 0 : _a.call(options, value);
|
|
681
679
|
}
|
|
682
|
-
function setLoading(value) {
|
|
683
|
-
var _a;
|
|
684
|
-
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, value);
|
|
685
|
-
}
|
|
686
|
-
function isWidgetReady() {
|
|
687
|
-
return !!window.turnstile && !!widgetId;
|
|
688
|
-
}
|
|
689
|
-
function handleVerificationSuccess(receivedToken) {
|
|
690
|
-
const pending = pendingRequest;
|
|
691
|
-
if (pending) {
|
|
692
|
-
if (pending.retryTimerId != null)
|
|
693
|
-
clearTimeout(pending.retryTimerId);
|
|
694
|
-
pending.resolve(receivedToken);
|
|
695
|
-
pendingRequest = null;
|
|
696
|
-
}
|
|
697
|
-
setToken(receivedToken);
|
|
698
|
-
setLoading(false);
|
|
699
|
-
shouldReset = false;
|
|
700
|
-
if (enableFallback)
|
|
701
|
-
errorCount = 0;
|
|
702
|
-
}
|
|
703
|
-
function scheduleNextExecute() {
|
|
704
|
-
const pending = pendingRequest;
|
|
705
|
-
if (!pending || !widgetId || !window.turnstile)
|
|
706
|
-
return;
|
|
707
|
-
pending.retryTimerId = setTimeout(() => {
|
|
708
|
-
if (!pendingRequest || !widgetId || !window.turnstile)
|
|
709
|
-
return;
|
|
710
|
-
errorCount += 1;
|
|
711
|
-
if (errorCount >= retryCount) {
|
|
712
|
-
if (pending.retryTimerId != null) {
|
|
713
|
-
clearTimeout(pending.retryTimerId);
|
|
714
|
-
}
|
|
715
|
-
try {
|
|
716
|
-
if (widgetId && window.turnstile) {
|
|
717
|
-
window.turnstile.reset(widgetId);
|
|
718
|
-
lastResetAt = Date.now();
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
catch (e) {
|
|
722
|
-
console.warn('[Turnstile] final reset failed', e);
|
|
723
|
-
}
|
|
724
|
-
setLoading(false);
|
|
725
|
-
shouldReset = false;
|
|
726
|
-
if (enableFallback) {
|
|
727
|
-
handleVerificationSuccess(DUMMY_TURNSTILE_RESPONSE);
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
pendingRequest = null;
|
|
731
|
-
currentPromise = null;
|
|
732
|
-
errorCount = 0;
|
|
733
|
-
pending.reject(new Error('[Turnstile] Verification failed. Please try again.'));
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
const now = Date.now();
|
|
737
|
-
if (shouldReset && now - lastResetAt >= RESET_COOL_DOWN_MS) {
|
|
738
|
-
try {
|
|
739
|
-
window.turnstile.reset(widgetId);
|
|
740
|
-
lastResetAt = now;
|
|
741
|
-
}
|
|
742
|
-
catch (e) {
|
|
743
|
-
console.warn('[Turnstile] reset error', e);
|
|
744
|
-
}
|
|
745
|
-
finally {
|
|
746
|
-
shouldReset = false;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
try {
|
|
750
|
-
window.turnstile.execute(widgetId);
|
|
751
|
-
}
|
|
752
|
-
catch (e) {
|
|
753
|
-
console.warn('[Turnstile] execute threw -> reschedule', e);
|
|
754
|
-
scheduleNextExecute();
|
|
755
|
-
}
|
|
756
|
-
}, RETRY_INTERVAL_MS);
|
|
757
|
-
}
|
|
758
680
|
function renderWidget() {
|
|
759
681
|
if (widgetId || !container || !window.turnstile)
|
|
760
682
|
return;
|
|
761
|
-
shouldReset = false;
|
|
762
683
|
widgetId = window.turnstile.render(container, {
|
|
763
684
|
sitekey: siteKey,
|
|
764
|
-
retry: '
|
|
685
|
+
retry: 'auto',
|
|
765
686
|
action,
|
|
766
687
|
appearance: 'interaction-only',
|
|
767
688
|
execution: 'execute',
|
|
768
|
-
|
|
769
|
-
'
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
689
|
+
theme: 'light',
|
|
690
|
+
'retry-interval': RETRY_INTERVAL_MS,
|
|
691
|
+
callback: (receivedToken) => {
|
|
692
|
+
var _a;
|
|
693
|
+
if (isDestroyed)
|
|
694
|
+
return;
|
|
695
|
+
errorCount = 0;
|
|
696
|
+
setToken(receivedToken);
|
|
697
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, false);
|
|
698
|
+
resolveToken === null || resolveToken === void 0 ? void 0 : resolveToken(receivedToken);
|
|
699
|
+
resolveToken = null;
|
|
700
|
+
rejectToken = null;
|
|
701
|
+
},
|
|
702
|
+
'error-callback': (errorCode) => {
|
|
703
|
+
var _a;
|
|
704
|
+
if (isDestroyed)
|
|
705
|
+
return true;
|
|
706
|
+
errorCount += 1;
|
|
707
|
+
if (errorCount <= retryCount) {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
errorCount = 0;
|
|
711
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, false);
|
|
712
|
+
if (widgetId && window.turnstile) {
|
|
713
|
+
try {
|
|
714
|
+
window.turnstile.reset(widgetId);
|
|
715
|
+
}
|
|
716
|
+
catch (_b) { }
|
|
717
|
+
}
|
|
718
|
+
if (enableFallback) {
|
|
719
|
+
resolveToken === null || resolveToken === void 0 ? void 0 : resolveToken(DUMMY_TURNSTILE_RESPONSE);
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
const error = `[Turnstile] Verification failed (${errorCode}). Please try again.`;
|
|
723
|
+
console.error(error);
|
|
724
|
+
rejectToken === null || rejectToken === void 0 ? void 0 : rejectToken(new Error(error));
|
|
725
|
+
}
|
|
726
|
+
resolveToken = null;
|
|
727
|
+
rejectToken = null;
|
|
728
|
+
return true;
|
|
773
729
|
},
|
|
774
730
|
'expired-callback': () => {
|
|
775
731
|
setToken(null);
|
|
776
|
-
shouldReset = true;
|
|
777
|
-
},
|
|
778
|
-
'timeout-callback': () => {
|
|
779
|
-
if (pendingRequest) {
|
|
780
|
-
shouldReset = true;
|
|
781
|
-
scheduleNextExecute();
|
|
782
|
-
}
|
|
783
732
|
}
|
|
784
733
|
});
|
|
785
734
|
}
|
|
786
|
-
/**
|
|
787
|
-
* Loads the Turnstile script (once) and renders the invisible widget into
|
|
788
|
-
* `hostContainer`. Safe to call before the script is available.
|
|
789
|
-
*/
|
|
790
735
|
async function render(hostContainer) {
|
|
791
736
|
var _a;
|
|
792
737
|
if (!isEnabled)
|
|
@@ -801,101 +746,71 @@ function createTurnstile(options) {
|
|
|
801
746
|
console.error('[Turnstile] script load error', err);
|
|
802
747
|
}
|
|
803
748
|
}
|
|
804
|
-
/**
|
|
805
|
-
* Executes the challenge and returns a token Promise. If a request is already
|
|
806
|
-
* in-flight the same Promise is returned (no duplicate challenges).
|
|
807
|
-
*/
|
|
808
749
|
async function getToken() {
|
|
750
|
+
var _a;
|
|
809
751
|
if (!isEnabled)
|
|
810
752
|
return undefined;
|
|
811
|
-
if (!
|
|
753
|
+
if (!widgetId) {
|
|
812
754
|
await loadTurnstile();
|
|
813
755
|
renderWidget();
|
|
814
|
-
if (!
|
|
756
|
+
if (!widgetId)
|
|
815
757
|
throw new Error('[Turnstile] widget not ready');
|
|
816
|
-
}
|
|
817
758
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
759
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, true);
|
|
760
|
+
return new Promise((resolve, reject) => {
|
|
761
|
+
var _a;
|
|
762
|
+
resolveToken = resolve;
|
|
763
|
+
rejectToken = reject;
|
|
823
764
|
try {
|
|
824
765
|
window.turnstile.execute(widgetId);
|
|
825
766
|
}
|
|
826
767
|
catch (e) {
|
|
827
768
|
console.error('[Turnstile] execute error', e);
|
|
828
|
-
|
|
769
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, false);
|
|
770
|
+
resolveToken = null;
|
|
771
|
+
rejectToken = null;
|
|
772
|
+
reject(e);
|
|
829
773
|
}
|
|
830
|
-
}).finally(() => {
|
|
831
|
-
if (currentPromise === promise)
|
|
832
|
-
currentPromise = null;
|
|
833
774
|
});
|
|
834
|
-
currentPromise = promise;
|
|
835
|
-
return promise;
|
|
836
775
|
}
|
|
837
|
-
/**
|
|
838
|
-
* Returns the cached token immediately if still valid; otherwise calls
|
|
839
|
-
* `getToken()`. Prefer this on form submit.
|
|
840
|
-
*/
|
|
841
776
|
async function ensureToken() {
|
|
842
777
|
if (!isEnabled)
|
|
843
778
|
return undefined;
|
|
844
|
-
if (token)
|
|
779
|
+
if (token && Date.now() - tokenIssuedAt < TURNSTILE_TOKEN_EXPIRY_MS)
|
|
845
780
|
return token;
|
|
846
781
|
return getToken();
|
|
847
782
|
}
|
|
848
|
-
/**
|
|
849
|
-
* Resets the widget state and rejects any in-flight token promise.
|
|
850
|
-
* Call after a failed login attempt so the next submit gets a fresh token.
|
|
851
|
-
*/
|
|
852
783
|
function reset() {
|
|
784
|
+
var _a;
|
|
853
785
|
if (widgetId && window.turnstile) {
|
|
854
786
|
try {
|
|
855
787
|
window.turnstile.reset(widgetId);
|
|
856
|
-
lastResetAt = Date.now();
|
|
857
|
-
}
|
|
858
|
-
catch (_a) {
|
|
859
|
-
/* ignore */
|
|
860
788
|
}
|
|
789
|
+
catch (_b) { }
|
|
861
790
|
}
|
|
862
|
-
|
|
863
|
-
const pending = pendingRequest;
|
|
864
|
-
if (pending.retryTimerId != null)
|
|
865
|
-
clearTimeout(pending.retryTimerId);
|
|
866
|
-
pending.reject(new Error('[Turnstile] reset by caller'));
|
|
867
|
-
pendingRequest = null;
|
|
868
|
-
}
|
|
869
|
-
shouldReset = false;
|
|
870
|
-
currentPromise = null;
|
|
871
|
-
setLoading(false);
|
|
791
|
+
errorCount = 0;
|
|
872
792
|
setToken(null);
|
|
793
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, false);
|
|
794
|
+
rejectToken === null || rejectToken === void 0 ? void 0 : rejectToken(new Error('[Turnstile] reset by caller'));
|
|
795
|
+
resolveToken = null;
|
|
796
|
+
rejectToken = null;
|
|
873
797
|
}
|
|
874
|
-
/**
|
|
875
|
-
* Removes the widget from the DOM and rejects any pending promise.
|
|
876
|
-
* Call in `disconnectedCallback` / component unmount.
|
|
877
|
-
*/
|
|
878
798
|
function cleanup() {
|
|
879
|
-
|
|
880
|
-
|
|
799
|
+
var _a;
|
|
800
|
+
isDestroyed = true;
|
|
801
|
+
if (widgetId && window.turnstile) {
|
|
802
|
+
try {
|
|
881
803
|
window.turnstile.remove(widgetId);
|
|
882
804
|
}
|
|
805
|
+
catch (_b) { }
|
|
883
806
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
const pending = pendingRequest;
|
|
889
|
-
if (pending.retryTimerId != null)
|
|
890
|
-
clearTimeout(pending.retryTimerId);
|
|
891
|
-
pending.reject(new Error('[Turnstile] widget destroyed'));
|
|
892
|
-
pendingRequest = null;
|
|
893
|
-
}
|
|
807
|
+
errorCount = 0;
|
|
808
|
+
rejectToken === null || rejectToken === void 0 ? void 0 : rejectToken(null);
|
|
809
|
+
resolveToken = null;
|
|
810
|
+
rejectToken = null;
|
|
894
811
|
widgetId = undefined;
|
|
895
|
-
shouldReset = false;
|
|
896
|
-
currentPromise = null;
|
|
897
|
-
setLoading(false);
|
|
898
812
|
setToken(null);
|
|
813
|
+
(_a = options.onLoadingChange) === null || _a === void 0 ? void 0 : _a.call(options, false);
|
|
899
814
|
}
|
|
900
815
|
return { render, getToken, ensureToken, reset, cleanup };
|
|
901
816
|
}
|
|
@@ -7608,7 +7523,7 @@ const UserLogin = class {
|
|
|
7608
7523
|
* Login API call for Gm 1.7
|
|
7609
7524
|
*/
|
|
7610
7525
|
this.userLoginGm17 = async () => {
|
|
7611
|
-
var _a, _b, _c;
|
|
7526
|
+
var _a, _b, _c, _d, _e;
|
|
7612
7527
|
let headers = {
|
|
7613
7528
|
'Content-Type': 'application/json'
|
|
7614
7529
|
};
|
|
@@ -7620,11 +7535,13 @@ const UserLogin = class {
|
|
|
7620
7535
|
let token;
|
|
7621
7536
|
if (typeof ((_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.ensureToken) === "function") {
|
|
7622
7537
|
token = await ((_c = (_b = this.captchaInstance) === null || _b === void 0 ? void 0 : _b.ensureToken) === null || _c === void 0 ? void 0 : _c.call(_b));
|
|
7538
|
+
headers[TURNSTILE_TOKEN_RESPONSE_HEADER] = token !== null && token !== void 0 ? token : "";
|
|
7539
|
+
headers[TURNSTILE_IS_VISIBLE_HEADER] = "false";
|
|
7623
7540
|
}
|
|
7624
7541
|
else {
|
|
7625
7542
|
token = this.captchaToken;
|
|
7543
|
+
headers[RECAPTCHA_TOKEN_RESPONSE_HEADER] = token !== null && token !== void 0 ? token : "";
|
|
7626
7544
|
}
|
|
7627
|
-
headers['cf-captcha-response'] = token !== null && token !== void 0 ? token : "";
|
|
7628
7545
|
}
|
|
7629
7546
|
const options = {
|
|
7630
7547
|
method: 'POST',
|
|
@@ -7653,6 +7570,7 @@ const UserLogin = class {
|
|
|
7653
7570
|
}
|
|
7654
7571
|
finally {
|
|
7655
7572
|
this.isLoginLoading = false;
|
|
7573
|
+
(_e = (_d = this.captchaInstance) === null || _d === void 0 ? void 0 : _d.reset) === null || _e === void 0 ? void 0 : _e.call(_d);
|
|
7656
7574
|
}
|
|
7657
7575
|
};
|
|
7658
7576
|
/**
|
|
@@ -7715,15 +7633,17 @@ const UserLogin = class {
|
|
|
7715
7633
|
try {
|
|
7716
7634
|
const turnstileToken = await ((_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.ensureToken) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
7717
7635
|
if (turnstileToken) {
|
|
7718
|
-
headers.append(
|
|
7719
|
-
headers.append(
|
|
7636
|
+
headers.append(TURNSTILE_TOKEN_RESPONSE_HEADER, turnstileToken);
|
|
7637
|
+
headers.append(TURNSTILE_IS_VISIBLE_HEADER, 'false');
|
|
7720
7638
|
}
|
|
7721
7639
|
}
|
|
7722
7640
|
catch (error) {
|
|
7723
7641
|
this.hasError = true;
|
|
7724
|
-
this.errorMessage = translate('genericError', this.lang) || `${error}`;
|
|
7725
|
-
this.sendErrorNotification(this.errorMessage);
|
|
7726
7642
|
this.isLoginLoading = false;
|
|
7643
|
+
if (error !== null) {
|
|
7644
|
+
this.errorMessage = translate('genericError', this.lang) || `${error}`;
|
|
7645
|
+
this.sendErrorNotification(this.errorMessage);
|
|
7646
|
+
}
|
|
7727
7647
|
return;
|
|
7728
7648
|
}
|
|
7729
7649
|
}
|
|
@@ -7788,7 +7708,9 @@ const UserLogin = class {
|
|
|
7788
7708
|
this.sendErrorNotification(this.errorMessage);
|
|
7789
7709
|
})
|
|
7790
7710
|
.finally(() => {
|
|
7711
|
+
var _a, _b;
|
|
7791
7712
|
this.isLoginLoading = false;
|
|
7713
|
+
(_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.reset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
7792
7714
|
});
|
|
7793
7715
|
};
|
|
7794
7716
|
/**
|
|
@@ -7909,8 +7831,6 @@ const UserLogin = class {
|
|
|
7909
7831
|
this.biometricactionmode = 'switch';
|
|
7910
7832
|
this.isFromLogin = true;
|
|
7911
7833
|
this.turnstileSiteKey = undefined;
|
|
7912
|
-
this.turnstileEnableFallback = false;
|
|
7913
|
-
this.turnstileRetryCount = undefined;
|
|
7914
7834
|
this.userNameEmail = '';
|
|
7915
7835
|
this.userPassword = '';
|
|
7916
7836
|
this.isValidUserEmail = true;
|
|
@@ -7926,7 +7846,6 @@ const UserLogin = class {
|
|
|
7926
7846
|
this.isLoginLoading = false;
|
|
7927
7847
|
this.isNativeApp = false;
|
|
7928
7848
|
this.biometricsLoaded = false;
|
|
7929
|
-
this.isTurnstileLoading = false;
|
|
7930
7849
|
}
|
|
7931
7850
|
/**
|
|
7932
7851
|
* Watch for changes in the translation URL and fetch new translations
|
|
@@ -8027,7 +7946,6 @@ const UserLogin = class {
|
|
|
8027
7946
|
isEnabled: true,
|
|
8028
7947
|
provider: "cloudflare",
|
|
8029
7948
|
siteKey: this.turnstileSiteKey,
|
|
8030
|
-
enableFallback: this.turnstileEnableFallback
|
|
8031
7949
|
});
|
|
8032
7950
|
}
|
|
8033
7951
|
}
|
|
@@ -8060,8 +7978,7 @@ const UserLogin = class {
|
|
|
8060
7978
|
});
|
|
8061
7979
|
}
|
|
8062
7980
|
async initializeCaptcha({ provider, siteKey, enableFallback }) {
|
|
8063
|
-
const
|
|
8064
|
-
this.captchaContainerEl = slotElement;
|
|
7981
|
+
const captchaContainerEl = getSlottedElement(this.host, CAPTCHA_CONTAINER_SLOT);
|
|
8065
7982
|
const captchaCreator = {
|
|
8066
7983
|
"google": createRecaptcha,
|
|
8067
7984
|
"cloudflare": createTurnstile
|
|
@@ -8072,7 +7989,7 @@ const UserLogin = class {
|
|
|
8072
7989
|
enableFallback,
|
|
8073
7990
|
callback: provider === "google" ? (token) => { this.captchaToken = token; } : undefined
|
|
8074
7991
|
});
|
|
8075
|
-
await this.captchaInstance.render(
|
|
7992
|
+
await this.captchaInstance.render(captchaContainerEl);
|
|
8076
7993
|
}
|
|
8077
7994
|
/**
|
|
8078
7995
|
* Lifecycle method: Clean up event listeners when the component is removed
|
|
@@ -8082,7 +7999,8 @@ const UserLogin = class {
|
|
|
8082
7999
|
this.stylingSubscription && this.stylingSubscription.unsubscribe();
|
|
8083
8000
|
window.removeEventListener('LoginCredentials', this.autofillCredentialsHandler);
|
|
8084
8001
|
window.removeEventListener('message', this.messageHandler);
|
|
8085
|
-
|
|
8002
|
+
if (this.turnstileSiteKey)
|
|
8003
|
+
(_b = (_a = this.captchaInstance) === null || _a === void 0 ? void 0 : _a.cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
8086
8004
|
}
|
|
8087
8005
|
/**
|
|
8088
8006
|
* Send error notification as a post message
|
|
@@ -8164,7 +8082,7 @@ const UserLogin = class {
|
|
|
8164
8082
|
* Render function
|
|
8165
8083
|
*/
|
|
8166
8084
|
render() {
|
|
8167
|
-
return (index.h("section", { key: '
|
|
8085
|
+
return (index.h("section", { key: 'd53f60a484827fbb28b2ec8a907ac21e0781427a', ref: el => this.stylingContainer = el }, this.renderUserIdentification(), index.h("slot", { key: '8b42ec462b580ffb0d1448bbe185febada0bcd22', name: CAPTCHA_CONTAINER_SLOT })));
|
|
8168
8086
|
}
|
|
8169
8087
|
get host() { return index.getElement(this); }
|
|
8170
8088
|
static get watchers() { return {
|
|
@@ -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"],"
|
|
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);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|