@authon/js 0.7.2 → 0.7.3
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/index.cjs +24 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -866,6 +866,7 @@ var ModalRenderer = class {
|
|
|
866
866
|
<p style="font-size:13px;color:var(--authon-muted);margin-bottom:20px">${email}</p>
|
|
867
867
|
</div>
|
|
868
868
|
<div class="email-form" id="verify-form">
|
|
869
|
+
<div id="verify-error" style="display:none;padding:8px 12px;background:rgba(239,68,68,0.1);border:1px solid rgba(239,68,68,0.3);border-radius:8px;font-size:13px;color:#ef4444;text-align:center;margin-bottom:4px"></div>
|
|
869
870
|
<input type="text" id="verify-code" class="input" placeholder="000000" maxlength="6" inputmode="numeric" autocomplete="one-time-code" style="text-align:center;font-size:20px;letter-spacing:0.2em;font-family:ui-monospace,monospace" />
|
|
870
871
|
<button type="button" id="verify-submit" class="submit-btn">${this.t.signIn}</button>
|
|
871
872
|
</div>
|
|
@@ -880,12 +881,30 @@ var ModalRenderer = class {
|
|
|
880
881
|
codeInput?.addEventListener("input", () => {
|
|
881
882
|
codeInput.value = codeInput.value.replace(/\D/g, "").slice(0, 6);
|
|
882
883
|
});
|
|
884
|
+
const verifyError = this.shadowRoot.getElementById("verify-error");
|
|
883
885
|
submitBtn?.addEventListener("click", async () => {
|
|
884
886
|
const code = codeInput?.value?.trim();
|
|
885
887
|
if (!code || code.length < 6) return;
|
|
888
|
+
if (verifyError) {
|
|
889
|
+
verifyError.style.display = "none";
|
|
890
|
+
}
|
|
886
891
|
submitBtn.textContent = "...";
|
|
887
892
|
submitBtn.disabled = true;
|
|
888
|
-
|
|
893
|
+
try {
|
|
894
|
+
await onVerify(code);
|
|
895
|
+
} catch (err) {
|
|
896
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
897
|
+
if (verifyError) {
|
|
898
|
+
verifyError.textContent = msg || "Verification failed";
|
|
899
|
+
verifyError.style.display = "block";
|
|
900
|
+
}
|
|
901
|
+
submitBtn.textContent = this.t.signIn;
|
|
902
|
+
submitBtn.disabled = false;
|
|
903
|
+
if (codeInput) {
|
|
904
|
+
codeInput.value = "";
|
|
905
|
+
codeInput.focus();
|
|
906
|
+
}
|
|
907
|
+
}
|
|
889
908
|
});
|
|
890
909
|
codeInput?.addEventListener("keydown", (e) => {
|
|
891
910
|
if (e.key === "Enter") submitBtn?.click();
|
|
@@ -3479,13 +3498,8 @@ var Authon = class {
|
|
|
3479
3498
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3480
3499
|
this.modal?.setSubmitLoading(false);
|
|
3481
3500
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
this.modal?.close();
|
|
3485
|
-
} catch (err) {
|
|
3486
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
3487
|
-
this.modal?.showError(msg || "Verification failed");
|
|
3488
|
-
}
|
|
3501
|
+
await this.verifyEmail(email, code);
|
|
3502
|
+
this.modal?.close();
|
|
3489
3503
|
}, async () => {
|
|
3490
3504
|
await this.resendVerificationCode(email);
|
|
3491
3505
|
});
|
|
@@ -3504,13 +3518,8 @@ var Authon = class {
|
|
|
3504
3518
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3505
3519
|
this.modal?.setSubmitLoading(false);
|
|
3506
3520
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
this.modal?.close();
|
|
3510
|
-
} catch (err) {
|
|
3511
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
3512
|
-
this.modal?.showError(msg || "Verification failed");
|
|
3513
|
-
}
|
|
3521
|
+
await this.verifyEmail(email, code);
|
|
3522
|
+
this.modal?.close();
|
|
3514
3523
|
}, async () => {
|
|
3515
3524
|
await this.resendVerificationCode(email);
|
|
3516
3525
|
});
|