better-auth 0.0.8-beta.2 → 0.0.8-beta.21

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.
Files changed (58) hide show
  1. package/dist/access.d.ts +3 -4
  2. package/dist/access.js +3 -13
  3. package/dist/access.js.map +1 -1
  4. package/dist/cli.d.ts +1 -2
  5. package/dist/cli.js +36 -44
  6. package/dist/cli.js.map +1 -1
  7. package/dist/client/plugins.d.ts +97 -2407
  8. package/dist/client/plugins.js +143 -203
  9. package/dist/client/plugins.js.map +1 -1
  10. package/dist/client.d.ts +159 -1213
  11. package/dist/client.js +125 -527
  12. package/dist/client.js.map +1 -1
  13. package/dist/{helper-B5_2Vzba.d.ts → helper-D8dhRz72.d.ts} +1 -4
  14. package/dist/{index-Dg4eEXZW.d.ts → index-B9jOjqnF.d.ts} +1 -1
  15. package/dist/{schema-BOszzrbQ.d.ts → index-CcxejJTH.d.ts} +172 -142
  16. package/dist/{client-CaF9eUcv.d.ts → index-Dwhjsk4l.d.ts} +2014 -1971
  17. package/dist/index.d.ts +1124 -6
  18. package/dist/index.js +737 -707
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal-adapter-CVKQ4XR9.d.ts +637 -0
  21. package/dist/next-js.d.ts +17 -7
  22. package/dist/next-js.js +20 -3
  23. package/dist/next-js.js.map +1 -1
  24. package/dist/plugins.d.ts +12 -883
  25. package/dist/plugins.js +743 -679
  26. package/dist/plugins.js.map +1 -1
  27. package/dist/react.d.ts +312 -12
  28. package/dist/react.js +138 -148
  29. package/dist/react.js.map +1 -1
  30. package/dist/social.d.ts +2 -2
  31. package/dist/social.js +179 -151
  32. package/dist/social.js.map +1 -1
  33. package/dist/solid-start.d.ts +7 -6
  34. package/dist/solid-start.js +3 -3
  35. package/dist/solid-start.js.map +1 -1
  36. package/dist/solid.d.ts +91 -2713
  37. package/dist/solid.js +130 -139
  38. package/dist/solid.js.map +1 -1
  39. package/dist/{statement-COylZd3J.d.ts → statement-D6SPoYOh.d.ts} +7 -7
  40. package/dist/svelte-kit.d.ts +6 -5
  41. package/dist/svelte-kit.js +10 -9
  42. package/dist/svelte-kit.js.map +1 -1
  43. package/dist/svelte.d.ts +89 -2713
  44. package/dist/svelte.js +124 -138
  45. package/dist/svelte.js.map +1 -1
  46. package/dist/types-D4WrjKeJ.d.ts +81 -0
  47. package/dist/types.d.ts +31 -5
  48. package/dist/types.js +2 -0
  49. package/dist/types.js.map +1 -1
  50. package/dist/vue.d.ts +313 -12
  51. package/dist/vue.js +131 -145
  52. package/dist/vue.js.map +1 -1
  53. package/package.json +8 -3
  54. package/dist/index-CGeV0d2g.d.ts +0 -1498
  55. package/dist/preact.d.ts +0 -8
  56. package/dist/preact.js +0 -291
  57. package/dist/preact.js.map +0 -1
  58. package/dist/type-tYx_kmry.d.ts +0 -5724
@@ -1,108 +1,163 @@
1
- import * as nanostores from 'nanostores';
2
- import { u as useAuthStore, a as useAuthStore$1, b as AuthProxySignal } from './type-tYx_kmry.js';
3
- import { G as GenericEndpointContext } from './index-CGeV0d2g.js';
4
- import { U as User, S as Session } from './schema-BOszzrbQ.js';
5
- import * as zod from 'zod';
6
- import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
1
+ import { U as User, S as Session } from './index-CcxejJTH.js';
7
2
  import * as better_call from 'better-call';
8
- import { useAuthStore as useAuthStore$2 } from './preact.js';
3
+ import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-D6SPoYOh.js';
4
+ import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
9
5
  import * as _better_fetch_fetch from '@better-fetch/fetch';
10
6
  import { BetterFetch } from '@better-fetch/fetch';
11
- import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-COylZd3J.js';
7
+ import { H as HookEndpointContext } from './internal-adapter-CVKQ4XR9.js';
12
8
  import * as _simplewebauthn_types from '@simplewebauthn/types';
