better-auth 0.3.6 → 0.4.1
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 +1 -1
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +43 -54
- package/dist/client/plugins.d.ts +200 -8
- package/dist/client/plugins.js +9 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +0 -5
- package/dist/{index-Bh0h0nFa.d.ts → index-C6jmDLjB.d.ts} +25 -54
- package/dist/{index-DI8FMfhr.d.ts → index-DCBFTxDp.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +52 -66
- package/dist/next-js.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +43 -54
- package/dist/react.d.ts +1 -1
- package/dist/react.js +0 -5
- package/dist/social.js +6 -4
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/solid.js +0 -5
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +0 -5
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +0 -5
- package/package.json +3 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c 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-
|
|
1
|
+
export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c 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-C6jmDLjB.js';
|
|
2
2
|
import './helper-DPDj8Nix.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
export { APIError } from 'better-call';
|
package/dist/api.js
CHANGED
|
@@ -198,7 +198,7 @@ function generateCodeChallenge(codeVerifier) {
|
|
|
198
198
|
includePadding: false
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes) {
|
|
201
|
+
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes, disablePkce) {
|
|
202
202
|
const url = new URL(authorizationEndpoint);
|
|
203
203
|
url.searchParams.set("response_type", "code");
|
|
204
204
|
url.searchParams.set("client_id", options.clientId);
|
|
@@ -208,9 +208,11 @@ function createAuthorizationURL(id, options, authorizationEndpoint, state, codeV
|
|
|
208
208
|
"redirect_uri",
|
|
209
209
|
options.redirectURI || getRedirectURI(id)
|
|
210
210
|
);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
if (!disablePkce) {
|
|
212
|
+
const codeChallenge = generateCodeChallenge(codeVerifier);
|
|
213
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
214
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
215
|
+
}
|
|
214
216
|
return url;
|
|
215
217
|
}
|
|
216
218
|
|
|
@@ -778,14 +780,12 @@ var oAuthProviderList = Object.keys(oAuthProviders);
|
|
|
778
780
|
// src/utils/state.ts
|
|
779
781
|
import { generateState as generateStateOAuth } from "oslo/oauth2";
|
|
780
782
|
import { z as z2 } from "zod";
|
|
781
|
-
function generateState(callbackURL, currentURL
|
|
783
|
+
function generateState(callbackURL, currentURL) {
|
|
782
784
|
const code = generateStateOAuth();
|
|
783
785
|
const state = JSON.stringify({
|
|
784
786
|
code,
|
|
785
787
|
callbackURL,
|
|
786
|
-
currentURL
|
|
787
|
-
dontRememberMe,
|
|
788
|
-
additionalFields
|
|
788
|
+
currentURL
|
|
789
789
|
});
|
|
790
790
|
return { state, code };
|
|
791
791
|
}
|
|
@@ -793,9 +793,7 @@ function parseState(state) {
|
|
|
793
793
|
const data = z2.object({
|
|
794
794
|
code: z2.string(),
|
|
795
795
|
callbackURL: z2.string().optional(),
|
|
796
|
-
currentURL: z2.string().optional()
|
|
797
|
-
dontRememberMe: z2.boolean().optional(),
|
|
798
|
-
additionalFields: z2.record(z2.string()).optional()
|
|
796
|
+
currentURL: z2.string().optional()
|
|
799
797
|
}).safeParse(JSON.parse(state));
|
|
800
798
|
return data;
|
|
801
799
|
}
|
|
@@ -1020,11 +1018,7 @@ var signInOAuth = createAuthEndpoint(
|
|
|
1020
1018
|
/**
|
|
1021
1019
|
* OAuth2 provider to use`
|
|
1022
1020
|
*/
|
|
1023
|
-
provider: z4.enum(oAuthProviderList)
|
|
1024
|
-
/**
|
|
1025
|
-
* If this is true the session will only be valid for the current browser session
|
|
1026
|
-
*/
|
|
1027
|
-
dontRememberMe: z4.boolean().default(false).optional()
|
|
1021
|
+
provider: z4.enum(oAuthProviderList)
|
|
1028
1022
|
})
|
|
1029
1023
|
},
|
|
1030
1024
|
async (c) => {
|
|
@@ -1049,37 +1043,33 @@ var signInOAuth = createAuthEndpoint(
|
|
|
1049
1043
|
callbackURL || currentURL?.origin || c.context.baseURL,
|
|
1050
1044
|
c.query?.currentURL
|
|
1051
1045
|
);
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
};
|
|
1080
|
-
} catch (e) {
|
|
1081
|
-
throw new APIError3("INTERNAL_SERVER_ERROR");
|
|
1082
|
-
}
|
|
1046
|
+
await c.setSignedCookie(
|
|
1047
|
+
cookie.state.name,
|
|
1048
|
+
state.code,
|
|
1049
|
+
c.context.secret,
|
|
1050
|
+
cookie.state.options
|
|
1051
|
+
);
|
|
1052
|
+
const codeVerifier = generateCodeVerifier();
|
|
1053
|
+
await c.setSignedCookie(
|
|
1054
|
+
cookie.pkCodeVerifier.name,
|
|
1055
|
+
codeVerifier,
|
|
1056
|
+
c.context.secret,
|
|
1057
|
+
cookie.pkCodeVerifier.options
|
|
1058
|
+
);
|
|
1059
|
+
const url = provider.createAuthorizationURL({
|
|
1060
|
+
state: state.state,
|
|
1061
|
+
codeVerifier
|
|
1062
|
+
});
|
|
1063
|
+
url.searchParams.set(
|
|
1064
|
+
"redirect_uri",
|
|
1065
|
+
`${c.context.baseURL}/callback/${c.body.provider}`
|
|
1066
|
+
);
|
|
1067
|
+
return c.json({
|
|
1068
|
+
url: url.toString(),
|
|
1069
|
+
state: state.state,
|
|
1070
|
+
codeVerifier,
|
|
1071
|
+
redirect: true
|
|
1072
|
+
});
|
|
1083
1073
|
}
|
|
1084
1074
|
);
|
|
1085
1075
|
var signInEmail = createAuthEndpoint(
|
|
@@ -1373,14 +1363,14 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1373
1363
|
);
|
|
1374
1364
|
}
|
|
1375
1365
|
const {
|
|
1376
|
-
data: { callbackURL, currentURL,
|
|
1366
|
+
data: { callbackURL, currentURL, code: stateCode }
|
|
1377
1367
|
} = parsedState;
|
|
1378
|
-
const
|
|
1368
|
+
const storedState = await c.getSignedCookie(
|
|
1379
1369
|
c.context.authCookies.state.name,
|
|
1380
1370
|
c.context.secret
|
|
1381
1371
|
);
|
|
1382
|
-
if (
|
|
1383
|
-
logger.error("
|
|
1372
|
+
if (storedState !== stateCode) {
|
|
1373
|
+
logger.error("OAuth state mismatch", storedState, stateCode);
|
|
1384
1374
|
throw c.redirect(
|
|
1385
1375
|
`${c.context.baseURL}/error?error=please_restart_the_process`
|
|
1386
1376
|
);
|
|
@@ -1486,8 +1476,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1486
1476
|
try {
|
|
1487
1477
|
const session = await c.context.internalAdapter.createSession(
|
|
1488
1478
|
userId || id,
|
|
1489
|
-
c.request
|
|
1490
|
-
dontRememberMe
|
|
1479
|
+
c.request
|
|
1491
1480
|
);
|
|
1492
1481
|
if (!session) {
|
|
1493
1482
|
const url = new URL(currentURL || callbackURL);
|
|
@@ -1495,7 +1484,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1495
1484
|
throw c.redirect(url.toString());
|
|
1496
1485
|
}
|
|
1497
1486
|
try {
|
|
1498
|
-
await setSessionCookie(c, session.id
|
|
1487
|
+
await setSessionCookie(c, session.id);
|
|
1499
1488
|
} catch (e) {
|
|
1500
1489
|
c.context.logger.error("Unable to set session cookie", e);
|
|
1501
1490
|
const url = new URL(currentURL || callbackURL);
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ 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, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-DCBFTxDp.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DCBFTxDp.js';
|
|
7
7
|
import { P as Prettify } from '../helper-DPDj8Nix.js';
|
|
8
|
-
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-
|
|
9
|
-
import '
|
|
10
|
-
import 'zod';
|
|
11
|
-
import '
|
|
12
|
-
import '
|
|
8
|
+
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-C6jmDLjB.js';
|
|
9
|
+
import * as better_call from 'better-call';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { U as User } from '../types-Bs23H3QM.js';
|
|
12
|
+
import { OAuth2Tokens } from 'arctic';
|
|
13
13
|
import '@simplewebauthn/types';
|
|
14
14
|
import 'kysely';
|
|
15
15
|
import 'better-sqlite3';
|
|
@@ -256,4 +256,196 @@ declare const adminClient: () => {
|
|
|
256
256
|
$InferServerPlugin: ReturnType<typeof admin>;
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Configuration interface for generic OAuth providers.
|
|
261
|
+
*/
|
|
262
|
+
interface GenericOAuthConfig {
|
|
263
|
+
/** Unique identifier for the OAuth provider */
|
|
264
|
+
providerId: string;
|
|
265
|
+
/**
|
|
266
|
+
* URL to fetch OAuth 2.0 configuration.
|
|
267
|
+
* If provided, the authorization and token endpoints will be fetched from this URL.
|
|
268
|
+
*/
|
|
269
|
+
discoveryUrl?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Type of OAuth flow.
|
|
272
|
+
* @default "oauth2"
|
|
273
|
+
*/
|
|
274
|
+
type?: "oauth2" | "oidc";
|
|
275
|
+
/**
|
|
276
|
+
* URL for the authorization endpoint.
|
|
277
|
+
* Optional if using discoveryUrl.
|
|
278
|
+
*/
|
|
279
|
+
authorizationUrl?: string;
|
|
280
|
+
/**
|
|
281
|
+
* URL for the token endpoint.
|
|
282
|
+
* Optional if using discoveryUrl.
|
|
283
|
+
*/
|
|
284
|
+
tokenUrl?: string;
|
|
285
|
+
/**
|
|
286
|
+
* URL for the user info endpoint.
|
|
287
|
+
* Optional if using discoveryUrl.
|
|
288
|
+
*/
|
|
289
|
+
userInfoUrl?: string;
|
|
290
|
+
/** OAuth client ID */
|
|
291
|
+
clientId: string;
|
|
292
|
+
/** OAuth client secret */
|
|
293
|
+
clientSecret: string;
|
|
294
|
+
/**
|
|
295
|
+
* Array of OAuth scopes to request.
|
|
296
|
+
* @default []
|
|
297
|
+
*/
|
|
298
|
+
scopes?: string[];
|
|
299
|
+
/**
|
|
300
|
+
* Custom redirect URI.
|
|
301
|
+
* If not provided, a default URI will be constructed.
|
|
302
|
+
*/
|
|
303
|
+
redirectURI?: string;
|
|
304
|
+
/**
|
|
305
|
+
* OAuth response type.
|
|
306
|
+
* @default "code"
|
|
307
|
+
*/
|
|
308
|
+
responseType?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Prompt parameter for the authorization request.
|
|
311
|
+
* Controls the authentication experience for the user.
|
|
312
|
+
*/
|
|
313
|
+
prompt?: string;
|
|
314
|
+
/**
|
|
315
|
+
* Whether to use PKCE (Proof Key for Code Exchange)
|
|
316
|
+
* @default false
|
|
317
|
+
*/
|
|
318
|
+
pkce?: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Access type for the authorization request.
|
|
321
|
+
* Use "offline" to request a refresh token.
|
|
322
|
+
*/
|
|
323
|
+
accessType?: string;
|
|
324
|
+
/**
|
|
325
|
+
* Custom function to fetch user info.
|
|
326
|
+
* If provided, this function will be used instead of the default user info fetching logic.
|
|
327
|
+
* @param tokens - The OAuth tokens received after successful authentication
|
|
328
|
+
* @returns A promise that resolves to a User object or null
|
|
329
|
+
*/
|
|
330
|
+
getUserInfo?: (tokens: OAuth2Tokens) => Promise<User | null>;
|
|
331
|
+
}
|
|
332
|
+
interface GenericOAuthOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Array of OAuth provider configurations.
|
|
335
|
+
*/
|
|
336
|
+
config: GenericOAuthConfig[];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A generic OAuth plugin that can be used to add OAuth support to any provider
|
|
340
|
+
*/
|
|
341
|
+
declare const genericOAuth: (options: GenericOAuthOptions) => {
|
|
342
|
+
id: "generic-oauth";
|
|
343
|
+
endpoints: {
|
|
344
|
+
signInWithOAuth2: {
|
|
345
|
+
<C extends [better_call.Context<"/sign-in/oauth2", {
|
|
346
|
+
method: "POST";
|
|
347
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
348
|
+
/**
|
|
349
|
+
* Redirect to the current URL after the
|
|
350
|
+
* user has signed in.
|
|
351
|
+
*/
|
|
352
|
+
currentURL: z.ZodOptional<z.ZodString>;
|
|
353
|
+
}, "strip", z.ZodTypeAny, {
|
|
354
|
+
currentURL?: string | undefined;
|
|
355
|
+
}, {
|
|
356
|
+
currentURL?: string | undefined;
|
|
357
|
+
}>>;
|
|
358
|
+
body: z.ZodObject<{
|
|
359
|
+
providerId: z.ZodString;
|
|
360
|
+
callbackURL: z.ZodOptional<z.ZodString>;
|
|
361
|
+
}, "strip", z.ZodTypeAny, {
|
|
362
|
+
providerId: string;
|
|
363
|
+
callbackURL?: string | undefined;
|
|
364
|
+
}, {
|
|
365
|
+
providerId: string;
|
|
366
|
+
callbackURL?: string | undefined;
|
|
367
|
+
}>;
|
|
368
|
+
}>]>(...ctx: C): Promise<C extends [{
|
|
369
|
+
asResponse: true;
|
|
370
|
+
}] ? Response : {
|
|
371
|
+
url: string;
|
|
372
|
+
state: string;
|
|
373
|
+
codeVerifier: string;
|
|
374
|
+
redirect: boolean;
|
|
375
|
+
}>;
|
|
376
|
+
path: "/sign-in/oauth2";
|
|
377
|
+
options: {
|
|
378
|
+
method: "POST";
|
|
379
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
380
|
+
/**
|
|
381
|
+
* Redirect to the current URL after the
|
|
382
|
+
* user has signed in.
|
|
383
|
+
*/
|
|
384
|
+
currentURL: z.ZodOptional<z.ZodString>;
|
|
385
|
+
}, "strip", z.ZodTypeAny, {
|
|
386
|
+
currentURL?: string | undefined;
|
|
387
|
+
}, {
|
|
388
|
+
currentURL?: string | undefined;
|
|
389
|
+
}>>;
|
|
390
|
+
body: z.ZodObject<{
|
|
391
|
+
providerId: z.ZodString;
|
|
392
|
+
callbackURL: z.ZodOptional<z.ZodString>;
|
|
393
|
+
}, "strip", z.ZodTypeAny, {
|
|
394
|
+
providerId: string;
|
|
395
|
+
callbackURL?: string | undefined;
|
|
396
|
+
}, {
|
|
397
|
+
providerId: string;
|
|
398
|
+
callbackURL?: string | undefined;
|
|
399
|
+
}>;
|
|
400
|
+
};
|
|
401
|
+
method: better_call.Method | better_call.Method[];
|
|
402
|
+
headers: Headers;
|
|
403
|
+
};
|
|
404
|
+
oAuth2Callback: {
|
|
405
|
+
<C extends [better_call.Context<"/oauth2/callback/:providerId", {
|
|
406
|
+
method: "GET";
|
|
407
|
+
query: z.ZodObject<{
|
|
408
|
+
code: z.ZodOptional<z.ZodString>;
|
|
409
|
+
error: z.ZodOptional<z.ZodString>;
|
|
410
|
+
state: z.ZodString;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
state: string;
|
|
413
|
+
code?: string | undefined;
|
|
414
|
+
error?: string | undefined;
|
|
415
|
+
}, {
|
|
416
|
+
state: string;
|
|
417
|
+
code?: string | undefined;
|
|
418
|
+
error?: string | undefined;
|
|
419
|
+
}>;
|
|
420
|
+
}>]>(...ctx: C): Promise<C extends [{
|
|
421
|
+
asResponse: true;
|
|
422
|
+
}] ? Response : never>;
|
|
423
|
+
path: "/oauth2/callback/:providerId";
|
|
424
|
+
options: {
|
|
425
|
+
method: "GET";
|
|
426
|
+
query: z.ZodObject<{
|
|
427
|
+
code: z.ZodOptional<z.ZodString>;
|
|
428
|
+
error: z.ZodOptional<z.ZodString>;
|
|
429
|
+
state: z.ZodString;
|
|
430
|
+
}, "strip", z.ZodTypeAny, {
|
|
431
|
+
state: string;
|
|
432
|
+
code?: string | undefined;
|
|
433
|
+
error?: string | undefined;
|
|
434
|
+
}, {
|
|
435
|
+
state: string;
|
|
436
|
+
code?: string | undefined;
|
|
437
|
+
error?: string | undefined;
|
|
438
|
+
}>;
|
|
439
|
+
};
|
|
440
|
+
method: better_call.Method | better_call.Method[];
|
|
441
|
+
headers: Headers;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
declare const genericOAuthClient: () => {
|
|
447
|
+
id: "generic-oauth-client";
|
|
448
|
+
$InferServerPlugin: ReturnType<typeof genericOAuth>;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export { adminClient, anonymousClient, genericOAuthClient, inferAdditionalFields, magicLinkClient, organizationClient, phoneNumberClient, usernameClient };
|
package/dist/client/plugins.js
CHANGED
|
@@ -522,9 +522,18 @@ var adminClient = () => {
|
|
|
522
522
|
$InferServerPlugin: {}
|
|
523
523
|
};
|
|
524
524
|
};
|
|
525
|
+
|
|
526
|
+
// src/plugins/generic-oauth/client.ts
|
|
527
|
+
var genericOAuthClient = () => {
|
|
528
|
+
return {
|
|
529
|
+
id: "generic-oauth-client",
|
|
530
|
+
$InferServerPlugin: {}
|
|
531
|
+
};
|
|
532
|
+
};
|
|
525
533
|
export {
|
|
526
534
|
adminClient,
|
|
527
535
|
anonymousClient,
|
|
536
|
+
genericOAuthClient,
|
|
528
537
|
getPasskeyActions,
|
|
529
538
|
inferAdditionalFields,
|
|
530
539
|
magicLinkClient,
|
package/dist/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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-C6jmDLjB.js';
|
|
10
10
|
import 'kysely';
|
|
11
11
|
import './types-Bs23H3QM.js';
|
|
12
12
|
import 'arctic';
|
package/dist/client.js
CHANGED
|
@@ -82,11 +82,6 @@ var csrfPlugin = {
|
|
|
82
82
|
id: "csrf",
|
|
83
83
|
name: "CSRF Check",
|
|
84
84
|
async init(url, options) {
|
|
85
|
-
if (!options?.baseURL) {
|
|
86
|
-
throw new BetterAuthError(
|
|
87
|
-
"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`"
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
85
|
if (options?.method !== "GET") {
|
|
91
86
|
options = options || {};
|
|
92
87
|
const { data, error } = await betterFetch("/csrf", {
|
|
@@ -262,6 +262,7 @@ type AuthEndpoint = Endpoint<(ctx: {
|
|
|
262
262
|
options: BetterAuthOptions;
|
|
263
263
|
body: any;
|
|
264
264
|
query: any;
|
|
265
|
+
params: any;
|
|
265
266
|
headers: Headers;
|
|
266
267
|
}) => Promise<EndpointResponse>>;
|
|
267
268
|
type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
|
|
@@ -1174,19 +1175,13 @@ declare const signInOAuth: {
|
|
|
1174
1175
|
/**
|
|
1175
1176
|
* OAuth2 provider to use`
|
|
1176
1177
|
*/
|
|
1177
|
-
provider: z.ZodEnum<["github", ...("
|
|
1178
|
-
/**
|
|
1179
|
-
* If this is true the session will only be valid for the current browser session
|
|
1180
|
-
*/
|
|
1181
|
-
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1178
|
+
provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1182
1179
|
}, "strip", z.ZodTypeAny, {
|
|
1183
|
-
provider: "
|
|
1180
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1184
1181
|
callbackURL?: string | undefined;
|
|
1185
|
-
dontRememberMe?: boolean | undefined;
|
|
1186
1182
|
}, {
|
|
1187
|
-
provider: "
|
|
1183
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1188
1184
|
callbackURL?: string | undefined;
|
|
1189
|
-
dontRememberMe?: boolean | undefined;
|
|
1190
1185
|
}>;
|
|
1191
1186
|
}>]>(...ctx: C): Promise<C extends [{
|
|
1192
1187
|
asResponse: true;
|
|
@@ -1219,19 +1214,13 @@ declare const signInOAuth: {
|
|
|
1219
1214
|
/**
|
|
1220
1215
|
* OAuth2 provider to use`
|
|
1221
1216
|
*/
|
|
1222
|
-
provider: z.ZodEnum<["github", ...("
|
|
1223
|
-
/**
|
|
1224
|
-
* If this is true the session will only be valid for the current browser session
|
|
1225
|
-
*/
|
|
1226
|
-
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1217
|
+
provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1227
1218
|
}, "strip", z.ZodTypeAny, {
|
|
1228
|
-
provider: "
|
|
1219
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1229
1220
|
callbackURL?: string | undefined;
|
|
1230
|
-
dontRememberMe?: boolean | undefined;
|
|
1231
1221
|
}, {
|
|
1232
|
-
provider: "
|
|
1222
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1233
1223
|
callbackURL?: string | undefined;
|
|
1234
|
-
dontRememberMe?: boolean | undefined;
|
|
1235
1224
|
}>;
|
|
1236
1225
|
};
|
|
1237
1226
|
method: better_call.Method | better_call.Method[];
|
|
@@ -2447,16 +2436,13 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2447
2436
|
}>>;
|
|
2448
2437
|
body: zod.ZodObject<{
|
|
2449
2438
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2450
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2451
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2439
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2452
2440
|
}, "strip", zod.ZodTypeAny, {
|
|
2453
|
-
provider: "
|
|
2441
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2454
2442
|
callbackURL?: string | undefined;
|
|
2455
|
-
dontRememberMe?: boolean | undefined;
|
|
2456
2443
|
}, {
|
|
2457
|
-
provider: "
|
|
2444
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2458
2445
|
callbackURL?: string | undefined;
|
|
2459
|
-
dontRememberMe?: boolean | undefined;
|
|
2460
2446
|
}>;
|
|
2461
2447
|
}>]>(...ctx: C_1): Promise<C_1 extends [{
|
|
2462
2448
|
asResponse: true;
|
|
@@ -2479,16 +2465,13 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2479
2465
|
}>>;
|
|
2480
2466
|
body: zod.ZodObject<{
|
|
2481
2467
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2482
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2483
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2468
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2484
2469
|
}, "strip", zod.ZodTypeAny, {
|
|
2485
|
-
provider: "
|
|
2470
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2486
2471
|
callbackURL?: string | undefined;
|
|
2487
|
-
dontRememberMe?: boolean | undefined;
|
|
2488
2472
|
}, {
|
|
2489
|
-
provider: "
|
|
2473
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2490
2474
|
callbackURL?: string | undefined;
|
|
2491
|
-
dontRememberMe?: boolean | undefined;
|
|
2492
2475
|
}>;
|
|
2493
2476
|
};
|
|
2494
2477
|
method: better_call.Method | better_call.Method[];
|
|
@@ -3562,16 +3545,13 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3562
3545
|
}>>;
|
|
3563
3546
|
body: zod.ZodObject<{
|
|
3564
3547
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3565
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3566
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3548
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3567
3549
|
}, "strip", zod.ZodTypeAny, {
|
|
3568
|
-
provider: "
|
|
3550
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3569
3551
|
callbackURL?: string | undefined;
|
|
3570
|
-
dontRememberMe?: boolean | undefined;
|
|
3571
3552
|
}, {
|
|
3572
|
-
provider: "
|
|
3553
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3573
3554
|
callbackURL?: string | undefined;
|
|
3574
|
-
dontRememberMe?: boolean | undefined;
|
|
3575
3555
|
}>;
|
|
3576
3556
|
}>]>(...ctx: C_1): Promise<C_1 extends [{
|
|
3577
3557
|
asResponse: true;
|
|
@@ -3594,16 +3574,13 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3594
3574
|
}>>;
|
|
3595
3575
|
body: zod.ZodObject<{
|
|
3596
3576
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3597
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3598
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3577
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3599
3578
|
}, "strip", zod.ZodTypeAny, {
|
|
3600
|
-
provider: "
|
|
3579
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3601
3580
|
callbackURL?: string | undefined;
|
|
3602
|
-
dontRememberMe?: boolean | undefined;
|
|
3603
3581
|
}, {
|
|
3604
|
-
provider: "
|
|
3582
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3605
3583
|
callbackURL?: string | undefined;
|
|
3606
|
-
dontRememberMe?: boolean | undefined;
|
|
3607
3584
|
}>;
|
|
3608
3585
|
};
|
|
3609
3586
|
method: better_call.Method | better_call.Method[];
|
|
@@ -4679,16 +4656,13 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4679
4656
|
}>>;
|
|
4680
4657
|
body: zod.ZodObject<{
|
|
4681
4658
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4682
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4683
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4659
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4684
4660
|
}, "strip", zod.ZodTypeAny, {
|
|
4685
|
-
provider: "
|
|
4661
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4686
4662
|
callbackURL?: string | undefined;
|
|
4687
|
-
dontRememberMe?: boolean | undefined;
|
|
4688
4663
|
}, {
|
|
4689
|
-
provider: "
|
|
4664
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4690
4665
|
callbackURL?: string | undefined;
|
|
4691
|
-
dontRememberMe?: boolean | undefined;
|
|
4692
4666
|
}>;
|
|
4693
4667
|
}>]>(...ctx: C): Promise<C extends [{
|
|
4694
4668
|
asResponse: true;
|
|
@@ -4711,16 +4685,13 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4711
4685
|
}>>;
|
|
4712
4686
|
body: zod.ZodObject<{
|
|
4713
4687
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4714
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4715
|
-
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4688
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4716
4689
|
}, "strip", zod.ZodTypeAny, {
|
|
4717
|
-
provider: "
|
|
4690
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4718
4691
|
callbackURL?: string | undefined;
|
|
4719
|
-
dontRememberMe?: boolean | undefined;
|
|
4720
4692
|
}, {
|
|
4721
|
-
provider: "
|
|
4693
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4722
4694
|
callbackURL?: string | undefined;
|
|
4723
|
-
dontRememberMe?: boolean | undefined;
|
|
4724
4695
|
}>;
|
|
4725
4696
|
};
|
|
4726
4697
|
method: better_call.Method | better_call.Method[];
|
|
@@ -5,7 +5,7 @@ import { P as Prettify } from './helper-DPDj8Nix.js';
|
|
|
5
5
|
import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.js';
|
|
6
6
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
7
7
|
import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
|
|
8
|
-
import { H as HookEndpointContext, g as AuthContext } from './index-
|
|
8
|
+
import { H as HookEndpointContext, g as AuthContext } from './index-C6jmDLjB.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|