@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 +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -49,7 +49,10 @@ declare class Authon {
|
|
|
49
49
|
/** Update theme at runtime without destroying form state */
|
|
50
50
|
setTheme(theme: 'light' | 'dark' | 'auto'): void;
|
|
51
51
|
signInWithOAuth(provider: OAuthProviderType, options?: OAuthSignInOptions): Promise<void>;
|
|
52
|
-
signInWithEmail(email: string, password: string, turnstileToken?: string): Promise<AuthonUser
|
|
52
|
+
signInWithEmail(email: string, password: string, turnstileToken?: string): Promise<AuthonUser | {
|
|
53
|
+
needsVerification: true;
|
|
54
|
+
email: string;
|
|
55
|
+
}>;
|
|
53
56
|
signUpWithEmail(email: string, password: string, meta?: {
|
|
54
57
|
displayName?: string;
|
|
55
58
|
turnstileToken?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,7 +49,10 @@ declare class Authon {
|
|
|
49
49
|
/** Update theme at runtime without destroying form state */
|
|
50
50
|
setTheme(theme: 'light' | 'dark' | 'auto'): void;
|
|
51
51
|
signInWithOAuth(provider: OAuthProviderType, options?: OAuthSignInOptions): Promise<void>;
|
|
52
|
-
signInWithEmail(email: string, password: string, turnstileToken?: string): Promise<AuthonUser
|
|
52
|
+
signInWithEmail(email: string, password: string, turnstileToken?: string): Promise<AuthonUser | {
|
|
53
|
+
needsVerification: true;
|
|
54
|
+
email: string;
|
|
55
|
+
}>;
|
|
53
56
|
signUpWithEmail(email: string, password: string, meta?: {
|
|
54
57
|
displayName?: string;
|
|
55
58
|
turnstileToken?: string;
|
package/dist/index.js
CHANGED
|
@@ -3041,6 +3041,10 @@ var Authon = class {
|
|
|
3041
3041
|
"/v1/auth/signin",
|
|
3042
3042
|
body
|
|
3043
3043
|
);
|
|
3044
|
+
if (res.needsVerification) {
|
|
3045
|
+
this.emit("verificationRequired", res.email);
|
|
3046
|
+
return { needsVerification: true, email: res.email };
|
|
3047
|
+
}
|
|
3044
3048
|
if (res.mfaRequired && res.mfaToken) {
|
|
3045
3049
|
this.emit("mfaRequired", res.mfaToken);
|
|
3046
3050
|
throw new AuthonMfaRequiredError(res.mfaToken);
|
|
@@ -3445,7 +3449,23 @@ var Authon = class {
|
|
|
3445
3449
|
this.emit("error", err instanceof Error ? err : new Error(msg));
|
|
3446
3450
|
});
|
|
3447
3451
|
} else {
|
|
3448
|
-
this.signInWithEmail(email, password, turnstileToken).then(() =>
|
|
3452
|
+
this.signInWithEmail(email, password, turnstileToken).then((result) => {
|
|
3453
|
+
if ("needsVerification" in result && result.needsVerification) {
|
|
3454
|
+
this.modal?.showVerificationInput(email, async (code) => {
|
|
3455
|
+
try {
|
|
3456
|
+
await this.verifyEmail(email, code);
|
|
3457
|
+
this.modal?.close();
|
|
3458
|
+
} catch (err) {
|
|
3459
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
3460
|
+
this.modal?.showError(msg || "Verification failed");
|
|
3461
|
+
}
|
|
3462
|
+
}, async () => {
|
|
3463
|
+
await this.resendVerificationCode(email);
|
|
3464
|
+
});
|
|
3465
|
+
} else {
|
|
3466
|
+
this.modal?.close();
|
|
3467
|
+
}
|
|
3468
|
+
}).catch((err) => {
|
|
3449
3469
|
this.modal?.resetTurnstile?.();
|
|
3450
3470
|
const msg = err instanceof Error ? err.message : String(err);
|
|
3451
3471
|
this.modal?.showError(msg || "Authentication failed");
|