better-auth 0.2.6-beta.8 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access.js +2 -13
- package/dist/adapters/drizzle.d.ts +4 -2
- package/dist/adapters/drizzle.js +12 -12
- package/dist/adapters/mongodb.d.ts +3 -1
- package/dist/adapters/mongodb.js +2 -3
- package/dist/adapters/prisma.d.ts +3 -1
- package/dist/adapters/prisma.js +13 -53
- package/dist/api.d.ts +3 -1
- package/dist/api.js +145 -284
- package/dist/cli.js +90 -213
- package/dist/client/plugins.d.ts +5 -3
- package/dist/client/plugins.js +15 -73
- package/dist/client.d.ts +3 -1
- package/dist/client.js +6 -19
- package/dist/{index-JNEXCszr.d.ts → index-Cc76Cf2k.d.ts} +1 -1
- package/dist/{index-CpAh0Hjg.d.ts → index-Ckd9h_O2.d.ts} +9 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +180 -375
- package/dist/next-js.d.ts +3 -1
- package/dist/next-js.js +5 -6
- package/dist/node.d.ts +3 -1
- package/dist/node.js +5 -5
- package/dist/plugins.d.ts +5 -3
- package/dist/plugins.js +303 -520
- package/dist/react.d.ts +3 -1
- package/dist/react.js +8 -25
- package/dist/social.js +23 -73
- package/dist/solid-start.d.ts +3 -1
- package/dist/solid-start.js +2 -3
- package/dist/solid.d.ts +3 -1
- package/dist/solid.js +7 -21
- package/dist/svelte-kit.d.ts +3 -1
- package/dist/svelte-kit.js +4 -6
- package/dist/svelte.d.ts +3 -1
- package/dist/svelte.js +6 -18
- package/dist/types.d.ts +4 -2
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +4 -2
- package/dist/utils.js +9 -36
- package/dist/vue.d.ts +3 -1
- package/dist/vue.js +7 -21
- package/package.json +2 -2
package/dist/access.js
CHANGED
|
@@ -110,16 +110,5 @@ var defaultRoles = {
|
|
|
110
110
|
var permissionFromString = (permission) => {
|
|
111
111
|
return Role.fromString(permission ?? "");
|
|
112
112
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
ParsingError,
|
|
116
|
-
Role,
|
|
117
|
-
adminAc,
|
|
118
|
-
createAccessControl,
|
|
119
|
-
defaultAc,
|
|
120
|
-
defaultRoles,
|
|
121
|
-
defaultStatements,
|
|
122
|
-
memberAc,
|
|
123
|
-
ownerAc,
|
|
124
|
-
permissionFromString
|
|
125
|
-
};
|
|
113
|
+
|
|
114
|
+
export { AccessControl, ParsingError, Role, adminAc, createAccessControl, defaultAc, defaultRoles, defaultStatements, memberAc, ownerAc, permissionFromString };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { A as Adapter } from '../index-
|
|
1
|
+
import { A as Adapter } from '../index-Ckd9h_O2.js';
|
|
2
2
|
import 'kysely';
|
|
3
3
|
import '../index-37csVPVw.js';
|
|
4
4
|
import 'arctic';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../helper-D-PIAORk.js';
|
|
7
7
|
import 'better-call';
|
|
8
|
+
import 'better-sqlite3';
|
|
9
|
+
import 'mysql2';
|
|
8
10
|
|
|
9
11
|
interface DrizzleAdapterOptions {
|
|
10
|
-
schema
|
|
12
|
+
schema?: Record<string, any>;
|
|
11
13
|
provider: "pg" | "mysql" | "sqlite";
|
|
12
14
|
}
|
|
13
15
|
interface DB {
|
package/dist/adapters/drizzle.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { eq, and, or } from 'drizzle-orm';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
|
|
1
5
|
// src/adapters/drizzle-adapter/index.ts
|
|
2
|
-
import { and, eq, or } from "drizzle-orm";
|
|
3
6
|
|
|
4
7
|
// src/db/get-tables.ts
|
|
5
8
|
var getAuthTables = (options) => {
|
|
@@ -151,10 +154,6 @@ var getAuthTables = (options) => {
|
|
|
151
154
|
};
|
|
152
155
|
};
|
|
153
156
|
|
|
154
|
-
// src/adapters/drizzle-adapter/index.ts
|
|
155
|
-
import { existsSync } from "fs";
|
|
156
|
-
import fs from "fs/promises";
|
|
157
|
-
|
|
158
157
|
// src/error/better-auth-error.ts
|
|
159
158
|
var BetterAuthError = class extends Error {
|
|
160
159
|
constructor(message, cause, docsLink) {
|
|
@@ -202,7 +201,7 @@ function whereConvertor(where, schemaModel) {
|
|
|
202
201
|
return clause;
|
|
203
202
|
}
|
|
204
203
|
var drizzleAdapter = (db, options) => {
|
|
205
|
-
const schema = options.schema;
|
|
204
|
+
const schema = options.schema || db._.fullSchema;
|
|
206
205
|
const databaseType = options?.provider;
|
|
207
206
|
return {
|
|
208
207
|
id: "drizzle",
|
|
@@ -235,7 +234,10 @@ var drizzleAdapter = (db, options) => {
|
|
|
235
234
|
const { model, where } = data;
|
|
236
235
|
const schemaModel = getSchema(model, schema);
|
|
237
236
|
const wheres = where ? whereConvertor(where, schemaModel) : [];
|
|
238
|
-
|
|
237
|
+
if (!wheres.length) {
|
|
238
|
+
return await db.select().from(schemaModel);
|
|
239
|
+
}
|
|
240
|
+
return await db.select().from(schemaModel).where(...wheres);
|
|
239
241
|
},
|
|
240
242
|
async update(data) {
|
|
241
243
|
const { model, where, update } = data;
|
|
@@ -259,7 +261,7 @@ var drizzleAdapter = (db, options) => {
|
|
|
259
261
|
let code = `import { ${databaseType}Table, text, ${int}, ${timestampAndBoolean} } from "drizzle-orm/${databaseType}-core";
|
|
260
262
|
`;
|
|
261
263
|
const fileExist = existsSync(filePath);
|
|
262
|
-
|
|
264
|
+
fileExist ? await fs.readFile(filePath, "utf-8") : "";
|
|
263
265
|
for (const table in tables) {
|
|
264
266
|
let getType2 = function(name, type) {
|
|
265
267
|
if (type === "string") {
|
|
@@ -285,7 +287,6 @@ var drizzleAdapter = (db, options) => {
|
|
|
285
287
|
return `timestamp('${name}')`;
|
|
286
288
|
}
|
|
287
289
|
};
|
|
288
|
-
var getType = getType2;
|
|
289
290
|
const tableName = tables[table].tableName;
|
|
290
291
|
const fields = tables[table].fields;
|
|
291
292
|
const schema2 = `export const ${table} = ${databaseType}Table("${tableName}", {
|
|
@@ -307,6 +308,5 @@ ${schema2}
|
|
|
307
308
|
}
|
|
308
309
|
};
|
|
309
310
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
};
|
|
311
|
+
|
|
312
|
+
export { drizzleAdapter };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { W as Where } from '../index-
|
|
1
|
+
import { W as Where } from '../index-Ckd9h_O2.js';
|
|
2
2
|
import 'kysely';
|
|
3
3
|
import '../index-37csVPVw.js';
|
|
4
4
|
import 'arctic';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../helper-D-PIAORk.js';
|
|
7
7
|
import 'better-call';
|
|
8
|
+
import 'better-sqlite3';
|
|
9
|
+
import 'mysql2';
|
|
8
10
|
|
|
9
11
|
declare const mongodbAdapter: (mongo: any) => {
|
|
10
12
|
id: string;
|
package/dist/adapters/mongodb.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { A as Adapter } from '../index-
|
|
1
|
+
import { A as Adapter } from '../index-Ckd9h_O2.js';
|
|
2
2
|
import 'kysely';
|
|
3
3
|
import '../index-37csVPVw.js';
|
|
4
4
|
import 'arctic';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../helper-D-PIAORk.js';
|
|
7
7
|
import 'better-call';
|
|
8
|
+
import 'better-sqlite3';
|
|
9
|
+
import 'mysql2';
|
|
8
10
|
|
|
9
11
|
declare const prismaAdapter: (prisma: any, { provider, }: {
|
|
10
12
|
provider: "sqlite" | "cockroachdb" | "mysql" | "postgresql" | "sqlserver";
|
package/dist/adapters/prisma.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import { produceSchema } from '@mrleebo/prisma-ast';
|
|
5
|
+
import 'oslo';
|
|
6
|
+
import 'oslo/crypto';
|
|
7
|
+
import { createConsola } from 'consola';
|
|
8
|
+
import 'oslo/oauth2';
|
|
9
|
+
import 'zod';
|
|
10
|
+
|
|
1
11
|
// src/adapters/prisma-adapter/index.ts
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import path from "path";
|
|
4
12
|
|
|
5
13
|
// src/db/get-tables.ts
|
|
6
14
|
var getAuthTables = (options) => {
|
|
@@ -151,20 +159,7 @@ var getAuthTables = (options) => {
|
|
|
151
159
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
152
160
|
};
|
|
153
161
|
};
|
|
154
|
-
|
|
155
|
-
// src/adapters/prisma-adapter/index.ts
|
|
156
|
-
import fs from "fs/promises";
|
|
157
|
-
import { produceSchema } from "@mrleebo/prisma-ast";
|
|
158
|
-
|
|
159
|
-
// src/utils/cookies.ts
|
|
160
|
-
import { TimeSpan } from "oslo";
|
|
161
|
-
|
|
162
|
-
// src/utils/id.ts
|
|
163
|
-
import { alphabet, generateRandomString } from "oslo/crypto";
|
|
164
|
-
|
|
165
|
-
// src/utils/logger.ts
|
|
166
|
-
import { createConsola } from "consola";
|
|
167
|
-
var consola = createConsola({
|
|
162
|
+
createConsola({
|
|
168
163
|
formatOptions: {
|
|
169
164
|
date: false,
|
|
170
165
|
colors: true,
|
|
@@ -174,45 +169,12 @@ var consola = createConsola({
|
|
|
174
169
|
tag: "Better Auth"
|
|
175
170
|
}
|
|
176
171
|
});
|
|
177
|
-
var createLogger = (options) => {
|
|
178
|
-
return {
|
|
179
|
-
log: (...args) => {
|
|
180
|
-
!options?.disabled && consola.log("", ...args);
|
|
181
|
-
},
|
|
182
|
-
error: (...args) => {
|
|
183
|
-
!options?.disabled && consola.error("", ...args);
|
|
184
|
-
},
|
|
185
|
-
warn: (...args) => {
|
|
186
|
-
!options?.disabled && consola.warn("", ...args);
|
|
187
|
-
},
|
|
188
|
-
info: (...args) => {
|
|
189
|
-
!options?.disabled && consola.info("", ...args);
|
|
190
|
-
},
|
|
191
|
-
debug: (...args) => {
|
|
192
|
-
!options?.disabled && consola.debug("", ...args);
|
|
193
|
-
},
|
|
194
|
-
box: (...args) => {
|
|
195
|
-
!options?.disabled && consola.box("", ...args);
|
|
196
|
-
},
|
|
197
|
-
success: (...args) => {
|
|
198
|
-
!options?.disabled && consola.success("", ...args);
|
|
199
|
-
},
|
|
200
|
-
break: (...args) => {
|
|
201
|
-
!options?.disabled && console.log("\n");
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
var logger = createLogger();
|
|
206
172
|
|
|
207
173
|
// src/utils/misc.ts
|
|
208
174
|
function capitalizeFirstLetter(str) {
|
|
209
175
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
210
176
|
}
|
|
211
177
|
|
|
212
|
-
// src/utils/state.ts
|
|
213
|
-
import { generateState as generateStateOAuth } from "oslo/oauth2";
|
|
214
|
-
import { z } from "zod";
|
|
215
|
-
|
|
216
178
|
// src/adapters/prisma-adapter/index.ts
|
|
217
179
|
function whereConvertor(where) {
|
|
218
180
|
if (!where) return {};
|
|
@@ -328,7 +290,6 @@ var prismaAdapter = (prisma, {
|
|
|
328
290
|
return isOptional ? "DateTime?" : "DateTime";
|
|
329
291
|
}
|
|
330
292
|
};
|
|
331
|
-
var getType = getType2;
|
|
332
293
|
const fields = tables[table].fields;
|
|
333
294
|
const originalTable = tables[table].tableName;
|
|
334
295
|
const tableName = capitalizeFirstLetter(originalTable);
|
|
@@ -384,6 +345,5 @@ datasource db {
|
|
|
384
345
|
provider = "${provider}"
|
|
385
346
|
url = ${provider === "sqlite" ? `"file:./dev.db"` : `env("DATABASE_URL")`}
|
|
386
347
|
}`;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
};
|
|
348
|
+
|
|
349
|
+
export { prismaAdapter };
|
package/dist/api.d.ts
CHANGED
|
@@ -1,7 +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-
|
|
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-Ckd9h_O2.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './helper-D-PIAORk.js';
|
|
4
4
|
import 'better-call';
|
|
5
5
|
import 'kysely';
|
|
6
6
|
import './index-37csVPVw.js';
|
|
7
7
|
import 'arctic';
|
|
8
|
+
import 'better-sqlite3';
|
|
9
|
+
import 'mysql2';
|