better-auth 0.4.9-beta.3 → 0.4.9-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 +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 +7 -10
- package/dist/client/plugins.d.ts +6 -195
- package/dist/client.d.ts +1 -1
- package/dist/client.js +7 -3
- package/dist/{index-BxPsiFU2.d.ts → index-x0qUJonH.d.ts} +192 -3
- package/dist/{index-LP5tMWKG.d.ts → index-xf537-bb.d.ts} +25 -25
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -16
- 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 +321 -10
- package/dist/react.d.ts +1 -1
- package/dist/react.js +7 -3
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/solid.js +7 -3
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +7 -3
- package/dist/types.d.ts +5 -3
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +7 -3
- package/package.json +1 -1
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-xf537-bb.js';
|
|
2
2
|
import './helper-DPDj8Nix.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
export { APIError } from 'better-call';
|
package/dist/api.js
CHANGED
|
@@ -64,10 +64,10 @@ var csrfMiddleware = createAuthMiddleware(
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
const url = new URL(ctx.request.url);
|
|
67
|
-
if (
|
|
67
|
+
if (ctx.context.trustedOrigins.includes(url.origin)) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
const csrfToken = ctx.
|
|
70
|
+
const csrfToken = ctx.headers?.get("x-auth-csrf-token");
|
|
71
71
|
if (!csrfToken) {
|
|
72
72
|
throw new APIError2("UNAUTHORIZED", {
|
|
73
73
|
message: "CSRF Token is required"
|
|
@@ -1022,16 +1022,12 @@ var redirectURLMiddleware = createAuthMiddleware(async (ctx) => {
|
|
|
1022
1022
|
const callbackURL = ctx.body?.callbackURL || ctx.query?.callbackURL || ctx.query?.redirectTo || ctx.body?.redirectTo;
|
|
1023
1023
|
const clientCurrentURL = ctx.headers?.get("referer");
|
|
1024
1024
|
const currentURL = ctx.query?.currentURL || clientCurrentURL || ctx.context.baseURL;
|
|
1025
|
-
const trustedOrigins =
|
|
1026
|
-
ctx.context.baseURL ? new URL(ctx.context.baseURL).origin : void 0,
|
|
1027
|
-
...ctx.context.options.trustedOrigins || []
|
|
1028
|
-
];
|
|
1025
|
+
const trustedOrigins = ctx.context.trustedOrigins;
|
|
1029
1026
|
if (callbackURL?.includes("http")) {
|
|
1030
1027
|
const callbackOrigin = new URL(callbackURL).origin;
|
|
1031
1028
|
if (!trustedOrigins.includes(callbackOrigin)) {
|
|
1032
|
-
logger.error("
|
|
1033
|
-
callbackURL
|
|
1034
|
-
trustedOrigins
|
|
1029
|
+
logger.error("Unknown origin in callback URL", {
|
|
1030
|
+
callbackURL
|
|
1035
1031
|
});
|
|
1036
1032
|
throw new APIError4("FORBIDDEN", {
|
|
1037
1033
|
message: "Invalid callback URL"
|
|
@@ -1041,7 +1037,7 @@ var redirectURLMiddleware = createAuthMiddleware(async (ctx) => {
|
|
|
1041
1037
|
if (currentURL !== ctx.context.baseURL) {
|
|
1042
1038
|
const currentURLOrigin = new URL(currentURL).origin;
|
|
1043
1039
|
if (!trustedOrigins.includes(currentURLOrigin)) {
|
|
1044
|
-
logger.error("
|
|
1040
|
+
logger.error("Unknown origin in current URL", {
|
|
1045
1041
|
currentURL,
|
|
1046
1042
|
trustedOrigins
|
|
1047
1043
|
});
|
|
@@ -1050,6 +1046,7 @@ var redirectURLMiddleware = createAuthMiddleware(async (ctx) => {
|
|
|
1050
1046
|
});
|
|
1051
1047
|
}
|
|
1052
1048
|
}
|
|
1049
|
+
ctx.setHeader("x-auth-redirect", "true");
|
|
1053
1050
|
});
|
|
1054
1051
|
|
|
1055
1052
|
// src/api/routes/sign-in.ts
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ 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,
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, k as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin, j as genericOAuth } from '../index-x0qUJonH.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-x0qUJonH.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
|
|
11
|
-
import
|
|
8
|
+
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-xf537-bb.js';
|
|
9
|
+
import '../types-IzAbV4nB.js';
|
|
10
|
+
import 'zod';
|
|
11
|
+
import 'better-call';
|
|
12
12
|
import '@simplewebauthn/types';
|
|
13
13
|
import 'kysely';
|
|
14
14
|
import 'better-sqlite3';
|
|
@@ -255,195 +255,6 @@ declare const adminClient: () => {
|
|
|
255
255
|
$InferServerPlugin: ReturnType<typeof admin>;
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
/**
|
|
259
|
-
* Configuration interface for generic OAuth providers.
|
|
260
|
-
*/
|
|
261
|
-
interface GenericOAuthConfig {
|
|
262
|
-
/** Unique identifier for the OAuth provider */
|
|
263
|
-
providerId: string;
|
|
264
|
-
/**
|
|
265
|
-
* URL to fetch OAuth 2.0 configuration.
|
|
266
|
-
* If provided, the authorization and token endpoints will be fetched from this URL.
|
|
267
|
-
*/
|
|
268
|
-
discoveryUrl?: string;
|
|
269
|
-
/**
|
|
270
|
-
* Type of OAuth flow.
|
|
271
|
-
* @default "oauth2"
|
|
272
|
-
*/
|
|
273
|
-
type?: "oauth2" | "oidc";
|
|
274
|
-
/**
|
|
275
|
-
* URL for the authorization endpoint.
|
|
276
|
-
* Optional if using discoveryUrl.
|
|
277
|
-
*/
|
|
278
|
-
authorizationUrl?: string;
|
|
279
|
-
/**
|
|
280
|
-
* URL for the token endpoint.
|
|
281
|
-
* Optional if using discoveryUrl.
|
|
282
|
-
*/
|
|
283
|
-
tokenUrl?: string;
|
|
284
|
-
/**
|
|
285
|
-
* URL for the user info endpoint.
|
|
286
|
-
* Optional if using discoveryUrl.
|
|
287
|
-
*/
|
|
288
|
-
userInfoUrl?: string;
|
|
289
|
-
/** OAuth client ID */
|
|
290
|
-
clientId: string;
|
|
291
|
-
/** OAuth client secret */
|
|
292
|
-
clientSecret: string;
|
|
293
|
-
/**
|
|
294
|
-
* Array of OAuth scopes to request.
|
|
295
|
-
* @default []
|
|
296
|
-
*/
|
|
297
|
-
scopes?: string[];
|
|
298
|
-
/**
|
|
299
|
-
* Custom redirect URI.
|
|
300
|
-
* If not provided, a default URI will be constructed.
|
|
301
|
-
*/
|
|
302
|
-
redirectURI?: string;
|
|
303
|
-
/**
|
|
304
|
-
* OAuth response type.
|
|
305
|
-
* @default "code"
|
|
306
|
-
*/
|
|
307
|
-
responseType?: string;
|
|
308
|
-
/**
|
|
309
|
-
* Prompt parameter for the authorization request.
|
|
310
|
-
* Controls the authentication experience for the user.
|
|
311
|
-
*/
|
|
312
|
-
prompt?: string;
|
|
313
|
-
/**
|
|
314
|
-
* Whether to use PKCE (Proof Key for Code Exchange)
|
|
315
|
-
* @default false
|
|
316
|
-
*/
|
|
317
|
-
pkce?: boolean;
|
|
318
|
-
/**
|
|
319
|
-
* Access type for the authorization request.
|
|
320
|
-
* Use "offline" to request a refresh token.
|
|
321
|
-
*/
|
|
322
|
-
accessType?: string;
|
|
323
|
-
/**
|
|
324
|
-
* Custom function to fetch user info.
|
|
325
|
-
* If provided, this function will be used instead of the default user info fetching logic.
|
|
326
|
-
* @param tokens - The OAuth tokens received after successful authentication
|
|
327
|
-
* @returns A promise that resolves to a User object or null
|
|
328
|
-
*/
|
|
329
|
-
getUserInfo?: (tokens: OAuth2Tokens) => Promise<User | null>;
|
|
330
|
-
}
|
|
331
|
-
interface GenericOAuthOptions {
|
|
332
|
-
/**
|
|
333
|
-
* Array of OAuth provider configurations.
|
|
334
|
-
*/
|
|
335
|
-
config: GenericOAuthConfig[];
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* A generic OAuth plugin that can be used to add OAuth support to any provider
|
|
339
|
-
*/
|
|
340
|
-
declare const genericOAuth: (options: GenericOAuthOptions) => {
|
|
341
|
-
id: "generic-oauth";
|
|
342
|
-
endpoints: {
|
|
343
|
-
signInWithOAuth2: {
|
|
344
|
-
<C extends [better_call.Context<"/sign-in/oauth2", {
|
|
345
|
-
method: "POST";
|
|
346
|
-
query: z.ZodOptional<z.ZodObject<{
|
|
347
|
-
/**
|
|
348
|
-
* Redirect to the current URL after the
|
|
349
|
-
* user has signed in.
|
|
350
|
-
*/
|
|
351
|
-
currentURL: z.ZodOptional<z.ZodString>;
|
|
352
|
-
}, "strip", z.ZodTypeAny, {
|
|
353
|
-
currentURL?: string | undefined;
|
|
354
|
-
}, {
|
|
355
|
-
currentURL?: string | undefined;
|
|
356
|
-
}>>;
|
|
357
|
-
body: z.ZodObject<{
|
|
358
|
-
providerId: z.ZodString;
|
|
359
|
-
callbackURL: z.ZodOptional<z.ZodString>;
|
|
360
|
-
}, "strip", z.ZodTypeAny, {
|
|
361
|
-
providerId: string;
|
|
362
|
-
callbackURL?: string | undefined;
|
|
363
|
-
}, {
|
|
364
|
-
providerId: string;
|
|
365
|
-
callbackURL?: string | undefined;
|
|
366
|
-
}>;
|
|
367
|
-
use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
|
|
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
|
-
use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
|
|
401
|
-
};
|
|
402
|
-
method: better_call.Method | better_call.Method[];
|
|
403
|
-
headers: Headers;
|
|
404
|
-
};
|
|
405
|
-
oAuth2Callback: {
|
|
406
|
-
<C extends [better_call.Context<"/oauth2/callback/:providerId", {
|
|
407
|
-
method: "GET";
|
|
408
|
-
query: z.ZodObject<{
|
|
409
|
-
code: z.ZodOptional<z.ZodString>;
|
|
410
|
-
error: z.ZodOptional<z.ZodString>;
|
|
411
|
-
state: z.ZodString;
|
|
412
|
-
}, "strip", z.ZodTypeAny, {
|
|
413
|
-
state: string;
|
|
414
|
-
code?: string | undefined;
|
|
415
|
-
error?: string | undefined;
|
|
416
|
-
}, {
|
|
417
|
-
state: string;
|
|
418
|
-
code?: string | undefined;
|
|
419
|
-
error?: string | undefined;
|
|
420
|
-
}>;
|
|
421
|
-
}>]>(...ctx: C): Promise<C extends [{
|
|
422
|
-
asResponse: true;
|
|
423
|
-
}] ? Response : never>;
|
|
424
|
-
path: "/oauth2/callback/:providerId";
|
|
425
|
-
options: {
|
|
426
|
-
method: "GET";
|
|
427
|
-
query: z.ZodObject<{
|
|
428
|
-
code: z.ZodOptional<z.ZodString>;
|
|
429
|
-
error: z.ZodOptional<z.ZodString>;
|
|
430
|
-
state: z.ZodString;
|
|
431
|
-
}, "strip", z.ZodTypeAny, {
|
|
432
|
-
state: string;
|
|
433
|
-
code?: string | undefined;
|
|
434
|
-
error?: string | undefined;
|
|
435
|
-
}, {
|
|
436
|
-
state: string;
|
|
437
|
-
code?: string | undefined;
|
|
438
|
-
error?: string | undefined;
|
|
439
|
-
}>;
|
|
440
|
-
};
|
|
441
|
-
method: better_call.Method | better_call.Method[];
|
|
442
|
-
headers: Headers;
|
|
443
|
-
};
|
|
444
|
-
};
|
|
445
|
-
};
|
|
446
|
-
|
|
447
258
|
declare const genericOAuthClient: () => {
|
|
448
259
|
id: "generic-oauth-client";
|
|
449
260
|
$InferServerPlugin: ReturnType<typeof genericOAuth>;
|
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-xf537-bb.js';
|
|
10
10
|
import 'kysely';
|
|
11
11
|
import './types-IzAbV4nB.js';
|
|
12
12
|
import 'better-call';
|
package/dist/client.js
CHANGED
|
@@ -56,6 +56,10 @@ var redirectPlugin = {
|
|
|
56
56
|
name: "Redirect",
|
|
57
57
|
hooks: {
|
|
58
58
|
onSuccess(context) {
|
|
59
|
+
const header = context.response?.headers.get("x-auth-redirect");
|
|
60
|
+
if (!header) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
59
63
|
if (context.data?.url && context.data?.redirect) {
|
|
60
64
|
if (typeof window !== "undefined") {
|
|
61
65
|
window.location.href = context.data.url;
|
|
@@ -114,9 +118,9 @@ var csrfPlugin = {
|
|
|
114
118
|
);
|
|
115
119
|
}
|
|
116
120
|
const csrfToken = data?.csrfToken;
|
|
117
|
-
options.
|
|
118
|
-
...options
|
|
119
|
-
csrfToken
|
|
121
|
+
options.headers = {
|
|
122
|
+
...options.headers,
|
|
123
|
+
"x-auth-csrf-token": csrfToken
|
|
120
124
|
};
|
|
121
125
|
}
|
|
122
126
|
options.credentials = "include";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { U as User, S as Session } from './types-IzAbV4nB.js';
|
|
1
|
+
import { U as User, S as Session, O as OAuth2Tokens } from './types-IzAbV4nB.js';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
3
|
import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
|
|
4
4
|
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-xf537-bb.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
@@ -5455,4 +5455,193 @@ declare const admin: (options?: AdminOptions) => {
|
|
|
5455
5455
|
};
|
|
5456
5456
|
};
|
|
5457
5457
|
|
|
5458
|
-
|
|
5458
|
+
/**
|
|
5459
|
+
* Configuration interface for generic OAuth providers.
|
|
5460
|
+
*/
|
|
5461
|
+
interface GenericOAuthConfig {
|
|
5462
|
+
/** Unique identifier for the OAuth provider */
|
|
5463
|
+
providerId: string;
|
|
5464
|
+
/**
|
|
5465
|
+
* URL to fetch OAuth 2.0 configuration.
|
|
5466
|
+
* If provided, the authorization and token endpoints will be fetched from this URL.
|
|
5467
|
+
*/
|
|
5468
|
+
discoveryUrl?: string;
|
|
5469
|
+
/**
|
|
5470
|
+
* Type of OAuth flow.
|
|
5471
|
+
* @default "oauth2"
|
|
5472
|
+
*/
|
|
5473
|
+
type?: "oauth2" | "oidc";
|
|
5474
|
+
/**
|
|
5475
|
+
* URL for the authorization endpoint.
|
|
5476
|
+
* Optional if using discoveryUrl.
|
|
5477
|
+
*/
|
|
5478
|
+
authorizationUrl?: string;
|
|
5479
|
+
/**
|
|
5480
|
+
* URL for the token endpoint.
|
|
5481
|
+
* Optional if using discoveryUrl.
|
|
5482
|
+
*/
|
|
5483
|
+
tokenUrl?: string;
|
|
5484
|
+
/**
|
|
5485
|
+
* URL for the user info endpoint.
|
|
5486
|
+
* Optional if using discoveryUrl.
|
|
5487
|
+
*/
|
|
5488
|
+
userInfoUrl?: string;
|
|
5489
|
+
/** OAuth client ID */
|
|
5490
|
+
clientId: string;
|
|
5491
|
+
/** OAuth client secret */
|
|
5492
|
+
clientSecret: string;
|
|
5493
|
+
/**
|
|
5494
|
+
* Array of OAuth scopes to request.
|
|
5495
|
+
* @default []
|
|
5496
|
+
*/
|
|
5497
|
+
scopes?: string[];
|
|
5498
|
+
/**
|
|
5499
|
+
* Custom redirect URI.
|
|
5500
|
+
* If not provided, a default URI will be constructed.
|
|
5501
|
+
*/
|
|
5502
|
+
redirectURI?: string;
|
|
5503
|
+
/**
|
|
5504
|
+
* OAuth response type.
|
|
5505
|
+
* @default "code"
|
|
5506
|
+
*/
|
|
5507
|
+
responseType?: string;
|
|
5508
|
+
/**
|
|
5509
|
+
* Prompt parameter for the authorization request.
|
|
5510
|
+
* Controls the authentication experience for the user.
|
|
5511
|
+
*/
|
|
5512
|
+
prompt?: string;
|
|
5513
|
+
/**
|
|
5514
|
+
* Whether to use PKCE (Proof Key for Code Exchange)
|
|
5515
|
+
* @default false
|
|
5516
|
+
*/
|
|
5517
|
+
pkce?: boolean;
|
|
5518
|
+
/**
|
|
5519
|
+
* Access type for the authorization request.
|
|
5520
|
+
* Use "offline" to request a refresh token.
|
|
5521
|
+
*/
|
|
5522
|
+
accessType?: string;
|
|
5523
|
+
/**
|
|
5524
|
+
* Custom function to fetch user info.
|
|
5525
|
+
* If provided, this function will be used instead of the default user info fetching logic.
|
|
5526
|
+
* @param tokens - The OAuth tokens received after successful authentication
|
|
5527
|
+
* @returns A promise that resolves to a User object or null
|
|
5528
|
+
*/
|
|
5529
|
+
getUserInfo?: (tokens: OAuth2Tokens) => Promise<User | null>;
|
|
5530
|
+
}
|
|
5531
|
+
interface GenericOAuthOptions {
|
|
5532
|
+
/**
|
|
5533
|
+
* Array of OAuth provider configurations.
|
|
5534
|
+
*/
|
|
5535
|
+
config: GenericOAuthConfig[];
|
|
5536
|
+
}
|
|
5537
|
+
/**
|
|
5538
|
+
* A generic OAuth plugin that can be used to add OAuth support to any provider
|
|
5539
|
+
*/
|
|
5540
|
+
declare const genericOAuth: (options: GenericOAuthOptions) => {
|
|
5541
|
+
id: "generic-oauth";
|
|
5542
|
+
endpoints: {
|
|
5543
|
+
signInWithOAuth2: {
|
|
5544
|
+
<C extends [better_call.Context<"/sign-in/oauth2", {
|
|
5545
|
+
method: "POST";
|
|
5546
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
5547
|
+
/**
|
|
5548
|
+
* Redirect to the current URL after the
|
|
5549
|
+
* user has signed in.
|
|
5550
|
+
*/
|
|
5551
|
+
currentURL: z.ZodOptional<z.ZodString>;
|
|
5552
|
+
}, "strip", z.ZodTypeAny, {
|
|
5553
|
+
currentURL?: string | undefined;
|
|
5554
|
+
}, {
|
|
5555
|
+
currentURL?: string | undefined;
|
|
5556
|
+
}>>;
|
|
5557
|
+
body: z.ZodObject<{
|
|
5558
|
+
providerId: z.ZodString;
|
|
5559
|
+
callbackURL: z.ZodOptional<z.ZodString>;
|
|
5560
|
+
}, "strip", z.ZodTypeAny, {
|
|
5561
|
+
providerId: string;
|
|
5562
|
+
callbackURL?: string | undefined;
|
|
5563
|
+
}, {
|
|
5564
|
+
providerId: string;
|
|
5565
|
+
callbackURL?: string | undefined;
|
|
5566
|
+
}>;
|
|
5567
|
+
use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
|
|
5568
|
+
}>]>(...ctx: C): Promise<C extends [{
|
|
5569
|
+
asResponse: true;
|
|
5570
|
+
}] ? Response : {
|
|
5571
|
+
url: string;
|
|
5572
|
+
state: string;
|
|
5573
|
+
codeVerifier: string;
|
|
5574
|
+
redirect: boolean;
|
|
5575
|
+
}>;
|
|
5576
|
+
path: "/sign-in/oauth2";
|
|
5577
|
+
options: {
|
|
5578
|
+
method: "POST";
|
|
5579
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
5580
|
+
/**
|
|
5581
|
+
* Redirect to the current URL after the
|
|
5582
|
+
* user has signed in.
|
|
5583
|
+
*/
|
|
5584
|
+
currentURL: z.ZodOptional<z.ZodString>;
|
|
5585
|
+
}, "strip", z.ZodTypeAny, {
|
|
5586
|
+
currentURL?: string | undefined;
|
|
5587
|
+
}, {
|
|
5588
|
+
currentURL?: string | undefined;
|
|
5589
|
+
}>>;
|
|
5590
|
+
body: z.ZodObject<{
|
|
5591
|
+
providerId: z.ZodString;
|
|
5592
|
+
callbackURL: z.ZodOptional<z.ZodString>;
|
|
5593
|
+
}, "strip", z.ZodTypeAny, {
|
|
5594
|
+
providerId: string;
|
|
5595
|
+
callbackURL?: string | undefined;
|
|
5596
|
+
}, {
|
|
5597
|
+
providerId: string;
|
|
5598
|
+
callbackURL?: string | undefined;
|
|
5599
|
+
}>;
|
|
5600
|
+
use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
|
|
5601
|
+
};
|
|
5602
|
+
method: better_call.Method | better_call.Method[];
|
|
5603
|
+
headers: Headers;
|
|
5604
|
+
};
|
|
5605
|
+
oAuth2Callback: {
|
|
5606
|
+
<C extends [better_call.Context<"/oauth2/callback/:providerId", {
|
|
5607
|
+
method: "GET";
|
|
5608
|
+
query: z.ZodObject<{
|
|
5609
|
+
code: z.ZodOptional<z.ZodString>;
|
|
5610
|
+
error: z.ZodOptional<z.ZodString>;
|
|
5611
|
+
state: z.ZodString;
|
|
5612
|
+
}, "strip", z.ZodTypeAny, {
|
|
5613
|
+
state: string;
|
|
5614
|
+
code?: string | undefined;
|
|
5615
|
+
error?: string | undefined;
|
|
5616
|
+
}, {
|
|
5617
|
+
state: string;
|
|
5618
|
+
code?: string | undefined;
|
|
5619
|
+
error?: string | undefined;
|
|
5620
|
+
}>;
|
|
5621
|
+
}>]>(...ctx: C): Promise<C extends [{
|
|
5622
|
+
asResponse: true;
|
|
5623
|
+
}] ? Response : never>;
|
|
5624
|
+
path: "/oauth2/callback/:providerId";
|
|
5625
|
+
options: {
|
|
5626
|
+
method: "GET";
|
|
5627
|
+
query: z.ZodObject<{
|
|
5628
|
+
code: z.ZodOptional<z.ZodString>;
|
|
5629
|
+
error: z.ZodOptional<z.ZodString>;
|
|
5630
|
+
state: z.ZodString;
|
|
5631
|
+
}, "strip", z.ZodTypeAny, {
|
|
5632
|
+
state: string;
|
|
5633
|
+
code?: string | undefined;
|
|
5634
|
+
error?: string | undefined;
|
|
5635
|
+
}, {
|
|
5636
|
+
state: string;
|
|
5637
|
+
code?: string | undefined;
|
|
5638
|
+
error?: string | undefined;
|
|
5639
|
+
}>;
|
|
5640
|
+
};
|
|
5641
|
+
method: better_call.Method | better_call.Method[];
|
|
5642
|
+
headers: Headers;
|
|
5643
|
+
};
|
|
5644
|
+
};
|
|
5645
|
+
};
|
|
5646
|
+
|
|
5647
|
+
export { type AnonymousOptions as A, type Invitation as I, type Member as M, type OrganizationOptions as O, type PasskeyOptions as P, type UserWithPhoneNumber as U, twoFactorClient as a, type Passkey as b, passkeyClient as c, phoneNumber as d, anonymous as e, type UserWithRole as f, getPasskeyActions as g, adminMiddleware as h, admin as i, genericOAuth as j, type Organization as k, magicLink as m, organization as o, passkey as p, twoFactor as t, username as u };
|