13
- import { CredentialDeviceType, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
9
+ import { CredentialDeviceType, PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
14
10
 
15
- interface BackupCodeOptions {
16
- /**
17
- * The amount of backup codes to generate
18
- *
19
- * @default 10
20
- */
21
- amount?: number;
11
+ declare const memberSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ name: z.ZodString;
14
+ email: z.ZodString;
15
+ organizationId: z.ZodString;
16
+ userId: z.ZodString;
17
+ role: z.ZodEnum<["admin", "member", "owner"]>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ id: string;
20
+ userId: string;
21
+ name: string;
22
+ email: string;
23
+ organizationId: string;
24
+ role: "member" | "admin" | "owner";
25
+ }, {
26
+ id: string;
27
+ userId: string;
28
+ name: string;
29
+ email: string;
30
+ organizationId: string;
31
+ role: "member" | "admin" | "owner";
32
+ }>;
33
+ declare const invitationSchema: z.ZodObject<{
34
+ id: z.ZodString;
35
+ organizationId: z.ZodString;
36
+ email: z.ZodString;
37
+ role: z.ZodEnum<["admin", "member", "owner"]>;
38
+ status: z.ZodDefault<z.ZodEnum<["pending", "accepted", "rejected", "canceled"]>>;
22
39
  /**
23
- * The length of the backup codes
24
- *
25
- * @default 10
40
+ * The id of the user who invited the user.
26
41
  */
27
- length?: number;
28
- customBackupCodesGenerate?: () => string[];
29
- }
42
+ inviterId: z.ZodString;
43
+ expiresAt: z.ZodDate;
44
+ }, "strip", z.ZodTypeAny, {
45
+ id: string;
46
+ expiresAt: Date;
47
+ status: "pending" | "accepted" | "rejected" | "canceled";
48
+ email: string;
49
+ organizationId: string;
50
+ role: "member" | "admin" | "owner";
51
+ inviterId: string;
52
+ }, {
53
+ id: string;
54
+ expiresAt: Date;
55
+ email: string;
56
+ organizationId: string;
57
+ role: "member" | "admin" | "owner";
58
+ inviterId: string;
59
+ status?: "pending" | "accepted" | "rejected" | "canceled" | undefined;
60
+ }>;
61
+ type Member = z.infer<typeof memberSchema>;
62
+ type Invitation = z.infer<typeof invitationSchema>;
30
63
 
31
- interface OTPOptions {
64
+ interface OrganizationOptions {
32
65
  /**
33
- * How long the opt will be valid for
66
+ * Configure whether new users are able to create new organizations.
67
+ * You can also pass a function that returns a boolean.
34
68
  *
35
- * @default "5 mins"
69
+ * @example
70
+ * ```ts
71
+ * allowUserToCreateOrganization: async (user) => {
72
+ * const plan = await getUserPlan(user);
73
+ * return plan.name === "pro";
74
+ * }
75
+ * ```
76
+ * @default true
36
77
  */
37
- period?: number;
38
- sendOTP: (user: UserWithTwoFactor, otp: string) => Promise<void>;
39
- }
40
-
41
- type TOTPOptions = {
78
+ allowUserToCreateOrganization?: boolean | ((user: User) => Promise<boolean> | boolean);
42
79
  /**
43
- * Issuer
80
+ *
44
81
  */
45
- issuer: string;
82
+ organizationLimit?: number;
46
83
  /**
47
- * How many digits the otp to be
84
+ * The role that is assigned to the creator of the organization.
48
85
  *
49
- * @default 6
86
+ * @default "admin"
50
87
  */
51
- digits?: 6 | 8;
88
+ creatorRole?: "admin" | "owner";
52
89
  /**
53
- * Period for otp in seconds.
54
- * @default 30
90
+ * The number of memberships a user can have in an organization.
91
+ *
92
+ * @default "unlimited"
55
93
  */
56
- period?: number;
94
+ membershipLimit?: number;
57
95
  /**
58
- * Backup codes configuration
96
+ * Configure the roles and permissions for the organization plugin.
97
+ *
59
98
  */
60
- backupCodes?: BackupCodeOptions;
61
- };
62
-
63
- interface TwoFactorOptions {
64
- issuer: string;
65
- totpOptions?: Omit<TOTPOptions, "issuer">;
66
- otpOptions?: OTPOptions;
67
- backupCodeOptions?: BackupCodeOptions;
68
- }
69
- interface UserWithTwoFactor extends User {
99
+ ac?: AccessControl;
70
100
  /**
71
- * If the user has enabled two factor authentication.
101
+ *
72
102
  */
73
- twoFactorEnabled: boolean;
103
+ roles?: {
104
+ [key in "admin" | "member" | "owner"]?: Role<any>;
105
+ };
74
106
  /**
75
- * The secret used to generate the TOTP or OTP.
107
+ * The expiration time for the invitation link.
108
+ *
109
+ * @default 48 hours
76
110
  */
77
- twoFactorSecret: string;
111
+ invitationExpiresIn?: number;
78
112
  /**
79
- * List of backup codes separated by a
80
- * comma
113
+ * @param invitation the invitation object
114
+ * @param email the email of the user to be invited
115
+ *
116
+ * Make sure to construct the invitation link using the invitation id.
117
+ * @example
118
+ * ```ts
119
+ * const invitationLink = `${ctx.origin}/organization/accept-invitation?invitationId=$
120
+ * {invitation.id}`
121
+ *
122
+ * ```
81
123
  */
82
- twoFactorBackupCodes: string;
124
+ sendInvitationEmail?: (invitation: Invitation, email: string) => Promise<void>;
83
125
  }
84
-
85
- declare const twoFactorClient: (options?: {
86
- twoFactorPage: string;
87
- /**
88
- * Redirect to the two factor page. If twoFactorPage
89
- * is not set this will redirect to the root path.
90
- * @default true
91
- */
92
- redirect?: boolean;
93
- }) => ($fetch: _better_fetch_fetch.BetterFetch) => {
94
- integrations: {
95
- react?: ((useStore: typeof useAuthStore) => Record<string, any>) | undefined;
96
- vue?: ((useStore: typeof useAuthStore$1) => Record<string, any>) | undefined;
97
- preact?: ((useStore: typeof useAuthStore$2) => Record<string, any>) | undefined;
98
- svelte?: (() => Record<string, any>) | undefined;
99
- };
100
- plugin: {
101
- id: "two-factor";
102
- endpoints: {
103
- enableTwoFactor: {
104
- (ctx_0?: better_call.Context<"/two-factor/enable", {
105
- method: "POST";
126
+ declare const organization: <O extends OrganizationOptions>(options?: O) => {
127
+ id: "organization";
128
+ endpoints: {
129
+ hasPermission: {
130
+ (ctx_0: better_call.Context<"/organization/has-permission", {
131
+ method: "POST";
132
+ requireHeaders: true;
133
+ body: ZodObject<{
134
+ permission: ZodObject<{ [key in keyof (O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
135
+ readonly organization: readonly ["update", "delete"];
136
+ readonly member: readonly ["create", "update", "delete"];
137
+ readonly invitation: readonly ["create", "cancel"];
138
+ } : {
139
+ readonly organization: readonly ["update", "delete"];
140
+ readonly member: readonly ["create", "update", "delete"];
141
+ readonly invitation: readonly ["create", "cancel"];
142
+ } : {
143
+ readonly organization: readonly ["update", "delete"];
144
+ readonly member: readonly ["create", "update", "delete"];
145
+ readonly invitation: readonly ["create", "cancel"];
146
+ })]: ZodOptional<ZodArray<ZodLiteral<(O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
147
+ readonly organization: readonly ["update", "delete"];
148
+ readonly member: readonly ["create", "update", "delete"];
149
+ readonly invitation: readonly ["create", "cancel"];
150
+ } : {
151
+ readonly organization: readonly ["update", "delete"];
152
+ readonly member: readonly ["create", "update", "delete"];
153
+ readonly invitation: readonly ["create", "cancel"];
154
+ } : {
155
+ readonly organization: readonly ["update", "delete"];
156
+ readonly member: readonly ["create", "update", "delete"];
157
+ readonly invitation: readonly ["create", "cancel"];
158
+ })[key][number]>>>; }>;
159
+ }>;
160
+ use: better_call.Endpoint<better_call.Handler<string, {
106
161
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
107
162
  session: {
108
163
  session: {
@@ -123,12 +178,16 @@ declare const twoFactorClient: (options?: {
123
178
  };
124
179
  };
125
180
  }>, better_call.EndpointOptions>[];
126
- }> | undefined): Promise<{
127
- status: boolean;
128
- }>;
129
- path: "/two-factor/enable";
130
- options: {
131
- method: "POST";
181
+ } & {
182
+ method: "*";
183
+ }, {
184
+ session: {
185
+ session: Session & {
186
+ activeOrganizationId?: string;
187
+ };
188
+ user: User;
189
+ };
190
+ }>, {
132
191
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
133
192
  session: {
134
193
  session: {
@@ -149,13 +208,48 @@ declare const twoFactorClient: (options?: {
149
208
  };
150
209
  };
151
210
  }>, better_call.EndpointOptions>[];
152
- };
153
- method: better_call.Method | better_call.Method[];
154
- headers: Headers;
155
- };
156
- disableTwoFactor: {
157
- (ctx_0?: better_call.Context<"/two-factor/disable", {
158
- method: "POST";
211
+ } & {
212
+ method: "*";
213
+ }>[];
214
+ }>): Promise<{
215
+ error: string;
216
+ success: boolean;
217
+ } | {
218
+ error: null;
219
+ success: boolean;
220
+ }>;
221
+ path: "/organization/has-permission";
222
+ options: {
223
+ method: "POST";
224
+ requireHeaders: true;
225
+ body: ZodObject<{
226
+ permission: ZodObject<{ [key in keyof (O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
227
+ readonly organization: readonly ["update", "delete"];
228
+ readonly member: readonly ["create", "update", "delete"];
229
+ readonly invitation: readonly ["create", "cancel"];
230
+ } : {
231
+ readonly organization: readonly ["update", "delete"];
232
+ readonly member: readonly ["create", "update", "delete"];
233
+ readonly invitation: readonly ["create", "cancel"];
234
+ } : {
235
+ readonly organization: readonly ["update", "delete"];
236
+ readonly member: readonly ["create", "update", "delete"];
237
+ readonly invitation: readonly ["create", "cancel"];
238
+ })]: ZodOptional<ZodArray<ZodLiteral<(O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
239
+ readonly organization: readonly ["update", "delete"];
240
+ readonly member: readonly ["create", "update", "delete"];
241
+ readonly invitation: readonly ["create", "cancel"];
242
+ } : {
243
+ readonly organization: readonly ["update", "delete"];
244
+ readonly member: readonly ["create", "update", "delete"];
245
+ readonly invitation: readonly ["create", "cancel"];
246
+ } : {
247
+ readonly organization: readonly ["update", "delete"];
248
+ readonly member: readonly ["create", "update", "delete"];
249
+ readonly invitation: readonly ["create", "cancel"];
250
+ })[key][number]>>>; }>;
251
+ }>;
252
+ use: better_call.Endpoint<better_call.Handler<string, {
159
253
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
160
254
  session: {
161
255
  session: {
@@ -176,12 +270,16 @@ declare const twoFactorClient: (options?: {
176
270
  };
177
271
  };
178
272
  }>, better_call.EndpointOptions>[];
179
- }> | undefined): Promise<{
180
- status: boolean;
181
- }>;
182
- path: "/two-factor/disable";
183
- options: {
184
- method: "POST";
273
+ } & {
274
+ method: "*";
275
+ }, {
276
+ session: {
277
+ session: Session & {
278
+ activeOrganizationId?: string;
279
+ };
280
+ user: User;
281
+ };
282
+ }>, {
185
283
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
186
284
  session: {
187
285
  session: {
@@ -202,104 +300,41 @@ declare const twoFactorClient: (options?: {
202
300
  };
203
301
  };
204
302
  }>, better_call.EndpointOptions>[];
205
- };
206
- method: better_call.Method | better_call.Method[];
207
- headers: Headers;
303
+ } & {
304
+ method: "*";
305
+ }>[];
208
306
  };
209
- verifyBackupCode: {
210
- (ctx_0: better_call.Context<"/two-factor/verify-backup-code", {
211
- method: "POST";
212
- body: zod.ZodObject<{
213
- code: zod.ZodString;
214
- }, "strip", zod.ZodTypeAny, {
215
- code: string;
216
- }, {
217
- code: string;
218
- }>;
219
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
220
- valid: () => Promise<{
221
- response: {
222
- body: any;
223
- status: number;
224
- statusText: string;
225
- headers: Record<string, string> | undefined;
226
- };
227
- body: {
228
- status: boolean;
229
- };
230
- _flag: "json";
231
- }>;
232
- invalid: () => Promise<{
233
- response: {
234
- body: any;
235
- status: number;
236
- statusText: string;
237
- headers: Record<string, string> | undefined;
238
- };
239
- body: {
240
- status: boolean;
241
- };
242
- _flag: "json";
243
- }>;
244
- session: {
245
- id: string;
246
- userId: string;
247
- expiresAt: Date;
248
- user: UserWithTwoFactor;
249
- };
250
- }>, better_call.EndpointOptions>[];
251
- }>): Promise<{
252
- status: boolean;
307
+ method: better_call.Method | better_call.Method[];
308
+ headers: Headers;
309
+ };
310
+ createOrganization: {
311
+ (ctx_0: better_call.Context<"/organization/create", {
312
+ method: "POST";
313
+ body: ZodObject<{
314
+ name: z.ZodString;
315
+ slug: z.ZodString;
316
+ userId: ZodOptional<z.ZodString>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ name: string;
319
+ slug: string;
320
+ userId?: string | undefined;
321
+ }, {
322
+ name: string;
323
+ slug: string;
324
+ userId?: string | undefined;
253
325
  }>;
254
- path: "/two-factor/verify-backup-code";
255
- options: {
256
- method: "POST";
257
- body: zod.ZodObject<{
258
- code: zod.ZodString;
259
- }, "strip", zod.ZodTypeAny, {
260
- code: string;
261
- }, {
262
- code: string;
263
- }>;
264
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
265
- valid: () => Promise<{
266
- response: {
267
- body: any;
268
- status: number;
269
- statusText: string;
270
- headers: Record<string, string> | undefined;
271
- };
272
- body: {
273
- status: boolean;
274
- };
275
- _flag: "json";
276
- }>;
277
- invalid: () => Promise<{
278
- response: {
279
- body: any;
280
- status: number;
281
- statusText: string;
282
- headers: Record<string, string> | undefined;
283
- };
284
- body: {
285
- status: boolean;
286
- };
287
- _flag: "json";
288
- }>;
289
- session: {
290
- id: string;
291
- userId: string;
292
- expiresAt: Date;
293
- user: UserWithTwoFactor;
326
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
327
+ orgOptions: OrganizationOptions;
328
+ roles: typeof defaultRoles & {
329
+ [key: string]: Role<{}>;
330
+ };
331
+ getSession: (context: better_call.Context<any, any>) => Promise<{
332
+ session: Session & {
333
+ activeOrganizationId?: string;
294
334
  };
295
- }>, better_call.EndpointOptions>[];
296
- };
297
- method: better_call.Method | better_call.Method[];
298
- headers: Headers;
299
- };
300
- generateBackupCodes: {
301
- (ctx_0?: better_call.Context<"/two-factor/generate-backup-codes", {
302
- method: "POST";
335
+ user: User;
336
+ }>;
337
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
303
338
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
304
339
  session: {
305
340
  session: {
@@ -320,13 +355,16 @@ declare const twoFactorClient: (options?: {
320
355
  };
321
356
  };
322
357
  }>, better_call.EndpointOptions>[];
323
- }> | undefined): Promise<{
324
- status: boolean;
325
- backupCodes: string[];
326
- }>;
327
- path: "/two-factor/generate-backup-codes";
328
- options: {
329
- method: "POST";
358
+ } & {
359
+ method: "*";
360
+ }, {
361
+ session: {
362
+ session: Session & {
363
+ activeOrganizationId?: string;
364
+ };
365
+ user: User;
366
+ };
367
+ }>, {
330
368
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
331
369
  session: {
332
370
  session: {
@@ -347,13 +385,50 @@ declare const twoFactorClient: (options?: {
347
385
  };
348
386
  };
349
387
  }>, better_call.EndpointOptions>[];
350
- };
351
- method: better_call.Method | better_call.Method[];
352
- headers: Headers;
353
- };
354
- viewBackupCodes: {
355
- (ctx_0?: better_call.Context<"/view/backup-codes", {
356
- method: "GET";
388
+ } & {
389
+ method: "*";
390
+ }>)[];
391
+ }>): Promise<{
392
+ members: {
393
+ id: string;
394
+ userId: string;
395
+ name: string;
396
+ email: string;
397
+ organizationId: string;
398
+ role: "member" | "admin" | "owner";
399
+ }[];
400
+ id: string;
401
+ name: string;
402
+ slug: string;
403
+ } | null>;
404
+ path: "/organization/create";
405
+ options: {
406
+ method: "POST";
407
+ body: ZodObject<{
408
+ name: z.ZodString;
409
+ slug: z.ZodString;
410
+ userId: ZodOptional<z.ZodString>;
411
+ }, "strip", z.ZodTypeAny, {
412
+ name: string;
413
+ slug: string;
414
+ userId?: string | undefined;
415
+ }, {
416
+ name: string;
417
+ slug: string;
418
+ userId?: string | undefined;
419
+ }>;
420
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
421
+ orgOptions: OrganizationOptions;
422
+ roles: typeof defaultRoles & {
423
+ [key: string]: Role<{}>;
424
+ };
425
+ getSession: (context: better_call.Context<any, any>) => Promise<{
426
+ session: Session & {
427
+ activeOrganizationId?: string;
428
+ };
429
+ user: User;
430
+ }>;
431
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
357
432
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
358
433
  session: {
359
434
  session: {
@@ -374,13 +449,16 @@ declare const twoFactorClient: (options?: {
374
449
  };
375
450
  };
376
451
  }>, better_call.EndpointOptions>[];
377
- }> | undefined): Promise<{
378
- status: boolean;
379
- backupCodes: Promise<string[] | null>;
380
- }>;
381
- path: "/view/backup-codes";
382
- options: {
383
- method: "GET";
452
+ } & {
453
+ method: "*";
454
+ }, {
455
+ session: {
456
+ session: Session & {
457
+ activeOrganizationId?: string;
458
+ };
459
+ user: User;
460
+ };
461
+ }>, {
384
462
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
385
463
  session: {
386
464
  session: {
@@ -401,181 +479,286 @@ declare const twoFactorClient: (options?: {
401
479
  };
402
480
  };
403
481
  }>, better_call.EndpointOptions>[];
404
- };
405
- method: better_call.Method | better_call.Method[];
406
- headers: Headers;
482
+ } & {
483
+ method: "*";
484
+ }>)[];
407
485
  };
408
- send2FaOTP: {
409
- (ctx_0?: better_call.Context<"/two-factor/send-otp", {
410
- method: "POST";
411
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
412
- valid: () => Promise<{
413
- response: {
414
- body: any;
415
- status: number;
416
- statusText: string;
417
- headers: Record<string, string> | undefined;
418
- };
419
- body: {
420
- status: boolean;
421
- };
422
- _flag: "json";
423
- }>;
424
- invalid: () => Promise<{
425
- response: {
426
- body: any;
427
- status: number;
428
- statusText: string;
429
- headers: Record<string, string> | undefined;
430
- };
431
- body: {
432
- status: boolean;
433
- };
434
- _flag: "json";
435
- }>;
436
- session: {
437
- id: string;
438
- userId: string;
439
- expiresAt: Date;
440
- user: UserWithTwoFactor;
441
- };
442
- }>, better_call.EndpointOptions>[];
443
- }> | undefined): Promise<{
444
- status: boolean;
486
+ method: better_call.Method | better_call.Method[];
487
+ headers: Headers;
488
+ };
489
+ updateOrganization: {
490
+ (ctx_0: better_call.Context<"/organization/update", {
491
+ method: "POST";
492
+ body: ZodObject<{
493
+ data: ZodObject<{
494
+ name: ZodOptional<ZodOptional<z.ZodString>>;
495
+ slug: ZodOptional<ZodOptional<z.ZodString>>;
496
+ }, "strip", z.ZodTypeAny, {
497
+ name?: string | undefined;
498
+ slug?: string | undefined;
499
+ }, {
500
+ name?: string | undefined;
501
+ slug?: string | undefined;
502
+ }>;
503
+ orgId: ZodOptional<z.ZodString>;
504
+ }, "strip", z.ZodTypeAny, {
505
+ data: {
506
+ name?: string | undefined;
507
+ slug?: string | undefined;
508
+ };
509
+ orgId?: string | undefined;
510
+ }, {
511
+ data: {
512
+ name?: string | undefined;
513
+ slug?: string | undefined;
514
+ };
515
+ orgId?: string | undefined;
445
516
  }>;
446
- path: "/two-factor/send-otp";
447
- options: {
448
- method: "POST";
449
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
450
- valid: () => Promise<{
451
- response: {
452
- body: any;
453
- status: number;
454
- statusText: string;
455
- headers: Record<string, string> | undefined;
456
- };
457
- body: {
458
- status: boolean;
459
- };
460
- _flag: "json";
461
- }>;
462
- invalid: () => Promise<{
463
- response: {
464
- body: any;
465
- status: number;
466
- statusText: string;
467
- headers: Record<string, string> | undefined;
468
- };
469
- body: {
470
- status: boolean;
471
- };
472
- _flag: "json";
473
- }>;
474
- session: {
475
- id: string;
476
- userId: string;
477
- expiresAt: Date;
478
- user: UserWithTwoFactor;
517
+ requireHeaders: true;
518
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
519
+ orgOptions: OrganizationOptions;
520
+ roles: typeof defaultRoles & {
521
+ [key: string]: Role<{}>;
522
+ };
523
+ getSession: (context: better_call.Context<any, any>) => Promise<{
524
+ session: Session & {
525
+ activeOrganizationId?: string;
479
526
  };
480
- }>, better_call.EndpointOptions>[];
481
- };
482
- method: better_call.Method | better_call.Method[];
483
- headers: Headers;
484
- };
485
- verifyOTP: {
486
- (ctx_0: better_call.Context<"/two-factor/verify-otp", {
487
- method: "POST";
488
- body: zod.ZodObject<{
489
- code: zod.ZodString;
490
- }, "strip", zod.ZodTypeAny, {
491
- code: string;
527
+ user: User;
528
+ }>;
529
+ }>, better_call.EndpointOptions>[];
530
+ }>): Promise<{
531
+ id: string;
532
+ name: string;
533
+ slug: string;
534
+ } | null>;
535
+ path: "/organization/update";
536
+ options: {
537
+ method: "POST";
538
+ body: ZodObject<{
539
+ data: ZodObject<{
540
+ name: ZodOptional<ZodOptional<z.ZodString>>;
541
+ slug: ZodOptional<ZodOptional<z.ZodString>>;
542
+ }, "strip", z.ZodTypeAny, {
543
+ name?: string | undefined;
544
+ slug?: string | undefined;
492
545
  }, {
493
- code: string;
546
+ name?: string | undefined;
547
+ slug?: string | undefined;
494
548
  }>;
495
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
496
- valid: () => Promise<{
497
- response: {
498
- body: any;
499
- status: number;
500
- statusText: string;
501
- headers: Record<string, string> | undefined;
502
- };
503
- body: {
504
- status: boolean;
505
- };
506
- _flag: "json";
507
- }>;
508
- invalid: () => Promise<{
509
- response: {
510
- body: any;
511
- status: number;
512
- statusText: string;
513
- headers: Record<string, string> | undefined;
514
- };
515
- body: {
516
- status: boolean;
517
- };
518
- _flag: "json";
519
- }>;
520
- session: {
521
- id: string;
522
- userId: string;
523
- expiresAt: Date;
524
- user: UserWithTwoFactor;
549
+ orgId: ZodOptional<z.ZodString>;
550
+ }, "strip", z.ZodTypeAny, {
551
+ data: {
552
+ name?: string | undefined;
553
+ slug?: string | undefined;
554
+ };
555
+ orgId?: string | undefined;
556
+ }, {
557
+ data: {
558
+ name?: string | undefined;
559
+ slug?: string | undefined;
560
+ };
561
+ orgId?: string | undefined;
562
+ }>;
563
+ requireHeaders: true;
564
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
565
+ orgOptions: OrganizationOptions;
566
+ roles: typeof defaultRoles & {
567
+ [key: string]: Role<{}>;
568
+ };
569
+ getSession: (context: better_call.Context<any, any>) => Promise<{
570
+ session: Session & {
571
+ activeOrganizationId?: string;
525
572
  };
526
- }>, better_call.EndpointOptions>[];
527
- }>): Promise<{
528
- status: boolean;
573
+ user: User;
574
+ }>;
575
+ }>, better_call.EndpointOptions>[];
576
+ };
577
+ method: better_call.Method | better_call.Method[];
578
+ headers: Headers;
579
+ };
580
+ deleteOrganization: {
581
+ (ctx_0: better_call.Context<"/organization/delete", {
582
+ method: "POST";
583
+ body: ZodObject<{
584
+ orgId: z.ZodString;
585
+ }, "strip", z.ZodTypeAny, {
586
+ orgId: string;
587
+ }, {
588
+ orgId: string;
529
589
  }>;
530
- path: "/two-factor/verify-otp";
531
- options: {
532
- method: "POST";
533
- body: zod.ZodObject<{
534
- code: zod.ZodString;
535
- }, "strip", zod.ZodTypeAny, {
536
- code: string;
537
- }, {
538
- code: string;
590
+ requireHeaders: true;
591
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
592
+ orgOptions: OrganizationOptions;
593
+ roles: typeof defaultRoles & {
594
+ [key: string]: Role<{}>;
595
+ };
596
+ getSession: (context: better_call.Context<any, any>) => Promise<{
597
+ session: Session & {
598
+ activeOrganizationId?: string;
599
+ };
600
+ user: User;
539
601
  }>;
540
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
541
- valid: () => Promise<{
542
- response: {
543
- body: any;
544
- status: number;
545
- statusText: string;
546
- headers: Record<string, string> | undefined;
547
- };
548
- body: {
549
- status: boolean;
550
- };
551
- _flag: "json";
552
- }>;
553
- invalid: () => Promise<{
554
- response: {
555
- body: any;
556
- status: number;
557
- statusText: string;
558
- headers: Record<string, string> | undefined;
559
- };
560
- body: {
561
- status: boolean;
562
- };
563
- _flag: "json";
564
- }>;
602
+ }>, better_call.EndpointOptions>[];
603
+ }>): Promise<string | null>;
604
+ path: "/organization/delete";
605
+ options: {
606
+ method: "POST";
607
+ body: ZodObject<{
608
+ orgId: z.ZodString;
609
+ }, "strip", z.ZodTypeAny, {
610
+ orgId: string;
611
+ }, {
612
+ orgId: string;
613
+ }>;
614
+ requireHeaders: true;
615
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
616
+ orgOptions: OrganizationOptions;
617
+ roles: typeof defaultRoles & {
618
+ [key: string]: Role<{}>;
619
+ };
620
+ getSession: (context: better_call.Context<any, any>) => Promise<{
621
+ session: Session & {
622
+ activeOrganizationId?: string;
623
+ };
624
+ user: User;
625
+ }>;
626
+ }>, better_call.EndpointOptions>[];
627
+ };
628
+ method: better_call.Method | better_call.Method[];
629
+ headers: Headers;
630
+ };
631
+ setActiveOrganization: {
632
+ (ctx_0: better_call.Context<"/organization/activate", {
633
+ method: "POST";
634
+ body: ZodObject<{
635
+ orgId: z.ZodString;
636
+ }, "strip", z.ZodTypeAny, {
637
+ orgId: string;
638
+ }, {
639
+ orgId: string;
640
+ }>;
641
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
642
+ session: {
565
643
  session: {
566
644
  id: string;
567
645
  userId: string;
568
646
  expiresAt: Date;
569
- user: UserWithTwoFactor;
647
+ ipAddress?: string | undefined;
648
+ userAgent?: string | undefined;
570
649
  };
571
- }>, better_call.EndpointOptions>[];
572
- };
573
- method: better_call.Method | better_call.Method[];
574
- headers: Headers;
650
+ user: {
651
+ id: string;
652
+ name: string;
653
+ email: string;
654
+ emailVerified: boolean;
655
+ createdAt: Date;
656
+ updatedAt: Date;
657
+ image?: string | undefined;
658
+ };
659
+ };
660
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
661
+ orgOptions: OrganizationOptions;
662
+ roles: typeof defaultRoles & {
663
+ [key: string]: Role<{}>;
664
+ };
665
+ getSession: (context: better_call.Context<any, any>) => Promise<{
666
+ session: Session & {
667
+ activeOrganizationId?: string;
668
+ };
669
+ user: User;
670
+ }>;
671
+ }>, better_call.EndpointOptions>)[];
672
+ }>): Promise<{
673
+ members: {
674
+ id: string;
675
+ userId: string;
676
+ name: string;
677
+ email: string;
678
+ organizationId: string;
679
+ role: "member" | "admin" | "owner";
680
+ }[];
681
+ invitations: {
682
+ id: string;
683
+ expiresAt: Date;
684
+ status: "pending" | "accepted" | "rejected" | "canceled";
685
+ email: string;
686
+ organizationId: string;
687
+ role: "member" | "admin" | "owner";
688
+ inviterId: string;
689
+ }[];
690
+ id: string;
691
+ name: string;
692
+ slug: string;
693
+ } | null>;
694
+ path: "/organization/activate";
695
+ options: {
696
+ method: "POST";
697
+ body: ZodObject<{
698
+ orgId: z.ZodString;
699
+ }, "strip", z.ZodTypeAny, {
700
+ orgId: string;
701
+ }, {
702
+ orgId: string;
703
+ }>;
704
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
705
+ session: {
706
+ session: {
707
+ id: string;
708
+ userId: string;
709
+ expiresAt: Date;
710
+ ipAddress?: string | undefined;
711
+ userAgent?: string | undefined;
712
+ };
713
+ user: {
714
+ id: string;
715
+ name: string;
716
+ email: string;
717
+ emailVerified: boolean;
718
+ createdAt: Date;
719
+ updatedAt: Date;
720
+ image?: string | undefined;
721
+ };
722
+ };
723
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
724
+ orgOptions: OrganizationOptions;
725
+ roles: typeof defaultRoles & {
726
+ [key: string]: Role<{}>;
727
+ };
728
+ getSession: (context: better_call.Context<any, any>) => Promise<{
729
+ session: Session & {
730
+ activeOrganizationId?: string;
731
+ };
732
+ user: User;
733
+ }>;
734
+ }>, better_call.EndpointOptions>)[];
575
735
  };
576
- generateTOTP: {
577
- (ctx_0?: better_call.Context<"/totp/generate", {
578
- method: "POST";
736
+ method: better_call.Method | better_call.Method[];
737
+ headers: Headers;
738
+ };
739
+ getFullOrganization: {
740
+ (ctx_0: better_call.Context<"/organization/get-full", {
741
+ method: "GET";
742
+ query: ZodObject<{
743
+ orgId: ZodOptional<z.ZodString>;
744
+ }, "strip", z.ZodTypeAny, {
745
+ orgId?: string | undefined;
746
+ }, {
747
+ orgId?: string | undefined;
748
+ }>;
749
+ requireHeaders: true;
750
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
751
+ orgOptions: OrganizationOptions;
752
+ roles: typeof defaultRoles & {
753
+ [key: string]: Role<{}>;
754
+ };
755
+ getSession: (context: better_call.Context<any, any>) => Promise<{
756
+ session: Session & {
757
+ activeOrganizationId?: string;
758
+ };
759
+ user: User;
760
+ }>;
761
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
579
762
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
580
763
  session: {
581
764
  session: {
@@ -596,12 +779,16 @@ declare const twoFactorClient: (options?: {
596
779
  };
597
780
  };
598
781
  }>, better_call.EndpointOptions>[];
599
- }> | undefined): Promise<{
600
- code: string;
601
- }>;
602
- path: "/totp/generate";
603
- options: {
604
- method: "POST";
782
+ } & {
783
+ method: "*";
784
+ }, {
785
+ session: {
786
+ session: Session & {
787
+ activeOrganizationId?: string;
788
+ };
789
+ user: User;
790
+ };
791
+ }>, {
605
792
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
606
793
  session: {
607
794
  session: {
@@ -622,13 +809,54 @@ declare const twoFactorClient: (options?: {
622
809
  };
623
810
  };
624
811
  }>, better_call.EndpointOptions>[];
625
- };
626
- method: better_call.Method | better_call.Method[];
627
- headers: Headers;
628
- };
629
- viewTOTPURI: {
630
- (ctx_0?: better_call.Context<"/two-factor/get-totp-uri", {
631
- method: "GET";
812
+ } & {
813
+ method: "*";
814
+ }>)[];
815
+ }>): Promise<{
816
+ members: {
817
+ id: string;
818
+ userId: string;
819
+ name: string;
820
+ email: string;
821
+ organizationId: string;
822
+ role: "member" | "admin" | "owner";
823
+ }[];
824
+ invitations: {
825
+ id: string;
826
+ expiresAt: Date;
827
+ status: "pending" | "accepted" | "rejected" | "canceled";
828
+ email: string;
829
+ organizationId: string;
830
+ role: "member" | "admin" | "owner";
831
+ inviterId: string;
832
+ }[];
833
+ id: string;
834
+ name: string;
835
+ slug: string;
836
+ } | null>;
837
+ path: "/organization/get-full";
838
+ options: {
839
+ method: "GET";
840
+ query: ZodObject<{
841
+ orgId: ZodOptional<z.ZodString>;
842
+ }, "strip", z.ZodTypeAny, {
843
+ orgId?: string | undefined;
844
+ }, {
845
+ orgId?: string | undefined;
846
+ }>;
847
+ requireHeaders: true;
848
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
849
+ orgOptions: OrganizationOptions;
850
+ roles: typeof defaultRoles & {
851
+ [key: string]: Role<{}>;
852
+ };
853
+ getSession: (context: better_call.Context<any, any>) => Promise<{
854
+ session: Session & {
855
+ activeOrganizationId?: string;
856
+ };
857
+ user: User;
858
+ }>;
859
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
632
860
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
633
861
  session: {
634
862
  session: {
@@ -649,12 +877,16 @@ declare const twoFactorClient: (options?: {
649
877
  };
650
878
  };
651
879
  }>, better_call.EndpointOptions>[];
652
- }> | undefined): Promise<{
653
- totpURI: string;
654
- }>;
655
- path: "/two-factor/get-totp-uri";
656
- options: {
657
- method: "GET";
880
+ } & {
881
+ method: "*";
882
+ }, {
883
+ session: {
884
+ session: Session & {
885
+ activeOrganizationId?: string;
886
+ };
887
+ user: User;
888
+ };
889
+ }>, {
658
890
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
659
891
  session: {
660
892
  session: {
@@ -675,297 +907,101 @@ declare const twoFactorClient: (options?: {
675
907
  };
676
908
  };
677
909
  }>, better_call.EndpointOptions>[];
678
- };
679
- method: better_call.Method | better_call.Method[];
680
- headers: Headers;
910
+ } & {
911
+ method: "*";
912
+ }>)[];
681
913
  };
682
- verifyTOTP: {
683
- (ctx_0: better_call.Context<"/two-factor/verify-totp", {
684
- method: "POST";
685
- body: zod.ZodObject<{
686
- code: zod.ZodString;
687
- callbackURL: zod.ZodOptional<zod.ZodString>;
688
- }, "strip", zod.ZodTypeAny, {
689
- code: string;
690
- callbackURL?: string | undefined;
691
- }, {
692
- code: string;
693
- callbackURL?: string | undefined;
914
+ method: better_call.Method | better_call.Method[];
915
+ headers: Headers;
916
+ };
917
+ listOrganization: {
918
+ (ctx_0?: better_call.Context<"/organization/list", {
919
+ method: "GET";
920
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
921
+ orgOptions: OrganizationOptions;
922
+ roles: typeof defaultRoles & {
923
+ [key: string]: Role<{}>;
924
+ };
925
+ getSession: (context: better_call.Context<any, any>) => Promise<{
926
+ session: Session & {
927
+ activeOrganizationId?: string;
928
+ };
929
+ user: User;
694
930
  }>;
931
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
695
932
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
696
- valid: () => Promise<{
697
- response: {
698
- body: any;
699
- status: number;
700
- statusText: string;
701
- headers: Record<string, string> | undefined;
702
- };
703
- body: {
704
- status: boolean;
705
- };
706
- _flag: "json";
707
- }>;
708
- invalid: () => Promise<{
709
- response: {
710
- body: any;
711
- status: number;
712
- statusText: string;
713
- headers: Record<string, string> | undefined;
714
- };
715
- body: {
716
- status: boolean;
717
- };
718
- _flag: "json";
719
- }>;
720
933
  session: {
721
- id: string;
722
- userId: string;
723
- expiresAt: Date;
724
- user: UserWithTwoFactor;
934
+ session: {
935
+ id: string;
936
+ userId: string;
937
+ expiresAt: Date;
938
+ ipAddress?: string | undefined;
939
+ userAgent?: string | undefined;
940
+ };
941
+ user: {
942
+ id: string;
943
+ name: string;
944
+ email: string;
945
+ emailVerified: boolean;
946
+ createdAt: Date;
947
+ updatedAt: Date;
948
+ image?: string | undefined;
949
+ };
725
950
  };
726
951
  }>, better_call.EndpointOptions>[];
727
- }>): Promise<{
728
- status: boolean;
729
- }>;
730
- path: "/two-factor/verify-totp";
731
- options: {
732
- method: "POST";
733
- body: zod.ZodObject<{
734
- code: zod.ZodString;
735
- callbackURL: zod.ZodOptional<zod.ZodString>;
736
- }, "strip", zod.ZodTypeAny, {
737
- code: string;
738
- callbackURL?: string | undefined;
739
- }, {
740
- code: string;
741
- callbackURL?: string | undefined;
742
- }>;
952
+ } & {
953
+ method: "*";
954
+ }, {
955
+ session: {
956
+ session: Session & {
957
+ activeOrganizationId?: string;
958
+ };
959
+ user: User;
960
+ };
961
+ }>, {
743
962
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
744
- valid: () => Promise<{
745
- response: {
746
- body: any;
747
- status: number;
748
- statusText: string;
749
- headers: Record<string, string> | undefined;
750
- };
751
- body: {
752
- status: boolean;
753
- };
754
- _flag: "json";
755
- }>;
756
- invalid: () => Promise<{
757
- response: {
758
- body: any;
759
- status: number;
760
- statusText: string;
761
- headers: Record<string, string> | undefined;
762
- };
763
- body: {
764
- status: boolean;
765
- };
766
- _flag: "json";
767
- }>;
768
963
  session: {
769
- id: string;
770
- userId: string;
771
- expiresAt: Date;
772
- user: UserWithTwoFactor;
964
+ session: {
965
+ id: string;
966
+ userId: string;
967
+ expiresAt: Date;
968
+ ipAddress?: string | undefined;
969
+ userAgent?: string | undefined;
970
+ };
971
+ user: {
972
+ id: string;
973
+ name: string;
974
+ email: string;
975
+ emailVerified: boolean;
976
+ createdAt: Date;
977
+ updatedAt: Date;
978
+ image?: string | undefined;
979
+ };
773
980
  };
774
981
  }>, better_call.EndpointOptions>[];
775
- };
776
- method: better_call.Method | better_call.Method[];
777
- headers: Headers;
778
- };
779
- };
780
- options: TwoFactorOptions;
781
- hooks: {
782
- after: {
783
- matcher(context: GenericEndpointContext): boolean;
784
- handler: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
785
- response: Response;
786
- } | undefined>, better_call.EndpointOptions>;
787
- }[];
788
- };
789
- schema: {
790
- user: {
791
- fields: {
792
- twoFactorEnabled: {
793
- type: "boolean";
794
- required: false;
795
- defaultValue: false;
796
- };
797
- twoFactorSecret: {
798
- type: "string";
799
- required: false;
800
- };
801
- twoFactorBackupCodes: {
802
- type: "string";
803
- required: false;
804
- returned: false;
982
+ } & {
983
+ method: "*";
984
+ }>)[];
985
+ }> | undefined): Promise<{
986
+ id: string;
987
+ name: string;
988
+ slug: string;
989
+ }[]>;
990
+ path: "/organization/list";
991
+ options: {
992
+ method: "GET";
993
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
994
+ orgOptions: OrganizationOptions;
995
+ roles: typeof defaultRoles & {
996
+ [key: string]: Role<{}>;
805
997
  };
806
- };
807
- };
808
- };
809
- };
810
- id: string;
811
- actions?: Record<string, any> | undefined;
812
- authProxySignal?: AuthProxySignal[];
813
- signals?: Record<string, nanostores.PreinitializedWritableAtom<boolean>>;
814
- atoms?: Record<string, nanostores.Atom<any>>;
815
- pathMethods?: Record<string, "POST" | "GET">;
816
- fetchPlugins?: _better_fetch_fetch.BetterFetchPlugin[];
817
- };
818
-
819
- declare const memberSchema: z.ZodObject<{
820
- id: z.ZodString;
821
- name: z.ZodString;
822
- email: z.ZodString;
823
- organizationId: z.ZodString;
824
- userId: z.ZodString;
825
- role: z.ZodEnum<["admin", "member", "owner"]>;
826
- }, "strip", z.ZodTypeAny, {
827
- id: string;
828
- name: string;
829
- email: string;
830
- userId: string;
831
- organizationId: string;
832
- role: "admin" | "member" | "owner";
833
- }, {
834
- id: string;
835
- name: string;
836
- email: string;
837
- userId: string;
838
- organizationId: string;
839
- role: "admin" | "member" | "owner";
840
- }>;
841
- declare const invitationSchema: z.ZodObject<{
842
- id: z.ZodString;
843
- organizationId: z.ZodString;
844
- email: z.ZodString;
845
- role: z.ZodEnum<["admin", "member", "owner"]>;
846
- status: z.ZodDefault<z.ZodEnum<["pending", "accepted", "rejected", "canceled"]>>;
847
- /**
848
- * The id of the user who invited the user.
849
- */
850
- inviterId: z.ZodString;
851
- expiresAt: z.ZodDate;
852
- }, "strip", z.ZodTypeAny, {
853
- status: "pending" | "accepted" | "rejected" | "canceled";
854
- id: string;
855
- email: string;
856
- expiresAt: Date;
857
- organizationId: string;
858
- role: "admin" | "member" | "owner";
859
- inviterId: string;
860
- }, {
861
- id: string;
862
- email: string;
863
- expiresAt: Date;
864
- organizationId: string;
865
- role: "admin" | "member" | "owner";
866
- inviterId: string;
867
- status?: "pending" | "accepted" | "rejected" | "canceled" | undefined;
868
- }>;
869
- type Member = z.infer<typeof memberSchema>;
870
- type Invitation = z.infer<typeof invitationSchema>;
871
-
872
- interface OrganizationOptions {
873
- /**
874
- * Configure whether new users are able to create new organizations.
875
- * You can also pass a function that returns a boolean.
876
- *
877
- * @example
878
- * ```ts
879
- * allowUserToCreateOrganization: async (user) => {
880
- * const plan = await getUserPlan(user);
881
- * return plan.name === "pro";
882
- * }
883
- * ```
884
- * @default true
885
- */
886
- allowUserToCreateOrganization?: boolean | ((user: User) => Promise<boolean> | boolean);
887
- /**
888
- *
889
- */
890
- organizationLimit?: number;
891
- /**
892
- * The role that is assigned to the creator of the organization.
893
- *
894
- * @default "admin"
895
- */
896
- creatorRole?: "admin" | "owner";
897
- /**
898
- * The number of memberships a user can have in an organization.
899
- *
900
- * @default "unlimited"
901
- */
902
- membershipLimit?: number;
903
- /**
904
- * Configure the roles and permissions for the organization plugin.
905
- *
906
- */
907
- ac?: AccessControl;
908
- /**
909
- *
910
- */
911
- roles?: {
912
- [key in "admin" | "member" | "owner"]?: Role<any>;
913
- };
914
- /**
915
- * The expiration time for the invitation link.
916
- *
917
- * @default 48 hours
918
- */
919
- invitationExpiresIn?: number;
920
- /**
921
- * @param invitation the invitation object
922
- * @param email the email of the user to be invited
923
- *
924
- * Make sure to construct the invitation link using the invitation id.
925
- * @example
926
- * ```ts
927
- * const invitationLink = `${ctx.origin}/organization/accept-invitation?invitationId=$
928
- * {invitation.id}`
929
- *
930
- * ```
931
- */
932
- sendInvitationEmail?: (invitation: Invitation, email: string) => Promise<void>;
933
- }
934
- declare const organization: <O extends OrganizationOptions>(options?: O) => {
935
- id: "organization";
936
- endpoints: {
937
- hasPermission: {
938
- (ctx_0: better_call.Context<"/organization/has-permission", {
939
- method: "POST";
940
- requireHeaders: true;
941
- body: ZodObject<{
942
- permission: ZodObject<{ [key in keyof (O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
943
- readonly organization: readonly ["update", "delete"];
944
- readonly member: readonly ["create", "update", "delete"];
945
- readonly invitation: readonly ["create", "cancel"];
946
- } : {
947
- readonly organization: readonly ["update", "delete"];
948
- readonly member: readonly ["create", "update", "delete"];
949
- readonly invitation: readonly ["create", "cancel"];
950
- } : {
951
- readonly organization: readonly ["update", "delete"];
952
- readonly member: readonly ["create", "update", "delete"];
953
- readonly invitation: readonly ["create", "cancel"];
954
- })]: ZodOptional<ZodArray<ZodLiteral<(O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
955
- readonly organization: readonly ["update", "delete"];
956
- readonly member: readonly ["create", "update", "delete"];
957
- readonly invitation: readonly ["create", "cancel"];
958
- } : {
959
- readonly organization: readonly ["update", "delete"];
960
- readonly member: readonly ["create", "update", "delete"];
961
- readonly invitation: readonly ["create", "cancel"];
962
- } : {
963
- readonly organization: readonly ["update", "delete"];
964
- readonly member: readonly ["create", "update", "delete"];
965
- readonly invitation: readonly ["create", "cancel"];
966
- })[key][number]>>>; }>;
967
- }>;
968
- use: better_call.Endpoint<better_call.Handler<string, {
998
+ getSession: (context: better_call.Context<any, any>) => Promise<{
999
+ session: Session & {
1000
+ activeOrganizationId?: string;
1001
+ };
1002
+ user: User;
1003
+ }>;
1004
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
969
1005
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
970
1006
  session: {
971
1007
  session: {
@@ -1018,46 +1054,26 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1018
1054
  }>, better_call.EndpointOptions>[];
1019
1055
  } & {
1020
1056
  method: "*";
1021
- }>[];
1022
- }>): Promise<{
1023
- error: string;
1024
- success: boolean;
1025
- } | {
1026
- error: null;
1027
- success: boolean;
1028
- }>;
1029
- path: "/organization/has-permission";
1030
- options: {
1057
+ }>)[];
1058
+ };
1059
+ method: better_call.Method | better_call.Method[];
1060
+ headers: Headers;
1061
+ };
1062
+ createInvitation: {
1063
+ (ctx_0: better_call.Context<"/organization/invite-member", {
1031
1064
  method: "POST";
1032
- requireHeaders: true;
1033
- body: ZodObject<{
1034
- permission: ZodObject<{ [key in keyof (O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
1035
- readonly organization: readonly ["update", "delete"];
1036
- readonly member: readonly ["create", "update", "delete"];
1037
- readonly invitation: readonly ["create", "cancel"];
1038
- } : {
1039
- readonly organization: readonly ["update", "delete"];
1040
- readonly member: readonly ["create", "update", "delete"];
1041
- readonly invitation: readonly ["create", "cancel"];
1042
- } : {
1043
- readonly organization: readonly ["update", "delete"];
1044
- readonly member: readonly ["create", "update", "delete"];
1045
- readonly invitation: readonly ["create", "cancel"];
1046
- })]: ZodOptional<ZodArray<ZodLiteral<(O["ac"] extends AccessControl<infer S extends StatementsPrimitive> ? S extends Record<string, any> ? S & {
1047
- readonly organization: readonly ["update", "delete"];
1048
- readonly member: readonly ["create", "update", "delete"];
1049
- readonly invitation: readonly ["create", "cancel"];
1050
- } : {
1051
- readonly organization: readonly ["update", "delete"];
1052
- readonly member: readonly ["create", "update", "delete"];
1053
- readonly invitation: readonly ["create", "cancel"];
1054
- } : {
1055
- readonly organization: readonly ["update", "delete"];
1056
- readonly member: readonly ["create", "update", "delete"];
1057
- readonly invitation: readonly ["create", "cancel"];
1058
- })[key][number]>>>; }>;
1059
- }>;
1060
- use: better_call.Endpoint<better_call.Handler<string, {
1065
+ use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1066
+ orgOptions: OrganizationOptions;
1067
+ roles: typeof defaultRoles & {
1068
+ [key: string]: Role<{}>;
1069
+ };
1070
+ getSession: (context: better_call.Context<any, any>) => Promise<{
1071
+ session: Session & {
1072
+ activeOrganizationId?: string;
1073
+ };
1074
+ user: User;
1075
+ }>;
1076
+ }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
1061
1077
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1062
1078
  session: {
1063
1079
  session: {
@@ -1110,27 +1126,35 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1110
1126
  }>, better_call.EndpointOptions>[];
1111
1127
  } & {
1112
1128
  method: "*";
1113
- }>[];
1114
- };
1115
- method: better_call.Method | better_call.Method[];
1116
- headers: Headers;
1117
- };
1118
- createOrganization: {
1119
- (ctx_0: better_call.Context<"/organization/create", {
1120
- method: "POST";
1129
+ }>)[];
1121
1130
  body: ZodObject<{
1122
- name: z.ZodString;
1123
- slug: z.ZodString;
1124
- userId: ZodOptional<z.ZodString>;
1131
+ email: z.ZodString;
1132
+ role: z.ZodEnum<["admin", "member", "owner"]>;
1133
+ organizationId: ZodOptional<z.ZodString>;
1134
+ resend: ZodOptional<z.ZodBoolean>;
1125
1135
  }, "strip", z.ZodTypeAny, {
1126
- name: string;
1127
- slug: string;
1128
- userId?: string | undefined;
1129
- }, {
1130
- name: string;
1131
- slug: string;
1132
- userId?: string | undefined;
1136
+ email: string;
1137
+ role: "member" | "admin" | "owner";
1138
+ organizationId?: string | undefined;
1139
+ resend?: boolean | undefined;
1140
+ }, {
1141
+ email: string;
1142
+ role: "member" | "admin" | "owner";
1143
+ organizationId?: string | undefined;
1144
+ resend?: boolean | undefined;
1133
1145
  }>;
1146
+ }>): Promise<{
1147
+ id: string;
1148
+ expiresAt: Date;
1149
+ status: "pending" | "accepted" | "rejected" | "canceled";
1150
+ email: string;
1151
+ organizationId: string;
1152
+ role: "member" | "admin" | "owner";
1153
+ inviterId: string;
1154
+ } | null>;
1155
+ path: "/organization/invite-member";
1156
+ options: {
1157
+ method: "POST";
1134
1158
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1135
1159
  orgOptions: OrganizationOptions;
1136
1160
  roles: typeof defaultRoles & {
@@ -1196,34 +1220,35 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1196
1220
  } & {
1197
1221
  method: "*";
1198
1222
  }>)[];
