@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.js CHANGED
@@ -834,6 +834,7 @@ var ModalRenderer = class {
834
834
  <p style="font-size:13px;color:var(--authon-muted);margin-bottom:20px">${email}</p>
835
835
  </div>
836
836
  <div class="email-form" id="verify-form">
837
+ <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>
837
838
  <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" />
838
839
  <button type="button" id="verify-submit" class="submit-btn">${this.t.signIn}</button>
839
840
  </div>
@@ -848,12 +849,30 @@ var ModalRenderer = class {
848
849
  codeInput?.addEventListener("input", () => {
849
850
  codeInput.value = codeInput.value.replace(/\D/g, "").slice(0, 6);
850
851
  });
852
+ const verifyError = this.shadowRoot.getElementById("verify-error");
851
853
  submitBtn?.addEventListener("click", async () => {
852
854
  const code = codeInput?.value?.trim();
853
855
  if (!code || code.length < 6) return;
856
+ if (verifyError) {
857
+ verifyError.style.display = "none";
858
+ }
854
859
  submitBtn.textContent = "...";
855
860
  submitBtn.disabled = true;
856
- await onVerify(code);
861
+ try {
862
+ await onVerify(code);
863
+ } catch (err) {
864
+ const msg = err instanceof Error ? err.message : String(err);
865
+ if (verifyError) {
866
+ verifyError.textContent = msg || "Verification failed";
867
+ verifyError.style.display = "block";
868
+ }
869
+ submitBtn.textContent = this.t.signIn;
870
+ submitBtn.disabled = false;
871
+ if (codeInput) {
872
+ codeInput.value = "";
873
+ codeInput.focus();
874
+ }
875
+ }
857
876
  });
858
877
  codeInput?.addEventListener("keydown", (e) => {
859
878
  if (e.key === "Enter") submitBtn?.click();
@@ -3447,13 +3466,8 @@ var Authon = class {
3447
3466
  if ("needsVerification" in result && result.needsVerification) {
3448
3467
  this.modal?.setSubmitLoading(false);
3449
3468
  this.modal?.showVerificationInput(email, async (code) => {
3450
- try {
3451
- await this.verifyEmail(email, code);
3452
- this.modal?.close();
3453
- } catch (err) {
3454
- const msg = err instanceof Error ? err.message : String(err);
3455
- this.modal?.showError(msg || "Verification failed");
3456
- }
3469
+ await this.verifyEmail(email, code);
3470
+ this.modal?.close();
3457
3471
  }, async () => {
3458
3472
  await this.resendVerificationCode(email);
3459
3473
  });
@@ -3472,13 +3486,8 @@ var Authon = class {
3472
3486
  if ("needsVerification" in result && result.needsVerification) {
3473
3487
  this.modal?.setSubmitLoading(false);
3474
3488
  this.modal?.showVerificationInput(email, async (code) => {
3475
- try {
3476
- await this.verifyEmail(email, code);
3477
- this.modal?.close();
3478
- } catch (err) {
3479
- const msg = err instanceof Error ? err.message : String(err);
3480
- this.modal?.showError(msg || "Verification failed");
3481
- }
3489
+ await this.verifyEmail(email, code);
3490
+ this.modal?.close();
3482
3491
  }, async () => {
3483
3492
  await this.resendVerificationCode(email);
3484
3493
  });