better-auth 1.2.2-beta.1 → 1.2.2-beta.3

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 (28) hide show
  1. package/dist/client/plugins/index.d.cts +1 -1
  2. package/dist/client/plugins/index.d.mts +1 -1
  3. package/dist/client/plugins/index.d.ts +1 -1
  4. package/dist/integrations/next-js.cjs +1 -1
  5. package/dist/integrations/next-js.mjs +1 -1
  6. package/dist/plugins/index.cjs +2 -2
  7. package/dist/plugins/index.d.cts +1 -1
  8. package/dist/plugins/index.d.mts +1 -1
  9. package/dist/plugins/index.d.ts +1 -1
  10. package/dist/plugins/index.mjs +2 -2
  11. package/dist/plugins/organization/index.cjs +2 -2
  12. package/dist/plugins/organization/index.d.cts +1 -1
  13. package/dist/plugins/organization/index.d.mts +1 -1
  14. package/dist/plugins/organization/index.d.ts +1 -1
  15. package/dist/plugins/organization/index.mjs +2 -2
  16. package/dist/plugins/two-factor/index.cjs +20 -2
  17. package/dist/plugins/two-factor/index.d.cts +8 -0
  18. package/dist/plugins/two-factor/index.d.mts +8 -0
  19. package/dist/plugins/two-factor/index.d.ts +8 -0
  20. package/dist/plugins/two-factor/index.mjs +20 -2
  21. package/dist/shared/{better-auth.Dzj4ABgt.d.cts → better-auth.0i5RUFK_.d.cts} +12 -36
  22. package/dist/shared/{better-auth.DP4-qG45.mjs → better-auth.B7sMS79i.mjs} +7 -24
  23. package/dist/shared/{better-auth.ByqmtO_4.cjs → better-auth.BLio44fo.cjs} +7 -24
  24. package/dist/shared/{better-auth.CIROgwi1.mjs → better-auth.CVkvTxx8.mjs} +1 -1
  25. package/dist/shared/{better-auth.KKdVTsTP.cjs → better-auth.Ca7dLDPO.cjs} +1 -1
  26. package/dist/shared/{better-auth.Iwpq4tNv.d.mts → better-auth.DvFTih7n.d.mts} +12 -36
  27. package/dist/shared/{better-auth.C1RwKIqC.d.ts → better-auth.Dxn5Xplu.d.ts} +12 -36
  28. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { atom } from 'nanostores';
3
3
  import { AccessControl, Role, Statements, Subset, AuthortizeResponse } from '../../plugins/access/index.cjs';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
6
- import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.Dzj4ABgt.cjs';
6
+ import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.0i5RUFK_.cjs';
7
7
  import { b as Prettify } from '../../shared/better-auth.Bi8FQwDD.cjs';
8
8
  import { username } from '../../plugins/username/index.cjs';
9
9
  import { Passkey, passkey } from '../../plugins/passkey/index.cjs';
@@ -3,7 +3,7 @@ import { atom } from 'nanostores';
3
3
  import { AccessControl, Role, Statements, Subset, AuthortizeResponse } from '../../plugins/access/index.mjs';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
6
- import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.Iwpq4tNv.mjs';
6
+ import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.DvFTih7n.mjs';
7
7
  import { b as Prettify } from '../../shared/better-auth.Bi8FQwDD.mjs';
8
8
  import { username } from '../../plugins/username/index.mjs';
9
9
  import { Passkey, passkey } from '../../plugins/passkey/index.mjs';
@@ -3,7 +3,7 @@ import { atom } from 'nanostores';
3
3
  import { AccessControl, Role, Statements, Subset, AuthortizeResponse } from '../../plugins/access/index.js';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
6
- import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.C1RwKIqC.js';
6
+ import { o as organization, I as InferMember, a as InferInvitation, T as Team, b as Organization, M as Member, c as Invitation } from '../../shared/better-auth.Dxn5Xplu.js';
7
7
  import { b as Prettify } from '../../shared/better-auth.Bi8FQwDD.js';
8
8
  import { username } from '../../plugins/username/index.js';
9
9
  import { Passkey, passkey } from '../../plugins/passkey/index.js';
@@ -8,7 +8,7 @@ require('better-call');
8
8
  require('zod');