1199
- }>): Promise<{
1200
- members: {
1201
- id: string;
1202
- name: string;
1223
+ body: ZodObject<{
1224
+ email: z.ZodString;
1225
+ role: z.ZodEnum<["admin", "member", "owner"]>;
1226
+ organizationId: ZodOptional<z.ZodString>;
1227
+ resend: ZodOptional<z.ZodBoolean>;
1228
+ }, "strip", z.ZodTypeAny, {
1203
1229
  email: string;
1204
- userId: string;
1205
- organizationId: string;
1206
- role: "admin" | "member" | "owner";
1207
- }[];
1208
- id: string;
1209
- name: string;
1210
- slug: string;
1211
- } | null>;
1212
- path: "/organization/create";
1213
- options: {
1230
+ role: "member" | "admin" | "owner";
1231
+ organizationId?: string | undefined;
1232
+ resend?: boolean | undefined;
1233
+ }, {
1234
+ email: string;
1235
+ role: "member" | "admin" | "owner";
1236
+ organizationId?: string | undefined;
1237
+ resend?: boolean | undefined;
1238
+ }>;
1239
+ };
1240
+ method: better_call.Method | better_call.Method[];
1241
+ headers: Headers;
1242
+ };
1243
+ cancelInvitation: {
1244
+ (ctx_0: better_call.Context<"/organization/cancel-invitation", {
1214
1245
  method: "POST";
1215
1246
  body: ZodObject<{
1216
- name: z.ZodString;
1217
- slug: z.ZodString;
1218
- userId: ZodOptional<z.ZodString>;
1247
+ invitationId: z.ZodString;
1219
1248
  }, "strip", z.ZodTypeAny, {
1220
- name: string;
1221
- slug: string;
1222
- userId?: string | undefined;
1249
+ invitationId: string;
1223
1250
  }, {
1224
- name: string;
1225
- slug: string;
1226
- userId?: string | undefined;
1251
+ invitationId: string;
1227
1252
  }>;
1228
1253
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1229
1254
  orgOptions: OrganizationOptions;
@@ -1290,196 +1315,25 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1290
1315
  } & {
1291
1316
  method: "*";
1292
1317
  }>)[];
1293
- };
1294
- method: better_call.Method | better_call.Method[];
1295
- headers: Headers;
1296
- };
1297
- updateOrganization: {
1298
- (ctx_0: better_call.Context<"/organization/update", {
1299
- method: "POST";
1300
- body: ZodObject<{
1301
- name: ZodOptional<z.ZodString>;
1302
- slug: ZodOptional<z.ZodString>;
1303
- orgId: ZodOptional<z.ZodString>;
1304
- }, "strip", z.ZodTypeAny, {
1305
- name?: string | undefined;
1306
- slug?: string | undefined;
1307
- orgId?: string | undefined;
1308
- }, {
1309
- name?: string | undefined;
1310
- slug?: string | undefined;
1311
- orgId?: string | undefined;
1312
- }>;
1313
- requireHeaders: true;
1314
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1315
- orgOptions: OrganizationOptions;
1316
- roles: typeof defaultRoles & {
1317
- [key: string]: Role<{}>;
1318
- };
1319
- getSession: (context: better_call.Context<any, any>) => Promise<{
1320
- session: Session & {
1321
- activeOrganizationId?: string;
1322
- };
1323
- user: User;
1324
- }>;
1325
- }>, better_call.EndpointOptions>[];
1326
- }>): Promise<{
1327
- id: string;
1328
- name: string;
1329
- slug: string;
1330
- } | null>;
1331
- path: "/organization/update";
1332
- options: {
1333
- method: "POST";
1334
- body: ZodObject<{
1335
- name: ZodOptional<z.ZodString>;
1336
- slug: ZodOptional<z.ZodString>;
1337
- orgId: ZodOptional<z.ZodString>;
1338
- }, "strip", z.ZodTypeAny, {
1339
- name?: string | undefined;
1340
- slug?: string | undefined;
1341
- orgId?: string | undefined;
1342
- }, {
1343
- name?: string | undefined;
1344
- slug?: string | undefined;
1345
- orgId?: string | undefined;
1346
- }>;
1347
- requireHeaders: true;
1348
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1349
- orgOptions: OrganizationOptions;
1350
- roles: typeof defaultRoles & {
1351
- [key: string]: Role<{}>;
1352
- };
1353
- getSession: (context: better_call.Context<any, any>) => Promise<{
1354
- session: Session & {
1355
- activeOrganizationId?: string;
1356
- };
1357
- user: User;
1358
- }>;
1359
- }>, better_call.EndpointOptions>[];
1360
- };
1361
- method: better_call.Method | better_call.Method[];
1362
- headers: Headers;
1363
- };
1364
- setActiveOrganization: {
1365
- (ctx_0: better_call.Context<"/organization/set-active", {
1366
- method: "POST";
1367
- body: ZodObject<{
1368
- orgId: z.ZodString;
1369
- }, "strip", z.ZodTypeAny, {
1370
- orgId: string;
1371
- }, {
1372
- orgId: string;
1373
- }>;
1374
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1375
- session: {
1376
- session: {
1377
- id: string;
1378
- userId: string;
1379
- expiresAt: Date;
1380
- ipAddress?: string | undefined;
1381
- userAgent?: string | undefined;
1382
- };
1383
- user: {
1384
- id: string;
1385
- name: string;
1386
- email: string;
1387
- emailVerified: boolean;
1388
- createdAt: Date;
1389
- updatedAt: Date;
1390
- image?: string | undefined;
1391
- };
1392
- };
1393
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1394
- orgOptions: OrganizationOptions;
1395
- roles: typeof defaultRoles & {
1396
- [key: string]: Role<{}>;
1397
- };
1398
- getSession: (context: better_call.Context<any, any>) => Promise<{
1399
- session: Session & {
1400
- activeOrganizationId?: string;
1401
- };
1402
- user: User;
1403
- }>;
1404
- }>, better_call.EndpointOptions>)[];
1405
1318
  }>): Promise<{
1406
- members: {
1407
- id: string;
1408
- name: string;
1409
- email: string;
1410
- userId: string;
1411
- organizationId: string;
1412
- role: "admin" | "member" | "owner";
1413
- }[];
1414
- invitations: {
1415
- status: "pending" | "accepted" | "rejected" | "canceled";
1416
- id: string;
1417
- email: string;
1418
- expiresAt: Date;
1419
- organizationId: string;
1420
- role: "admin" | "member" | "owner";
1421
- inviterId: string;
1422
- }[];
1423
1319
  id: string;
1424
- name: string;
1425
- slug: string;
1320
+ expiresAt: Date;
1321
+ status: "pending" | "accepted" | "rejected" | "canceled";
1322
+ email: string;
1323
+ organizationId: string;
1324
+ role: "member" | "admin" | "owner";
1325
+ inviterId: string;
1426
1326
  } | null>;
