better-auth 0.3.4-beta.3 → 0.3.4-beta.5
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/adapters/drizzle.d.ts +2 -2
- package/dist/adapters/drizzle.js +8 -2
- package/dist/adapters/mongodb.d.ts +2 -2
- package/dist/adapters/prisma.d.ts +2 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.js +11 -31
- package/dist/client/plugins.d.ts +4 -4
- package/dist/client.d.ts +5 -5
- package/dist/client.js +1 -0
- package/dist/{index-C9daNPfT.d.ts → index-B1Z0XMic.d.ts} +680 -641
- package/dist/{index-CUhY6myj.d.ts → index-DY0drFY6.d.ts} +7 -7
- package/dist/{index-CT4RHCuS.d.ts → index-QaO4zgiz.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +61 -59
- package/dist/next-js.d.ts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/plugins.d.ts +4 -4
- package/dist/plugins.js +13 -33
- package/dist/react.d.ts +9 -9
- package/dist/react.js +1 -0
- package/dist/social.d.ts +1 -1
- package/dist/solid-start.d.ts +2 -2
- package/dist/solid.d.ts +7 -7
- package/dist/solid.js +1 -0
- package/dist/svelte-kit.d.ts +2 -2
- package/dist/svelte.d.ts +7 -7
- package/dist/svelte.js +1 -0
- package/dist/types.d.ts +19 -11
- package/dist/vue.d.ts +9 -9
- package/dist/vue.js +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as Adapter } from '../index-
|
|
1
|
+
import { A as Adapter } from '../index-B1Z0XMic.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'kysely';
|
|
4
|
-
import '../index-
|
|
4
|
+
import '../index-QaO4zgiz.js';
|
|
5
5
|
import 'arctic';
|
|
6
6
|
import '../helper-DPDj8Nix.js';
|
|
7
7
|
import 'better-call';
|
package/dist/adapters/drizzle.js
CHANGED
|
@@ -242,7 +242,10 @@ var drizzleAdapter = (db, options) => {
|
|
|
242
242
|
schema,
|
|
243
243
|
usePlural: options.usePlural
|
|
244
244
|
});
|
|
245
|
-
const
|
|
245
|
+
const mutation = db.insert(schemaModel).values(val);
|
|
246
|
+
if (databaseType !== "mysql") return (await mutation.returning())[0];
|
|
247
|
+
await mutation;
|
|
248
|
+
const res = await db.select().from(schemaModel).where(eq(schemaModel.id, data.data.id));
|
|
246
249
|
return res[0];
|
|
247
250
|
},
|
|
248
251
|
async findOne(data) {
|
|
@@ -287,7 +290,10 @@ var drizzleAdapter = (db, options) => {
|
|
|
287
290
|
usePlural: options.usePlural
|
|
288
291
|
});
|
|
289
292
|
const wheres = whereConvertor(where, schemaModel);
|
|
290
|
-
const
|
|
293
|
+
const mutation = db.update(schemaModel).set(update).where(...wheres);
|
|
294
|
+
if (databaseType !== "mysql") return (await mutation.returning())[0];
|
|
295
|
+
await mutation;
|
|
296
|
+
const res = await db.select().from(schemaModel).where(eq(schemaModel.id, data.update.id));
|
|
291
297
|
return res[0];
|
|
292
298
|
},
|
|
293
299
|
async delete(data) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Db } from 'mongodb';
|
|
2
|
-
import { W as Where } from '../index-
|
|
2
|
+
import { W as Where } from '../index-B1Z0XMic.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'kysely';
|
|
5
|
-
import '../index-
|
|
5
|
+
import '../index-QaO4zgiz.js';
|
|
6
6
|
import 'arctic';
|
|
7
7
|
import '../helper-DPDj8Nix.js';
|
|
8
8
|
import 'better-call';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as Adapter } from '../index-
|
|
1
|
+
import { A as Adapter } from '../index-B1Z0XMic.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'kysely';
|
|
4
|
-
import '../index-
|
|
4
|
+
import '../index-QaO4zgiz.js';
|
|
5
5
|
import 'arctic';
|
|
6
6
|
import '../helper-DPDj8Nix.js';
|
|
7
7
|
import 'better-call';
|
package/dist/api.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { f as AuthEndpoint, g as AuthMiddleware,
|
|
1
|
+
export { f as AuthEndpoint, g as AuthMiddleware, v as callbackOAuth, T as changePassword, e as createAuthEndpoint, d as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-B1Z0XMic.js';
|
|
2
2
|
import './helper-DPDj8Nix.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
export { APIError } from 'better-call';
|
|
5
5
|
import 'kysely';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-QaO4zgiz.js';
|
|
7
7
|
import 'arctic';
|
|
8
8
|
import 'better-sqlite3';
|
|
9
9
|
import 'mysql2';
|
package/dist/api.js
CHANGED
|
@@ -1218,21 +1218,6 @@ var verificationSchema = z5.object({
|
|
|
1218
1218
|
expiresAt: z5.date(),
|
|
1219
1219
|
identifier: z5.string()
|
|
1220
1220
|
});
|
|
1221
|
-
function getAllFields(options, table) {
|
|
1222
|
-
let schema = {
|
|
1223
|
-
...table === "user" ? options.user?.additionalFields : {},
|
|
1224
|
-
...table === "session" ? options.session?.additionalFields : {}
|
|
1225
|
-
};
|
|
1226
|
-
for (const plugin of options.plugins || []) {
|
|
1227
|
-
if (plugin.schema && plugin.schema[table]) {
|
|
1228
|
-
schema = {
|
|
1229
|
-
...schema,
|
|
1230
|
-
...plugin.schema[table].fields
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
return schema;
|
|
1235
|
-
}
|
|
1236
1221
|
function parseInputData(data, schema) {
|
|
1237
1222
|
const fields = schema.fields;
|
|
1238
1223
|
const parsedData = {};
|
|
@@ -1248,8 +1233,10 @@ function parseInputData(data, schema) {
|
|
|
1248
1233
|
}
|
|
1249
1234
|
return parsedData;
|
|
1250
1235
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const schema =
|
|
1236
|
+
function parseAdditionalUserInput(options, user) {
|
|
1237
|
+
const schema = {
|
|
1238
|
+
...options.user?.additionalFields
|
|
1239
|
+
};
|
|
1253
1240
|
return parseInputData(user || {}, { fields: schema });
|
|
1254
1241
|
}
|
|
1255
1242
|
|
|
@@ -2191,14 +2178,7 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2191
2178
|
query: z11.object({
|
|
2192
2179
|
currentURL: z11.string().optional()
|
|
2193
2180
|
}).optional(),
|
|
2194
|
-
body: z11.
|
|
2195
|
-
name: z11.string(),
|
|
2196
|
-
email: z11.string(),
|
|
2197
|
-
password: z11.string(),
|
|
2198
|
-
image: z11.string().optional(),
|
|
2199
|
-
callbackURL: z11.string().optional(),
|
|
2200
|
-
additionalFields: z11.record(z11.string(), z11.any()).optional()
|
|
2201
|
-
})
|
|
2181
|
+
body: z11.record(z11.string(), z11.any())
|
|
2202
2182
|
},
|
|
2203
2183
|
async (ctx) => {
|
|
2204
2184
|
if (!ctx.context.options.emailAndPassword?.enabled) {
|
|
@@ -2206,8 +2186,8 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2206
2186
|
message: "Email and password sign up is not enabled"
|
|
2207
2187
|
});
|
|
2208
2188
|
}
|
|
2209
|
-
const
|
|
2210
|
-
const additionalFields =
|
|
2189
|
+
const body = ctx.body;
|
|
2190
|
+
const { name, email, password, image, ...additionalFields } = body;
|
|
2211
2191
|
const isValidEmail = z11.string().email().safeParse(email);
|
|
2212
2192
|
if (!isValidEmail.success) {
|
|
2213
2193
|
throw new APIError9("BAD_REQUEST", {
|
|
@@ -2234,7 +2214,7 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2234
2214
|
message: "User already exists"
|
|
2235
2215
|
});
|
|
2236
2216
|
}
|
|
2237
|
-
const additionalData =
|
|
2217
|
+
const additionalData = parseAdditionalUserInput(
|
|
2238
2218
|
ctx.context.options,
|
|
2239
2219
|
additionalFields
|
|
2240
2220
|
);
|
|
@@ -2276,7 +2256,7 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2276
2256
|
ctx.context.secret,
|
|
2277
2257
|
createdUser.email
|
|
2278
2258
|
);
|
|
2279
|
-
const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${
|
|
2259
|
+
const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${body.callbackURL || ctx.query?.currentURL || "/"}`;
|
|
2280
2260
|
await ctx.context.options.emailAndPassword.sendVerificationEmail?.(
|
|
2281
2261
|
createdUser.email,
|
|
2282
2262
|
url,
|
|
@@ -2290,8 +2270,8 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2290
2270
|
error: null
|
|
2291
2271
|
},
|
|
2292
2272
|
{
|
|
2293
|
-
body:
|
|
2294
|
-
url:
|
|
2273
|
+
body: body.callbackURL ? {
|
|
2274
|
+
url: body.callbackURL,
|
|
2295
2275
|
redirect: true
|
|
2296
2276
|
} : {
|
|
2297
2277
|
user: createdUser,
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import * as nanostores from 'nanostores';
|
|
|
2
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, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-DY0drFY6.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DY0drFY6.js';
|
|
7
7
|
import { P as Prettify } from '../helper-DPDj8Nix.js';
|
|
8
|
-
import { F as FieldAttribute, B as BetterAuthOptions, c as BetterAuthPlugin } from '../index-
|
|
9
|
-
import '../index-
|
|
8
|
+
import { F as FieldAttribute, B as BetterAuthOptions, c as BetterAuthPlugin } from '../index-B1Z0XMic.js';
|
|
9
|
+
import '../index-QaO4zgiz.js';
|
|
10
10
|
import 'arctic';
|
|
11
11
|
import 'zod';
|
|
12
12
|
import 'better-call';
|
package/dist/client.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
|
|
|
6
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-
|
|
9
|
+
import './index-B1Z0XMic.js';
|
|
10
10
|
import 'kysely';
|
|
11
|
-
import './index-
|
|
11
|
+
import './index-QaO4zgiz.js';
|
|
12
12
|
import 'arctic';
|
|
13
13
|
import 'better-call';
|
|
14
14
|
import 'better-sqlite3';
|
|
@@ -28,14 +28,14 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
28
28
|
createdAt: Date;
|
|
29
29
|
updatedAt: Date;
|
|
30
30
|
image?: string | undefined;
|
|
31
|
-
} & UnionToIntersection<InferAdditionalFromClient<Option, "user">>>>;
|
|
31
|
+
} & UnionToIntersection<InferAdditionalFromClient<Option, "user", "output">>>>;
|
|
32
32
|
session: Prettify<StripEmptyObjects<{
|
|
33
33
|
id: string;
|
|
34
34
|
userId: string;
|
|
35
35
|
expiresAt: Date;
|
|
36
36
|
ipAddress?: string | undefined;
|
|
37
37
|
userAgent?: string | undefined;
|
|
38
|
-
} & UnionToIntersection<InferAdditionalFromClient<Option, "session">>>>;
|
|
38
|
+
} & UnionToIntersection<InferAdditionalFromClient<Option, "session", "output">>>>;
|
|
39
39
|
} | null;
|
|
40
40
|
error: null | _better_fetch_fetch.BetterFetchError;
|
|
41
41
|
isPending: boolean;
|
|
@@ -196,7 +196,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
196
196
|
authorization: "Bearer" | "Basic";
|
|
197
197
|
})) | undefined;
|
|
198
198
|
redirect?: RequestRedirect;
|
|
199
|
-
method
|
|
199
|
+
method: string;
|
|
200
200
|
cache?: RequestCache;
|
|
201
201
|
credentials: RequestCredentials;
|
|
202
202
|
integrity?: string;
|
package/dist/client.js
CHANGED
|
@@ -138,6 +138,7 @@ var getClientConfig = (options) => {
|
|
|
138
138
|
const $fetch = createFetch({
|
|
139
139
|
baseURL: getBaseURL(options?.fetchOptions?.baseURL || options?.baseURL),
|
|
140
140
|
credentials: "include",
|
|
141
|
+
method: "GET",
|
|
141
142
|
...options?.fetchOptions,
|
|
142
143
|
plugins: [
|
|
143
144
|
csrfPlugin,
|