zitejs 0.9.78 → 0.9.80

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.
@@ -250,11 +250,11 @@ export declare function logout(opts?: {
250
250
  export type User = {
251
251
  id: string;
252
252
  name: string;
253
+ firstName?: string;
254
+ lastName?: string;
253
255
  email: string;
254
256
  emailVerified: boolean;
255
257
  image?: string | null;
256
- firstName?: string;
257
- lastName?: string;
258
258
  createdAt: Date;
259
259
  updatedAt: Date;
260
260
  };
@@ -11,6 +11,8 @@ const authClient = (0, react_1.createAuthClient)({
11
11
  });
12
12
  exports.useSession = authClient.useSession, exports.signIn = authClient.signIn, exports.signOut = authClient.signOut, exports.signUp = authClient.signUp;
13
13
  function loginWithRedirect(opts) {
14
+ if (window.location.pathname.startsWith('/auth/'))
15
+ return;
14
16
  const params = new URLSearchParams();
15
17
  if (opts?.redirectUrl)
16
18
  params.set('redirectUrl', opts.redirectUrl);
@@ -2,8 +2,8 @@ export interface ZiteAuthUser {
2
2
  id: string;
3
3
  email: string;
4
4
  name: string;
5
- firstName?: string;
6
- lastName?: string;
5
+ firstName: string;
6
+ lastName: string;
7
7
  }
8
8
  import type { ZiteAuthMethods } from '../auth/index.js';
9
9
  export type { ZiteAuthMethods };
@@ -34,7 +34,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
34
34
  max: number;
35
35
  };
36
36
  emailAndPassword: {
37
- enabled: boolean;
37
+ enabled: true;
38
38
  };
39
39
  plugins: {
40
40
  id: "generic-oauth";
@@ -223,7 +223,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
223
223
  databaseHooks: {
224
224
  user: {
225
225
  create: {
226
- before: ((user: {
226
+ before: (user: {
227
227
  id: string;
228
228
  createdAt: Date;
229
229
  updatedAt: Date;
@@ -231,7 +231,19 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
231
231
  emailVerified: boolean;
232
232
  name: string;
233
233
  image?: string | null | undefined;
234
- } & Record<string, unknown>) => Promise<undefined>) | undefined;
234
+ } & Record<string, unknown>) => Promise<{
235
+ data: {
236
+ firstName: string;
237
+ lastName: string;
238
+ id: string;
239
+ createdAt: Date;
240
+ updatedAt: Date;
241
+ email: string;
242
+ emailVerified: boolean;
243
+ name: string;
244
+ image?: string | null | undefined;
245
+ };
246
+ } | undefined>;
235
247
  after: ((user: {
236
248
  id: string;
237
249
  createdAt: Date;
@@ -58,7 +58,7 @@ function ziteAuth(config = {}) {
58
58
  baseURL: 'http://localhost',
59
59
  advanced: { disableCSRFCheck: true },
60
60
  rateLimit: { window: 60, max: 10 },
61
- emailAndPassword: { enabled: methods.emailPassword !== false },
61
+ emailAndPassword: { enabled: true },
62
62
  plugins,
63
63
  user: {
64
64
  modelName: 'zite_user',
@@ -73,23 +73,35 @@ function ziteAuth(config = {}) {
73
73
  databaseHooks: {
74
74
  user: {
75
75
  create: {
76
- before: domainCheckHook
77
- ? async (user) => {
76
+ before: async (user) => {
77
+ if (domainCheckHook) {
78
78
  const allowed = await domainCheckHook(user.email);
79
79
  if (!allowed) {
80
80
  throw new Error('Signup not allowed for this email');
81
81
  }
82
- return undefined;
83
82
  }
84
- : undefined,
83
+ const u = user;
84
+ if (user.name && !u.firstName && !u.lastName) {
85
+ const parts = user.name.split(' ');
86
+ return {
87
+ data: {
88
+ ...user,
89
+ firstName: parts[0] || '',
90
+ lastName: parts.slice(1).join(' ') || '',
91
+ },
92
+ };
93
+ }
94
+ return undefined;
95
+ },
85
96
  after: config.onSignup
86
97
  ? async (user) => {
98
+ const u = user;
87
99
  await config.onSignup({
88
100
  id: user.id,
89
101
  email: user.email,
90
102
  name: user.name,
91
- firstName: user.firstName,
92
- lastName: user.lastName,
103
+ firstName: u.firstName || '',
104
+ lastName: u.lastName || '',
93
105
  });
94
106
  }
95
107
  : undefined,
@@ -103,6 +115,8 @@ function ziteAuth(config = {}) {
103
115
  id: session.userId,
104
116
  email: '',
105
117
  name: '',
118
+ firstName: '',
119
+ lastName: '',
106
120
  });
107
121
  }
108
122
  : undefined,
@@ -250,11 +250,11 @@ export declare function logout(opts?: {
250
250
  export type User = {
251
251
  id: string;
252
252
  name: string;
253
+ firstName?: string;
254
+ lastName?: string;
253
255
  email: string;
254
256
  emailVerified: boolean;
255
257
  image?: string | null;
256
- firstName?: string;
257
- lastName?: string;
258
258
  createdAt: Date;
259
259
  updatedAt: Date;
260
260
  };
@@ -6,6 +6,8 @@ const authClient = createAuthClient({
6
6
  });
7
7
  export const { useSession, signIn, signOut, signUp } = authClient;
8
8
  export function loginWithRedirect(opts) {
9
+ if (window.location.pathname.startsWith('/auth/'))
10
+ return;
9
11
  const params = new URLSearchParams();
10
12
  if (opts?.redirectUrl)
11
13
  params.set('redirectUrl', opts.redirectUrl);
@@ -2,8 +2,8 @@ export interface ZiteAuthUser {
2
2
  id: string;
3
3
  email: string;
4
4
  name: string;
5
- firstName?: string;
6
- lastName?: string;
5
+ firstName: string;
6
+ lastName: string;
7
7
  }
8
8
  import type { ZiteAuthMethods } from '../auth/index.js';
9
9
  export type { ZiteAuthMethods };
@@ -34,7 +34,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
34
34
  max: number;
35
35
  };
36
36
  emailAndPassword: {
37
- enabled: boolean;
37
+ enabled: true;
38
38
  };
39
39
  plugins: {
40
40
  id: "generic-oauth";
@@ -223,7 +223,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
223
223
  databaseHooks: {
224
224
  user: {
225
225
  create: {
226
- before: ((user: {
226
+ before: (user: {
227
227
  id: string;
228
228
  createdAt: Date;
229
229
  updatedAt: Date;
@@ -231,7 +231,19 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
231
231
  emailVerified: boolean;
232
232
  name: string;
233
233
  image?: string | null | undefined;
234
- } & Record<string, unknown>) => Promise<undefined>) | undefined;
234
+ } & Record<string, unknown>) => Promise<{
235
+ data: {
236
+ firstName: string;
237
+ lastName: string;
238
+ id: string;
239
+ createdAt: Date;
240
+ updatedAt: Date;
241
+ email: string;
242
+ emailVerified: boolean;
243
+ name: string;
244
+ image?: string | null | undefined;
245
+ };
246
+ } | undefined>;
235
247
  after: ((user: {
236
248
  id: string;
237
249
  createdAt: Date;
@@ -55,7 +55,7 @@ export function ziteAuth(config = {}) {
55
55
  baseURL: 'http://localhost',
56
56
  advanced: { disableCSRFCheck: true },
57
57
  rateLimit: { window: 60, max: 10 },
58
- emailAndPassword: { enabled: methods.emailPassword !== false },
58
+ emailAndPassword: { enabled: true },
59
59
  plugins,
60
60
  user: {
61
61
  modelName: 'zite_user',
@@ -70,23 +70,35 @@ export function ziteAuth(config = {}) {
70
70
  databaseHooks: {
71
71
  user: {
72
72
  create: {
73
- before: domainCheckHook
74
- ? async (user) => {
73
+ before: async (user) => {
74
+ if (domainCheckHook) {
75
75
  const allowed = await domainCheckHook(user.email);
76
76
  if (!allowed) {
77
77
  throw new Error('Signup not allowed for this email');
78
78
  }
79
- return undefined;
80
79
  }
81
- : undefined,
80
+ const u = user;
81
+ if (user.name && !u.firstName && !u.lastName) {
82
+ const parts = user.name.split(' ');
83
+ return {
84
+ data: {
85
+ ...user,
86
+ firstName: parts[0] || '',
87
+ lastName: parts.slice(1).join(' ') || '',
88
+ },
89
+ };
90
+ }
91
+ return undefined;
92
+ },
82
93
  after: config.onSignup
83
94
  ? async (user) => {
95
+ const u = user;
84
96
  await config.onSignup({
85
97
  id: user.id,
86
98
  email: user.email,
87
99
  name: user.name,
88
- firstName: user.firstName,
89
- lastName: user.lastName,
100
+ firstName: u.firstName || '',
101
+ lastName: u.lastName || '',
90
102
  });
91
103
  }
92
104
  : undefined,
@@ -100,6 +112,8 @@ export function ziteAuth(config = {}) {
100
112
  id: session.userId,
101
113
  email: '',
102
114
  name: '',
115
+ firstName: '',
116
+ lastName: '',
103
117
  });
104
118
  }
105
119
  : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.78",
3
+ "version": "0.9.80",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",