1427
- path: "/organization/set-active";
1327
+ path: "/organization/cancel-invitation";
1428
1328
  options: {
1429
1329
  method: "POST";
1430
1330
  body: ZodObject<{
1431
- orgId: z.ZodString;
1432
- }, "strip", z.ZodTypeAny, {
1433
- orgId: string;
1434
- }, {
1435
- orgId: string;
1436
- }>;
1437
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1438
- session: {
1439
- session: {
1440
- id: string;
1441
- userId: string;
1442
- expiresAt: Date;
1443
- ipAddress?: string | undefined;
1444
- userAgent?: string | undefined;
1445
- };
1446
- user: {
1447
- id: string;
1448
- name: string;
1449
- email: string;
1450
- emailVerified: boolean;
1451
- createdAt: Date;
1452
- updatedAt: Date;
1453
- image?: string | undefined;
1454
- };
1455
- };
1456
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1457
- orgOptions: OrganizationOptions;
1458
- roles: typeof defaultRoles & {
1459
- [key: string]: Role<{}>;
1460
- };
1461
- getSession: (context: better_call.Context<any, any>) => Promise<{
1462
- session: Session & {
1463
- activeOrganizationId?: string;
1464
- };
1465
- user: User;
1466
- }>;
1467
- }>, better_call.EndpointOptions>)[];
1468
- };
1469
- method: better_call.Method | better_call.Method[];
1470
- headers: Headers;
1471
- };
1472
- getFullOrganization: {
1473
- (ctx_0: better_call.Context<"/organization/full", {
1474
- method: "GET";
1475
- query: ZodObject<{
1476
- orgId: ZodOptional<z.ZodString>;
1331
+ invitationId: z.ZodString;
1477
1332
  }, "strip", z.ZodTypeAny, {
1478
- orgId?: string | undefined;
1333
+ invitationId: string;
1479
1334
  }, {
1480
- orgId?: string | undefined;
1335
+ invitationId: string;
1481
1336
  }>;
1482
- requireHeaders: true;
1483
1337
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1484
1338
  orgOptions: OrganizationOptions;
1485
1339
  roles: typeof defaultRoles & {
@@ -1545,39 +1399,20 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1545
1399
  } & {
1546
1400
  method: "*";
1547
1401
  }>)[];
1548
- }>): Promise<{
1549
- members: {
1550
- id: string;
1551
- name: string;
1552
- email: string;
1553
- userId: string;
1554
- organizationId: string;
1555
- role: "admin" | "member" | "owner";
1556
- }[];
1557
- invitations: {
1558
- status: "pending" | "accepted" | "rejected" | "canceled";
1559
- id: string;
1560
- email: string;
1561
- expiresAt: Date;
1562
- organizationId: string;
1563
- role: "admin" | "member" | "owner";
1564
- inviterId: string;
1565
- }[];
1566
- id: string;
1567
- name: string;
1568
- slug: string;
1569
- } | null>;
1570
- path: "/organization/full";
1571
- options: {
1572
- method: "GET";
1573
- query: ZodObject<{
1574
- orgId: ZodOptional<z.ZodString>;
1402
+ };
1403
+ method: better_call.Method | better_call.Method[];
1404
+ headers: Headers;
1405
+ };
1406
+ acceptInvitation: {
1407
+ (ctx_0: better_call.Context<"/organization/accept-invitation", {
1408
+ method: "POST";
1409
+ body: ZodObject<{
1410
+ invitationId: z.ZodString;
1575
1411
  }, "strip", z.ZodTypeAny, {
1576
- orgId?: string | undefined;
1412
+ invitationId: string;
1577
1413
  }, {
1578
- orgId?: string | undefined;
1414
+ invitationId: string;
1579
1415
  }>;
1580
- requireHeaders: true;
1581
1416
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1582
1417
  orgOptions: OrganizationOptions;
1583
1418
  roles: typeof defaultRoles & {
@@ -1643,13 +1478,35 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1643
1478
  } & {
1644
1479
  method: "*";
1645
1480
  }>)[];
1646
- };
1647
- method: better_call.Method | better_call.Method[];
1648
- headers: Headers;
1649
- };
1650
- listOrganization: {
1651
- (ctx_0?: better_call.Context<"/organization/list", {
1652
- method: "GET";
1481
+ }>): Promise<{
1482
+ invitation: {
1483
+ id: string;
1484
+ expiresAt: Date;
1485
+ status: "pending" | "accepted" | "rejected" | "canceled";
1486
+ email: string;
1487
+ organizationId: string;
1488
+ role: "member" | "admin" | "owner";
1489
+ inviterId: string;
1490
+ };
1491
+ member: {
1492
+ id: string;
1493
+ userId: string;
1494
+ name: string;
1495
+ email: string;
1496
+ organizationId: string;
1497
+ role: "member" | "admin" | "owner";
1498
+ };
1499
+ } | null>;
1500
+ path: "/organization/accept-invitation";
1501
+ options: {
1502
+ method: "POST";
1503
+ body: ZodObject<{
1504
+ invitationId: z.ZodString;
1505
+ }, "strip", z.ZodTypeAny, {
1506
+ invitationId: string;
1507
+ }, {
1508
+ invitationId: string;
1509
+ }>;
1653
1510
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1654
1511
  orgOptions: OrganizationOptions;
1655
1512
  roles: typeof defaultRoles & {
@@ -1715,14 +1572,81 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1715
1572
  } & {
1716
1573
  method: "*";
1717
1574
  }>)[];
1718
- }> | undefined): Promise<{
1575
+ };
1576
+ method: better_call.Method | better_call.Method[];
1577
+ headers: Headers;
1578
+ };
1579
+ getActiveInvitation: {
1580
+ (ctx_0: better_call.Context<"/organization/get-active-invitation", {
1581
+ method: "GET";
1582
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1583
+ orgOptions: OrganizationOptions;
1584
+ roles: typeof defaultRoles & {
1585
+ [key: string]: Role<{}>;
1586
+ };
1587
+ getSession: (context: better_call.Context<any, any>) => Promise<{
1588
+ session: Session & {
1589
+ activeOrganizationId?: string;
1590
+ };
1591
+ user: User;
1592
+ }>;
1593
+ }>, better_call.EndpointOptions>[];
1594
+ query: ZodObject<{
1595
+ id: z.ZodString;
1596
+ }, "strip", z.ZodTypeAny, {
1597
+ id: string;
1598
+ }, {
1599
+ id: string;
1600
+ }>;
1601
+ }>): Promise<{
1602
+ organizationName: string;
1603
+ organizationSlug: string;
1604
+ inviterEmail: string;
1605
+ inviterName: string;
1719
1606
  id: string;
1720
- name: string;
1721
- slug: string;
1722
- }[]>;
1723
- path: "/organization/list";
1607
+ expiresAt: Date;
1608
+ status: "pending" | "accepted" | "rejected" | "canceled";
1609
+ email: string;
1610
+ organizationId: string;
1611
+ role: "member" | "admin" | "owner";
1612
+ inviterId: string;
1613
+ } | null>;
1614
+ path: "/organization/get-active-invitation";
1724
1615
  options: {
1725
1616
  method: "GET";
1617
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1618
+ orgOptions: OrganizationOptions;
1619
+ roles: typeof defaultRoles & {
1620
+ [key: string]: Role<{}>;
1621
+ };
1622
+ getSession: (context: better_call.Context<any, any>) => Promise<{
1623
+ session: Session & {
1624
+ activeOrganizationId?: string;
1625
+ };
1626
+ user: User;
1627
+ }>;
1628
+ }>, better_call.EndpointOptions>[];
1629
+ query: ZodObject<{
1630
+ id: z.ZodString;
1631
+ }, "strip", z.ZodTypeAny, {
1632
+ id: string;
1633
+ }, {
1634
+ id: string;
1635
+ }>;
1636
+ };
1637
+ method: better_call.Method | better_call.Method[];
1638
+ headers: Headers;
1639
+ };
1640
+ rejectInvitation: {
1641
+ (ctx_0: better_call.Context<"/organization/reject-invitation", {
1642
+ method: "POST";
1643
+ body: ZodObject<{
1644
+ invitationId: z.ZodString;
1645
+ }, "strip", z.ZodTypeAny, {
1646
+ invitationId: string;
1647
+ }, {
1648
+ invitationId: string;
1649
+ }>;
1726
1650
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1727
1651
  orgOptions: OrganizationOptions;
1728
1652
  roles: typeof defaultRoles & {
@@ -1788,13 +1712,28 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1788
1712
  } & {
1789
1713
  method: "*";
1790
1714
  }>)[];
1791
- };
1792
- method: better_call.Method | better_call.Method[];
1793
- headers: Headers;
1794
- };
1795
- createInvitation: {
1796
- (ctx_0: better_call.Context<"/organization/invite-member", {
1715
+ }>): Promise<{
1716
+ invitation: {
1717
+ id: string;
1718
+ expiresAt: Date;
1719
+ status: "pending" | "accepted" | "rejected" | "canceled";
1720
+ email: string;
1721
+ organizationId: string;
1722
+ role: "member" | "admin" | "owner";
1723
+ inviterId: string;
1724
+ } | null;
1725
+ member: null;
1726
+ } | null>;
1727
+ path: "/organization/reject-invitation";
1728
+ options: {
1797
1729
  method: "POST";
1730
+ body: ZodObject<{
1731
+ invitationId: z.ZodString;
1732
+ }, "strip", z.ZodTypeAny, {
1733
+ invitationId: string;
1734
+ }, {
1735
+ invitationId: string;
1736
+ }>;
1798
1737
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1799
1738
  orgOptions: OrganizationOptions;
1800
1739
  roles: typeof defaultRoles & {
@@ -1860,34 +1799,23 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1860
1799
  } & {
1861
1800
  method: "*";
1862
1801
  }>)[];
1802
+ };
1803
+ method: better_call.Method | better_call.Method[];
1804
+ headers: Headers;
1805
+ };
1806
+ removeMember: {
1807
+ (ctx_0: better_call.Context<"/organization/remove-member", {
1808
+ method: "POST";
1863
1809
  body: ZodObject<{
1864
- email: z.ZodString;
1865
- role: z.ZodEnum<["admin", "member", "owner"]>;
1810
+ memberIdOrEmail: z.ZodString;
1866
1811
  organizationId: ZodOptional<z.ZodString>;
1867
- resend: ZodOptional<z.ZodBoolean>;
1868
1812
  }, "strip", z.ZodTypeAny, {
1869
- email: string;
1870
- role: "admin" | "member" | "owner";
1813
+ memberIdOrEmail: string;
1871
1814
  organizationId?: string | undefined;
1872
- resend?: boolean | undefined;
1873
1815
  }, {
1874
- email: string;
1875
- role: "admin" | "member" | "owner";
1816
+ memberIdOrEmail: string;
1876
1817
  organizationId?: string | undefined;
1877
- resend?: boolean | undefined;
1878
1818
  }>;
1879
- }>): Promise<{
1880
- status: "pending" | "accepted" | "rejected" | "canceled";
1881
- id: string;
1882
- email: string;
1883
- expiresAt: Date;
1884
- organizationId: string;
1885
- role: "admin" | "member" | "owner";
1886
- inviterId: string;
1887
- } | null>;
1888
- path: "/organization/invite-member";
1889
- options: {
1890
- method: "POST";
1891
1819
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1892
1820
  orgOptions: OrganizationOptions;
1893
1821
  roles: typeof defaultRoles & {
@@ -1953,35 +1881,28 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
1953
1881
  } & {
1954
1882
  method: "*";
1955
1883
  }>)[];
1884
+ }>): Promise<{
1885
+ member: {
1886
+ id: string;
1887
+ userId: string;
1888
+ name: string;
1889
+ email: string;
1890
+ organizationId: string;
1891
+ role: "member" | "admin" | "owner";
1892
+ };
1893
+ } | null>;
1894
+ path: "/organization/remove-member";
1895
+ options: {
1896
+ method: "POST";
1956
1897
  body: ZodObject<{
1957
- email: z.ZodString;
1958
- role: z.ZodEnum<["admin", "member", "owner"]>;
1898
+ memberIdOrEmail: z.ZodString;
1959
1899
  organizationId: ZodOptional<z.ZodString>;
1960
- resend: ZodOptional<z.ZodBoolean>;
1961
1900
  }, "strip", z.ZodTypeAny, {
1962
- email: string;
1963
- role: "admin" | "member" | "owner";
1901
+ memberIdOrEmail: string;
1964
1902
  organizationId?: string | undefined;
1965
- resend?: boolean | undefined;
1966
1903
  }, {
1967
- email: string;
1968
- role: "admin" | "member" | "owner";
1904
+ memberIdOrEmail: string;
1969
1905
  organizationId?: string | undefined;
1970
- resend?: boolean | undefined;
1971
- }>;
1972
- };
1973
- method: better_call.Method | better_call.Method[];
1974
- headers: Headers;
1975
- };
1976
- cancelInvitation: {
1977
- (ctx_0: better_call.Context<"/organization/cancel-invitation", {
1978
- method: "POST";
1979
- body: ZodObject<{
1980
- invitationId: z.ZodString;
1981
- }, "strip", z.ZodTypeAny, {
1982
- invitationId: string;
1983
- }, {
1984
- invitationId: string;
1985
1906
  }>;
1986
1907
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1987
1908
  orgOptions: OrganizationOptions;
@@ -2048,24 +1969,25 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
2048
1969
  } & {
2049
1970
  method: "*";
2050
1971
  }>)[];
2051
- }>): Promise<{
2052
- status: "pending" | "accepted" | "rejected" | "canceled";
2053
- id: string;
2054
- email: string;
2055
- expiresAt: Date;
2056
- organizationId: string;
2057
- role: "admin" | "member" | "owner";
2058
- inviterId: string;
2059
- } | null>;
2060
- path: "/organization/cancel-invitation";
2061
- options: {
1972
+ };
1973
+ method: better_call.Method | better_call.Method[];
1974
+ headers: Headers;
1975
+ };
1976
+ updateMemberRole: {
1977
+ (ctx_0: better_call.Context<"/organization/update-member-role", {
2062
1978
  method: "POST";
2063
1979
  body: ZodObject<{
2064
- invitationId: z.ZodString;
1980
+ role: z.ZodEnum<["admin", "member", "owner"]>;
1981
+ memberId: z.ZodString;
1982
+ organizationId: ZodOptional<z.ZodString>;
2065
1983
  }, "strip", z.ZodTypeAny, {
2066
- invitationId: string;
1984
+ role: "member" | "admin" | "owner";
1985
+ memberId: string;
1986
+ organizationId?: string | undefined;
2067
1987
  }, {
2068
- invitationId: string;
1988
+ role: "member" | "admin" | "owner";
1989
+ memberId: string;
1990
+ organizationId?: string | undefined;
2069
1991
  }>;
2070
1992
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2071
1993
  orgOptions: OrganizationOptions;
@@ -2132,113 +2054,29 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
2132
2054
  } & {
2133
2055
  method: "*";
2134
2056
  }>)[];
2135
- };
2136
- method: better_call.Method | better_call.Method[];
2137
- headers: Headers;
2138
- };
2139
- acceptInvitation: {
2140
- (ctx_0: better_call.Context<"/organization/accept-invitation", {
2057
+ }>): Promise<{
2058
+ id: string;
2059
+ userId: string;
2060
+ name: string;
2061
+ email: string;
2062
+ organizationId: string;
2063
+ role: "member" | "admin" | "owner";
2064
+ } | null>;
2065
+ path: "/organization/update-member-role";
2066
+ options: {
2141
2067
  method: "POST";
2142
2068
  body: ZodObject<{
2143
- invitationId: z.ZodString;
2069
+ role: z.ZodEnum<["admin", "member", "owner"]>;
2070
+ memberId: z.ZodString;
2071
+ organizationId: ZodOptional<z.ZodString>;
2144
2072
  }, "strip", z.ZodTypeAny, {
2145
- invitationId: string;
2146
- }, {
2147
- invitationId: string;
2148
- }>;
2149
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2150
- orgOptions: OrganizationOptions;
2151
- roles: typeof defaultRoles & {
2152
- [key: string]: Role<{}>;
2153
- };
2154
- getSession: (context: better_call.Context<any, any>) => Promise<{
2155
- session: Session & {
2156
- activeOrganizationId?: string;
2157
- };
2158
- user: User;
2159
- }>;
2160
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2161
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2162
- session: {
2163
- session: {
2164
- id: string;
2165
- userId: string;
2166
- expiresAt: Date;
2167
- ipAddress?: string | undefined;
2168
- userAgent?: string | undefined;
2169
- };
2170
- user: {
2171
- id: string;
2172
- name: string;
2173
- email: string;
2174
- emailVerified: boolean;
2175
- createdAt: Date;
2176
- updatedAt: Date;
2177
- image?: string | undefined;
2178
- };
2179
- };
2180
- }>, better_call.EndpointOptions>[];
2181
- } & {
2182
- method: "*";
2183
- }, {
2184
- session: {
2185
- session: Session & {
2186
- activeOrganizationId?: string;
2187
- };
2188
- user: User;
2189
- };
2190
- }>, {
2191
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2192
- session: {
2193
- session: {
2194
- id: string;
2195
- userId: string;
2196
- expiresAt: Date;
2197
- ipAddress?: string | undefined;
2198
- userAgent?: string | undefined;
2199
- };
2200
- user: {
2201
- id: string;
2202
- name: string;
2203
- email: string;
2204
- emailVerified: boolean;
2205
- createdAt: Date;
2206
- updatedAt: Date;
2207
- image?: string | undefined;
2208
- };
2209
- };
2210
- }>, better_call.EndpointOptions>[];
2211
- } & {
2212
- method: "*";
2213
- }>)[];
2214
- }>): Promise<{
2215
- invitation: {
2216
- status: "pending" | "accepted" | "rejected" | "canceled";
2217
- id: string;
2218
- email: string;
2219
- expiresAt: Date;
2220
- organizationId: string;
2221
- role: "admin" | "member" | "owner";
2222
- inviterId: string;
2223
- };
2224
- member: {
2225
- id: string;
2226
- name: string;
2227
- email: string;
2228
- userId: string;
2229
- organizationId: string;
2230
- role: "admin" | "member" | "owner";
2231
- };
2232
- } | null>;
2233
- path: "/organization/accept-invitation";
2234
- options: {
2235
- method: "POST";
2236
- body: ZodObject<{
2237
- invitationId: z.ZodString;
2238
- }, "strip", z.ZodTypeAny, {
2239
- invitationId: string;
2073
+ role: "member" | "admin" | "owner";
2074
+ memberId: string;
2075
+ organizationId?: string | undefined;
2240
2076
  }, {
2241
- invitationId: string;
2077
+ role: "member" | "admin" | "owner";
2078
+ memberId: string;
2079
+ organizationId?: string | undefined;
2242
2080
  }>;
2243
2081
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2244
2082
  orgOptions: OrganizationOptions;
@@ -2309,636 +2147,976 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
2309
2147
  method: better_call.Method | better_call.Method[];
2310
2148
  headers: Headers;
2311
2149
  };
