better-auth 0.2.8-beta.7 → 0.2.8-beta.9

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 (40) hide show
  1. package/dist/access.d.ts +3 -3
  2. package/dist/adapters/drizzle.d.ts +9 -3
  3. package/dist/adapters/drizzle.js +49 -11
  4. package/dist/adapters/mongodb.d.ts +3 -3
  5. package/dist/adapters/prisma.d.ts +3 -3
  6. package/dist/api.d.ts +3 -3
  7. package/dist/api.js +178 -142
  8. package/dist/cli.js +3 -3
  9. package/dist/client/plugins.d.ts +6 -6
  10. package/dist/client/plugins.js +15 -11
  11. package/dist/client.d.ts +3 -3
  12. package/dist/client.js +21 -6
  13. package/dist/{helper-D-PIAORk.d.ts → helper-DPDj8Nix.d.ts} +4 -1
  14. package/dist/{index-CVYpdIik.d.ts → index-CKn-Zrry.d.ts} +280 -116
  15. package/dist/{index-D1yWsqP4.d.ts → index-DfAHOgpj.d.ts} +1 -1
  16. package/dist/{index-CVIZ94nq.d.ts → index-DtRHPoYF.d.ts} +8 -8
  17. package/dist/{index-XxjbEPqj.d.ts → index-JM-i6hLs.d.ts} +1 -1
  18. package/dist/index.d.ts +3 -3
  19. package/dist/index.js +322 -282
  20. package/dist/next-js.d.ts +4 -4
  21. package/dist/node.d.ts +3 -3
  22. package/dist/plugins.d.ts +7 -7
  23. package/dist/plugins.js +223 -176
  24. package/dist/react.d.ts +3 -3
  25. package/dist/react.js +21 -6
  26. package/dist/social.d.ts +2 -2
  27. package/dist/social.js +54 -52
  28. package/dist/solid-start.d.ts +3 -3
  29. package/dist/solid.d.ts +3 -3
  30. package/dist/solid.js +21 -6
  31. package/dist/{statement-BYDTZ_xW.d.ts → statement-CfnyN34h.d.ts} +1 -1
  32. package/dist/svelte-kit.d.ts +3 -3
  33. package/dist/svelte.d.ts +3 -3
  34. package/dist/svelte.js +21 -6
  35. package/dist/types.d.ts +7 -7
  36. package/dist/utils.d.ts +6 -6
  37. package/dist/utils.js +3 -3
  38. package/dist/vue.d.ts +3 -3
  39. package/dist/vue.js +21 -6
  40. package/package.json +1 -1
package/dist/access.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AccessControl, a as AuthortizeResponse, P as ParsingError, R as Role, S as StatementsPrimitive, b as SubArray, c as Subset, d as adminAc, e as createAccessControl, f as defaultAc, g as defaultRoles, h as defaultStatements, m as memberAc, o as ownerAc } from './statement-BYDTZ_xW.js';
2
- export { p as permissionFromString } from './index-D1yWsqP4.js';
3
- import './helper-D-PIAORk.js';
1
+ export { A as AccessControl, a as AuthortizeResponse, P as ParsingError, R as Role, S as StatementsPrimitive, b as SubArray, c as Subset, d as adminAc, e as createAccessControl, f as defaultAc, g as defaultRoles, h as defaultStatements, m as memberAc, o as ownerAc } from './statement-CfnyN34h.js';
2
+ export { p as permissionFromString } from './index-DfAHOgpj.js';
3
+ import './helper-DPDj8Nix.js';
4
4
  import 'zod';
@@ -1,9 +1,9 @@
1
- import { A as Adapter } from '../index-CVYpdIik.js';
1
+ import { A as Adapter } from '../index-CKn-Zrry.js';
2
2
  import 'kysely';
3
- import '../index-XxjbEPqj.js';
3
+ import '../index-JM-i6hLs.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
- import '../helper-D-PIAORk.js';
6
+ import '../helper-DPDj8Nix.js';
7
7
  import 'better-call';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
@@ -11,6 +11,12 @@ import 'mysql2';
11
11
  interface DrizzleAdapterOptions {
12
12
  schema?: Record<string, any>;
13
13
  provider: "pg" | "mysql" | "sqlite";
14
+ /**
15
+ * If the table names in the schema are plural
16
+ * set this to true. For example, if the schema
17
+ * has an object with a key "users" instead of "user"
18
+ */
19
+ usePlural?: boolean;
14
20
  }
