@authon/js 0.7.0 → 0.7.1

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 CHANGED
@@ -3073,6 +3073,10 @@ var Authon = class {
3073
3073
  "/v1/auth/signin",
3074
3074
  body
3075
3075
  );
3076
+ if (res.needsVerification) {
3077
+ this.emit("verificationRequired", res.email);
3078
+ return { needsVerification: true, email: res.email };
3079
+ }
3076
3080
  if (res.mfaRequired && res.mfaToken) {
3077
3081
  this.emit("mfaRequired", res.mfaToken);
3078
3082
  throw new AuthonMfaRequiredError(res.mfaToken);
@@ -3477,7 +3481,23 @@ var Authon = class {
3477
3481
  this.emit("error", err instanceof Error ? err : new Error(msg));
3478
3482
  });
3479
3483
  } else {
3480
- this.signInWithEmail(email, password, turnstileToken).then(() => this.modal?.close()).catch((err) => {
3484
+ this.signInWithEmail(email, password, turnstileToken).then((result) => {
3485
+ if ("needsVerification" in result && result.needsVerification) {
3486
+ this.modal?.showVerificationInput(email, async (code) => {
3487
+ try {
3488
+ await this.verifyEmail(email, code);
3489
+ this.modal?.close();
3490
+ } catch (err) {
3491
+ const msg = err instanceof Error ? err.message : String(err);
3492
+ this.modal?.showError(msg || "Verification failed");
3493
+ }
3494
+ }, async () => {
3495
+ await this.resendVerificationCode(email);
3496
+ });
3497
+ } else {
3498
+ this.modal?.close();
3499
+ }
3500
+ }).catch((err) => {
3481
3501
  this.modal?.resetTurnstile?.();
3482
3502
  const msg = err instanceof Error ? err.message : String(err);
3483
3503
  this.modal?.showError(msg || "Authentication failed");