9
9
  const account = require('../shared/better-auth.DcdXBLtR.cjs');
10
10
  require('../shared/better-auth.CHyZMcYK.cjs');
11
- require('../shared/better-auth.ByqmtO_4.cjs');
11
+ require('../shared/better-auth.BLio44fo.cjs');
12
12
  require('../plugins/organization/access/index.cjs');
13
13
  require('../shared/better-auth.CYeOI8C-.cjs');
14
14
  require('../shared/better-auth.GpOOav9x.cjs');
@@ -6,7 +6,7 @@ import 'better-call';
6
6
  import 'zod';
7
7
  import { c as createAuthMiddleware } from '../shared/better-auth.DEf1xRKI.mjs';
8
8
  import '../shared/better-auth.C24Bzw4w.mjs';
9
- import '../shared/better-auth.DP4-qG45.mjs';
9
+ import '../shared/better-auth.B7sMS79i.mjs';
10
10
  import '../plugins/organization/access/index.mjs';
11
11
  import '../shared/better-auth.B4Qoxdgc.mjs';
12
12
  import '../shared/better-auth.DH3YjMQH.mjs';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const organization = require('../shared/better-auth.KKdVTsTP.cjs');
3
+ const organization = require('../shared/better-auth.Ca7dLDPO.cjs');
4
4
  const plugins_twoFactor_index = require('./two-factor/index.cjs');
5
5
  const plugins_username_index = require('./username/index.cjs');
6
6
  const plugins_bearer_index = require('./bearer/index.cjs');
@@ -46,7 +46,7 @@ const json = require('../shared/better-auth.D3mtHEZg.cjs');
46
46
  const id = require('../shared/better-auth.Bg6iw3ig.cjs');
47
47
  const plugins_access_index = require('./access/index.cjs');
48
48
  const client = require('../shared/better-auth.DnER2-iT.cjs');
49
- require('../shared/better-auth.ByqmtO_4.cjs');
49
+ require('../shared/better-auth.BLio44fo.cjs');
50
50
  require('../cookies/index.cjs');
51
51
  require('../shared/better-auth.ANpbi45u.cjs');
52
52
  require('./organization/access/index.cjs');
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../shared/better-auth.Dzj4ABgt.cjs';
1
+ export { O as OrganizationOptions, o as organization } from '../shared/better-auth.0i5RUFK_.cjs';
2
2
  export { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, twoFactor, twoFactorClient } from './two-factor/index.cjs';
3
3
  export { UsernameOptions, username } from './username/index.cjs';
4
4
  export { bearer } from './bearer/index.cjs';
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../shared/better-auth.Iwpq4tNv.mjs';
1
+ export { O as OrganizationOptions, o as organization } from '../shared/better-auth.DvFTih7n.mjs';
2
2
  export { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, twoFactor, twoFactorClient } from './two-factor/index.mjs';
3
3
  export { UsernameOptions, username } from './username/index.mjs';
4
4
  export { bearer } from './bearer/index.mjs';
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../shared/better-auth.C1RwKIqC.js';
1
+ export { O as OrganizationOptions, o as organization } from '../shared/better-auth.Dxn5Xplu.js';
2
2
  export { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, twoFactor, twoFactorClient } from './two-factor/index.js';
3
3
  export { UsernameOptions, username } from './username/index.js';
4
4
  export { bearer } from './bearer/index.js';
@@ -1,4 +1,4 @@
1
- export { o as organization } from '../shared/better-auth.CIROgwi1.mjs';
1
+ export { o as organization } from '../shared/better-auth.CVkvTxx8.mjs';
2
2
  export { twoFactor } from './two-factor/index.mjs';
3
3
  export { username } from './username/index.mjs';
4
4
  export { bearer } from './bearer/index.mjs';
@@ -45,7 +45,7 @@ import { s as safeJSONParse } from '../shared/better-auth.tB5eU6EY.mjs';
45
45
  import { g as generateId } from '../shared/better-auth.BUPPRXfK.mjs';
46
46
  import { role } from './access/index.mjs';
47
47
  export { t as twoFactorClient } from '../shared/better-auth.Ddw8bVyV.mjs';
