@contentgrowth/content-auth 0.2.5 → 0.2.6

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.
@@ -1104,6 +1104,23 @@ interface AuthConfig {
1104
1104
  * Defaults to true. Set to false to use Better Auth's default (Scrypt/Argon2).
1105
1105
  */
1106
1106
  useCloudflareNativeHashing?: boolean;
1107
+ /**
1108
+ * Email verification configuration.
1109
+ * For email/password signups, you can enable automatic verification emails.
1110
+ * OAuth signups (Google, GitHub) automatically set emailVerified = true.
1111
+ */
1112
+ emailVerification?: {
1113
+ /** Send verification email automatically on signup. Default: false */
1114
+ sendOnSignUp?: boolean;
1115
+ /** Auto sign in user after email verification. Default: true */
1116
+ autoSignInAfterVerification?: boolean;
1117
+ /** Callback to send verification email */
1118
+ sendVerificationEmail?: (data: {
1119
+ user: any;
1120
+ url: string;
1121
+ token: string;
1122
+ }, request: any) => Promise<void> | void;
1123
+ };
1107
1124
  [key: string]: any;
1108
1125
  }
1109
1126
  declare const createAuth: (config: AuthConfig) => better_auth.Auth<any>;
@@ -6,7 +6,7 @@ import {
6
6
  getInvitationLink,
7
7
  getSessionToken,
8
8
  schema_exports
9
- } from "../chunk-6DFIEMYG.js";
9
+ } from "../chunk-N5OK3XPK.js";
10
10
  import "../chunk-R5U7XKVJ.js";
11
11
  export {
12
12
  Hono,
@@ -201,7 +201,7 @@ var createAuth = (config) => {
201
201
  } else {
202
202
  db = config.database;
203
203
  }
204
- const { database, secret, baseUrl, provider: _, useCloudflareNativeHashing = true, ...rest } = config;
204
+ const { database, secret, baseUrl, provider: _, useCloudflareNativeHashing = true, emailVerification, ...rest } = config;
205
205
  let adapterOptions = {
206
206
  provider,
207
207
  schema: {
@@ -230,6 +230,8 @@ var createAuth = (config) => {
230
230
  secret,
231
231
  baseURL: baseUrl,
232
232
  emailAndPassword: emailPasswordOptions,
233
+ // Pass emailVerification config if provided
234
+ ...emailVerification ? { emailVerification } : {},
233
235
  ...otherOptions
234
236
  });
235
237
  return auth;
@@ -37,21 +37,22 @@ var AuthForm = ({
37
37
  setLoading(true);
38
38
  setError(null);
39
39
  try {
40
+ let response;
40
41
  if (isLogin) {
41
- const { error: error2 } = await client.signIn.email({
42
+ response = await client.signIn.email({
42
43
  email,
43
44
  password
44
45
  });
45
- if (error2) throw error2;
46
+ if (response.error) throw response.error;
46
47
  } else {
47
- const { error: error2 } = await client.signUp.email({
48
+ response = await client.signUp.email({
48
49
  email,
49
50
  password,
50
51
  name
51
52
  });
52
- if (error2) throw error2;
53
+ if (response.error) throw response.error;
53
54
  }
54
- onSuccess?.();
55
+ onSuccess?.(response.data);
55
56
  } catch (err) {
56
57
  setError(err.message || "An error occurred");
57
58
  } finally {
@@ -9,7 +9,7 @@ import 'better-auth/plugins';
9
9
  interface AuthFormProps {
10
10
  view?: 'signin' | 'signup';
11
11
  client?: typeof authClient;
12
- onSuccess?: () => void;
12
+ onSuccess?: (data?: any) => void;
13
13
  className?: string;
14
14
  socialProviders?: string[];
15
15
  socialLayout?: 'row' | 'column';
@@ -5,7 +5,7 @@ import {
5
5
  InviteMemberForm,
6
6
  OrganizationSwitcher,
7
7
  ResetPasswordForm
8
- } from "../chunk-7JTB52CI.js";
8
+ } from "../chunk-YXUGDZZK.js";
9
9
  import {
10
10
  authClient,
11
11
  createClient
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getInvitationLink,
7
7
  getSessionToken,
8
8
  schema_exports
9
- } from "./chunk-6DFIEMYG.js";
9
+ } from "./chunk-N5OK3XPK.js";
10
10
  import {
11
11
  AuthForm,
12
12
  CreateOrganizationForm,
@@ -14,7 +14,7 @@ import {
14
14
  InviteMemberForm,
15
15
  OrganizationSwitcher,
16
16
  ResetPasswordForm
17
- } from "./chunk-7JTB52CI.js";
17
+ } from "./chunk-YXUGDZZK.js";
18
18
  import {
19
19
  authClient,
20
20
  createClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentgrowth/content-auth",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Better Auth wrapper with UI components for Cloudflare Workers & Pages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",