2312
- getActiveInvitation: {
2313
- (ctx_0: better_call.Context<"/organization/get-active-invitation", {
2314
- method: "GET";
2315
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2316
- orgOptions: OrganizationOptions;
2317
- roles: typeof defaultRoles & {
2318
- [key: string]: Role<{}>;
2319
- };
2320
- getSession: (context: better_call.Context<any, any>) => Promise<{
2321
- session: Session & {
2322
- activeOrganizationId?: string;
2323
- };
2324
- user: User;
2325
- }>;
2326
- }>, better_call.EndpointOptions>[];
2327
- query: ZodObject<{
2328
- id: z.ZodString;
2329
- }, "strip", z.ZodTypeAny, {
2330
- id: string;
2331
- }, {
2332
- id: string;
2333
- }>;
2334
- }>): Promise<{
2335
- organizationName: string;
2336
- organizationSlug: string;
2337
- inviterEmail: string;
2338
- inviterName: string;
2339
- status: "pending" | "accepted" | "rejected" | "canceled";
2340
- id: string;
2341
- email: string;
2342
- expiresAt: Date;
2343
- organizationId: string;
2344
- role: "admin" | "member" | "owner";
2345
- inviterId: string;
2346
- } | null>;
2347
- path: "/organization/get-active-invitation";
2348
- options: {
2349
- method: "GET";
2350
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2351
- orgOptions: OrganizationOptions;
2352
- roles: typeof defaultRoles & {
2353
- [key: string]: Role<{}>;
2354
- };
2355
- getSession: (context: better_call.Context<any, any>) => Promise<{
2356
- session: Session & {
2357
- activeOrganizationId?: string;
2358
- };
2359
- user: User;
2360
- }>;
2361
- }>, better_call.EndpointOptions>[];
2362
- query: ZodObject<{
2363
- id: z.ZodString;
2364
- }, "strip", z.ZodTypeAny, {
2365
- id: string;
2366
- }, {
2367
- id: string;
2368
- }>;
2150
+ };
2151
+ schema: {
2152
+ session: {
2153
+ fields: {
2154
+ activeOrganizationId: {
2155
+ type: "string";
2156
+ required: false;
2157
+ };
2369
2158
  };
2370
- method: better_call.Method | better_call.Method[];
2371
- headers: Headers;
2372
2159
  };
2373
- rejectInvitation: {
2374
- (ctx_0: better_call.Context<"/organization/reject-invitation", {
2375
- method: "POST";
2376
- body: ZodObject<{
2377
- invitationId: z.ZodString;
2378
- }, "strip", z.ZodTypeAny, {
2379
- invitationId: string;
2380
- }, {
2381
- invitationId: string;
2382
- }>;
2383
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2384
- orgOptions: OrganizationOptions;
2385
- roles: typeof defaultRoles & {
2386
- [key: string]: Role<{}>;
2387
- };
2388
- getSession: (context: better_call.Context<any, any>) => Promise<{
2389
- session: Session & {
2390
- activeOrganizationId?: string;
2391
- };
2392
- user: User;
2393
- }>;
2394
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2395
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2396
- session: {
2397
- session: {
2398
- id: string;
2399
- userId: string;
2400
- expiresAt: Date;
2401
- ipAddress?: string | undefined;
2402
- userAgent?: string | undefined;
2403
- };
2404
- user: {
2405
- id: string;
2406
- name: string;
2407
- email: string;
2408
- emailVerified: boolean;
2409
- createdAt: Date;
2410
- updatedAt: Date;
2411
- image?: string | undefined;
2412
- };
2413
- };
2414
- }>, better_call.EndpointOptions>[];
2415
- } & {
2416
- method: "*";
2417
- }, {
2418
- session: {
2419
- session: Session & {
2420
- activeOrganizationId?: string;
2421
- };
2422
- user: User;
2423
- };
2424
- }>, {
2425
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2426
- session: {
2427
- session: {
2428
- id: string;
2429
- userId: string;
2430
- expiresAt: Date;
2431
- ipAddress?: string | undefined;
2432
- userAgent?: string | undefined;
2433
- };
2434
- user: {
2435
- id: string;
2436
- name: string;
2437
- email: string;
2438
- emailVerified: boolean;
2439
- createdAt: Date;
2440
- updatedAt: Date;
2441
- image?: string | undefined;
2442
- };
2443
- };
2444
- }>, better_call.EndpointOptions>[];
2445
- } & {
2446
- method: "*";
2447
- }>)[];
2448
- }>): Promise<{
2449
- invitation: {
2450
- status: "pending" | "accepted" | "rejected" | "canceled";
2451
- id: string;
2452
- email: string;
2453
- expiresAt: Date;
2454
- organizationId: string;
2455
- role: "admin" | "member" | "owner";
2456
- inviterId: string;
2160
+ organization: {
2161
+ fields: {
2162
+ name: {
2163
+ type: "string";
2457
2164
  };
2458
- member: null;
2459
- } | null>;
2460
- path: "/organization/reject-invitation";
2461
- options: {
2462
- method: "POST";
2463
- body: ZodObject<{
2464
- invitationId: z.ZodString;
2165
+ slug: {
2166
+ type: "string";
2167
+ unique: true;
2168
+ };
2169
+ };
2170
+ };
2171
+ member: {
2172
+ fields: {
2173
+ organizationId: {
2174
+ type: "string";
2175
+ required: true;
2176
+ };
2177
+ userId: {
2178
+ type: "string";
2179
+ required: true;
2180
+ };
2181
+ email: {
2182
+ type: "string";
2183
+ required: true;
2184
+ };
2185
+ name: {
2186
+ type: "string";
2187
+ };
2188
+ role: {
2189
+ type: "string";
2190
+ required: true;
2191
+ defaultValue: string;
2192
+ };
2193
+ };
2194
+ };
2195
+ invitation: {
2196
+ fields: {
2197
+ organizationId: {
2198
+ type: "string";
2199
+ required: true;
2200
+ };
2201
+ email: {
2202
+ type: "string";
2203
+ required: true;
2204
+ };
2205
+ role: {
2206
+ type: "string";
2207
+ required: false;
2208
+ };
2209
+ status: {
2210
+ type: "string";
2211
+ required: true;
2212
+ defaultValue: string;
2213
+ };
2214
+ expiresAt: {
2215
+ type: "date";
2216
+ required: true;
2217
+ };
2218
+ inviterId: {
2219
+ type: "string";
2220
+ references: {
2221
+ model: string;
2222
+ field: string;
2223
+ };
2224
+ };
2225
+ };
2226
+ };
2227
+ };
2228
+ };
2229
+
2230
+ interface BackupCodeOptions {
2231
+ /**
2232
+ * The amount of backup codes to generate
2233
+ *
2234
+ * @default 10
2235
+ */
2236
+ amount?: number;
2237
+ /**
2238
+ * The length of the backup codes
2239
+ *
2240
+ * @default 10
2241
+ */
2242
+ length?: number;
2243
+ customBackupCodesGenerate?: () => string[];
2244
+ }
2245
+
2246
+ interface OTPOptions {
2247
+ /**
2248
+ * How long the opt will be valid for
2249
+ *
2250
+ * @default "5 mins"
2251
+ */
2252
+ period?: number;
2253
+ sendOTP: (user: UserWithTwoFactor, otp: string) => Promise<void>;
2254
+ }
2255
+
2256
+ type TOTPOptions = {
2257
+ /**
2258
+ * Issuer
2259
+ */
2260
+ issuer: string;
2261
+ /**
2262
+ * How many digits the otp to be
2263
+ *
2264
+ * @default 6
2265
+ */
2266
+ digits?: 6 | 8;
2267
+ /**
2268
+ * Period for otp in seconds.
2269
+ * @default 30
2270
+ */
2271
+ period?: number;
2272
+ /**
2273
+ * Backup codes configuration
2274
+ */
2275
+ backupCodes?: BackupCodeOptions;
2276
+ };
2277
+
2278
+ interface TwoFactorOptions {
2279
+ issuer: string;
2280
+ totpOptions?: Omit<TOTPOptions, "issuer">;
2281
+ otpOptions?: OTPOptions;
2282
+ backupCodeOptions?: BackupCodeOptions;
2283
+ }
2284
+ interface UserWithTwoFactor extends User {
2285
+ /**
2286
+ * If the user has enabled two factor authentication.
2287
+ */
2288
+ twoFactorEnabled: boolean;
2289
+ /**
2290
+ * The secret used to generate the TOTP or OTP.
2291
+ */
2292
+ twoFactorSecret: string;
2293
+ /**
2294
+ * List of backup codes separated by a
2295
+ * comma
2296
+ */
2297
+ twoFactorBackupCodes: string;
2298
+ }
2299
+
2300
+ declare const twoFactorClient: (options?: {
2301
+ twoFactorPage: string;
2302
+ /**
2303
+ * Redirect to the two factor page. If twoFactorPage
2304
+ * is not set this will redirect to the root path.
2305
+ * @default true
2306
+ */
2307
+ redirect?: boolean;
2308
+ }) => {
2309
+ id: "two-factor";
2310
+ $InferServerPlugin: ReturnType<typeof twoFactor>;
2311
+ atomListeners: {
2312
+ matcher: (path: string) => path is "/two-factor/send-otp" | "/two-factor/enable" | "/two-factor/disable";
2313
+ signal: string;
2314
+ }[];
2315
+ pathMethods: {
2316
+ "enable/totp": "POST";
2317
+ "/two-factor/disable": "POST";
2318
+ "/two-factor/enable": "POST";
2319
+ "/two-factor/send-otp": "POST";
2320
+ };
2321
+ fetchPlugins: {
2322
+ id: string;
2323
+ name: string;
2324
+ hooks: {
2325
+ onSuccess(context: _better_fetch_fetch.SuccessContext): Promise<void>;
2326
+ };
2327
+ }[];
2328
+ };
2329
+
2330
+ declare const twoFactor: <O extends TwoFactorOptions>(options: O) => {
2331
+ id: "two-factor";
2332
+ endpoints: {
2333
+ enableTwoFactor: {
2334
+ (ctx_0?: better_call.Context<"/two-factor/enable", {
2335
+ method: "POST";
2336
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2337
+ session: {
2338
+ session: {
2339
+ id: string;
2340
+ userId: string;
2341
+ expiresAt: Date;
2342
+ ipAddress?: string | undefined;
2343
+ userAgent?: string | undefined;
2344
+ };
2345
+ user: {
2346
+ id: string;
2347
+ name: string;
2348
+ email: string;
2349
+ emailVerified: boolean;
2350
+ createdAt: Date;
2351
+ updatedAt: Date;
2352
+ image?: string | undefined;
2353
+ };
2354
+ };
2355
+ }>, better_call.EndpointOptions>[];
2356
+ }> | undefined): Promise<{
2357
+ status: boolean;
2358
+ }>;
2359
+ path: "/two-factor/enable";
2360
+ options: {
2361
+ method: "POST";
2362
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2363
+ session: {
2364
+ session: {
2365
+ id: string;
2366
+ userId: string;
2367
+ expiresAt: Date;
2368
+ ipAddress?: string | undefined;
2369
+ userAgent?: string | undefined;
2370
+ };
2371
+ user: {
2372
+ id: string;
2373
+ name: string;
2374
+ email: string;
2375
+ emailVerified: boolean;
2376
+ createdAt: Date;
2377
+ updatedAt: Date;
2378
+ image?: string | undefined;
2379
+ };
2380
+ };
2381
+ }>, better_call.EndpointOptions>[];
2382
+ };
2383
+ method: better_call.Method | better_call.Method[];
2384
+ headers: Headers;
2385
+ };
2386
+ disableTwoFactor: {
2387
+ (ctx_0?: better_call.Context<"/two-factor/disable", {
2388
+ method: "POST";
2389
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2390
+ session: {
2391
+ session: {
2392
+ id: string;
2393
+ userId: string;
2394
+ expiresAt: Date;
2395
+ ipAddress?: string | undefined;
2396
+ userAgent?: string | undefined;
2397
+ };
2398
+ user: {
2399
+ id: string;
2400
+ name: string;
2401
+ email: string;
2402
+ emailVerified: boolean;
2403
+ createdAt: Date;
2404
+ updatedAt: Date;
2405
+ image?: string | undefined;
2406
+ };
2407
+ };
2408
+ }>, better_call.EndpointOptions>[];
2409
+ }> | undefined): Promise<{
2410
+ status: boolean;
2411
+ }>;
2412
+ path: "/two-factor/disable";
2413
+ options: {
2414
+ method: "POST";
2415
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2416
+ session: {
2417
+ session: {
2418
+ id: string;
2419
+ userId: string;
2420
+ expiresAt: Date;
2421
+ ipAddress?: string | undefined;
2422
+ userAgent?: string | undefined;
2423
+ };
2424
+ user: {
2425
+ id: string;
2426
+ name: string;
2427
+ email: string;
2428
+ emailVerified: boolean;
2429
+ createdAt: Date;
2430
+ updatedAt: Date;
2431
+ image?: string | undefined;
2432
+ };
2433
+ };
2434
+ }>, better_call.EndpointOptions>[];
2435
+ };
2436
+ method: better_call.Method | better_call.Method[];
2437
+ headers: Headers;
2438
+ };
2439
+ verifyBackupCode: {
2440
+ (ctx_0: better_call.Context<"/two-factor/verify-backup-code", {
2441
+ method: "POST";
2442
+ body: z.ZodObject<{
2443
+ code: z.ZodString;
2465
2444
  }, "strip", z.ZodTypeAny, {
2466
- invitationId: string;
2445
+ code: string;
2467
2446
  }, {
2468
- invitationId: string;
2447
+ code: string;
2469
2448
  }>;
2470
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2471
- orgOptions: OrganizationOptions;
2472
- roles: typeof defaultRoles & {
2473
- [key: string]: Role<{}>;
2449
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2450
+ valid: () => Promise<{
2451
+ response: {
2452
+ body: any;
2453
+ status: number;
2454
+ statusText: string;
2455
+ headers: Record<string, string> | undefined;
2456
+ };
2457
+ body: {
2458
+ status: boolean;
2459
+ };
2460
+ _flag: "json";
2461
+ }>;
2462
+ invalid: () => Promise<{
2463
+ response: {
2464
+ body: any;
2465
+ status: number;
2466
+ statusText: string;
2467
+ headers: Record<string, string> | undefined;
2468
+ };
2469
+ body: {
2470
+ status: boolean;
2471
+ };
2472
+ _flag: "json";
2473
+ }>;
2474
+ session: {
2475
+ id: string;
2476
+ userId: string;
2477
+ expiresAt: Date;
2478
+ user: UserWithTwoFactor;
2474
2479
  };
2475
- getSession: (context: better_call.Context<any, any>) => Promise<{
2476
- session: Session & {
2477
- activeOrganizationId?: string;
2480
+ }>, better_call.EndpointOptions>[];
2481
+ }>): Promise<{
2482
+ status: boolean;
2483
+ }>;
2484
+ path: "/two-factor/verify-backup-code";
2485
+ options: {
2486
+ method: "POST";
2487
+ body: z.ZodObject<{
2488
+ code: z.ZodString;
2489
+ }, "strip", z.ZodTypeAny, {
2490
+ code: string;
2491
+ }, {
2492
+ code: string;
2493
+ }>;
2494
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2495
+ valid: () => Promise<{
2496
+ response: {
2497
+ body: any;
2498
+ status: number;
2499
+ statusText: string;
2500
+ headers: Record<string, string> | undefined;
2478
2501
  };
2479
- user: User;
2502
+ body: {
2503
+ status: boolean;
2504
+ };
2505
+ _flag: "json";
2480
2506
  }>;
2481
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2482
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2507
+ invalid: () => Promise<{
2508
+ response: {
2509
+ body: any;
2510
+ status: number;
2511
+ statusText: string;
2512
+ headers: Record<string, string> | undefined;
2513
+ };
2514
+ body: {
2515
+ status: boolean;
2516
+ };
2517
+ _flag: "json";
2518
+ }>;
2519
+ session: {
2520
+ id: string;
2521
+ userId: string;
2522
+ expiresAt: Date;
2523
+ user: UserWithTwoFactor;
2524
+ };
2525
+ }>, better_call.EndpointOptions>[];
2526
+ };
2527
+ method: better_call.Method | better_call.Method[];
2528
+ headers: Headers;
2529
+ };
2530
+ generateBackupCodes: {
2531
+ (ctx_0?: better_call.Context<"/two-factor/generate-backup-codes", {
2532
+ method: "POST";
2533
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2534
+ session: {
2483
2535
  session: {
2484
- session: {
2485
- id: string;
2486
- userId: string;
2487
- expiresAt: Date;
2488
- ipAddress?: string | undefined;
2489
- userAgent?: string | undefined;
2490
- };
2491
- user: {
2492
- id: string;
2493
- name: string;
2494
- email: string;
2495
- emailVerified: boolean;
2496
- createdAt: Date;
2497
- updatedAt: Date;
2498
- image?: string | undefined;
2499
- };
2536
+ id: string;
2537
+ userId: string;
2538
+ expiresAt: Date;
2539
+ ipAddress?: string | undefined;
2540
+ userAgent?: string | undefined;
2541
+ };
2542
+ user: {
2543
+ id: string;
2544
+ name: string;
2545
+ email: string;
2546
+ emailVerified: boolean;
2547
+ createdAt: Date;
2548
+ updatedAt: Date;
2549
+ image?: string | undefined;
2550
+ };
2551
+ };
2552
+ }>, better_call.EndpointOptions>[];
2553
+ }> | undefined): Promise<{
2554
+ status: boolean;
2555
+ backupCodes: string[];
2556
+ }>;
2557
+ path: "/two-factor/generate-backup-codes";
2558
+ options: {
2559
+ method: "POST";
2560
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2561
+ session: {
2562
+ session: {
2563
+ id: string;
2564
+ userId: string;
2565
+ expiresAt: Date;
2566
+ ipAddress?: string | undefined;
2567
+ userAgent?: string | undefined;
2568
+ };
2569
+ user: {
2570
+ id: string;
2571
+ name: string;
2572
+ email: string;
2573
+ emailVerified: boolean;
2574
+ createdAt: Date;
2575
+ updatedAt: Date;
2576
+ image?: string | undefined;
2577
+ };
2578
+ };
2579
+ }>, better_call.EndpointOptions>[];
2580
+ };
2581
+ method: better_call.Method | better_call.Method[];
2582
+ headers: Headers;
2583
+ };
2584
+ viewBackupCodes: {
2585
+ (ctx_0?: better_call.Context<"/view/backup-codes", {
2586
+ method: "GET";
2587
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2588
+ session: {
2589
+ session: {
2590
+ id: string;
2591
+ userId: string;
2592
+ expiresAt: Date;
2593
+ ipAddress?: string | undefined;
2594
+ userAgent?: string | undefined;
2595
+ };
2596
+ user: {
2597
+ id: string;
2598
+ name: string;
2599
+ email: string;
2600
+ emailVerified: boolean;
2601
+ createdAt: Date;
2602
+ updatedAt: Date;
2603
+ image?: string | undefined;
2604
+ };
2605
+ };
2606
+ }>, better_call.EndpointOptions>[];
2607
+ }> | undefined): Promise<{
2608
+ status: boolean;
2609
+ backupCodes: Promise<string[] | null>;
2610
+ }>;
2611
+ path: "/view/backup-codes";
2612
+ options: {
2613
+ method: "GET";
2614
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2615
+ session: {
2616
+ session: {
2617
+ id: string;
2618
+ userId: string;
2619
+ expiresAt: Date;
2620
+ ipAddress?: string | undefined;
2621
+ userAgent?: string | undefined;
2622
+ };
2623
+ user: {
2624
+ id: string;
2625
+ name: string;
2626
+ email: string;
2627
+ emailVerified: boolean;
2628
+ createdAt: Date;
2629
+ updatedAt: Date;
2630
+ image?: string | undefined;
2631
+ };
2632
+ };
2633
+ }>, better_call.EndpointOptions>[];
2634
+ };
2635
+ method: better_call.Method | better_call.Method[];
2636
+ headers: Headers;
2637
+ };
2638
+ send2FaOTP: {
2639
+ (ctx_0?: better_call.Context<"/two-factor/send-otp", {
2640
+ method: "POST";
2641
+ body: z.ZodOptional<z.ZodObject<{
2642
+ returnOTP: z.ZodDefault<z.ZodBoolean>;
2643
+ }, "strip", z.ZodTypeAny, {
2644
+ returnOTP: boolean;
2645
+ }, {
2646
+ returnOTP?: boolean | undefined;
2647
+ }>>;
2648
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2649
+ valid: () => Promise<{
2650
+ response: {
2651
+ body: any;
2652
+ status: number;
2653
+ statusText: string;
2654
+ headers: Record<string, string> | undefined;
2655
+ };
2656
+ body: {
2657
+ status: boolean;
2658
+ };
2659
+ _flag: "json";
2660
+ }>;
2661
+ invalid: () => Promise<{
2662
+ response: {
2663
+ body: any;
2664
+ status: number;
2665
+ statusText: string;
2666
+ headers: Record<string, string> | undefined;
2667
+ };
2668
+ body: {
2669
+ status: boolean;
2670
+ };
2671
+ _flag: "json";
2672
+ }>;
2673
+ session: {
2674
+ id: string;
2675
+ userId: string;
2676
+ expiresAt: Date;
2677
+ user: UserWithTwoFactor;
2678
+ };
2679
+ }>, better_call.EndpointOptions>[];
2680
+ }> | undefined): Promise<{
2681
+ OTP: string;
2682
+ status: boolean;
2683
+ } | {
2684
+ status: boolean;
2685
+ OTP: undefined;
2686
+ }>;
2687
+ path: "/two-factor/send-otp";
2688
+ options: {
2689
+ method: "POST";
2690
+ body: z.ZodOptional<z.ZodObject<{
2691
+ returnOTP: z.ZodDefault<z.ZodBoolean>;
2692
+ }, "strip", z.ZodTypeAny, {
2693
+ returnOTP: boolean;
2694
+ }, {
2695
+ returnOTP?: boolean | undefined;
2696
+ }>>;
2697
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2698
+ valid: () => Promise<{
2699
+ response: {
2700
+ body: any;
2701
+ status: number;
2702
+ statusText: string;
2703
+ headers: Record<string, string> | undefined;
2704
+ };
2705
+ body: {
2706
+ status: boolean;
2707
+ };
2708
+ _flag: "json";
2709
+ }>;
2710
+ invalid: () => Promise<{
2711
+ response: {
2712
+ body: any;
2713
+ status: number;
2714
+ statusText: string;
2715
+ headers: Record<string, string> | undefined;
2716
+ };
2717
+ body: {
2718
+ status: boolean;
2500
2719
  };
2501
- }>, better_call.EndpointOptions>[];
2502
- } & {
2503
- method: "*";
2504
- }, {
2720
+ _flag: "json";
2721
+ }>;
2505
2722
  session: {
2506
- session: Session & {
2507
- activeOrganizationId?: string;
2508
- };
2509
- user: User;
2723
+ id: string;
2724
+ userId: string;
2725
+ expiresAt: Date;
2726
+ user: UserWithTwoFactor;
2510
2727
  };
