better-auth 0.4.0 → 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/client/plugins.d.ts +197 -5
- package/dist/client/plugins.js +9 -0
- package/package.json +1 -1
package/dist/client/plugins.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import { o as organization, j as Organization, M as Member, I as Invitation, u a
|
|
|
6
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
8
|
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-C6jmDLjB.js';
|
|
9
|
-
import '
|
|
10
|
-
import 'zod';
|
|
11
|
-
import '
|
|
12
|
-
import '
|
|
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,
|