15
21
  interface DB {
16
22
  [key: string]: any;
@@ -1,6 +1,12 @@
1
1
  import { eq, and, or } from 'drizzle-orm';
2
2
  import { existsSync } from 'fs';
3
3
  import fs from 'fs/promises';
4
+ import 'oslo';
5
+ import 'nanoid';
6
+ import { createConsola } from 'consola';
7
+ import 'oslo/oauth2';
8
+ import 'zod';
9
+ import 'chalk';
4
10
 
5
11
  // src/adapters/drizzle-adapter/index.ts
6
12
 
@@ -172,10 +178,20 @@ var getAuthTables = (options) => {
172
178
  ...shouldAddRateLimitTable ? rateLimitTable : {}
173
179
  };
174
180
  };
181
+ createConsola({
182
+ formatOptions: {
183
+ date: false,
184
+ colors: true,
185
+ compact: true
186
+ },
187
+ defaults: {
188
+ tag: "Better Auth"
189
+ }
190
+ });
175
191
 
176
192
  // src/error/better-auth-error.ts
177
193
  var BetterAuthError = class extends Error {
178
- constructor(message, cause, docsLink) {
194
+ constructor(message, cause) {
179
195
  super(message);
180
196
  this.name = "BetterAuthError";
181
197
  this.message = message;
@@ -183,15 +199,21 @@ var BetterAuthError = class extends Error {
183
199
  this.stack = "";
184
200
  }
185
201
  };
186
-
187
- // src/adapters/drizzle-adapter/index.ts
188
- function getSchema(modelName, schema) {
202
+ function getSchema(modelName, options) {
203
+ const schema = options.schema;
189
204
  if (!schema) {
190
205
  throw new BetterAuthError(
191
206
  "Drizzle adapter failed to initialize. Schema not found. Please provide a schema object in the adapter options object."
192
207
  );
193
208
  }
194
- return schema[modelName];
209
+ const model = options.usePlural ? `${modelName}s` : modelName;
210
+ const schemaModel = schema[model];
211
+ if (!schemaModel) {
212
+ throw new BetterAuthError(
213
+ `[# Drizzle Adapter]: The model "${modelName}" was not found in the schema object. Please pass the schema directly to the adapter options.`
214
+ );
215
+ }
216
+ return schemaModel;
195
217
  }
196
218
  function whereConvertor(where, schemaModel) {
197
219
  if (!where) return [];
@@ -226,13 +248,19 @@ var drizzleAdapter = (db, options) => {
226
248
  id: "drizzle",
227
249
  async create(data) {
228
250
  const { model, data: val } = data;
229
- const schemaModel = getSchema(model, schema);
251
+ const schemaModel = getSchema(model, {
252
+ schema,
253
+ usePlural: options.usePlural
254
+ });
230
255
  const res = await db.insert(schemaModel).values(val).returning();
231
256
  return res[0];
232
257
  },
233
258
  async findOne(data) {
234
259
  const { model, where, select: included } = data;
235
- const schemaModel = getSchema(model, schema);
260
+ const schemaModel = getSchema(model, {
261
+ schema,
262
+ usePlural: options.usePlural
263
+ });
236
264
  const wheres = whereConvertor(where, schemaModel);
237
265
  let res = null;
238
266
  if (!!included?.length) {
@@ -251,23 +279,33 @@ var drizzleAdapter = (db, options) => {
251
279
  },
252
280
  async findMany(data) {
253
281
  const { model, where } = data;
254
- const schemaModel = getSchema(model, schema);
282
+ const schemaModel = getSchema(model, {
283
+ schema,
284
+ usePlural: options.usePlural
285
+ });
255
286
  const wheres = where ? whereConvertor(where, schemaModel) : [];
256
287
  if (!wheres.length) {
257
288
  return await db.select().from(schemaModel);
258
289
  }
259
- return await db.select().from(schemaModel).where(...wheres);
290
+ const res = await db.select().from(schemaModel).where(...wheres);
291
+ return res;
260
292
  },
261
293
  async update(data) {
262
294
  const { model, where, update } = data;
263
- const schemaModel = getSchema(model, schema);
295
+ const schemaModel = getSchema(model, {
296
+ schema,
297
+ usePlural: options.usePlural
298
+ });
264
299
  const wheres = whereConvertor(where, schemaModel);
265
300
  const res = await db.update(schemaModel).set(update).where(...wheres).returning();
266
301
  return res[0];
267
302
  },
268
303
  async delete(data) {
269
304
  const { model, where } = data;
270
- const schemaModel = getSchema(model, schema);
305
+ const schemaModel = getSchema(model, {
306
+ schema,
307
+ usePlural: options.usePlural
308
+ });
271
309
  const wheres = whereConvertor(where, schemaModel);
272
310
  const res = await db.delete(schemaModel).where(...wheres);
273
311
  return res[0];
@@ -1,9 +1,9 @@
1
- import { W as Where } from '../index-CVYpdIik.js';
1
+ import { W as Where } from '../index-CKn-Zrry.js';
2
2
  import 'kysely';
3
- import '../index-XxjbEPqj.js';
3
+ import '../index-JM-i6hLs.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
- import '../helper-D-PIAORk.js';
6
+ import '../helper-DPDj8Nix.js';
7
7
  import 'better-call';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
@@ -1,9 +1,9 @@
1
- import { A as Adapter } from '../index-CVYpdIik.js';
1
+ import { A as Adapter } from '../index-CKn-Zrry.js';
2
2
  import 'kysely';
3
- import '../index-XxjbEPqj.js';
3
+ import '../index-JM-i6hLs.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
- import '../helper-D-PIAORk.js';
6
+ import '../helper-DPDj8Nix.js';
7
7
  import 'better-call';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
package/dist/api.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { b as AuthEndpoint, d as AuthMiddleware, y as callbackOAuth, X as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, Q as createEmailVerificationToken, a1 as csrfMiddleware, _ as error, M as forgetPassword, N as forgetPasswordCallback, Z as getCSRFToken, u as getEndpoints, z as getSession, C as getSessionFromCtx, E as listSessions, $ as ok, o as optionsMiddleware, O as resetPassword, J as revokeSession, K as revokeSessions, v as router, T as sendVerificationEmail, D as sessionMiddleware, Y as setPassword, x as signInEmail, w as signInOAuth, L as signOut, a0 as signUpEmail, V as updateUser, U as verifyEmail } from './index-CVYpdIik.js';
1
+ export { b as AuthEndpoint, d as AuthMiddleware, y as callbackOAuth, X as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, Q as createEmailVerificationToken, a2 as csrfMiddleware, Z as deleteUser, $ as error, M as forgetPassword, N as forgetPasswordCallback, _ as getCSRFToken, u as getEndpoints, z as getSession, C as getSessionFromCtx, E as listSessions, a0 as ok, o as optionsMiddleware, O as resetPassword, J as revokeSession, K as revokeSessions, v as router, T as sendVerificationEmail, D as sessionMiddleware, Y as setPassword, x as signInEmail, w as signInOAuth, L as signOut, a1 as signUpEmail, V as updateUser, U as verifyEmail } from './index-CKn-Zrry.js';
2
2
  import 'zod';
3
- import './helper-D-PIAORk.js';
3
+ import './helper-DPDj8Nix.js';
4
4
  import 'better-call';
5
5
  import 'kysely';
6
- import './index-XxjbEPqj.js';
6
+ import './index-JM-i6hLs.js';
7
7
  import 'arctic';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
package/dist/api.js CHANGED
@@ -8,9 +8,9 @@ import { generateCodeVerifier, generateState as generateState$1 } from 'oslo/oau
8
8
  import { Facebook, GitHub, Google, Spotify, Twitch, Twitter, OAuth2Tokens } from 'arctic';
9
9
  import { createJWT, validateJWT, parseJWT } from 'oslo/jwt';
10
10
  import { betterFetch } from '@better-fetch/fetch';
11
- import { createConsola } from 'consola';
12
11
  import { TimeSpan } from 'oslo';
13
12
  import { nanoid } from 'nanoid';
13
+ import { createConsola } from 'consola';
14
14
  import chalk from 'chalk';
15
15
 
16
16
  // src/api/index.ts
@@ -90,17 +90,6 @@ var csrfMiddleware = createAuthMiddleware(
90
90
  }
91
91
  );
92
92
 
93
- // src/error/better-auth-error.ts
94
- var BetterAuthError = class extends Error {
95
- constructor(message, cause, docsLink) {
96
- super(message);
97
- this.name = "BetterAuthError";
98
- this.message = message;
99
- this.cause = cause;
100
- this.stack = "";
101
- }
102
- };
103
-
104
93
  // src/utils/base-url.ts
105
94
  function checkHasPath(url) {
106
95
  try {
@@ -131,6 +120,142 @@ function getBaseURL(url, path) {
131
120
  }
132
121
  return void 0;
133
122
  }
123
+ async function setSessionCookie(ctx, sessionToken, dontRememberMe, overrides) {
124
+ const options = ctx.context.authCookies.sessionToken.options;
125
+ options.maxAge = dontRememberMe ? void 0 : options.maxAge;
126
+ await ctx.setSignedCookie(
127
+ ctx.context.authCookies.sessionToken.name,
128
+ sessionToken,
129
+ ctx.context.secret,
130
+ options
131
+ );
132
+ if (dontRememberMe) {
133
+ await ctx.setSignedCookie(
134
+ ctx.context.authCookies.dontRememberToken.name,
135
+ "true",
136
+ ctx.context.secret,
137
+ ctx.context.authCookies.dontRememberToken.options
138
+ );
139
+ }
140
+ }
141
+ function deleteSessionCookie(ctx) {
142
+ ctx.setCookie(ctx.context.authCookies.sessionToken.name, "", {
143
+ maxAge: 0
144
+ });
145
+ ctx.setCookie(ctx.context.authCookies.dontRememberToken.name, "", {
146
+ maxAge: 0
147
+ });
148
+ }
149
+
150
+ // src/utils/date.ts
151
+ var getDate = (span, unit = "ms") => {
152
+ const date = /* @__PURE__ */ new Date();
153
+ return new Date(date.getTime() + (unit === "sec" ? span * 1e3 : span));
154
+ };
155
+
156
+ // src/utils/get-request-ip.ts
157
+ function getIp(req) {
158
+ const testIP = "127.0.0.1";
159
+ if (process.env.NODE_ENV === "test") {
160
+ return testIP;
161
+ }
162
+ const headers = [
163
+ "x-client-ip",
164
+ "x-forwarded-for",
165
+ "cf-connecting-ip",
166
+ "fastly-client-ip",
167
+ "x-real-ip",
168
+ "x-cluster-client-ip",
169
+ "x-forwarded",
170
+ "forwarded-for",
171
+ "forwarded"
172
+ ];
173
+ for (const header of headers) {
174
+ const value = req.headers.get(header);
175
+ if (typeof value === "string") {
176
+ const ip = value.split(",")[0].trim();
177
+ if (ip) return ip;
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+
183
+ // src/utils/hide-metadata.ts
184
+ var HIDE_METADATA = {
185
+ isAction: false
186
+ };
187
+ var generateId = (size) => {
188
+ return nanoid(size);
189
+ };
190
+ var consola = createConsola({
191
+ formatOptions: {
192
+ date: false,
193
+ colors: true,
194
+ compact: true
195
+ },
196
+ defaults: {
197
+ tag: "Better Auth"
198
+ }
199
+ });
200
+ var createLogger = (options) => {
201
+ return {
202
+ log: (...args) => {
203
+ consola.log("", ...args);
204
+ },
205
+ error: (...args) => {
206
+ consola.error("", ...args);
207
+ },
208
+ warn: (...args) => {
209
+ consola.warn("", ...args);
210
+ },
211
+ info: (...args) => {
212
+ consola.info("", ...args);
213
+ },
214
+ debug: (...args) => {
215
+ consola.debug("", ...args);
216
+ },
217
+ box: (...args) => {
218
+ consola.box("", ...args);
219
+ },
220
+ success: (...args) => {
221
+ consola.success("", ...args);
222
+ },
223
+ break: (...args) => {
224
+ console.log("\n");
225
+ }
226
+ };
227
+ };
228
+ var logger = createLogger();
229
+ function generateState(callbackURL, currentURL, dontRememberMe) {
230
+ const code = generateState$1();
231
+ const state = JSON.stringify({
232
+ code,
233
+ callbackURL,
234
+ currentURL,
235
+ dontRememberMe
236
+ });
237
+ return { state, code };
238
+ }
239
+ function parseState(state) {
240
+ const data = z.object({
241
+ code: z.string(),
242
+ callbackURL: z.string().optional(),
243
+ currentURL: z.string().optional(),
244
+ dontRememberMe: z.boolean().optional()
245
+ }).safeParse(JSON.parse(state));
246
+ return data;
247
+ }
248
+
249
+ // src/error/better-auth-error.ts
250
+ var BetterAuthError = class extends Error {
251
+ constructor(message, cause) {
252
+ super(message);
253
+ this.name = "BetterAuthError";
254
+ this.message = message;
255
+ this.cause = cause;
256
+ this.stack = "";
257
+ }
258
+ };
134
259
  function getRedirectURI(providerId, redirectURI) {
135
260
  return redirectURI || `${getBaseURL()}/callback/${providerId}`;
136
261
  }
@@ -364,47 +489,6 @@ var github = ({
364
489
  }
365
490
  };
366
491
  };
367
- var consola = createConsola({
368
- formatOptions: {
369
- date: false,
370
- colors: true,
371
- compact: true
372
- },
373
- defaults: {
374
- tag: "Better Auth"
375
- }
376
- });
377
- var createLogger = (options) => {
378
- return {
379
- log: (...args) => {
380
- consola.log("", ...args);
381
- },
382
- error: (...args) => {
383
- consola.error("", ...args);
384
- },
385
- warn: (...args) => {
386
- consola.warn("", ...args);
387
- },
388
- info: (...args) => {
389
- consola.info("", ...args);
390
- },
391
- debug: (...args) => {
392
- consola.debug("", ...args);
393
- },
394
- box: (...args) => {
395
- consola.box("", ...args);
396
- },
397
- success: (...args) => {
398
- consola.success("", ...args);
399
- },
400
- break: (...args) => {
401
- console.log("\n");
402
- }
403
- };
404
- };
405
- var logger = createLogger();
406
-
407
- // src/social-providers/google.ts
408
492
  var google = (options) => {
409
493
  const googleArctic = new Google(
410
494
  options.clientId,
@@ -622,86 +706,6 @@ var oAuthProviders = {
622
706
  twitter
623
707
  };
624
708
  var oAuthProviderList = Object.keys(oAuthProviders);
625
- function generateState(callbackURL, currentURL, dontRememberMe) {
626
- const code = generateState$1();
627
- const state = JSON.stringify({
628
- code,
629
- callbackURL,
630
- currentURL,
631
- dontRememberMe
632
- });
633
- return { state, code };
634
- }
635
- function parseState(state) {
636
- const data = z.object({
637
- code: z.string(),
638
- callbackURL: z.string().optional(),
639
- currentURL: z.string().optional(),
640
- dontRememberMe: z.boolean().optional()
641
- }).safeParse(JSON.parse(state));
642
- return data;
643
- }
644
-
645
- // src/utils/date.ts
646
- var getDate = (span, unit = "ms") => {
647
- const date = /* @__PURE__ */ new Date();
648
- return new Date(date.getTime() + (unit === "sec" ? span * 1e3 : span));
649
- };
650
- async function setSessionCookie(ctx, sessionToken, dontRememberMe, overrides) {
651
- const options = ctx.context.authCookies.sessionToken.options;
652
- options.maxAge = dontRememberMe ? void 0 : options.maxAge;
653
- await ctx.setSignedCookie(
654
- ctx.context.authCookies.sessionToken.name,
655
- sessionToken,
656
- ctx.context.secret,
657
- options
658
- );
659
- if (dontRememberMe) {
660
- await ctx.setSignedCookie(
661
- ctx.context.authCookies.dontRememberToken.name,
662
- "true",
663
- ctx.context.secret,
664
- ctx.context.authCookies.dontRememberToken.options
665
- );
666
- }
667
- }
668
- function deleteSessionCookie(ctx) {
669
- ctx.setCookie(ctx.context.authCookies.sessionToken.name, "", {
670
- maxAge: 0
671
- });
672
- ctx.setCookie(ctx.context.authCookies.dontRememberToken.name, "", {
673
- maxAge: 0
674
- });
675
- }
676
-
677
- // src/utils/get-request-ip.ts
678
- function getIp(req) {
679
- const testIP = "127.0.0.1";
680
- if (process.env.NODE_ENV === "test") {
681
- return testIP;
682
- }
683
- const headers = [
684
- "x-client-ip",
685
- "x-forwarded-for",
686
- "cf-connecting-ip",
687
- "fastly-client-ip",
688
- "x-real-ip",
689
- "x-cluster-client-ip",
690
- "x-forwarded",
691
- "forwarded-for",
692
- "forwarded"
693
- ];
694
- for (const header of headers) {
695
- const value = req.headers.get(header);
696
- if (typeof value === "string") {
697
- const ip = value.split(",")[0].trim();
698
- if (ip) return ip;
699
- }
700
- }
701
- return null;
702
- }
703
-
704
- // src/api/routes/session.ts
705
709
  function getRequestUniqueKey(ctx, token) {
706
710
  if (!ctx.request) {
707
711
  return "";
@@ -1088,14 +1092,6 @@ z.object({
1088
1092
  expiresAt: z.date(),
1089
1093
  identifier: z.string()
1090
1094
  });
1091
- var generateId = (size) => {
1092
- return nanoid(size);
1093
- };
1094
-
1095
- // src/utils/hide-metadata.ts
1096
- var HIDE_METADATA = {
1097
- isAction: false
1098
- };
1099
1095
 
1100
1096
  // src/utils/getAccount.ts
1101
1097
  function getAccountTokens(tokens) {
@@ -1860,6 +1856,45 @@ var setPassword = createAuthEndpoint(
1860
1856
  });
1861
1857
  }
1862
1858
  );
1859
+ var deleteUser = createAuthEndpoint(
1860
+ "/user/delete",
1861
+ {
1862
+ method: "POST",
1863
+ body: z.object({
1864
+ password: z.string()
1865
+ }),
1866
+ use: [sessionMiddleware]
1867
+ },
1868
+ async (ctx) => {
1869
+ const { password } = ctx.body;
1870
+ const session = ctx.context.session;
1871
+ const accounts = await ctx.context.internalAdapter.findAccounts(
1872
+ session.user.id
1873
+ );
1874
+ const account = accounts.find(
1875
+ (account2) => account2.providerId === "credential" && account2.password
1876
+ );
1877
+ if (!account || !account.password) {
1878
+ return ctx.json(null, {
1879
+ status: 400,
1880
+ body: { message: "User does not have a password" }
1881
+ });
1882
+ }
1883
+ const verify = await ctx.context.password.verify(
1884
+ account.password,
1885
+ password
1886
+ );
1887
+ if (!verify) {
1888
+ return ctx.json(null, {
1889
+ status: 400,
1890
+ body: { message: "Invalid password" }
1891
+ });
1892
+ }
1893
+ await ctx.context.internalAdapter.deleteUser(session.user.id);
1894
+ await ctx.context.internalAdapter.deleteSessions(session.user.id);
1895
+ return ctx.json(null);
1896
+ }
1897
+ );
1863
1898
 
1864
1899
  // src/api/routes/csrf.ts
1865
1900
  var getCSRFToken = createAuthEndpoint(
@@ -2335,6 +2370,7 @@ function getEndpoints(ctx, options) {
2335
2370
  changePassword,
2336
2371
  setPassword,
2337
2372
  updateUser,
2373
+ deleteUser,
2338
2374
  forgetPasswordCallback,
2339
2375
  listSessions: listSessions(),
2340
2376
  revokeSession,
@@ -2469,4 +2505,4 @@ var router = (ctx, options) => {
2469
2505
  });
2470
2506
  };
2471
2507
 
2472
- export { callbackOAuth, changePassword, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, csrfMiddleware, error, forgetPassword, forgetPasswordCallback, getCSRFToken, getEndpoints, getSession, getSessionFromCtx, listSessions, ok, optionsMiddleware, resetPassword, revokeSession, revokeSessions, router, sendVerificationEmail, sessionMiddleware, setPassword, signInEmail, signInOAuth, signOut, signUpEmail, updateUser, verifyEmail };
2508
+ export { callbackOAuth, changePassword, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, csrfMiddleware, deleteUser, error, forgetPassword, forgetPasswordCallback, getCSRFToken, getEndpoints, getSession, getSessionFromCtx, listSessions, ok, optionsMiddleware, resetPassword, revokeSession, revokeSessions, router, sendVerificationEmail, sessionMiddleware, setPassword, signInEmail, signInOAuth, signOut, signUpEmail, updateUser, verifyEmail };
package/dist/cli.js CHANGED
@@ -12,11 +12,11 @@ import { SqliteDialect, MysqlDialect, PostgresDialect, Kysely } from 'kysely';
12
12
  import ora2 from 'ora';
13
13
  import chalk from 'chalk';
14
14
  import prompts3 from 'prompts';
15
- import '@antfu/ni';
16
- import 'execa';
17
15
  import 'oslo';
18
16
  import 'nanoid';
19
17
  import 'oslo/oauth2';
18
+ import '@antfu/ni';
19
+ import 'execa';
20
20
  import fs from 'fs/promises';
21
21
 
22
22
  var consola = createConsola({
@@ -530,7 +530,7 @@ async function getMigrations(config) {
530
530
 
531
531
  // src/error/better-auth-error.ts
532
532
  var BetterAuthError = class extends Error {
533
- constructor(message, cause, docsLink) {
533
+ constructor(message, cause) {
534
534
  super(message);
535
535
  this.name = "BetterAuthError";
536
536
  this.message = message;
@@ -1,15 +1,15 @@
1
1
  import * as nanostores from 'nanostores';
2
- import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-BYDTZ_xW.js';
2
+ import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.js';
3
3
  import * as _better_fetch_fetch from '@better-fetch/fetch';
4
4
  import { BetterFetchOption } from '@better-fetch/fetch';
5
- import { o as organization, e as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber } from '../index-CVIZ94nq.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-CVIZ94nq.js';
7
- import { P as Prettify } from '../helper-D-PIAORk.js';
8
- import '../index-XxjbEPqj.js';
5
+ import { o as organization, e as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber } from '../index-DtRHPoYF.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DtRHPoYF.js';
7
+ import { P as Prettify } from '../helper-DPDj8Nix.js';
8
+ import '../index-JM-i6hLs.js';
9
9
  import 'arctic';
10
10
  import 'zod';
11
11
  import 'better-call';
12
- import '../index-CVYpdIik.js';
12
+ import '../index-CKn-Zrry.js';
13
13
  import 'kysely';
14
14
  import 'better-sqlite3';
15
15
  import 'mysql2';
@@ -1,7 +1,11 @@
1
1
  import { atom, onMount } from 'nanostores';
2
2
  import '@better-fetch/fetch';
3
- import { startAuthentication, startRegistration, WebAuthnError } from '@simplewebauthn/browser';
3
+ import 'oslo';
4
+ import 'nanoid';
4
5
  import { createConsola } from 'consola';
6
+ import 'oslo/oauth2';
7
+ import 'zod';
8
+ import { startAuthentication, startRegistration, WebAuthnError } from '@simplewebauthn/browser';
5
9
 
6
10
  // src/plugins/organization/client.ts
7
11
 
@@ -107,6 +111,16 @@ defaultAc.newRole({
107
111
  member: [],
108
112
  invitation: []
109
113
  });
114
+ createConsola({
115
+ formatOptions: {
116
+ date: false,
117
+ colors: true,
118
+ compact: true
119
+ },
120
+ defaults: {
121
+ tag: "Better Auth"
122
+ }
123
+ });
110
124
  var useAuthQuery = (initializedAtom, path, $fetch, options) => {
111
125
  const value = atom({
112
126
  data: null,
@@ -251,16 +265,6 @@ var usernameClient = () => {
251
265
  $InferServerPlugin: {}
252
266
  };
253
267
  };
254
- createConsola({
255
- formatOptions: {
256
- date: false,
257
- colors: true,
258
- compact: true
259
- },
260
- defaults: {
261
- tag: "Better Auth"
262
- }
263
- });
264
268
  var getPasskeyActions = ($fetch, {
265
269
  _listPasskeys
266
270
  }) => {
package/dist/client.d.ts CHANGED
@@ -3,12 +3,12 @@ import * as nanostores from 'nanostores';
3
3
  import { PreinitializedWritableAtom } from 'nanostores';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/fetch';
6
- import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-D-PIAORk.js';
6
+ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
7
7
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
8
8
  export { AtomListener, InferPluginsFromClient } from './types.js';
9
- import './index-CVYpdIik.js';
9
+ import './index-CKn-Zrry.js';
10
10
  import 'kysely';
11
- import './index-XxjbEPqj.js';
11
+ import './index-JM-i6hLs.js';
12
12
  import 'arctic';
13
13
  import 'better-call';
14
14
  import 'better-sqlite3';