2511
- }>, {
2512
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2513
- session: {
2514
- session: {
2515
- id: string;
2516
- userId: string;
2517
- expiresAt: Date;
2518
- ipAddress?: string | undefined;
2519
- userAgent?: string | undefined;
2520
- };
2521
- user: {
2522
- id: string;
2523
- name: string;
2524
- email: string;
2525
- emailVerified: boolean;
2526
- createdAt: Date;
2527
- updatedAt: Date;
2528
- image?: string | undefined;
2529
- };
2530
- };
2531
- }>, better_call.EndpointOptions>[];
2532
- } & {
2533
- method: "*";
2534
- }>)[];
2728
+ }>, better_call.EndpointOptions>[];
2535
2729
  };
2536
2730
  method: better_call.Method | better_call.Method[];
2537
2731
  headers: Headers;
2538
2732
  };
2539
- removeMember: {
2540
- (ctx_0: better_call.Context<"/organization/remove-member", {
2733
+ verifyOTP: {
2734
+ (ctx_0: better_call.Context<"/two-factor/verify-otp", {
2541
2735
  method: "POST";
2542
- body: ZodObject<{
2543
- memberId: z.ZodString;
2736
+ body: z.ZodObject<{
2737
+ code: z.ZodString;
2544
2738
  }, "strip", z.ZodTypeAny, {
2545
- memberId: string;
2739
+ code: string;
2546
2740
  }, {
2547
- memberId: string;
2741
+ code: string;
2548
2742
  }>;
2549
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2550
- orgOptions: OrganizationOptions;
2551
- roles: typeof defaultRoles & {
2552
- [key: string]: Role<{}>;
2553
- };
2554
- getSession: (context: better_call.Context<any, any>) => Promise<{
2555
- session: Session & {
2556
- activeOrganizationId?: string;
2743
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2744
+ valid: () => Promise<{
2745
+ response: {
2746
+ body: any;
2747
+ status: number;
2748
+ statusText: string;
2749
+ headers: Record<string, string> | undefined;
2557
2750
  };
2558
- user: User;
2751
+ body: {
2752
+ status: boolean;
2753
+ };
2754
+ _flag: "json";
2559
2755
  }>;
2560
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2561
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2562
- session: {
2563
- session: {
2564
- id: string;
2565
- userId: string;
2566
- expiresAt: Date;
2567
- ipAddress?: string | undefined;
2568
- userAgent?: string | undefined;
2569
- };
2570
- user: {
2571
- id: string;
2572
- name: string;
2573
- email: string;
2574
- emailVerified: boolean;
2575
- createdAt: Date;
2576
- updatedAt: Date;
2577
- image?: string | undefined;
2578
- };
2756
+ invalid: () => Promise<{
2757
+ response: {
2758
+ body: any;
2759
+ status: number;
2760
+ statusText: string;
2761
+ headers: Record<string, string> | undefined;
2579
2762
  };
2580
- }>, better_call.EndpointOptions>[];
2581
- } & {
2582
- method: "*";
2583
- }, {
2584
- session: {
2585
- session: Session & {
2586
- activeOrganizationId?: string;
2763
+ body: {
2764
+ status: boolean;
2587
2765
  };
2588
- user: User;
2766
+ _flag: "json";
2767
+ }>;
2768
+ session: {
2769
+ id: string;
2770
+ userId: string;
2771
+ expiresAt: Date;
2772
+ user: UserWithTwoFactor;
2589
2773
  };
2590
- }>, {
2591
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2592
- session: {
2593
- session: {
2594
- id: string;
2595
- userId: string;
2596
- expiresAt: Date;
2597
- ipAddress?: string | undefined;
2598
- userAgent?: string | undefined;
2599
- };
2600
- user: {
2601
- id: string;
2602
- name: string;
2603
- email: string;
2604
- emailVerified: boolean;
2605
- createdAt: Date;
2606
- updatedAt: Date;
2607
- image?: string | undefined;
2608
- };
2609
- };
2610
- }>, better_call.EndpointOptions>[];
2611
- } & {
2612
- method: "*";
2613
- }>)[];
2614
- }>): Promise<void | null>;
2615
- path: "/organization/remove-member";
2774
+ }>, better_call.EndpointOptions>[];
2775
+ }>): Promise<{
2776
+ status: boolean;
2777
+ }>;
2778
+ path: "/two-factor/verify-otp";
2616
2779
  options: {
2617
2780
  method: "POST";
2618
- body: ZodObject<{
2619
- memberId: z.ZodString;
2781
+ body: z.ZodObject<{
2782
+ code: z.ZodString;
2620
2783
  }, "strip", z.ZodTypeAny, {
2621
- memberId: string;
2784
+ code: string;
2622
2785
  }, {
2623
- memberId: string;
2786
+ code: string;
2624
2787
  }>;
2625
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2626
- orgOptions: OrganizationOptions;
2627
- roles: typeof defaultRoles & {
2628
- [key: string]: Role<{}>;
2629
- };
2630
- getSession: (context: better_call.Context<any, any>) => Promise<{
2631
- session: Session & {
2632
- activeOrganizationId?: string;
2788
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2789
+ valid: () => Promise<{
2790
+ response: {
2791
+ body: any;
2792
+ status: number;
2793
+ statusText: string;
2794
+ headers: Record<string, string> | undefined;
2633
2795
  };
2634
- user: User;
2796
+ body: {
2797
+ status: boolean;
2798
+ };
2799
+ _flag: "json";
2635
2800
  }>;
2636
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2637
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2801
+ invalid: () => Promise<{
2802
+ response: {
2803
+ body: any;
2804
+ status: number;
2805
+ statusText: string;
2806
+ headers: Record<string, string> | undefined;
2807
+ };
2808
+ body: {
2809
+ status: boolean;
2810
+ };
2811
+ _flag: "json";
2812
+ }>;
2813
+ session: {
2814
+ id: string;
2815
+ userId: string;
2816
+ expiresAt: Date;
2817
+ user: UserWithTwoFactor;
2818
+ };
2819
+ }>, better_call.EndpointOptions>[];
2820
+ };
2821
+ method: better_call.Method | better_call.Method[];
2822
+ headers: Headers;
2823
+ };
2824
+ generateTOTP: {
2825
+ (ctx_0?: better_call.Context<"/totp/generate", {
2826
+ method: "POST";
2827
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2828
+ session: {
2638
2829
  session: {
2639
- session: {
2640
- id: string;
2641
- userId: string;
2642
- expiresAt: Date;
2643
- ipAddress?: string | undefined;
2644
- userAgent?: string | undefined;
2645
- };
2646
- user: {
2647
- id: string;
2648
- name: string;
2649
- email: string;
2650
- emailVerified: boolean;
2651
- createdAt: Date;
2652
- updatedAt: Date;
2653
- image?: string | undefined;
2654
- };
2830
+ id: string;
2831
+ userId: string;
2832
+ expiresAt: Date;
2833
+ ipAddress?: string | undefined;
2834
+ userAgent?: string | undefined;
2655
2835
  };
2656
- }>, better_call.EndpointOptions>[];
2657
- } & {
2658
- method: "*";
2659
- }, {
2836
+ user: {
2837
+ id: string;
2838
+ name: string;
2839
+ email: string;
2840
+ emailVerified: boolean;
2841
+ createdAt: Date;
2842
+ updatedAt: Date;
2843
+ image?: string | undefined;
2844
+ };
2845
+ };
2846
+ }>, better_call.EndpointOptions>[];
2847
+ }> | undefined): Promise<{
2848
+ code: string;
2849
+ }>;
2850
+ path: "/totp/generate";
2851
+ options: {
2852
+ method: "POST";
2853
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2660
2854
  session: {
2661
- session: Session & {
2662
- activeOrganizationId?: string;
2855
+ session: {
2856
+ id: string;
2857
+ userId: string;
2858
+ expiresAt: Date;
2859
+ ipAddress?: string | undefined;
2860
+ userAgent?: string | undefined;
2861
+ };
2862
+ user: {
2863
+ id: string;
2864
+ name: string;
2865
+ email: string;
2866
+ emailVerified: boolean;
2867
+ createdAt: Date;
2868
+ updatedAt: Date;
2869
+ image?: string | undefined;
2870
+ };
2871
+ };
2872
+ }>, better_call.EndpointOptions>[];
2873
+ };
2874
+ method: better_call.Method | better_call.Method[];
2875
+ headers: Headers;
2876
+ };
2877
+ viewTOTPURI: {
2878
+ (ctx_0?: better_call.Context<"/two-factor/get-totp-uri", {
2879
+ method: "GET";
2880
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2881
+ session: {
2882
+ session: {
2883
+ id: string;
2884
+ userId: string;
2885
+ expiresAt: Date;
2886
+ ipAddress?: string | undefined;
2887
+ userAgent?: string | undefined;
2888
+ };
2889
+ user: {
2890
+ id: string;
2891
+ name: string;
2892
+ email: string;
2893
+ emailVerified: boolean;
2894
+ createdAt: Date;
2895
+ updatedAt: Date;
2896
+ image?: string | undefined;
2897
+ };
2898
+ };
2899
+ }>, better_call.EndpointOptions>[];
2900
+ }> | undefined): Promise<{
2901
+ totpURI: string;
2902
+ }>;
2903
+ path: "/two-factor/get-totp-uri";
2904
+ options: {
2905
+ method: "GET";
2906
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2907
+ session: {
2908
+ session: {
2909
+ id: string;
2910
+ userId: string;
2911
+ expiresAt: Date;
2912
+ ipAddress?: string | undefined;
2913
+ userAgent?: string | undefined;
2914
+ };
2915
+ user: {
2916
+ id: string;
2917
+ name: string;
2918
+ email: string;
2919
+ emailVerified: boolean;
2920
+ createdAt: Date;
2921
+ updatedAt: Date;
2922
+ image?: string | undefined;
2663
2923
  };
2664
- user: User;
2665
2924
  };
2666
- }>, {
2667
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2668
- session: {
2669
- session: {
2670
- id: string;
2671
- userId: string;
2672
- expiresAt: Date;
2673
- ipAddress?: string | undefined;
2674
- userAgent?: string | undefined;
2675
- };
2676
- user: {
2677
- id: string;
2678
- name: string;
2679
- email: string;
2680
- emailVerified: boolean;
2681
- createdAt: Date;
2682
- updatedAt: Date;
2683
- image?: string | undefined;
2684
- };
2685
- };
2686
- }>, better_call.EndpointOptions>[];
2687
- } & {
2688
- method: "*";
2689
- }>)[];
2925
+ }>, better_call.EndpointOptions>[];
2690
2926
  };