48
- import '../shared/better-auth.DP4-qG45.mjs';
48
+ import '../shared/better-auth.B7sMS79i.mjs';
49
49
  import '../cookies/index.mjs';
50
50
  import '../shared/better-auth.DdzSJf-n.mjs';
51
51
  import './organization/access/index.mjs';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const organization = require('../../shared/better-auth.KKdVTsTP.cjs');
3
+ const organization = require('../../shared/better-auth.Ca7dLDPO.cjs');
4
4
  require('better-call');
5
5
  require('zod');
6
6
  require('../../shared/better-auth.DcdXBLtR.cjs');
@@ -34,7 +34,7 @@ require('../../shared/better-auth.BMYo0QR-.cjs');
34
34
  require('../../shared/better-auth.DssCybTk.cjs');
35
35
  require('jose/errors');
36
36
  require('@better-auth/utils/binary');
37
- require('../../shared/better-auth.ByqmtO_4.cjs');
37
+ require('../../shared/better-auth.BLio44fo.cjs');
38
38
  require('../../shared/better-auth.DhsGZ30Q.cjs');
39
39
  require('./access/index.cjs');
40
40
  require('../access/index.cjs');
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.Dzj4ABgt.cjs';
1
+ export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.0i5RUFK_.cjs';
2
2
  import '../access/index.cjs';
3
3
  import '../../shared/better-auth.Bi8FQwDD.cjs';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.Iwpq4tNv.mjs';
1
+ export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.DvFTih7n.mjs';
2
2
  import '../access/index.mjs';
3
3
  import '../../shared/better-auth.Bi8FQwDD.mjs';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.C1RwKIqC.js';
1
+ export { O as OrganizationOptions, o as organization } from '../../shared/better-auth.Dxn5Xplu.js';
2
2
  import '../access/index.js';
3
3
  import '../../shared/better-auth.Bi8FQwDD.js';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { o as organization } from '../../shared/better-auth.CIROgwi1.mjs';
1
+ export { o as organization } from '../../shared/better-auth.CVkvTxx8.mjs';
2
2
  import 'better-call';
3
3
  import 'zod';
4
4
  import '../../shared/better-auth.DEf1xRKI.mjs';
@@ -32,7 +32,7 @@ import '../../shared/better-auth.DDEbWX-S.mjs';
32
32
  import '../../shared/better-auth.D_yrCdEQ.mjs';
33
33
  import 'jose/errors';
34
34
  import '@better-auth/utils/binary';
35
- import '../../shared/better-auth.DP4-qG45.mjs';
35
+ import '../../shared/better-auth.B7sMS79i.mjs';
36
36
  import '../../shared/better-auth.ffWeg50w.mjs';
37
37
  import './access/index.mjs';
38
38
  import '../access/index.mjs';
@@ -96,7 +96,17 @@ const backupCode2fa = (options) => {
96
96
  /**
97
97
  * Disable setting the session cookie
98
98
  */
99
- disableSession: zod.z.boolean().optional()
99
+ disableSession: zod.z.boolean({
100
+ description: "If true, the session cookie will not be set."
101
+ }).optional(),
102
+ /**
103
+ * if true, the device will be trusted
104
+ * for 30 days. It'll be refreshed on
105
+ * every sign in request within this time.
106
+ */
107
+ trustDevice: zod.z.boolean({
108
+ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time."
109
+ }).optional()
100
110
  }),
101
111
  use: [verifyMiddleware.verifyTwoFactorMiddleware]
102
112
  },
@@ -565,7 +575,15 @@ const totp2fa = (options) => {
565
575
  body: zod.z.object({
566
576
  code: zod.z.string({
567
577
  description: "The otp code to verify"
568
- })
578
+ }),
579
+ /**
580
+ * if true, the device will be trusted
581
+ * for 30 days. It'll be refreshed on
582
+ * every sign in request within this time.
583
+ */
584
+ trustDevice: zod.z.boolean({
585
+ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time."
586
+ }).optional()
569
587
  }),
570
588
  use: [verifyMiddleware.verifyTwoFactorMiddleware],