2691
2927
  method: better_call.Method | better_call.Method[];
2692
2928
  headers: Headers;
2693
2929
  };
2694
- updateMember: {
2695
- (ctx_0: better_call.Context<"/organization/update-member", {
2930
+ verifyTOTP: {
2931
+ (ctx_0: better_call.Context<"/two-factor/verify-totp", {
2696
2932
  method: "POST";
2697
- body: ZodObject<{
2698
- memberId: z.ZodString;
2699
- role: z.ZodString;
2933
+ body: z.ZodObject<{
2934
+ code: z.ZodString;
2935
+ callbackURL: z.ZodOptional<z.ZodString>;
2700
2936
  }, "strip", z.ZodTypeAny, {
2701
- role: string;
2702
- memberId: string;
2937
+ code: string;
2938
+ callbackURL?: string | undefined;
2703
2939
  }, {
2704
- role: string;
2705
- memberId: string;
2940
+ code: string;
2941
+ callbackURL?: string | undefined;
2706
2942
  }>;
2707
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2708
- orgOptions: OrganizationOptions;
2709
- roles: typeof defaultRoles & {
2710
- [key: string]: Role<{}>;
2711
- };
2712
- getSession: (context: better_call.Context<any, any>) => Promise<{
2713
- session: Session & {
2714
- activeOrganizationId?: string;
2943
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2944
+ valid: () => Promise<{
2945
+ response: {
2946
+ body: any;
2947
+ status: number;
2948
+ statusText: string;
2949
+ headers: Record<string, string> | undefined;
2715
2950
  };
2716
- user: User;
2951
+ body: {
2952
+ status: boolean;
2953
+ };
2954
+ _flag: "json";
2717
2955
  }>;
2718
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2719
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2720
- session: {
2721
- session: {
2722
- id: string;
2723
- userId: string;
2724
- expiresAt: Date;
2725
- ipAddress?: string | undefined;
2726
- userAgent?: string | undefined;
2727
- };
2728
- user: {
2729
- id: string;
2730
- name: string;
2731
- email: string;
2732
- emailVerified: boolean;
2733
- createdAt: Date;
2734
- updatedAt: Date;
2735
- image?: string | undefined;
2736
- };
2956
+ invalid: () => Promise<{
2957
+ response: {
2958
+ body: any;
2959
+ status: number;
2960
+ statusText: string;
2961
+ headers: Record<string, string> | undefined;
2737
2962
  };
2738
- }>, better_call.EndpointOptions>[];
2739
- } & {
2740
- method: "*";
2741
- }, {
2742
- session: {
2743
- session: Session & {
2744
- activeOrganizationId?: string;
2963
+ body: {
2964
+ status: boolean;
2745
2965
  };
2746
- user: User;
2966
+ _flag: "json";
2967
+ }>;
2968
+ session: {
2969
+ id: string;
2970
+ userId: string;
2971
+ expiresAt: Date;
2972
+ user: UserWithTwoFactor;
2747
2973
  };
2748
- }>, {
2749
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2750
- session: {
2751
- session: {
2752
- id: string;
2753
- userId: string;
2754
- expiresAt: Date;
2755
- ipAddress?: string | undefined;
2756
- userAgent?: string | undefined;
2757
- };
2758
- user: {
2759
- id: string;
2760
- name: string;
2761
- email: string;
2762
- emailVerified: boolean;
2763
- createdAt: Date;
2764
- updatedAt: Date;
2765
- image?: string | undefined;
2766
- };
2767
- };
2768
- }>, better_call.EndpointOptions>[];
2769
- } & {
2770
- method: "*";
2771
- }>)[];
2974
+ }>, better_call.EndpointOptions>[];
2772
2975
  }>): Promise<{
2773
- id: string;
2774
- name: string;
2775
- email: string;
2776
- userId: string;
2777
- organizationId: string;
2778
- role: "admin" | "member" | "owner";
2779
- } | null>;
2780
- path: "/organization/update-member";
2976
+ status: boolean;
2977
+ }>;
2978
+ path: "/two-factor/verify-totp";
2781
2979
  options: {
2782
2980
  method: "POST";
2783
- body: ZodObject<{
2784
- memberId: z.ZodString;
2785
- role: z.ZodString;
2981
+ body: z.ZodObject<{
2982
+ code: z.ZodString;
2983
+ callbackURL: z.ZodOptional<z.ZodString>;
2786
2984
  }, "strip", z.ZodTypeAny, {
2787
- role: string;
2788
- memberId: string;
2985
+ code: string;
2986
+ callbackURL?: string | undefined;
2789
2987
  }, {
2790
- role: string;
2791
- memberId: string;
2988
+ code: string;
2989
+ callbackURL?: string | undefined;
2792
2990
  }>;
2793
- use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2794
- orgOptions: OrganizationOptions;
2795
- roles: typeof defaultRoles & {
2796
- [key: string]: Role<{}>;
2797
- };
2798
- getSession: (context: better_call.Context<any, any>) => Promise<{
2799
- session: Session & {
2800
- activeOrganizationId?: string;
2991
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2992
+ valid: () => Promise<{
2993
+ response: {
2994
+ body: any;
2995
+ status: number;
2996
+ statusText: string;
2997
+ headers: Record<string, string> | undefined;
2801
2998
  };
2802
- user: User;
2999
+ body: {
3000
+ status: boolean;
3001
+ };
3002
+ _flag: "json";
2803
3003
  }>;
2804
- }>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, {
2805
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2806
- session: {
2807
- session: {
2808
- id: string;
2809
- userId: string;
2810
- expiresAt: Date;
2811
- ipAddress?: string | undefined;
2812
- userAgent?: string | undefined;
2813
- };
2814
- user: {
2815
- id: string;
2816
- name: string;
2817
- email: string;
2818
- emailVerified: boolean;
2819
- createdAt: Date;
2820
- updatedAt: Date;
2821
- image?: string | undefined;
2822
- };
3004
+ invalid: () => Promise<{
3005
+ response: {
3006
+ body: any;
3007
+ status: number;
3008
+ statusText: string;
3009
+ headers: Record<string, string> | undefined;
2823
3010
  };
2824
- }>, better_call.EndpointOptions>[];
2825
- } & {
2826
- method: "*";
2827
- }, {
2828
- session: {
2829
- session: Session & {
2830
- activeOrganizationId?: string;
3011
+ body: {
3012
+ status: boolean;
2831
3013
  };
2832
- user: User;
3014
+ _flag: "json";
3015
+ }>;
3016
+ session: {
3017
+ id: string;
3018
+ userId: string;
3019
+ expiresAt: Date;
3020
+ user: UserWithTwoFactor;
2833
3021
  };
2834
- }>, {
2835
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2836
- session: {
2837
- session: {
2838
- id: string;
2839
- userId: string;
2840
- expiresAt: Date;
2841
- ipAddress?: string | undefined;
2842
- userAgent?: string | undefined;
2843
- };
2844
- user: {
2845
- id: string;
2846
- name: string;
2847
- email: string;
2848
- emailVerified: boolean;
2849
- createdAt: Date;
2850
- updatedAt: Date;
2851
- image?: string | undefined;
2852
- };
2853
- };
2854
- }>, better_call.EndpointOptions>[];
2855
- } & {
2856
- method: "*";
2857
- }>)[];
3022
+ }>, better_call.EndpointOptions>[];
2858
3023
  };
2859
3024
  method: better_call.Method | better_call.Method[];
2860
3025
  headers: Headers;
2861
3026
  };
2862
3027
  };
3028
+ options: O;
3029
+ hooks: {
3030
+ after: {
3031
+ matcher(context: HookEndpointContext): boolean;
3032
+ handler: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3033
+ response: Response;
3034
+ } | undefined>, better_call.EndpointOptions>;
3035
+ }[];
3036
+ };
2863
3037
  schema: {
2864
- session: {
3038
+ user: {
2865
3039
  fields: {
2866
- activeOrganizationId: {
2867
- type: "string";
3040
+ twoFactorEnabled: {
3041
+ type: "boolean";
2868
3042
  required: false;
3043
+ defaultValue: false;
2869
3044
  };
2870
- };
2871
- };
2872
- organization: {
2873
- fields: {
2874
- name: {
2875
- type: "string";
2876
- };
2877
- slug: {
2878
- type: "string";
2879
- unique: true;
2880
- };
2881
- };
2882
- };
2883
- member: {
2884
- fields: {
2885
- organizationId: {
2886
- type: "string";
2887
- required: true;
2888
- };
2889
- userId: {
2890
- type: "string";
2891
- required: true;
2892
- };
2893
- email: {
2894
- type: "string";
2895
- required: true;
2896
- };
2897
- name: {
2898
- type: "string";
2899
- };
2900
- role: {
2901
- type: "string";
2902
- required: true;
2903
- defaultValue: string;
2904
- };
2905
- };
2906
- };
2907
- invitation: {
2908
- fields: {
2909
- organizationId: {
2910
- type: "string";
2911
- required: true;
2912
- };
2913
- email: {
2914
- type: "string";
2915
- required: true;
2916
- };
2917
- role: {
3045
+ twoFactorSecret: {
2918
3046
  type: "string";
2919
3047
  required: false;
2920
3048
  };
2921
- status: {
2922
- type: "string";
2923
- required: true;
2924
- defaultValue: string;
2925
- };
2926
- expiresAt: {
2927
- type: "date";
2928
- required: true;
2929
- };
2930
- inviterId: {
3049
+ twoFactorBackupCodes: {
2931
3050
  type: "string";
2932
- references: {
2933
- model: string;
2934
- field: string;
2935
- };
3051
+ required: false;
3052
+ returned: false;
2936
3053
  };
2937
3054
  };
2938
3055
  };
2939
3056
  };
2940
3057
  };
2941
3058
 
3059
+ declare const getPasskeyActions: ($fetch: BetterFetch) => {
3060
+ signIn: {
3061
+ passkey: (opts?: {
3062
+ autoFill?: boolean;
3063
+ email?: string;
3064
+ callbackURL?: string;
3065
+ }) => Promise<{
3066
+ data: null;
3067
+ error: {
3068
+ message?: string | undefined;
3069
+ status: number;
3070
+ statusText: string;
3071
+ };
3072
+ } | undefined>;
3073
+ };
3074
+ passkey: {
3075
+ register: () => Promise<{
3076
+ data: null;
3077
+ error: {
3078
+ message?: string | undefined;
3079
+ status: number;
3080
+ statusText: string;
3081
+ };
3082
+ } | undefined>;
3083
+ };
3084
+ };
3085
+ declare const passkeyClient: () => {
3086
+ id: "passkey";
3087
+ $InferServerPlugin: ReturnType<typeof passkey>;
3088
+ getActions: ($fetch: BetterFetch) => {
3089
+ signIn: {
3090
+ passkey: (opts?: {
3091
+ autoFill?: boolean;
3092
+ email?: string;
3093
+ callbackURL?: string;
3094
+ }) => Promise<{
3095
+ data: null;
3096
+ error: {
3097
+ message?: string | undefined;
3098
+ status: number;
3099
+ statusText: string;
3100
+ };
3101
+ } | undefined>;
3102
+ };
3103
+ passkey: {
3104
+ register: () => Promise<{
3105
+ data: null;
3106
+ error: {
3107
+ message?: string | undefined;
3108
+ status: number;
3109
+ statusText: string;
3110
+ };
3111
+ } | undefined>;
3112
+ };
3113
+ };
3114
+ pathMethods: {
3115
+ "/passkey/register": "POST";
3116
+ "/passkey/authenticate": "POST";
3117
+ };
3118
+ };
3119
+
2942
3120
  interface PasskeyOptions {
2943
3121
  /**
2944
3122
  * A unique identifier for your website. 'localhost' is okay for
@@ -3051,11 +3229,11 @@ declare const passkey: (options: PasskeyOptions) => {
3051
3229
  email: z.ZodOptional<z.ZodString>;
3052
3230
  callbackURL: z.ZodOptional<z.ZodString>;
3053
3231
  }, "strip", z.ZodTypeAny, {
3054
- callbackURL?: string | undefined;
3055
3232
  email?: string | undefined;
3056
- }, {
3057
3233
  callbackURL?: string | undefined;
3234
+ }, {
3058
3235
  email?: string | undefined;
3236
+ callbackURL?: string | undefined;
3059
3237
  }>>;
3060
3238
  }> | undefined): Promise<_simplewebauthn_types.PublicKeyCredentialRequestOptionsJSON>;
3061
3239
  path: "/passkey/generate-authenticate-options";
@@ -3065,11 +3243,11 @@ declare const passkey: (options: PasskeyOptions) => {
3065
3243
  email: z.ZodOptional<z.ZodString>;
3066
3244
  callbackURL: z.ZodOptional<z.ZodString>;
3067
3245
  }, "strip", z.ZodTypeAny, {
3068
- callbackURL?: string | undefined;
3069
3246
  email?: string | undefined;
3070
- }, {
3071
3247
  callbackURL?: string | undefined;
3248
+ }, {
3072
3249
  email?: string | undefined;
3250
+ callbackURL?: string | undefined;
3073
3251
  }>>;
3074
3252
  };
3075
3253
  method: better_call.Method | better_call.Method[];
@@ -3213,291 +3391,156 @@ declare const passkey: (options: PasskeyOptions) => {
3213
3391
  };
3214
3392
  };
3215
3393
 
3216
- declare const getPasskeyActions: ($fetch: BetterFetch) => {
3217
- signInPasskey: (opts?: {
3218
- autoFill?: boolean;
3219
- email?: string;
3220
- callbackURL?: string;
3221
- }) => Promise<{
3222
- data: null;
3223
- error: {
3224
- message?: string | undefined;
3225
- status: number;
3226
- statusText: string;
3227
- };
3228
- } | undefined>;
3229
- registerPasskey: () => Promise<{
3230
- data: null;
3231
- error: {
3232
- message?: string | undefined;
3233
- status: number;
3234
- statusText: string;
3235
- };
3236
- } | undefined>;
3237
- };
3238
- declare const passkeyClient: ($fetch: BetterFetch) => {
3239
- integrations: {
3240
- react?: ((useStore: typeof useAuthStore) => Record<string, any>) | undefined;
3241
- vue?: ((useStore: typeof useAuthStore$1) => Record<string, any>) | undefined;
3242
- preact?: ((useStore: typeof useAuthStore$2) => Record<string, any>) | undefined;
3243
- svelte?: (() => Record<string, any>) | undefined;
3244
- };
3245
- plugin: {
3246
- id: "passkey";
3247
- endpoints: {
3248
- generatePasskeyRegistrationOptions: {
3249
- (ctx_0?: better_call.Context<"/passkey/generate-register-options", {
3250
- method: "GET";
3251
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3252
- session: {
3253
- session: {
3254
- id: string;
3255
- userId: string;
3256
- expiresAt: Date;
3257
- ipAddress?: string | undefined;
3258
- userAgent?: string | undefined;
3259
- };
3260
- user: {
3261
- id: string;
3262
- name: string;
3263
- email: string;
3264
- emailVerified: boolean;
3265
- createdAt: Date;
3266
- updatedAt: Date;
3267
- image?: string | undefined;
3268
- };
3269
- };
3270
- }>, better_call.EndpointOptions>[];
3271
- metadata: {
3272
- client: boolean;
3273
- };
3274
- }> | undefined): Promise<PublicKeyCredentialCreationOptionsJSON>;
3275
- path: "/passkey/generate-register-options";
3276
- options: {
3277
- method: "GET";
3278
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3279
- session: {
3280
- session: {
3281
- id: string;
3282
- userId: string;
3283
- expiresAt: Date;
3284
- ipAddress?: string | undefined;
3285
- userAgent?: string | undefined;
3286
- };
3287
- user: {
3288
- id: string;
3289
- name: string;
3290
- email: string;
3291
- emailVerified: boolean;
3292
- createdAt: Date;
3293
- updatedAt: Date;
3294
- image?: string | undefined;
3295
- };
3296
- };
3297
- }>, better_call.EndpointOptions>[];
3298
- metadata: {
3299
- client: boolean;
3300
- };
3394
+ declare const username: () => {
3395
+ id: "username";
3396
+ endpoints: {
3397
+ signInUsername: {
3398
+ (ctx_0: better_call.Context<"/sign-in/username", {
3399
+ method: "POST";
3400
+ body: z.ZodObject<{
3401
+ username: z.ZodString;
3402
+ password: z.ZodString;
3403
+ dontRememberMe: z.ZodOptional<z.ZodBoolean>;
3404
+ callbackURL: z.ZodOptional<z.ZodString>;
3405
+ }, "strip", z.ZodTypeAny, {
3406
+ password: string;
3407
+ username: string;
3408
+ callbackURL?: string | undefined;
3409
+ dontRememberMe?: boolean | undefined;
3410
+ }, {
3411
+ password: string;
3412
+ username: string;
3413
+ callbackURL?: string | undefined;
3414
+ dontRememberMe?: boolean | undefined;
3415
+ }>;
3416
+ }>): Promise<{
3417
+ user: {
3418
+ id: string;
3419
+ name: string;
3420
+ email: string;
3421
+ emailVerified: boolean;
3422
+ createdAt: Date;
3423
+ updatedAt: Date;
3424
+ image?: string | undefined;
3301
3425
  };
3302
- method: better_call.Method | better_call.Method[];
3303
- headers: Headers;
3304
- };
3305
- generatePasskeyAuthenticationOptions: {
3306
- (ctx_0?: better_call.Context<"/passkey/generate-authenticate-options", {
3307
- method: "POST";
3308
- body: zod.ZodOptional<zod.ZodObject<{
3309
- email: zod.ZodOptional<zod.ZodString>;
3310
- callbackURL: zod.ZodOptional<zod.ZodString>;
3311
- }, "strip", zod.ZodTypeAny, {
3312
- callbackURL?: string | undefined;
3313
- email?: string | undefined;
3314
- }, {
3315
- callbackURL?: string | undefined;
3316
- email?: string | undefined;
3317
- }>>;
3318
- }> | undefined): Promise<PublicKeyCredentialRequestOptionsJSON>;
3319
- path: "/passkey/generate-authenticate-options";
3320
- options: {
3321
- method: "POST";
3322
- body: zod.ZodOptional<zod.ZodObject<{
3323
- email: zod.ZodOptional<zod.ZodString>;
3324
- callbackURL: zod.ZodOptional<zod.ZodString>;
3325
- }, "strip", zod.ZodTypeAny, {
3326
- callbackURL?: string | undefined;
3327
- email?: string | undefined;
3328
- }, {
3329
- callbackURL?: string | undefined;
3330
- email?: string | undefined;
3331
- }>>;
3426
+ session: {
3427
+ id: string;
3428
+ userId: string;
3429
+ expiresAt: Date;
3430
+ ipAddress?: string | undefined;
3431
+ userAgent?: string | undefined;
3332
3432
  };
3333
- method: better_call.Method | better_call.Method[];
3334
- headers: Headers;
3433
+ redirect: boolean;
3434
+ url: string | undefined;
3435
+ }>;
3436
+ path: "/sign-in/username";
3437
+ options: {
3438
+ method: "POST";
3439
+ body: z.ZodObject<{
3440
+ username: z.ZodString;
3441
+ password: z.ZodString;
3442
+ dontRememberMe: z.ZodOptional<z.ZodBoolean>;
3443
+ callbackURL: z.ZodOptional<z.ZodString>;
3444
+ }, "strip", z.ZodTypeAny, {
3445
+ password: string;
3446
+ username: string;
3447
+ callbackURL?: string | undefined;
3448
+ dontRememberMe?: boolean | undefined;
3449
+ }, {
3450
+ password: string;
3451
+ username: string;
3452
+ callbackURL?: string | undefined;
3453
+ dontRememberMe?: boolean | undefined;
3454
+ }>;
3335
3455
  };
3336
- verifyPasskeyRegistration: {
3337
- (ctx_0: better_call.Context<"/passkey/verify-registration", {
3338
- method: "POST";
3339
- body: zod.ZodObject<{
3340
- response: zod.ZodAny;
3341
- }, "strip", zod.ZodTypeAny, {
3342
- response?: any;
3343
- }, {
3344
- response?: any;
3345
- }>;
3346
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3347
- session: {
3348
- session: {
3349
- id: string;
3350
- userId: string;
3351
- expiresAt: Date;
3352
- ipAddress?: string | undefined;
3353
- userAgent?: string | undefined;
3354
- };
3355
- user: {
3356
- id: string;
3357
- name: string;
3358
- email: string;
3359
- emailVerified: boolean;
3360
- createdAt: Date;
3361
- updatedAt: Date;
3362
- image?: string | undefined;
3363
- };
3364
- };
3365
- }>, better_call.EndpointOptions>[];
3366
- }>): Promise<Passkey | null>;
3367
- path: "/passkey/verify-registration";
3368
- options: {
3369
- method: "POST";
3370
- body: zod.ZodObject<{
3371
- response: zod.ZodAny;
3372
- }, "strip", zod.ZodTypeAny, {
3373
- response?: any;
3374
- }, {
3375
- response?: any;
3376
- }>;
3377
- use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3378
- session: {
3379
- session: {
3380
- id: string;
3381
- userId: string;
3382
- expiresAt: Date;
3383
- ipAddress?: string | undefined;
3384
- userAgent?: string | undefined;
3385
- };
3386
- user: {
3387
- id: string;
3388
- name: string;
3389
- email: string;
3390
- emailVerified: boolean;
3391
- createdAt: Date;
3392
- updatedAt: Date;
3393
- image?: string | undefined;
3394
- };
3395
- };
3396
- }>, better_call.EndpointOptions>[];
3456
+ method: better_call.Method | better_call.Method[];
3457
+ headers: Headers;
3458
+ };
3459
+ signUpUsername: {
3460
+ (ctx_0: better_call.Context<"/sign-up/username", {
3461
+ method: "POST";
3462
+ body: z.ZodObject<{
3463
+ username: z.ZodString;
3464
+ name: z.ZodString;
3465
+ email: z.ZodString;
3466
+ password: z.ZodString;
3467
+ image: z.ZodOptional<z.ZodString>;
3468
+ callbackURL: z.ZodOptional<z.ZodString>;
3469
+ }, "strip", z.ZodTypeAny, {
3470
+ password: string;
3471
+ name: string;
3472
+ email: string;
3473
+ username: string;
3474
+ image?: string | undefined;
3475
+ callbackURL?: string | undefined;
3476
+ }, {
3477
+ password: string;
3478
+ name: string;
3479
+ email: string;
3480
+ username: string;
3481
+ image?: string | undefined;
3482
+ callbackURL?: string | undefined;
3483
+ }>;
3484
+ }>): Promise<{
3485
+ user: {
3486
+ id: string;
3487
+ name: string;
3488
+ email: string;
3489
+ emailVerified: boolean;
3490
+ createdAt: Date;
3491
+ updatedAt: Date;
3492
+ image?: string | undefined;
3397
3493
  };
3398
- method: better_call.Method | better_call.Method[];
3399
- headers: Headers;
3400
- };
3401
- verifyPasskeyAuthentication: {
3402
- (ctx_0: better_call.Context<"/passkey/verify-authentication", {
3403
- method: "POST";
3404
- body: zod.ZodObject<{
3405
- response: zod.ZodAny;
3406
- }, "strip", zod.ZodTypeAny, {
3407
- response?: any;
3408
- }, {
3409
- response?: any;
3410
- }>;
3411
- }>): Promise<{
3412
- session: {
3413
- id: string;
3414
- userId: string;
3415
- expiresAt: Date;
3416
- ipAddress?: string | undefined;
3417
- userAgent?: string | undefined;
3418
- };
3419
- } | null>;
3420
- path: "/passkey/verify-authentication";
3421
- options: {
3422
- method: "POST";
3423
- body: zod.ZodObject<{
3424
- response: zod.ZodAny;
3425
- }, "strip", zod.ZodTypeAny, {
3426
- response?: any;
3427
- }, {
3428
- response?: any;
3429
- }>;
3494
+ session: {
3495
+ id: string;
3496
+ userId: string;
3497
+ expiresAt: Date;
3498
+ ipAddress?: string | undefined;
3499
+ userAgent?: string | undefined;
3430
3500
  };
3431
- method: better_call.Method | better_call.Method[];
3432
- headers: Headers;
3501
+ } | null>;
3502
+ path: "/sign-up/username";
3503
+ options: {
3504
+ method: "POST";
3505
+ body: z.ZodObject<{
3506
+ username: z.ZodString;
3507
+ name: z.ZodString;
3508
+ email: z.ZodString;
3509
+ password: z.ZodString;
3510
+ image: z.ZodOptional<z.ZodString>;
3511
+ callbackURL: z.ZodOptional<z.ZodString>;
3512
+ }, "strip", z.ZodTypeAny, {
3513
+ password: string;
3514
+ name: string;
3515
+ email: string;
3516
+ username: string;
3517
+ image?: string | undefined;
3518
+ callbackURL?: string | undefined;
3519
+ }, {
3520
+ password: string;
3521
+ name: string;
3522
+ email: string;
3523
+ username: string;
3524
+ image?: string | undefined;
3525
+ callbackURL?: string | undefined;
3526
+ }>;
3433
3527
  };
3528
+ method: better_call.Method | better_call.Method[];
3529
+ headers: Headers;
3434
3530
  };
3435
- schema: {
3436
- passkey: {
3437
- fields: {
3438
- publicKey: {
3439
- type: "string";
3440
- };
3441
- userId: {
3442
- type: "string";
3443
- references: {
3444
- model: string;
3445
- field: string;
3446
- };
3447
- };
3448
- webauthnUserID: {
3449
- type: "string";
3450
- };
3451
- counter: {
3452
- type: "number";
3453
- };
3454
- deviceType: {
3455
- type: "string";
3456
- };
3457
- backedUp: {
3458
- type: "boolean";
3459
- };
3460
- transports: {
3461
- type: "string";
3462
- required: false;
3463
- };
3464
- createdAt: {
3465
- type: "date";
3466
- defaultValue: Date;
3467
- required: false;
3468
- };
3531
+ };
3532
+ schema: {
3533
+ user: {
3534
+ fields: {
3535
+ username: {
3536
+ type: "string";
3537
+ required: false;
3538
+ unique: true;
3539
+ returned: true;
3469
3540
  };
3470
3541
  };
3471
3542
  };
3472
3543
  };
3473
- id: string;
3474
- actions?: {
3475
- signInPasskey: (opts?: {
3476
- autoFill?: boolean;
3477
- email?: string;
3478
- callbackURL?: string;
3479
- }) => Promise<{
3480
- data: null;
3481
- error: {
3482
- message?: string | undefined;
3483
- status: number;
3484
- statusText: string;
3485
- };
3486
- } | undefined>;
3487
- registerPasskey: () => Promise<{
3488
- data: null;
3489
- error: {
3490
- message?: string | undefined;
3491
- status: number;
3492
- statusText: string;
3493
- };
3494
- } | undefined>;
3495
- } | undefined;
3496
- authProxySignal?: AuthProxySignal[];
3497
- signals?: Record<string, nanostores.PreinitializedWritableAtom<boolean>>;
3498
- atoms?: Record<string, nanostores.Atom<any>>;
3499
- pathMethods?: Record<string, "POST" | "GET">;
3500
- fetchPlugins?: _better_fetch_fetch.BetterFetchPlugin[];
3501
3544
  };
3502
3545
 
3503
- export { type Invitation as I, type Member as M, type OrganizationOptions as O, type PasskeyOptions as P, type TwoFactorOptions as T, type UserWithTwoFactor as U, type WebAuthnCookieType as W, type Passkey as a, passkey as b, getPasskeyActions as g, organization as o, passkeyClient as p, twoFactorClient as t };
3546
+ export { type Invitation as I, type Member as M, type OrganizationOptions as O, type PasskeyOptions as P, type WebAuthnCookieType as W, twoFactorClient as a, type Passkey as b, passkeyClient as c, getPasskeyActions as g, organization as o, passkey as p, twoFactor as t, username as u };