571
589
  metadata: {
@@ -401,6 +401,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
401
401
  <C extends [{
402
402
  body: {
403
403
  code: string;
404
+ trustDevice?: boolean | undefined;
404
405
  disableSession?: boolean | undefined;
405
406
  };
406
407
  method?: "POST" | undefined;
@@ -501,11 +502,14 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
501
502
  body: z.ZodObject<{
502
503
  code: z.ZodString;
503
504
  disableSession: z.ZodOptional<z.ZodBoolean>;
505
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
504
506
  }, "strip", z.ZodTypeAny, {
505
507
  code: string;
508
+ trustDevice?: boolean | undefined;
506
509
  disableSession?: boolean | undefined;
507
510
  }, {
508
511
  code: string;
512
+ trustDevice?: boolean | undefined;
509
513
  disableSession?: boolean | undefined;
510
514
  }>;
511
515
  use: ((inputContext: {
@@ -1181,6 +1185,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1181
1185
  <C extends [{
1182
1186
  body: {
1183
1187
  code: string;
1188
+ trustDevice?: boolean | undefined;
1184
1189
  };
1185
1190
  method?: "POST" | undefined;
1186
1191
  query?: Record<string, any> | undefined;
@@ -1225,10 +1230,13 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1225
1230
  method: "POST";
1226
1231
  body: z.ZodObject<{
1227
1232
  code: z.ZodString;
1233
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
1228
1234
  }, "strip", z.ZodTypeAny, {
1229
1235
  code: string;
1236
+ trustDevice?: boolean | undefined;
1230
1237
  }, {
1231
1238
  code: string;
1239
+ trustDevice?: boolean | undefined;
1232
1240
  }>;
1233
1241
  use: ((inputContext: {
1234
1242
  body: {
@@ -401,6 +401,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
401
401
  <C extends [{
402
402
  body: {
403
403
  code: string;
404
+ trustDevice?: boolean | undefined;
404
405
  disableSession?: boolean | undefined;
405
406
  };
406
407
  method?: "POST" | undefined;
@@ -501,11 +502,14 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
501
502
  body: z.ZodObject<{
502
503
  code: z.ZodString;
503
504
  disableSession: z.ZodOptional<z.ZodBoolean>;
505
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
504
506
  }, "strip", z.ZodTypeAny, {
505
507
  code: string;
508
+ trustDevice?: boolean | undefined;
506
509
  disableSession?: boolean | undefined;
507
510
  }, {
508
511
  code: string;
512
+ trustDevice?: boolean | undefined;
509
513
  disableSession?: boolean | undefined;
510
514
  }>;
511
515
  use: ((inputContext: {
@@ -1181,6 +1185,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1181
1185
  <C extends [{
1182
1186
  body: {
1183
1187
  code: string;
1188
+ trustDevice?: boolean | undefined;
1184
1189
  };
1185
1190
  method?: "POST" | undefined;
1186
1191
  query?: Record<string, any> | undefined;
@@ -1225,10 +1230,13 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1225
1230
  method: "POST";
1226
1231
  body: z.ZodObject<{
1227
1232
  code: z.ZodString;
1233
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
1228
1234
  }, "strip", z.ZodTypeAny, {
1229
1235
  code: string;
1236
+ trustDevice?: boolean | undefined;
1230
1237
  }, {
1231
1238
  code: string;
1239
+ trustDevice?: boolean | undefined;
1232
1240
  }>;
1233
1241
  use: ((inputContext: {
1234
1242
  body: {
@@ -401,6 +401,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
401
401
  <C extends [{
402
402
  body: {
403
403
  code: string;
404
+ trustDevice?: boolean | undefined;
404
405
  disableSession?: boolean | undefined;
405
406
  };
406
407
  method?: "POST" | undefined;
@@ -501,11 +502,14 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
501
502
  body: z.ZodObject<{
502
503
  code: z.ZodString;
503
504
  disableSession: z.ZodOptional<z.ZodBoolean>;
505
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
504
506
  }, "strip", z.ZodTypeAny, {
505
507
  code: string;
508
+ trustDevice?: boolean | undefined;
506
509
  disableSession?: boolean | undefined;
507
510
  }, {
508
511
  code: string;
512
+ trustDevice?: boolean | undefined;
509
513
  disableSession?: boolean | undefined;
510
514
  }>;
511
515
  use: ((inputContext: {
@@ -1181,6 +1185,7 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1181
1185
  <C extends [{
1182
1186
  body: {
1183
1187
  code: string;
1188
+ trustDevice?: boolean | undefined;
1184
1189
  };
1185
1190
  method?: "POST" | undefined;
1186
1191
  query?: Record<string, any> | undefined;
@@ -1225,10 +1230,13 @@ declare const twoFactor: (options?: TwoFactorOptions) => {
1225
1230
  method: "POST";
1226
1231
  body: z.ZodObject<{
1227
1232
  code: z.ZodString;
1233
+ trustDevice: z.ZodOptional<z.ZodBoolean>;
1228
1234
  }, "strip", z.ZodTypeAny, {
1229
1235
  code: string;
1236
+ trustDevice?: boolean | undefined;
1230
1237
  }, {
1231
1238
  code: string;
1239
+ trustDevice?: boolean | undefined;
1232
1240
  }>;
1233
1241
  use: ((inputContext: {
1234
1242
  body: {
@@ -94,7 +94,17 @@ const backupCode2fa = (options) => {
94
94
  /**
95
95
  * Disable setting the session cookie
96
96
  */
97
- disableSession: z.boolean().optional()
97
+ disableSession: z.boolean({
98
+ description: "If true, the session cookie will not be set."
99
+ }).optional(),
100
+ /**
101
+ * if true, the device will be trusted
102
+ * for 30 days. It'll be refreshed on
103
+ * every sign in request within this time.
104
+ */
105
+ trustDevice: z.boolean({
106
+ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time."
107
+ }).optional()
98
108
  }),
99
109
  use: [verifyTwoFactorMiddleware]
100
110
  },
@@ -563,7 +573,15 @@ const totp2fa = (options) => {
563
573
  body: z.object({
564
574
  code: z.string({
565
575
  description: "The otp code to verify"
566
- })
576
+ }),
577
+ /**
578
+ * if true, the device will be trusted
579
+ * for 30 days. It'll be refreshed on
580
+ * every sign in request within this time.
581
+ */
582
+ trustDevice: z.boolean({
583
+ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time."
584
+ }).optional()
567
585
  }),
568
586
  use: [verifyTwoFactorMiddleware],
569
587
  metadata: {
@@ -767,19 +767,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
767
767
  }] ? {
768
768
  headers: Headers;
769
769
  response: {
770
- metadata: any;
770
+ metadata: Record<string, any> | undefined;
771
771
  members: {
772
- user: {
773
- id: string;
774
- name: string;
775
- email: string;
776
- image: string | null | undefined;
777
- };
772
+ id: string;
773
+ createdAt: Date;
778
774
  userId: string;
779
775
  organizationId: string;
780
776
  role: string;
781
- id?: string | undefined;
782
- createdAt?: Date | undefined;
783
777
  teamId?: string | undefined;
784
778
  }[];
785
779
  id: string;
@@ -789,19 +783,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
789
783
  logo?: string | null | undefined;
790
784
  } | null;
791
785
  } : {
792
- metadata: any;
786
+ metadata: Record<string, any> | undefined;
793
787
  members: {
794
- user: {
795
- id: string;
796
- name: string;
797
- email: string;
798
- image: string | null | undefined;
799
- };
788
+ id: string;
789
+ createdAt: Date;
800
790
  userId: string;
801
791
  organizationId: string;
802
792
  role: string;
803
- id?: string | undefined;
804
- createdAt?: Date | undefined;
805
793
  teamId?: string | undefined;
806
794
  }[];
807
795
  id: string;
@@ -3683,19 +3671,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3683
3671
  }] ? {
3684
3672
  headers: Headers;
3685
3673
  response: {
3686
- metadata: any;
3674
+ metadata: Record<string, any> | undefined;
3687
3675
  members: {
3688
- user: {
3689
- id: string;
3690
- name: string;
3691
- email: string;
3692
- image: string | null | undefined;
3693
- };
3676
+ id: string;
3677
+ createdAt: Date;
3694
3678
  userId: string;
3695
3679
  organizationId: string;
3696
3680
  role: string;
3697
- id?: string | undefined;
3698
- createdAt?: Date | undefined;
3699
3681
  teamId?: string | undefined;
3700
3682
  }[];
3701
3683
  id: string;
@@ -3705,19 +3687,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3705
3687
  logo?: string | null | undefined;
3706
3688
  } | null;
3707
3689
  } : {
3708
- metadata: any;
3690
+ metadata: Record<string, any> | undefined;
3709
3691
  members: {
3710
- user: {
3711
- id: string;
3712
- name: string;
3713
- email: string;
3714
- image: string | null | undefined;
3715
- };
3692
+ id: string;
3693
+ createdAt: Date;
3716
3694
  userId: string;
3717
3695
  organizationId: string;
3718
3696
  role: string;
3719
- id?: string | undefined;
3720
- createdAt?: Date | undefined;
3721
3697
  teamId?: string | undefined;
3722
3698
  }[];
3723
3699
  id: string;
@@ -47,29 +47,9 @@ const getOrgAdapter = (context, options) => {
47
47
  metadata: data.organization.metadata ? JSON.stringify(data.organization.metadata) : void 0
48
48
  }
49
49
  });
50
- const member = await adapter.create({
51
- model: "member",
52
- data: {
53
- organizationId: organization.id,
54
- userId: data.user.id,
55
- createdAt: /* @__PURE__ */ new Date(),
56
- role: options?.creatorRole || "owner"
57
- }
58
- });
59
50
  return {
60
51
  ...organization,
61
- metadata: organization.metadata ? JSON.parse(organization.metadata) : void 0,
62
- members: [
63
- {
64
- ...member,
65
- user: {
66
- id: data.user.id,
67
- name: data.user.name,
68
- email: data.user.email,
69
- image: data.user.image
70
- }
71
- }
72
- ]
52
+ metadata: organization.metadata ? JSON.parse(organization.metadata) : void 0
73
53
  };
74
54
  },
75
55
  findMemberByEmail: async (data) => {
@@ -1689,8 +1669,7 @@ const createOrganization = createAuthEndpoint(
1689
1669
  createdAt: /* @__PURE__ */ new Date(),
1690
1670
  metadata: ctx.body.metadata,
1691
1671
  ...hookResponse?.data || {}
1692
- },
1693
- user
1672
+ }
1694
1673
  });
1695
1674
  let member;
1696
1675
  if (options?.teams?.enabled && options.teams.defaultTeam?.enabled !== false) {
@@ -1732,7 +1711,11 @@ const createOrganization = createAuthEndpoint(
1732
1711
  organization.id
1733
1712
  );
1734
1713
  }
1735
- return ctx.json(organization);
1714
+ return ctx.json({
1715
+ ...organization,
1716
+ metadata: ctx.body.metadata,
1717
+ members: [member]
1718
+ });
1736
1719
  }
1737
1720
  );
1738
1721
  const checkOrganizationSlug = createAuthEndpoint(
@@ -49,29 +49,9 @@ const getOrgAdapter = (context, options) => {
49
49
  metadata: data.organization.metadata ? JSON.stringify(data.organization.metadata) : void 0
50
50
  }
51
51
  });
52
- const member = await adapter.create({
53
- model: "member",
54
- data: {
55
- organizationId: organization.id,
56
- userId: data.user.id,
57
- createdAt: /* @__PURE__ */ new Date(),
58
- role: options?.creatorRole || "owner"
59
- }
60
- });
61
52
  return {
62
53
  ...organization,
63
- metadata: organization.metadata ? JSON.parse(organization.metadata) : void 0,
64
- members: [
65
- {
66
- ...member,
67
- user: {
68
- id: data.user.id,
69
- name: data.user.name,
70
- email: data.user.email,
71
- image: data.user.image
72
- }
73
- }
74
- ]
54
+ metadata: organization.metadata ? JSON.parse(organization.metadata) : void 0
75
55
  };
76
56
  },
77
57
  findMemberByEmail: async (data) => {
@@ -1691,8 +1671,7 @@ const createOrganization = account.createAuthEndpoint(
1691
1671
  createdAt: /* @__PURE__ */ new Date(),
1692
1672
  metadata: ctx.body.metadata,
1693
1673
  ...hookResponse?.data || {}
1694
- },
1695
- user
1674
+ }
1696
1675
  });
1697
1676
  let member;
1698
1677
  if (options?.teams?.enabled && options.teams.defaultTeam?.enabled !== false) {
@@ -1734,7 +1713,11 @@ const createOrganization = account.createAuthEndpoint(
1734
1713
  organization.id
1735
1714
  );
1736
1715
  }
1737
- return ctx.json(organization);
1716
+ return ctx.json({
1717
+ ...organization,
1718
+ metadata: ctx.body.metadata,
1719
+ members: [member]
1720
+ });
1738
1721
  }
1739
1722
  );
1740
1723
  const checkOrganizationSlug = account.createAuthEndpoint(
@@ -5,7 +5,7 @@ import './better-auth.8zoxzg-F.mjs';
5
5
  import '@better-auth/utils/base64';
6
6
  import '@better-auth/utils/hmac';
7
7
  import './better-auth.C24Bzw4w.mjs';
8
- import { u as updateMemberRole, a as addMember, c as createInvitation, g as getFullOrganization, s as setActiveOrganization, b as createTeam, d as updateTeam, r as removeTeam, l as listOrganizationTeams, e as leaveOrganization, f as getActiveMember, h as removeMember, i as checkOrganizationSlug, j as rejectInvitation, k as getInvitation, m as acceptInvitation, n as cancelInvitation, o as listOrganizations, p as deleteOrganization, q as updateOrganization, t as createOrganization, O as ORGANIZATION_ERROR_CODES, v as orgSessionMiddleware, w as getOrgAdapter, x as hasPermission } from './better-auth.DP4-qG45.mjs';
8
+ import { u as updateMemberRole, a as addMember, c as createInvitation, g as getFullOrganization, s as setActiveOrganization, b as createTeam, d as updateTeam, r as removeTeam, l as listOrganizationTeams, e as leaveOrganization, f as getActiveMember, h as removeMember, i as checkOrganizationSlug, j as rejectInvitation, k as getInvitation, m as acceptInvitation, n as cancelInvitation, o as listOrganizations, p as deleteOrganization, q as updateOrganization, t as createOrganization, O as ORGANIZATION_ERROR_CODES, v as orgSessionMiddleware, w as getOrgAdapter, x as hasPermission } from './better-auth.B7sMS79i.mjs';
9
9
  import { defaultRoles } from '../plugins/organization/access/index.mjs';
10
10
 
11
11
  const shimContext = (originalObject, newContext) => {
@@ -7,7 +7,7 @@ require('./better-auth.DiSjtgs9.cjs');
7
7
  require('@better-auth/utils/base64');
8
8
  require('@better-auth/utils/hmac');
9
9
  require('./better-auth.CHyZMcYK.cjs');
10
- const crudTeam = require('./better-auth.ByqmtO_4.cjs');
10
+ const crudTeam = require('./better-auth.BLio44fo.cjs');
11
11
  const plugins_organization_access_index = require('../plugins/organization/access/index.cjs');
12
12
 
13
13
  const shimContext = (originalObject, newContext) => {
@@ -767,19 +767,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
767
767
  }] ? {
768
768
  headers: Headers;
769
769
  response: {
770
- metadata: any;
770
+ metadata: Record<string, any> | undefined;
771
771
  members: {
772
- user: {
773
- id: string;
774
- name: string;
775
- email: string;
776
- image: string | null | undefined;
777
- };
772
+ id: string;
773
+ createdAt: Date;
778
774
  userId: string;
779
775
  organizationId: string;
780
776
  role: string;
781
- id?: string | undefined;
782
- createdAt?: Date | undefined;
783
777
  teamId?: string | undefined;
784
778
  }[];
785
779
  id: string;
@@ -789,19 +783,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
789
783
  logo?: string | null | undefined;
790
784
  } | null;
791
785
  } : {
792
- metadata: any;
786
+ metadata: Record<string, any> | undefined;
793
787
  members: {
794
- user: {
795
- id: string;
796
- name: string;
797
- email: string;
798
- image: string | null | undefined;
799
- };
788
+ id: string;
789
+ createdAt: Date;
800
790
  userId: string;
801
791
  organizationId: string;
802
792
  role: string;
803
- id?: string | undefined;
804
- createdAt?: Date | undefined;
805
793
  teamId?: string | undefined;
806
794
  }[];
807
795
  id: string;
@@ -3683,19 +3671,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3683
3671
  }] ? {
3684
3672
  headers: Headers;
3685
3673
  response: {
3686
- metadata: any;
3674
+ metadata: Record<string, any> | undefined;
3687
3675
  members: {
3688
- user: {
3689
- id: string;
3690
- name: string;
3691
- email: string;
3692
- image: string | null | undefined;
3693
- };
3676
+ id: string;
3677
+ createdAt: Date;
3694
3678
  userId: string;
3695
3679
  organizationId: string;
3696
3680
  role: string;
3697
- id?: string | undefined;
3698
- createdAt?: Date | undefined;
3699
3681
  teamId?: string | undefined;
3700
3682
  }[];
3701
3683
  id: string;
@@ -3705,19 +3687,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3705
3687
  logo?: string | null | undefined;
3706
3688
  } | null;
3707
3689
  } : {
3708
- metadata: any;
3690
+ metadata: Record<string, any> | undefined;
3709
3691
  members: {
3710
- user: {
3711
- id: string;
3712
- name: string;
3713
- email: string;
3714
- image: string | null | undefined;
3715
- };
3692
+ id: string;
3693
+ createdAt: Date;
3716
3694
  userId: string;
3717
3695
  organizationId: string;
3718
3696
  role: string;
3719
- id?: string | undefined;
3720
- createdAt?: Date | undefined;
3721
3697
  teamId?: string | undefined;
3722
3698
  }[];
3723
3699
  id: string;
@@ -767,19 +767,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
767
767
  }] ? {
768
768
  headers: Headers;
769
769
  response: {
770
- metadata: any;
770
+ metadata: Record<string, any> | undefined;
771
771
  members: {
772
- user: {
773
- id: string;
774
- name: string;
775
- email: string;
776
- image: string | null | undefined;
777
- };
772
+ id: string;
773
+ createdAt: Date;
778
774
  userId: string;
779
775
  organizationId: string;
780
776
  role: string;
781
- id?: string | undefined;
782
- createdAt?: Date | undefined;
783
777
  teamId?: string | undefined;
784
778
  }[];
785
779
  id: string;
@@ -789,19 +783,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
789
783
  logo?: string | null | undefined;
790
784
  } | null;
791
785
  } : {
792
- metadata: any;
786
+ metadata: Record<string, any> | undefined;
793
787
  members: {
794
- user: {
795
- id: string;
796
- name: string;
797
- email: string;
798
- image: string | null | undefined;
799
- };
788
+ id: string;
789
+ createdAt: Date;
800
790
  userId: string;
801
791
  organizationId: string;
802
792
  role: string;
803
- id?: string | undefined;
804
- createdAt?: Date | undefined;
805
793
  teamId?: string | undefined;
806
794
  }[];
807
795
  id: string;
@@ -3683,19 +3671,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3683
3671
  }] ? {
3684
3672
  headers: Headers;
3685
3673
  response: {
3686
- metadata: any;
3674
+ metadata: Record<string, any> | undefined;
3687
3675
  members: {
3688
- user: {
3689
- id: string;
3690
- name: string;
3691
- email: string;
3692
- image: string | null | undefined;
3693
- };
3676
+ id: string;
3677
+ createdAt: Date;
3694
3678
  userId: string;
3695
3679
  organizationId: string;
3696
3680
  role: string;
3697
- id?: string | undefined;
3698
- createdAt?: Date | undefined;
3699
3681
  teamId?: string | undefined;
3700
3682
  }[];
3701
3683
  id: string;
@@ -3705,19 +3687,13 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
3705
3687
  logo?: string | null | undefined;
3706
3688
  } | null;
3707
3689
  } : {
3708
- metadata: any;
3690
+ metadata: Record<string, any> | undefined;
3709
3691
  members: {
3710
- user: {
3711
- id: string;
3712
- name: string;
3713
- email: string;
3714
- image: string | null | undefined;
3715
- };
3692
+ id: string;
3693
+ createdAt: Date;
3716
3694
  userId: string;
3717
3695
  organizationId: string;
3718
3696
  role: string;
3719
- id?: string | undefined;
3720
- createdAt?: Date | undefined;
3721
3697
  teamId?: string | undefined;
3722
3698
  }[];
3723
3699
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "1.2.2-beta.1",
3
+ "version": "1.2.2-beta.3",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "repository": {