@better-auth/electron 1.7.0-beta.3 → 1.7.0-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.
@@ -1,5 +1,7 @@
1
1
  import electron from "electron";
2
2
  import * as z from "zod";
3
+ import * as jose from "jose";
4
+ import { JWTVerifyGetKey } from "jose";
3
5
  import { Database } from "bun:sqlite";
4
6
  import { DatabaseSync } from "node:sqlite";
5
7
  import { D1Database } from "@cloudflare/workers-types";
@@ -30,6 +32,7 @@ type DBAdapterDebugLogOption = boolean | {
30
32
  findMany?: boolean | undefined;
31
33
  delete?: boolean | undefined;
32
34
  deleteMany?: boolean | undefined;
35
+ consumeOne?: boolean | undefined;
33
36
  count?: boolean | undefined;
34
37
  } | {
35
38
  /**
@@ -205,7 +208,7 @@ interface DBAdapterFactoryConfig<Options extends BetterAuthOptions = BetterAuthO
205
208
  /**
206
209
  * The action which was called from the adapter.
207
210
  */
208
- action: "create" | "update" | "findOne" | "findMany" | "updateMany" | "delete" | "deleteMany" | "count";
211
+ action: "create" | "update" | "findOne" | "findMany" | "updateMany" | "delete" | "deleteMany" | "consumeOne" | "count";
209
212
  /**
210
213
  * The model name.
211
214
  */
@@ -423,6 +426,26 @@ type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
423
426
  model: string;
424
427
  where: Where[];
425
428
  }) => Promise<number>;
429
+ /**
430
+ * Atomically consume a single row matching the where clause: delete it and
431
+ * return the deleted row, or return `null` if no row matched.
432
+ * Implementations MUST NOT delete any additional rows that also match a
433
+ * non-unique predicate.
434
+ *
435
+ * Under concurrent invocation against the same row, exactly one caller
436
+ * receives the row; subsequent racers receive `null`. This is the
437
+ * race-safe primitive for consuming single-use credentials
438
+ * (verification tokens, authorization codes, one-time tokens).
439
+ *
440
+ * Always defined on the factory-wrapped adapter. When the underlying
441
+ * `CustomAdapter` does not implement `consumeOne`, the factory provides
442
+ * a fallback that wraps `findMany + deleteMany` in `transaction(...)`
443
+ * and returns the row only when the delete reports an affected row.
444
+ */
445
+ consumeOne: <T>(data: {
446
+ model: string;
447
+ where: Where[];
448
+ }) => Promise<T | null>;
426
449
  /**
427
450
  * Execute multiple operations in a transaction.
428
451
  * If the adapter doesn't support transactions, operations will be executed sequentially.
@@ -504,6 +527,19 @@ interface CustomAdapter {
504
527
  model: string;
505
528
  where: CleanedWhere[];
506
529
  }) => Promise<number>;
530
+ /**
531
+ * Optional native atomic single-row consume. When omitted, the adapter
532
+ * factory falls back to `transaction(findMany + deleteMany)`.
533
+ * Implementing this method natively (e.g. `DELETE ... RETURNING *`,
534
+ * `findOneAndDelete`, `OUTPUT deleted.*`) gives one round trip and the
535
+ * strongest race-safety guarantee. Implementations must delete at most
536
+ * one matching row. TODO(consume-one-required): tighten to required in the
537
+ * next minor on `next`.
538
+ */
539
+ consumeOne?: <T>(data: {
540
+ model: string;
541
+ where: CleanedWhere[];
542
+ }) => Promise<T | null>;
507
543
  count: ({
508
544
  model,
509
545
  where
@@ -610,6 +646,52 @@ declare const createLogger: (options?: Logger | undefined) => InternalLogger;
610
646
  //#endregion
611
647
  //#region ../core/dist/oauth2/oauth-provider.d.mts
612
648
  //#region src/oauth2/oauth-provider.d.ts
649
+ /**
650
+ * id_token verification config for a social provider.
651
+ *
652
+ * Declares how a client-submitted id_token is verified. The shared verifier
653
+ * (`verifyProviderIdToken`) consumes this instead of each provider implementing its own
654
+ * boolean check, so verification is centralized and fail-closed: a provider without a config
655
+ * cannot accept a forged token by omission.
656
+ */
657
+ type OAuthIdTokenConfig = {
658
+ /**
659
+ * JWKS resolver used to verify the JWS signature. Accepts a jose
660
+ * `createRemoteJWKSet` resolver or a key-resolving function
661
+ * `(protectedHeader) => key`.
662
+ */
663
+ jwks: JWTVerifyGetKey; /** Expected `iss`. Omit for providers whose issuer varies per tenant. */
664
+ issuer?: (string | string[]) | undefined; /** Expected `aud`, usually the client ID. */
665
+ audience: string | string[]; /** Permitted JWS algorithms. Defaults to the token's `alg` header. */
666
+ algorithms?: string[] | undefined; /** Maximum token age passed to jose (e.g. `"1h"`). */
667
+ maxTokenAge?: string | undefined;
668
+ /**
669
+ * How the `nonce` claim is compared to the expected nonce.
670
+ * - `"exact"` (default): strict equality.
671
+ * - `"exact-or-sha256"`: matches the raw nonce or its SHA-256 hex digest (Apple).
672
+ */
673
+ nonceComparison?: ("exact" | "exact-or-sha256") | undefined;
674
+ /**
675
+ * Accept non-JWS (opaque) tokens without signature verification. Identity is then
676
+ * resolved by getUserInfo from the access token via the provider userinfo endpoint,
677
+ * which validates it (e.g. Facebook Graph access tokens).
678
+ */
679
+ allowOpaqueToken?: boolean | undefined;
680
+ /**
681
+ * Provider-specific claim check applied after the signature, issuer,
682
+ * audience, max-age, and nonce checks pass. Return `false` to reject the
683
+ * token. Used to enforce constraints the standard checks cannot express,
684
+ * e.g. Google's hosted-domain (`hd`) restriction. Omitted by providers
685
+ * that have no extra claim requirement.
686
+ */
687
+ verifyClaims?: ((claims: Record<string, unknown>) => boolean) | undefined;
688
+ } | {
689
+ /**
690
+ * Custom verifier for providers that cannot verify against a local JWKS, such as a
691
+ * remote verification endpoint (e.g. LINE).
692
+ */
693
+ verify: (token: string, nonce?: string) => Promise<boolean>;
694
+ };
613
695
  interface OAuth2Tokens {
614
696
  tokenType?: string | undefined;
615
697
  accessToken?: string | undefined;
@@ -631,8 +713,58 @@ type OAuth2UserInfo = {
631
713
  image?: string | undefined;
632
714
  emailVerified: boolean;
633
715
  };
634
- interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
716
+ /**
717
+ * The result of building a provider authorization URL.
718
+ *
719
+ * `requestedScopes` is the effective set of scopes encoded in the URL (the
720
+ * provider's built-in defaults + configured `options.scope` + per-request
721
+ * `scopes`, composed by `resolveRequestedScopes`). Callers persist it so the
722
+ * callback can fall back to the request when the provider omits `scope` from
723
+ * its token response (RFC 6749 §5.1).
724
+ */
725
+ interface AuthorizationURLResult {
726
+ url: URL;
727
+ requestedScopes: string[];
728
+ }
729
+ /**
730
+ * How much an RP trusts a provider's echoed token-response `scope` when
731
+ * persisting `account.grantedScopes`.
732
+ *
733
+ * - `"full-grant"`: the echo is the user's complete current grant, so the seam
734
+ * replaces the stored grant with it. This is the only path that may narrow
735
+ * the grant. Declare it only for providers whose token response reports the
736
+ * full combined grant, e.g. Google with `include_granted_scopes`.
737
+ * - `"projection"`: the echo is this request's subset, so the seam unions it
738
+ * onto the stored grant. The safe default for every provider.
739
+ * - `"absent-echo"`: the provider omitted `scope`, so the grant equals what was
740
+ * requested (RFC 6749 §5.1) and the seam unions the requested set. Resolved
741
+ * at runtime by the persistence seam, never declared by a provider.
742
+ *
743
+ * @see https://www.rfc-editor.org/rfc/rfc6749#section-5.1
744
+ */
745
+ type GrantAuthority = "full-grant" | "projection" | "absent-echo";
746
+ /**
747
+ * The authority a provider may declare for its own echoed scope. `"absent-echo"`
748
+ * is excluded because it is a runtime condition (an omitted echo), not a
749
+ * provider trait.
750
+ */
751
+ type ProviderGrantAuthority = Exclude<GrantAuthority, "absent-echo">;
752
+ interface UpstreamProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
635
753
  id: LiteralString;
754
+ /**
755
+ * The path the provider redirects back to, relative to the app base URL,
756
+ * e.g. `/callback/google`.
757
+ */
758
+ callbackPath: string;
759
+ /**
760
+ * How the persistence seam treats this provider's echoed token-response
761
+ * `scope`. Declare `"full-grant"` only when the echo is the user's complete
762
+ * current grant (e.g. Google with `include_granted_scopes`); otherwise the
763
+ * echo is unioned onto the stored grant.
764
+ *
765
+ * @default "projection"
766
+ */
767
+ grantAuthority?: ProviderGrantAuthority | undefined;
636
768
  createAuthorizationURL: (data: {
637
769
  state: string;
638
770
  codeVerifier: string;
@@ -640,7 +772,14 @@ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O e
640
772
  redirectURI: string;
641
773
  display?: string | undefined;
642
774
  loginHint?: string | undefined;
643
- }) => Awaitable<URL>;
775
+ /**
776
+ * Extra query parameters to append to the authorization URL.
777
+ * Providers forward these to the shared `createAuthorizationURL` helper,
778
+ * which drops any keys present in `RESERVED_AUTHORIZATION_PARAMS`
779
+ * before applying them.
780
+ */
781
+ additionalParams?: Record<string, string> | undefined;
782
+ }) => Awaitable<AuthorizationURLResult>;
644
783
  name: string;
645
784
  validateAuthorizationCode: (data: {
646
785
  code: string;
@@ -668,14 +807,12 @@ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O e
668
807
  * Custom function to refresh a token
669
808
  */
670
809
  refreshAccessToken?: ((refreshToken: string) => Promise<OAuth2Tokens>) | undefined;
671
- revokeToken?: ((token: string) => Promise<void>) | undefined;
672
810
  /**
673
- * Verify the id token
674
- * @param token - The id token
675
- * @param nonce - The nonce
676
- * @returns True if the id token is valid, false otherwise
811
+ * Declarative id_token verification config consumed by the shared
812
+ * `verifyProviderIdToken` verifier. Providers set this instead of implementing a boolean
813
+ * verify method, which keeps verification centralized and fail-closed.
677
814
  */
678
- verifyIdToken?: ((token: string, nonce?: string) => Promise<boolean>) | undefined;
815
+ idToken?: OAuthIdTokenConfig | undefined;
679
816
  /**
680
817
  * The expected issuer identifier for this provider (RFC 9207).
681
818
  * When set, the callback handler validates the `iss` query parameter
@@ -691,6 +828,17 @@ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O e
691
828
  * Disable sign up for new users.
692
829
  */
693
830
  disableSignUp?: boolean | undefined;
831
+ /**
832
+ * Accept callbacks that arrive without a `state` parameter. When true,
833
+ * the shared OAuth callback handler restarts the flow server-side with
834
+ * fresh `state` and PKCE instead of rejecting the request. Intended for
835
+ * providers that initiate OAuth without RP-side flow kickoff (e.g.
836
+ * Clever). Leave unset for any provider that always initiates from the
837
+ * RP.
838
+ *
839
+ * @default false
840
+ */
841
+ allowIdpInitiated?: boolean | undefined;
694
842
  /**
695
843
  * Options for the provider
696
844
  */
@@ -700,9 +848,10 @@ type ProviderOptions<Profile extends Record<string, any> = any> = {
700
848
  /**
701
849
  * The client ID of your application.
702
850
  *
703
- * This is usually a string but can be any type depending on the provider.
851
+ * Some providers accept multiple platform client IDs. The first entry is the
852
+ * primary client ID used for token endpoint client authentication.
704
853
  */
705
- clientId?: unknown | undefined;
854
+ clientId?: LiteralString | string[] | undefined;
706
855
  /**
707
856
  * The client secret of your application
708
857
  */
@@ -803,6 +952,29 @@ type ProviderOptions<Profile extends Record<string, any> = any> = {
803
952
  * @default false
804
953
  */
805
954
  overrideUserInfoOnSignIn?: boolean | undefined;
955
+ /**
956
+ * Require this provider's email to be verified before a session is created.
957
+ *
958
+ * When the provider reports the email as unverified, the user and account are
959
+ * still created/linked, but no session is issued: the OAuth callback redirects
960
+ * with `?error=email_not_verified` and id-token sign-in returns a `403`
961
+ * `EMAIL_NOT_VERIFIED`. A verification email is (re)sent per the
962
+ * `emailVerification` settings (`sendOnSignUp` / `sendOnSignIn`).
963
+ *
964
+ * The gate checks the local user's verification state, not the provider's
965
+ * claim on each request: a user already verified through another method (or a
966
+ * prior verified sign-in) keeps access even if the provider later reports the
967
+ * email as unverified.
968
+ *
969
+ * This is opt-in per provider and is independent of
970
+ * `emailAndPassword.requireEmailVerification`; enabling that does not gate
971
+ * social sign-in. Only enable it for providers that report a trustworthy
972
+ * `email_verified` signal: several providers always report the email as
973
+ * unverified, which would block every sign-in.
974
+ *
975
+ * @default false
976
+ */
977
+ requireEmailVerification?: boolean | undefined;
806
978
  }; //#endregion
807
979
  //#endregion
808
980
  //#region ../core/dist/social-providers/apple.d.mts
@@ -925,6 +1097,19 @@ interface CognitoOptions extends ProviderOptions<CognitoProfile> {
925
1097
  region: string;
926
1098
  userPoolId: string;
927
1099
  requireClientSecret?: boolean | undefined;
1100
+ /**
1101
+ * Skip the Cognito hosted-UI identity-provider picker by preselecting an
1102
+ * IdP (maps to the `identity_provider` query parameter on the authorize
1103
+ * request). Accepts `"COGNITO"`, a SAML/OIDC provider name configured on
1104
+ * the User Pool, or one of the social providers (`"Google"`, `"Facebook"`,
1105
+ * `"LoginWithAmazon"`, `"SignInWithApple"`).
1106
+ *
1107
+ * Per-request overrides via `signIn.social({ additionalParams: { identity_provider } })`
1108
+ * take precedence over this value.
1109
+ *
1110
+ * @see https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html
1111
+ */
1112
+ identityProvider?: string | undefined;
928
1113
  }
929
1114
  //#endregion
930
1115
  //#region ../core/dist/social-providers/discord.d.mts
@@ -1098,6 +1283,15 @@ interface GithubOptions extends ProviderOptions<GithubProfile> {
1098
1283
  clientId: string;
1099
1284
  }
1100
1285
  //#endregion
1286
+ //#region ../core/dist/oauth2/client-assertion.d.mts
1287
+ type ClientAssertionGrantType = "authorization_code" | "refresh_token" | "client_credentials";
1288
+ interface ClientAssertionContext {
1289
+ clientId: string;
1290
+ tokenEndpoint: string;
1291
+ grantType: ClientAssertionGrantType;
1292
+ }
1293
+ type ClientAssertionGetter = (context: ClientAssertionContext) => Awaitable<string>;
1294
+ //#endregion
1101
1295
  //#region ../core/dist/social-providers/microsoft-entra-id.d.mts
1102
1296
  //#region src/social-providers/microsoft-entra-id.d.ts
1103
1297
  /**
@@ -1209,21 +1403,29 @@ interface MicrosoftOptions extends ProviderOptions<MicrosoftEntraIDProfile> {
1209
1403
  * The tenant ID of the Microsoft account
1210
1404
  * @default "common"
1211
1405
  */
1212
- tenantId?: string | undefined;
1406
+ tenantId?: string;
1213
1407
  /**
1214
1408
  * The authentication authority URL. Use the default "https://login.microsoftonline.com" for standard Entra ID or "https://<tenant-id>.ciamlogin.com" for CIAM scenarios.
1215
1409
  * @default "https://login.microsoftonline.com"
1216
1410
  */
1217
- authority?: string | undefined;
1411
+ authority?: string;
1412
+ /**
1413
+ * Function that returns a JWT client assertion for token endpoint authentication.
1414
+ *
1415
+ * Use this instead of `clientSecret` when your Microsoft Entra ID app is
1416
+ * configured for client authentication with assertions (private_key_jwt or
1417
+ * workload identity federation).
1418
+ */
1419
+ clientAssertion?: ClientAssertionGetter;
1218
1420
  /**
1219
1421
  * The size of the profile photo
1220
1422
  * @default 48
1221
1423
  */
1222
- profilePhotoSize?: (48 | 64 | 96 | 120 | 240 | 360 | 432 | 504 | 648) | undefined;
1424
+ profilePhotoSize?: 48 | 64 | 96 | 120 | 240 | 360 | 432 | 504 | 648;
1223
1425
  /**
1224
1426
  * Disable profile photo
1225
1427
  */
1226
- disableProfilePhoto?: boolean | undefined;
1428
+ disableProfilePhoto?: boolean;
1227
1429
  }
1228
1430
  //#endregion
1229
1431
  //#region ../core/dist/social-providers/google.d.mts
@@ -1265,9 +1467,22 @@ interface GoogleOptions extends ProviderOptions<GoogleProfile> {
1265
1467
  */
1266
1468
  display?: ("page" | "popup" | "touch" | "wap") | undefined;
1267
1469
  /**
1268
- * The hosted domain of the user
1470
+ * The hosted domain (Google Workspace) the user must belong to.
1471
+ *
1472
+ * This is sent to Google as the `hd` authorization hint and, when set, is
1473
+ * also enforced against the `hd` claim of the returned id token/profile.
1474
+ * Sign-in is rejected when the claim is missing or does not match, so this
1475
+ * can be used to restrict sign-in to a Workspace domain.
1269
1476
  */
1270
1477
  hd?: string | undefined;
1478
+ /**
1479
+ * Enable incremental authorization via Google's `include_granted_scopes`
1480
+ * parameter. When enabled, Google reports the user's full granted scope set
1481
+ * in the token response.
1482
+ *
1483
+ * @default true
1484
+ */
1485
+ includeGrantedScopes?: boolean | undefined;
1271
1486
  }
1272
1487
  //#endregion
1273
1488
  //#region ../core/dist/social-providers/huggingface.d.mts
@@ -2138,10 +2353,12 @@ declare const socialProviders: {
2138
2353
  apple: (options: AppleOptions) => {
2139
2354
  id: "apple";
2140
2355
  name: string;
2356
+ callbackPath: string;
2141
2357
  createAuthorizationURL({
2142
2358
  state,
2143
2359
  scopes,
2144
- redirectURI
2360
+ redirectURI,
2361
+ additionalParams
2145
2362
  }: {
2146
2363
  state: string;
2147
2364
  codeVerifier: string;
@@ -2149,7 +2366,11 @@ declare const socialProviders: {
2149
2366
  redirectURI: string;
2150
2367
  display?: string | undefined;
2151
2368
  loginHint?: string | undefined;
2152
- }): Promise<URL>;
2369
+ additionalParams?: Record<string, string> | undefined;
2370
+ }): Promise<{
2371
+ url: URL;
2372
+ requestedScopes: string[];
2373
+ }>;
2153
2374
  validateAuthorizationCode: ({
2154
2375
  code,
2155
2376
  codeVerifier,
@@ -2160,7 +2381,13 @@ declare const socialProviders: {
2160
2381
  codeVerifier?: string | undefined;
2161
2382
  deviceId?: string | undefined;
2162
2383
  }) => Promise<OAuth2Tokens>;
2163
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
2384
+ idToken: {
2385
+ jwks: (header: jose.JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
2386
+ issuer: string;
2387
+ audience: string | string[];
2388
+ maxTokenAge: string;
2389
+ nonceComparison: "exact-or-sha256";
2390
+ };
2164
2391
  refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
2165
2392
  getUserInfo(token: OAuth2Tokens & {
2166
2393
  user?: {
@@ -2186,11 +2413,13 @@ declare const socialProviders: {
2186
2413
  atlassian: (options: AtlassianOptions) => {
2187
2414
  id: "atlassian";
2188
2415
  name: string;
2416
+ callbackPath: string;
2189
2417
  createAuthorizationURL({
2190
2418
  state,
2191
2419
  scopes,
2192
2420
  codeVerifier,
2193
- redirectURI
2421
+ redirectURI,
2422
+ additionalParams
2194
2423
  }: {
2195
2424
  state: string;
2196
2425
  codeVerifier: string;
@@ -2198,7 +2427,11 @@ declare const socialProviders: {
2198
2427
  redirectURI: string;
2199
2428
  display?: string | undefined;
2200
2429
  loginHint?: string | undefined;
2201
- }): Promise<URL>;
2430
+ additionalParams?: Record<string, string> | undefined;
2431
+ }): Promise<{
2432
+ url: URL;
2433
+ requestedScopes: string[];
2434
+ }>;
2202
2435
  validateAuthorizationCode: ({
2203
2436
  code,
2204
2437
  codeVerifier,
@@ -2234,11 +2467,13 @@ declare const socialProviders: {
2234
2467
  cognito: (options: CognitoOptions) => {
2235
2468
  id: "cognito";
2236
2469
  name: string;
2470
+ callbackPath: string;
2237
2471
  createAuthorizationURL({
2238
2472
  state,
2239
2473
  scopes,
2240
2474
  codeVerifier,
2241
- redirectURI
2475
+ redirectURI,
2476
+ additionalParams
2242
2477
  }: {
2243
2478
  state: string;
2244
2479
  codeVerifier: string;
@@ -2246,7 +2481,11 @@ declare const socialProviders: {
2246
2481
  redirectURI: string;
2247
2482
  display?: string | undefined;
2248
2483
  loginHint?: string | undefined;
2249
- }): Promise<URL>;
2484
+ additionalParams?: Record<string, string> | undefined;
2485
+ }): Promise<{
2486
+ url: URL;
2487
+ requestedScopes: string[];
2488
+ }>;
2250
2489
  validateAuthorizationCode: ({
2251
2490
  code,
2252
2491
  codeVerifier,
@@ -2258,7 +2497,12 @@ declare const socialProviders: {
2258
2497
  deviceId?: string | undefined;
2259
2498
  }) => Promise<OAuth2Tokens>;
2260
2499
  refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
2261
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
2500
+ idToken: {
2501
+ jwks: (header: jose.JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
2502
+ issuer: string;
2503
+ audience: string | string[];
2504
+ maxTokenAge: string;
2505
+ };
2262
2506
  getUserInfo(token: OAuth2Tokens & {
2263
2507
  user?: {
2264
2508
  name?: {
@@ -2283,10 +2527,12 @@ declare const socialProviders: {
2283
2527
  discord: (options: DiscordOptions) => {
2284
2528
  id: "discord";
2285
2529
  name: string;
2530
+ callbackPath: string;
2286
2531
  createAuthorizationURL({
2287
2532
  state,
2288
2533
  scopes,
2289
- redirectURI
2534
+ redirectURI,
2535
+ additionalParams
2290
2536
  }: {
2291
2537
  state: string;
2292
2538
  codeVerifier: string;
@@ -2294,7 +2540,11 @@ declare const socialProviders: {
2294
2540
  redirectURI: string;
2295
2541
  display?: string | undefined;
2296
2542
  loginHint?: string | undefined;
2297
- }): URL;
2543
+ additionalParams?: Record<string, string> | undefined;
2544
+ }): Promise<{
2545
+ url: URL;
2546
+ requestedScopes: string[];
2547
+ }>;
2298
2548
  validateAuthorizationCode: ({
2299
2549
  code,
2300
2550
  redirectURI
@@ -2329,11 +2579,13 @@ declare const socialProviders: {
2329
2579
  facebook: (options: FacebookOptions) => {
2330
2580
  id: "facebook";
2331
2581
  name: string;
2582
+ callbackPath: string;
2332
2583
  createAuthorizationURL({
2333
2584
  state,
2334
2585
  scopes,
2335
2586
  redirectURI,
2336
- loginHint
2587
+ loginHint,
2588
+ additionalParams
2337
2589
  }: {
2338
2590
  state: string;
2339
2591
  codeVerifier: string;
@@ -2341,7 +2593,11 @@ declare const socialProviders: {
2341
2593
  redirectURI: string;
2342
2594
  display?: string | undefined;
2343
2595
  loginHint?: string | undefined;
2344
- }): Promise<URL>;
2596
+ additionalParams?: Record<string, string> | undefined;
2597
+ }): Promise<{
2598
+ url: URL;
2599
+ requestedScopes: string[];
2600
+ }>;
2345
2601
  validateAuthorizationCode: ({
2346
2602
  code,
2347
2603
  redirectURI
@@ -2351,7 +2607,20 @@ declare const socialProviders: {
2351
2607
  codeVerifier?: string | undefined;
2352
2608
  deviceId?: string | undefined;
2353
2609
  }) => Promise<OAuth2Tokens>;
2354
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
2610
+ idToken: {
2611
+ jwks: {
2612
+ (protectedHeader?: jose.JWSHeaderParameters, token?: jose.FlattenedJWSInput): Promise<jose.CryptoKey>;
2613
+ coolingDown: boolean;
2614
+ fresh: boolean;
2615
+ reloading: boolean;
2616
+ reload: () => Promise<void>;
2617
+ jwks: () => jose.JSONWebKeySet | undefined;
2618
+ };
2619
+ issuer: string;
2620
+ audience: string | string[];
2621
+ algorithms: string[];
2622
+ allowOpaqueToken: true;
2623
+ };
2355
2624
  refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
2356
2625
  getUserInfo(token: OAuth2Tokens & {
2357
2626
  user?: {
@@ -2377,11 +2646,13 @@ declare const socialProviders: {
2377
2646
  figma: (options: FigmaOptions) => {
2378
2647
  id: "figma";
2379
2648
  name: string;
2649
+ callbackPath: string;
2380
2650
  createAuthorizationURL({
2381
2651
  state,
2382
2652
  scopes,
2383
2653
  codeVerifier,
2384
- redirectURI
2654
+ redirectURI,
2655
+ additionalParams
2385
2656
  }: {
2386
2657
  state: string;
2387
2658
  codeVerifier: string;
@@ -2389,7 +2660,11 @@ declare const socialProviders: {
2389
2660
  redirectURI: string;
2390
2661
  display?: string | undefined;
2391
2662
  loginHint?: string | undefined;
2392
- }): Promise<URL>;
2663
+ additionalParams?: Record<string, string> | undefined;
2664
+ }): Promise<{
2665
+ url: URL;
2666
+ requestedScopes: string[];
2667
+ }>;
2393
2668
  validateAuthorizationCode: ({
2394
2669
  code,
2395
2670
  codeVerifier,
@@ -2425,12 +2700,14 @@ declare const socialProviders: {
2425
2700
  github: (options: GithubOptions) => {
2426
2701
  id: "github";
2427
2702
  name: string;
2703
+ callbackPath: string;
2428
2704
  createAuthorizationURL({
2429
2705
  state,
2430
2706
  scopes,
2431
2707
  loginHint,
2432
2708
  codeVerifier,
2433
- redirectURI
2709
+ redirectURI,
2710
+ additionalParams
2434
2711
  }: {
2435
2712
  state: string;
2436
2713
  codeVerifier: string;
@@ -2438,7 +2715,11 @@ declare const socialProviders: {
2438
2715
  redirectURI: string;
2439
2716
  display?: string | undefined;
2440
2717
  loginHint?: string | undefined;
2441
- }): Promise<URL>;
2718
+ additionalParams?: Record<string, string> | undefined;
2719
+ }): Promise<{
2720
+ url: URL;
2721
+ requestedScopes: string[];
2722
+ }>;
2442
2723
  validateAuthorizationCode: ({
2443
2724
  code,
2444
2725
  codeVerifier,
@@ -2474,6 +2755,7 @@ declare const socialProviders: {
2474
2755
  microsoft: (options: MicrosoftOptions) => {
2475
2756
  id: "microsoft";
2476
2757
  name: string;
2758
+ callbackPath: string;
2477
2759
  createAuthorizationURL(data: {
2478
2760
  state: string;
2479
2761
  codeVerifier: string;
@@ -2481,7 +2763,11 @@ declare const socialProviders: {
2481
2763
  redirectURI: string;
2482
2764
  display?: string | undefined;
2483
2765
  loginHint?: string | undefined;
2484
- }): Promise<URL>;
2766
+ additionalParams?: Record<string, string> | undefined;
2767
+ }): Promise<{
2768
+ url: URL;
2769
+ requestedScopes: string[];
2770
+ }>;
2485
2771
  validateAuthorizationCode({
2486
2772
  code,
2487
2773
  codeVerifier,
@@ -2492,7 +2778,12 @@ declare const socialProviders: {
2492
2778
  codeVerifier?: string | undefined;
2493
2779
  deviceId?: string | undefined;
2494
2780
  }): Promise<OAuth2Tokens>;
2495
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
2781
+ idToken: {
2782
+ jwks: (header: jose.JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
2783
+ audience: string | string[];
2784
+ maxTokenAge: string;
2785
+ issuer: string | undefined;
2786
+ };
2496
2787
  getUserInfo(token: OAuth2Tokens & {
2497
2788
  user?: {
2498
2789
  name?: {
@@ -2518,13 +2809,16 @@ declare const socialProviders: {
2518
2809
  google: (options: GoogleOptions) => {
2519
2810
  id: "google";
2520
2811
  name: string;
2812
+ callbackPath: string;
2813
+ grantAuthority: "full-grant" | "projection";
2521
2814
  createAuthorizationURL({
2522
2815
  state,
2523
2816
  scopes,
2524
2817
  codeVerifier,
2525
2818
  redirectURI,
2526
2819
  loginHint,
2527
- display
2820
+ display,
2821
+ additionalParams
2528
2822
  }: {
2529
2823
  state: string;
2530
2824
  codeVerifier: string;
@@ -2532,7 +2826,11 @@ declare const socialProviders: {
2532
2826
  redirectURI: string;
2533
2827
  display?: string | undefined;
2534
2828
  loginHint?: string | undefined;
2535
- }): Promise<URL>;
2829
+ additionalParams?: Record<string, string> | undefined;
2830
+ }): Promise<{
2831
+ url: URL;
2832
+ requestedScopes: string[];
2833
+ }>;
2536
2834
  validateAuthorizationCode: ({
2537
2835
  code,
2538
2836
  codeVerifier,
@@ -2544,7 +2842,13 @@ declare const socialProviders: {
2544
2842
  deviceId?: string | undefined;
2545
2843
  }) => Promise<OAuth2Tokens>;
2546
2844
  refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
2547
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
2845
+ idToken: {
2846
+ jwks: (header: jose.JWTHeaderParameters) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
2847
+ issuer: string[];
2848
+ audience: string | string[];
2849
+ maxTokenAge: string;
2850
+ verifyClaims: ((claims: Record<string, unknown>) => boolean) | undefined;
2851
+ };
2548
2852
  getUserInfo(token: OAuth2Tokens & {
2549
2853
  user?: {
2550
2854
  name?: {
@@ -2569,11 +2873,13 @@ declare const socialProviders: {
2569
2873
  huggingface: (options: HuggingFaceOptions) => {
2570
2874
  id: "huggingface";
2571
2875
  name: string;
2876
+ callbackPath: string;
2572
2877
  createAuthorizationURL({
2573
2878
  state,
2574
2879
  scopes,
2575
2880
  codeVerifier,
2576
- redirectURI
2881
+ redirectURI,
2882
+ additionalParams
2577
2883
  }: {
2578
2884
  state: string;
2579
2885
  codeVerifier: string;
@@ -2581,7 +2887,11 @@ declare const socialProviders: {
2581
2887
  redirectURI: string;
2582
2888
  display?: string | undefined;
2583
2889
  loginHint?: string | undefined;
2584
- }): Promise<URL>;
2890
+ additionalParams?: Record<string, string> | undefined;
2891
+ }): Promise<{
2892
+ url: URL;
2893
+ requestedScopes: string[];
2894
+ }>;
2585
2895
  validateAuthorizationCode: ({
2586
2896
  code,
2587
2897
  codeVerifier,
@@ -2617,10 +2927,12 @@ declare const socialProviders: {
2617
2927
  slack: (options: SlackOptions) => {
2618
2928
  id: "slack";
2619
2929
  name: string;
2930
+ callbackPath: string;
2620
2931
  createAuthorizationURL({
2621
2932
  state,
2622
2933
  scopes,
2623
- redirectURI
2934
+ redirectURI,
2935
+ additionalParams
2624
2936
  }: {
2625
2937
  state: string;
2626
2938
  codeVerifier: string;
@@ -2628,7 +2940,11 @@ declare const socialProviders: {
2628
2940
  redirectURI: string;
2629
2941
  display?: string | undefined;
2630
2942
  loginHint?: string | undefined;
2631
- }): URL;
2943
+ additionalParams?: Record<string, string> | undefined;
2944
+ }): Promise<{
2945
+ url: URL;
2946
+ requestedScopes: string[];
2947
+ }>;
2632
2948
  validateAuthorizationCode: ({
2633
2949
  code,
2634
2950
  redirectURI
@@ -2663,11 +2979,13 @@ declare const socialProviders: {
2663
2979
  spotify: (options: SpotifyOptions) => {
2664
2980
  id: "spotify";
2665
2981
  name: string;
2982
+ callbackPath: string;
2666
2983
  createAuthorizationURL({
2667
2984
  state,
2668
2985
  scopes,
2669
2986
  codeVerifier,
2670
- redirectURI
2987
+ redirectURI,
2988
+ additionalParams
2671
2989
  }: {
2672
2990
  state: string;
2673
2991
  codeVerifier: string;
@@ -2675,7 +2993,11 @@ declare const socialProviders: {
2675
2993
  redirectURI: string;
2676
2994
  display?: string | undefined;
2677
2995
  loginHint?: string | undefined;
2678
- }): Promise<URL>;
2996
+ additionalParams?: Record<string, string> | undefined;
2997
+ }): Promise<{
2998
+ url: URL;
2999
+ requestedScopes: string[];
3000
+ }>;
2679
3001
  validateAuthorizationCode: ({
2680
3002
  code,
2681
3003
  codeVerifier,
@@ -2711,10 +3033,12 @@ declare const socialProviders: {
2711
3033
  twitch: (options: TwitchOptions) => {
2712
3034
  id: "twitch";
2713
3035
  name: string;
3036
+ callbackPath: string;
2714
3037
  createAuthorizationURL({
2715
3038
  state,
2716
3039
  scopes,
2717
- redirectURI
3040
+ redirectURI,
3041
+ additionalParams
2718
3042
  }: {
2719
3043
  state: string;
2720
3044
  codeVerifier: string;
@@ -2722,7 +3046,11 @@ declare const socialProviders: {
2722
3046
  redirectURI: string;
2723
3047
  display?: string | undefined;
2724
3048
  loginHint?: string | undefined;
2725
- }): Promise<URL>;
3049
+ additionalParams?: Record<string, string> | undefined;
3050
+ }): Promise<{
3051
+ url: URL;
3052
+ requestedScopes: string[];
3053
+ }>;
2726
3054
  validateAuthorizationCode: ({
2727
3055
  code,
2728
3056
  redirectURI
@@ -2757,6 +3085,7 @@ declare const socialProviders: {
2757
3085
  twitter: (options: TwitterOption) => {
2758
3086
  id: "twitter";
2759
3087
  name: string;
3088
+ callbackPath: string;
2760
3089
  createAuthorizationURL(data: {
2761
3090
  state: string;
2762
3091
  codeVerifier: string;
@@ -2764,7 +3093,11 @@ declare const socialProviders: {
2764
3093
  redirectURI: string;
2765
3094
  display?: string | undefined;
2766
3095
  loginHint?: string | undefined;
2767
- }): Promise<URL>;
3096
+ additionalParams?: Record<string, string> | undefined;
3097
+ }): Promise<{
3098
+ url: URL;
3099
+ requestedScopes: string[];
3100
+ }>;
2768
3101
  validateAuthorizationCode: ({
2769
3102
  code,
2770
3103
  codeVerifier,
@@ -2800,11 +3133,13 @@ declare const socialProviders: {
2800
3133
  dropbox: (options: DropboxOptions) => {
2801
3134
  id: "dropbox";
2802
3135
  name: string;
3136
+ callbackPath: string;
2803
3137
  createAuthorizationURL: ({
2804
3138
  state,
2805
3139
  scopes,
2806
3140
  codeVerifier,
2807
- redirectURI
3141
+ redirectURI,
3142
+ additionalParams
2808
3143
  }: {
2809
3144
  state: string;
2810
3145
  codeVerifier: string;
@@ -2812,7 +3147,11 @@ declare const socialProviders: {
2812
3147
  redirectURI: string;
2813
3148
  display?: string | undefined;
2814
3149
  loginHint?: string | undefined;
2815
- }) => Promise<URL>;
3150
+ additionalParams?: Record<string, string> | undefined;
3151
+ }) => Promise<{
3152
+ url: URL;
3153
+ requestedScopes: string[];
3154
+ }>;
2816
3155
  validateAuthorizationCode: ({
2817
3156
  code,
2818
3157
  codeVerifier,
@@ -2848,11 +3187,13 @@ declare const socialProviders: {
2848
3187
  kick: (options: KickOptions) => {
2849
3188
  id: "kick";
2850
3189
  name: string;
3190
+ callbackPath: string;
2851
3191
  createAuthorizationURL({
2852
3192
  state,
2853
3193
  scopes,
2854
3194
  redirectURI,
2855
- codeVerifier
3195
+ codeVerifier,
3196
+ additionalParams
2856
3197
  }: {
2857
3198
  state: string;
2858
3199
  codeVerifier: string;
@@ -2860,7 +3201,11 @@ declare const socialProviders: {
2860
3201
  redirectURI: string;
2861
3202
  display?: string | undefined;
2862
3203
  loginHint?: string | undefined;
2863
- }): Promise<URL>;
3204
+ additionalParams?: Record<string, string> | undefined;
3205
+ }): Promise<{
3206
+ url: URL;
3207
+ requestedScopes: string[];
3208
+ }>;
2864
3209
  validateAuthorizationCode({
2865
3210
  code,
2866
3211
  redirectURI,
@@ -2896,11 +3241,13 @@ declare const socialProviders: {
2896
3241
  linear: (options: LinearOptions) => {
2897
3242
  id: "linear";
2898
3243
  name: string;
3244
+ callbackPath: string;
2899
3245
  createAuthorizationURL({
2900
3246
  state,
2901
3247
  scopes,
2902
3248
  loginHint,
2903
- redirectURI
3249
+ redirectURI,
3250
+ additionalParams
2904
3251
  }: {
2905
3252
  state: string;
2906
3253
  codeVerifier: string;
@@ -2908,7 +3255,11 @@ declare const socialProviders: {
2908
3255
  redirectURI: string;
2909
3256
  display?: string | undefined;
2910
3257
  loginHint?: string | undefined;
2911
- }): Promise<URL>;
3258
+ additionalParams?: Record<string, string> | undefined;
3259
+ }): Promise<{
3260
+ url: URL;
3261
+ requestedScopes: string[];
3262
+ }>;
2912
3263
  validateAuthorizationCode: ({
2913
3264
  code,
2914
3265
  redirectURI
@@ -2943,11 +3294,13 @@ declare const socialProviders: {
2943
3294
  linkedin: (options: LinkedInOptions) => {
2944
3295
  id: "linkedin";
2945
3296
  name: string;
3297
+ callbackPath: string;
2946
3298
  createAuthorizationURL: ({
2947
3299
  state,
2948
3300
  scopes,
2949
3301
  redirectURI,
2950
- loginHint
3302
+ loginHint,
3303
+ additionalParams
2951
3304
  }: {
2952
3305
  state: string;
2953
3306
  codeVerifier: string;
@@ -2955,7 +3308,11 @@ declare const socialProviders: {
2955
3308
  redirectURI: string;
2956
3309
  display?: string | undefined;
2957
3310
  loginHint?: string | undefined;
2958
- }) => Promise<URL>;
3311
+ additionalParams?: Record<string, string> | undefined;
3312
+ }) => Promise<{
3313
+ url: URL;
3314
+ requestedScopes: string[];
3315
+ }>;
2959
3316
  validateAuthorizationCode: ({
2960
3317
  code,
2961
3318
  redirectURI
@@ -2990,12 +3347,14 @@ declare const socialProviders: {
2990
3347
  gitlab: (options: GitlabOptions) => {
2991
3348
  id: "gitlab";
2992
3349
  name: string;
3350
+ callbackPath: string;
2993
3351
  createAuthorizationURL: ({
2994
3352
  state,
2995
3353
  scopes,
2996
3354
  codeVerifier,
2997
3355
  loginHint,
2998
- redirectURI
3356
+ redirectURI,
3357
+ additionalParams
2999
3358
  }: {
3000
3359
  state: string;
3001
3360
  codeVerifier: string;
@@ -3003,7 +3362,11 @@ declare const socialProviders: {
3003
3362
  redirectURI: string;
3004
3363
  display?: string | undefined;
3005
3364
  loginHint?: string | undefined;
3006
- }) => Promise<URL>;
3365
+ additionalParams?: Record<string, string> | undefined;
3366
+ }) => Promise<{
3367
+ url: URL;
3368
+ requestedScopes: string[];
3369
+ }>;
3007
3370
  validateAuthorizationCode: ({
3008
3371
  code,
3009
3372
  redirectURI,
@@ -3060,10 +3423,12 @@ declare const socialProviders: {
3060
3423
  tiktok: (options: TiktokOptions) => {
3061
3424
  id: "tiktok";
3062
3425
  name: string;
3426
+ callbackPath: string;
3063
3427
  createAuthorizationURL({
3064
3428
  state,
3065
3429
  scopes,
3066
- redirectURI
3430
+ redirectURI,
3431
+ additionalParams
3067
3432
  }: {
3068
3433
  state: string;
3069
3434
  codeVerifier: string;
@@ -3071,7 +3436,11 @@ declare const socialProviders: {
3071
3436
  redirectURI: string;
3072
3437
  display?: string | undefined;
3073
3438
  loginHint?: string | undefined;
3074
- }): URL;
3439
+ additionalParams?: Record<string, string> | undefined;
3440
+ }): {
3441
+ url: URL;
3442
+ requestedScopes: string[];
3443
+ };
3075
3444
  validateAuthorizationCode: ({
3076
3445
  code,
3077
3446
  redirectURI
@@ -3106,10 +3475,12 @@ declare const socialProviders: {
3106
3475
  reddit: (options: RedditOptions) => {
3107
3476
  id: "reddit";
3108
3477
  name: string;
3478
+ callbackPath: string;
3109
3479
  createAuthorizationURL({
3110
3480
  state,
3111
3481
  scopes,
3112
- redirectURI
3482
+ redirectURI,
3483
+ additionalParams
3113
3484
  }: {
3114
3485
  state: string;
3115
3486
  codeVerifier: string;
@@ -3117,7 +3488,11 @@ declare const socialProviders: {
3117
3488
  redirectURI: string;
3118
3489
  display?: string | undefined;
3119
3490
  loginHint?: string | undefined;
3120
- }): Promise<URL>;
3491
+ additionalParams?: Record<string, string> | undefined;
3492
+ }): Promise<{
3493
+ url: URL;
3494
+ requestedScopes: string[];
3495
+ }>;
3121
3496
  validateAuthorizationCode: ({
3122
3497
  code,
3123
3498
  redirectURI
@@ -3152,10 +3527,12 @@ declare const socialProviders: {
3152
3527
  roblox: (options: RobloxOptions) => {
3153
3528
  id: "roblox";
3154
3529
  name: string;
3530
+ callbackPath: string;
3155
3531
  createAuthorizationURL({
3156
3532
  state,
3157
3533
  scopes,
3158
- redirectURI
3534
+ redirectURI,
3535
+ additionalParams
3159
3536
  }: {
3160
3537
  state: string;
3161
3538
  codeVerifier: string;
@@ -3163,7 +3540,11 @@ declare const socialProviders: {
3163
3540
  redirectURI: string;
3164
3541
  display?: string | undefined;
3165
3542
  loginHint?: string | undefined;
3166
- }): URL;
3543
+ additionalParams?: Record<string, string> | undefined;
3544
+ }): Promise<{
3545
+ url: URL;
3546
+ requestedScopes: string[];
3547
+ }>;
3167
3548
  validateAuthorizationCode: ({
3168
3549
  code,
3169
3550
  redirectURI
@@ -3198,11 +3579,13 @@ declare const socialProviders: {
3198
3579
  salesforce: (options: SalesforceOptions) => {
3199
3580
  id: "salesforce";
3200
3581
  name: string;
3582
+ callbackPath: string;
3201
3583
  createAuthorizationURL({
3202
3584
  state,
3203
3585
  scopes,
3204
3586
  codeVerifier,
3205
- redirectURI
3587
+ redirectURI,
3588
+ additionalParams
3206
3589
  }: {
3207
3590
  state: string;
3208
3591
  codeVerifier: string;
@@ -3210,7 +3593,11 @@ declare const socialProviders: {
3210
3593
  redirectURI: string;
3211
3594
  display?: string | undefined;
3212
3595
  loginHint?: string | undefined;
3213
- }): Promise<URL>;
3596
+ additionalParams?: Record<string, string> | undefined;
3597
+ }): Promise<{
3598
+ url: URL;
3599
+ requestedScopes: string[];
3600
+ }>;
3214
3601
  validateAuthorizationCode: ({
3215
3602
  code,
3216
3603
  codeVerifier,
@@ -3246,11 +3633,13 @@ declare const socialProviders: {
3246
3633
  vk: (options: VkOption) => {
3247
3634
  id: "vk";
3248
3635
  name: string;
3636
+ callbackPath: string;
3249
3637
  createAuthorizationURL({
3250
3638
  state,
3251
3639
  scopes,
3252
3640
  codeVerifier,
3253
- redirectURI
3641
+ redirectURI,
3642
+ additionalParams
3254
3643
  }: {
3255
3644
  state: string;
3256
3645
  codeVerifier: string;
@@ -3258,7 +3647,11 @@ declare const socialProviders: {
3258
3647
  redirectURI: string;
3259
3648
  display?: string | undefined;
3260
3649
  loginHint?: string | undefined;
3261
- }): Promise<URL>;
3650
+ additionalParams?: Record<string, string> | undefined;
3651
+ }): Promise<{
3652
+ url: URL;
3653
+ requestedScopes: string[];
3654
+ }>;
3262
3655
  validateAuthorizationCode: ({
3263
3656
  code,
3264
3657
  codeVerifier,
@@ -3295,10 +3688,13 @@ declare const socialProviders: {
3295
3688
  zoom: (userOptions: ZoomOptions) => {
3296
3689
  id: "zoom";
3297
3690
  name: string;
3691
+ callbackPath: string;
3298
3692
  createAuthorizationURL: ({
3299
3693
  state,
3694
+ scopes,
3300
3695
  redirectURI,
3301
- codeVerifier
3696
+ codeVerifier,
3697
+ additionalParams
3302
3698
  }: {
3303
3699
  state: string;
3304
3700
  codeVerifier: string;
@@ -3306,7 +3702,11 @@ declare const socialProviders: {
3306
3702
  redirectURI: string;
3307
3703
  display?: string | undefined;
3308
3704
  loginHint?: string | undefined;
3309
- }) => Promise<URL>;
3705
+ additionalParams?: Record<string, string> | undefined;
3706
+ }) => Promise<{
3707
+ url: URL;
3708
+ requestedScopes: string[];
3709
+ }>;
3310
3710
  validateAuthorizationCode: ({
3311
3711
  code,
3312
3712
  redirectURI,
@@ -3341,11 +3741,13 @@ declare const socialProviders: {
3341
3741
  notion: (options: NotionOptions) => {
3342
3742
  id: "notion";
3343
3743
  name: string;
3744
+ callbackPath: string;
3344
3745
  createAuthorizationURL({
3345
3746
  state,
3346
3747
  scopes,
3347
3748
  loginHint,
3348
- redirectURI
3749
+ redirectURI,
3750
+ additionalParams
3349
3751
  }: {
3350
3752
  state: string;
3351
3753
  codeVerifier: string;
@@ -3353,7 +3755,11 @@ declare const socialProviders: {
3353
3755
  redirectURI: string;
3354
3756
  display?: string | undefined;
3355
3757
  loginHint?: string | undefined;
3356
- }): Promise<URL>;
3758
+ additionalParams?: Record<string, string> | undefined;
3759
+ }): Promise<{
3760
+ url: URL;
3761
+ requestedScopes: string[];
3762
+ }>;
3357
3763
  validateAuthorizationCode: ({
3358
3764
  code,
3359
3765
  redirectURI
@@ -3388,10 +3794,12 @@ declare const socialProviders: {
3388
3794
  kakao: (options: KakaoOptions) => {
3389
3795
  id: "kakao";
3390
3796
  name: string;
3797
+ callbackPath: string;
3391
3798
  createAuthorizationURL({
3392
3799
  state,
3393
3800
  scopes,
3394
- redirectURI
3801
+ redirectURI,
3802
+ additionalParams
3395
3803
  }: {
3396
3804
  state: string;
3397
3805
  codeVerifier: string;
@@ -3399,7 +3807,11 @@ declare const socialProviders: {
3399
3807
  redirectURI: string;
3400
3808
  display?: string | undefined;
3401
3809
  loginHint?: string | undefined;
3402
- }): Promise<URL>;
3810
+ additionalParams?: Record<string, string> | undefined;
3811
+ }): Promise<{
3812
+ url: URL;
3813
+ requestedScopes: string[];
3814
+ }>;
3403
3815
  validateAuthorizationCode: ({
3404
3816
  code,
3405
3817
  redirectURI
@@ -3455,10 +3867,12 @@ declare const socialProviders: {
3455
3867
  naver: (options: NaverOptions) => {
3456
3868
  id: "naver";
3457
3869
  name: string;
3870
+ callbackPath: string;
3458
3871
  createAuthorizationURL({
3459
3872
  state,
3460
3873
  scopes,
3461
- redirectURI
3874
+ redirectURI,
3875
+ additionalParams
3462
3876
  }: {
3463
3877
  state: string;
3464
3878
  codeVerifier: string;
@@ -3466,7 +3880,11 @@ declare const socialProviders: {
3466
3880
  redirectURI: string;
3467
3881
  display?: string | undefined;
3468
3882
  loginHint?: string | undefined;
3469
- }): Promise<URL>;
3883
+ additionalParams?: Record<string, string> | undefined;
3884
+ }): Promise<{
3885
+ url: URL;
3886
+ requestedScopes: string[];
3887
+ }>;
3470
3888
  validateAuthorizationCode: ({
3471
3889
  code,
3472
3890
  redirectURI
@@ -3522,12 +3940,14 @@ declare const socialProviders: {
3522
3940
  line: (options: LineOptions) => {
3523
3941
  id: "line";
3524
3942
  name: string;
3943
+ callbackPath: string;
3525
3944
  createAuthorizationURL({
3526
3945
  state,
3527
3946
  scopes,
3528
3947
  codeVerifier,
3529
3948
  redirectURI,
3530
- loginHint
3949
+ loginHint,
3950
+ additionalParams
3531
3951
  }: {
3532
3952
  state: string;
3533
3953
  codeVerifier: string;
@@ -3535,7 +3955,11 @@ declare const socialProviders: {
3535
3955
  redirectURI: string;
3536
3956
  display?: string | undefined;
3537
3957
  loginHint?: string | undefined;
3538
- }): Promise<URL>;
3958
+ additionalParams?: Record<string, string> | undefined;
3959
+ }): Promise<{
3960
+ url: URL;
3961
+ requestedScopes: string[];
3962
+ }>;
3539
3963
  validateAuthorizationCode: ({
3540
3964
  code,
3541
3965
  codeVerifier,
@@ -3547,7 +3971,9 @@ declare const socialProviders: {
3547
3971
  deviceId?: string | undefined;
3548
3972
  }) => Promise<OAuth2Tokens>;
3549
3973
  refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
3550
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
3974
+ idToken: {
3975
+ verify: (token: string, nonce: string | undefined) => Promise<boolean>;
3976
+ };
3551
3977
  getUserInfo(token: OAuth2Tokens & {
3552
3978
  user?: {
3553
3979
  name?: {
@@ -3593,12 +4019,14 @@ declare const socialProviders: {
3593
4019
  paybin: (options: PaybinOptions) => {
3594
4020
  id: "paybin";
3595
4021
  name: string;
4022
+ callbackPath: string;
3596
4023
  createAuthorizationURL({
3597
4024
  state,
3598
4025
  scopes,
3599
4026
  codeVerifier,
3600
4027
  redirectURI,
3601
- loginHint
4028
+ loginHint,
4029
+ additionalParams
3602
4030
  }: {
3603
4031
  state: string;
3604
4032
  codeVerifier: string;
@@ -3606,7 +4034,11 @@ declare const socialProviders: {
3606
4034
  redirectURI: string;
3607
4035
  display?: string | undefined;
3608
4036
  loginHint?: string | undefined;
3609
- }): Promise<URL>;
4037
+ additionalParams?: Record<string, string> | undefined;
4038
+ }): Promise<{
4039
+ url: URL;
4040
+ requestedScopes: string[];
4041
+ }>;
3610
4042
  validateAuthorizationCode: ({
3611
4043
  code,
3612
4044
  codeVerifier,
@@ -3642,10 +4074,12 @@ declare const socialProviders: {
3642
4074
  paypal: (options: PayPalOptions) => {
3643
4075
  id: "paypal";
3644
4076
  name: string;
4077
+ callbackPath: string;
3645
4078
  createAuthorizationURL({
3646
4079
  state,
3647
4080
  codeVerifier,
3648
- redirectURI
4081
+ redirectURI,
4082
+ additionalParams
3649
4083
  }: {
3650
4084
  state: string;
3651
4085
  codeVerifier: string;
@@ -3653,7 +4087,11 @@ declare const socialProviders: {
3653
4087
  redirectURI: string;
3654
4088
  display?: string | undefined;
3655
4089
  loginHint?: string | undefined;
3656
- }): Promise<URL>;
4090
+ additionalParams?: Record<string, string> | undefined;
4091
+ }): Promise<{
4092
+ url: URL;
4093
+ requestedScopes: string[];
4094
+ }>;
3657
4095
  validateAuthorizationCode: ({
3658
4096
  code,
3659
4097
  redirectURI
@@ -3673,7 +4111,6 @@ declare const socialProviders: {
3673
4111
  refreshToken: any;
3674
4112
  accessTokenExpiresAt: Date | undefined;
3675
4113
  }>);
3676
- verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
3677
4114
  getUserInfo(token: OAuth2Tokens & {
3678
4115
  user?: {
3679
4116
  name?: {
@@ -3719,11 +4156,13 @@ declare const socialProviders: {
3719
4156
  polar: (options: PolarOptions) => {
3720
4157
  id: "polar";
3721
4158
  name: string;
4159
+ callbackPath: string;
3722
4160
  createAuthorizationURL({
3723
4161
  state,
3724
4162
  scopes,
3725
4163
  codeVerifier,
3726
- redirectURI
4164
+ redirectURI,
4165
+ additionalParams
3727
4166
  }: {
3728
4167
  state: string;
3729
4168
  codeVerifier: string;
@@ -3731,7 +4170,11 @@ declare const socialProviders: {
3731
4170
  redirectURI: string;
3732
4171
  display?: string | undefined;
3733
4172
  loginHint?: string | undefined;
3734
- }): Promise<URL>;
4173
+ additionalParams?: Record<string, string> | undefined;
4174
+ }): Promise<{
4175
+ url: URL;
4176
+ requestedScopes: string[];
4177
+ }>;
3735
4178
  validateAuthorizationCode: ({
3736
4179
  code,
3737
4180
  codeVerifier,
@@ -3767,11 +4210,13 @@ declare const socialProviders: {
3767
4210
  railway: (options: RailwayOptions) => {
3768
4211
  id: "railway";
3769
4212
  name: string;
4213
+ callbackPath: string;
3770
4214
  createAuthorizationURL({
3771
4215
  state,
3772
4216
  scopes,
3773
4217
  codeVerifier,
3774
- redirectURI
4218
+ redirectURI,
4219
+ additionalParams
3775
4220
  }: {
3776
4221
  state: string;
3777
4222
  codeVerifier: string;
@@ -3779,7 +4224,11 @@ declare const socialProviders: {
3779
4224
  redirectURI: string;
3780
4225
  display?: string | undefined;
3781
4226
  loginHint?: string | undefined;
3782
- }): Promise<URL>;
4227
+ additionalParams?: Record<string, string> | undefined;
4228
+ }): Promise<{
4229
+ url: URL;
4230
+ requestedScopes: string[];
4231
+ }>;
3783
4232
  validateAuthorizationCode: ({
3784
4233
  code,
3785
4234
  codeVerifier,
@@ -3815,11 +4264,13 @@ declare const socialProviders: {
3815
4264
  vercel: (options: VercelOptions) => {
3816
4265
  id: "vercel";
3817
4266
  name: string;
4267
+ callbackPath: string;
3818
4268
  createAuthorizationURL({
3819
4269
  state,
3820
4270
  scopes,
3821
4271
  codeVerifier,
3822
- redirectURI
4272
+ redirectURI,
4273
+ additionalParams
3823
4274
  }: {
3824
4275
  state: string;
3825
4276
  codeVerifier: string;
@@ -3827,7 +4278,11 @@ declare const socialProviders: {
3827
4278
  redirectURI: string;
3828
4279
  display?: string | undefined;
3829
4280
  loginHint?: string | undefined;
3830
- }): Promise<URL>;
4281
+ additionalParams?: Record<string, string> | undefined;
4282
+ }): Promise<{
4283
+ url: URL;
4284
+ requestedScopes: string[];
4285
+ }>;
3831
4286
  validateAuthorizationCode: ({
3832
4287
  code,
3833
4288
  codeVerifier,
@@ -3862,10 +4317,12 @@ declare const socialProviders: {
3862
4317
  wechat: (options: WeChatOptions) => {
3863
4318
  id: "wechat";
3864
4319
  name: string;
4320
+ callbackPath: string;
3865
4321
  createAuthorizationURL({
3866
4322
  state,
3867
4323
  scopes,
3868
- redirectURI
4324
+ redirectURI,
4325
+ additionalParams
3869
4326
  }: {
3870
4327
  state: string;
3871
4328
  codeVerifier: string;
@@ -3873,7 +4330,11 @@ declare const socialProviders: {
3873
4330
  redirectURI: string;
3874
4331
  display?: string | undefined;
3875
4332
  loginHint?: string | undefined;
3876
- }): URL;
4333
+ additionalParams?: Record<string, string> | undefined;
4334
+ }): {
4335
+ url: URL;
4336
+ requestedScopes: string[];
4337
+ };
3877
4338
  validateAuthorizationCode: ({
3878
4339
  code
3879
4340
  }: {
@@ -3939,7 +4400,7 @@ declare const accountSchema: z.ZodObject<{
3939
4400
  idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3940
4401
  accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3941
4402
  refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3942
- scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4403
+ grantedScopes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
3943
4404
  password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3944
4405
  }, z.core.$strip>;
3945
4406
  type BaseAccount = z.infer<typeof accountSchema>;
@@ -3948,14 +4409,14 @@ type BaseAccount = z.infer<typeof accountSchema>;
3948
4409
  */
3949
4410
  type Account<DBOptions extends BetterAuthOptions["account"] = BetterAuthOptions["account"], Plugins extends BetterAuthOptions["plugins"] = BetterAuthOptions["plugins"]> = Prettify$1<BaseAccount & InferDBFieldsFromOptions<DBOptions> & InferDBFieldsFromPlugins<"account", Plugins>>; //#endregion
3950
4411
  //#endregion
3951
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
4412
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
3952
4413
  type Prettify<T> = { [K in keyof T]: T[K] } & {};
3953
4414
  type IsEmptyObject<T> = keyof T extends never ? true : false;
3954
4415
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
3955
4416
  type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
3956
4417
  type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}/*` ? { [K in "_"]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {}; //#endregion
3957
4418
  //#endregion
3958
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
4419
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
3959
4420
  //#region src/standard-schema.d.ts
3960
4421
  /** The Standard Schema interface. */
3961
4422
  interface StandardSchemaV1$1<Input = unknown, Output = Input> {
@@ -4013,7 +4474,7 @@ declare namespace StandardSchemaV1$1 {
4013
4474
  type InferOutput<Schema extends StandardSchemaV1$1> = NonNullable<Schema["~standard"]["types"]>["output"];
4014
4475
  } //#endregion
4015
4476
  //#endregion
4016
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/error.d.mts
4477
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/error.d.mts
4017
4478
  declare const statusCodes: {
4018
4479
  OK: number;
4019
4480
  CREATED: number;
@@ -4091,7 +4552,7 @@ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "
4091
4552
  errorStack: string | undefined;
4092
4553
  }; //#endregion
4093
4554
  //#endregion
4094
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
4555
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
4095
4556
  //#region src/cookies.d.ts
4096
4557
  type CookiePrefixOptions = "host" | "secure";
4097
4558
  type CookieOptions = {
@@ -4181,7 +4642,7 @@ type CookieOptions = {
4181
4642
  prefix?: CookiePrefixOptions;
4182
4643
  };
4183
4644
  //#endregion
4184
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
4645
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
4185
4646
  //#region src/openapi.d.ts
4186
4647
  type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
4187
4648
  interface OpenAPIParameter {
@@ -4203,7 +4664,7 @@ interface OpenAPIParameter {
4203
4664
  };
4204
4665
  }
4205
4666
  //#endregion
4206
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
4667
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
4207
4668
  //#region src/endpoint.d.ts
4208
4669
  interface EndpointBaseOptions {
4209
4670
  /**
@@ -4524,6 +4985,22 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
4524
4985
  * @returns - The cookie string
4525
4986
  */
4526
4987
  setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
4988
+ /**
4989
+ * Response headers
4990
+ *
4991
+ * The live `Headers` for the response being built in the current
4992
+ * request. Read it to inspect what has already been queued, e.g. to
4993
+ * avoid emitting a `Set-Cookie` twice or to check headers set by an
4994
+ * earlier handler in the chain.
4995
+ *
4996
+ * @example
4997
+ * ```ts
4998
+ * const alreadySet = ctx.responseHeaders
4999
+ * .getSetCookie()
5000
+ * .some((c) => c.startsWith("session="));
5001
+ * ```
5002
+ */
5003
+ responseHeaders: Headers;
4527
5004
  /**
4528
5005
  * JSON
4529
5006
  *
@@ -4566,7 +5043,7 @@ type Endpoint<Path extends string = string, Options extends EndpointOptions = En
4566
5043
  path: Path;
4567
5044
  }; //#endregion
4568
5045
  //#endregion
4569
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
5046
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
4570
5047
  //#region src/middleware.d.ts
4571
5048
  interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
4572
5049
  type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
@@ -4673,7 +5150,7 @@ type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler e
4673
5150
  options: Options;
4674
5151
  }; //#endregion
4675
5152
  //#endregion
4676
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/context.d.mts
5153
+ //#region ../../node_modules/.pnpm/better-call@1.3.6_zod@4.3.6/node_modules/better-call/dist/context.d.mts
4677
5154
  //#region src/context.d.ts
4678
5155
  type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
4679
5156
  type Method = HTTPMethod | "*";
@@ -4809,11 +5286,13 @@ type GenericEndpointContext<Options extends BetterAuthOptions = BetterAuthOption
4809
5286
  context: AuthContext<Options>;
4810
5287
  };
4811
5288
  interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions> {
4812
- createOAuthUser(user: Omit<User, "id" | "createdAt" | "updatedAt">, account: Omit<Account, "userId" | "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<{
4813
- user: User;
4814
- account: Account;
4815
- }>;
4816
- createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>): Promise<T & User>;
5289
+ createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>,
5290
+ /**
5291
+ * Provisioning source. The creation seam adds `action: "create-user"` and
5292
+ * runs the `user.validateUserInfo` gate.
5293
+ */
5294
+
5295
+ source: UserProvisioningSource): Promise<T & User>;
4817
5296
  createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
4818
5297
  listSessions(userId: string, options?: {
4819
5298
  onlyActiveSessions?: boolean | undefined;
@@ -4844,7 +5323,14 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
4844
5323
  * @param id - The account row's primary key (the `id` column, not the `accountId` column).
4845
5324
  */
4846
5325
  deleteAccount(id: string): Promise<void>;
4847
- deleteSessions(userIdOrSessionTokens: string | string[]): Promise<void>;
5326
+ /**
5327
+ * Delete every session belonging to a user.
5328
+ */
5329
+ deleteUserSessions(userId: string): Promise<void>;
5330
+ /**
5331
+ * Delete sessions by their session tokens.
5332
+ */
5333
+ deleteSessions(sessionTokens: string[]): Promise<void>;
4848
5334
  findOAuthUser(email: string, accountId: string, providerId: string): Promise<{
4849
5335
  user: User;
4850
5336
  linkedAccount: Account | null;
@@ -4862,13 +5348,26 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
4862
5348
  updateUserByEmail<T extends Record<string, any>>(email: string, data: Partial<User & Record<string, any>>): Promise<User & T>;
4863
5349
  updatePassword(userId: string, password: string): Promise<void>;
4864
5350
  findAccounts(userId: string): Promise<Account[]>;
4865
- findAccount(accountId: string): Promise<Account | null>;
4866
5351
  findAccountByProviderId(accountId: string, providerId: string): Promise<Account | null>;
4867
5352
  findAccountByUserId(userId: string): Promise<Account[]>;
4868
5353
  updateAccount(id: string, data: Partial<Account>): Promise<Account>;
4869
5354
  createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
4870
5355
  findVerificationValue(identifier: string): Promise<Verification | null>;
4871
5356
  deleteVerificationByIdentifier(identifier: string): Promise<void>;
5357
+ /**
5358
+ * Atomically consume a single-use verification row by `identifier` and
5359
+ * return it. Only the first concurrent caller receives the latest row;
5360
+ * subsequent callers receive `null`. Consuming one row invalidates the
5361
+ * whole identifier so stale rows cannot be replayed. Rows past their
5362
+ * `expiresAt` are treated as already invalid: the row is deleted but
5363
+ * `null` is returned, so callers do not need to gate on `expiresAt`
5364
+ * themselves. Callers MUST gate any state change (issue session, mint
5365
+ * token, change password) on a non-null result.
5366
+ *
5367
+ * Replaces the racy `findVerificationValue` + `deleteVerificationByIdentifier`
5368
+ * pair at single-use credential consumption sites.
5369
+ */
5370
+ consumeVerificationValue(identifier: string): Promise<Verification | null>;
4872
5371
  updateVerificationByIdentifier(identifier: string, data: Partial<Verification>): Promise<Verification>;
4873
5372
  refreshUserSessions(user: User): Promise<void>;
4874
5373
  }
@@ -4926,7 +5425,7 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
4926
5425
  * - "cookie": Store state in an encrypted cookie (stateless)
4927
5426
  * - "database": Store state in the database
4928
5427
  *
4929
- * @default "cookie"
5428
+ * @default "database" when `database` or `secondaryStorage` is configured, "cookie" otherwise
4930
5429
  */
4931
5430
  storeStateStrategy: "database" | "cookie";
4932
5431
  };
@@ -4948,7 +5447,7 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
4948
5447
  session: Session & Record<string, any>;
4949
5448
  user: User & Record<string, any>;
4950
5449
  } | null) => void;
4951
- socialProviders: OAuthProvider[];
5450
+ socialProviders: UpstreamProvider[];
4952
5451
  authCookies: BetterAuthCookies;
4953
5452
  logger: ReturnType<typeof createLogger>;
4954
5453
  rateLimit: {
@@ -5114,7 +5613,7 @@ declare const createAuthMiddleware: {
5114
5613
  image?: string | null | undefined;
5115
5614
  } & Record<string, any>;
5116
5615
  } | null) => void;
5117
- socialProviders: OAuthProvider[];
5616
+ socialProviders: UpstreamProvider[];
5118
5617
  authCookies: BetterAuthCookies;
5119
5618
  logger: ReturnType<typeof createLogger>;
5120
5619
  rateLimit: {
@@ -5243,7 +5742,7 @@ declare const createAuthMiddleware: {
5243
5742
  image?: string | null | undefined;
5244
5743
  } & Record<string, any>;
5245
5744
  } | null) => void;
5246
- socialProviders: OAuthProvider[];
5745
+ socialProviders: UpstreamProvider[];
5247
5746
  authCookies: BetterAuthCookies;
5248
5747
  logger: ReturnType<typeof createLogger>;
5249
5748
  rateLimit: {
@@ -5309,6 +5808,73 @@ type GenerateIdFn = (options: {
5309
5808
  model: ModelNames;
5310
5809
  size?: number | undefined;
5311
5810
  }) => string | false;
5811
+ /**
5812
+ * What Better Auth is about to do with an incoming identity when
5813
+ * {@link BetterAuthOptions.user}'s `validateUserInfo` runs.
5814
+ *
5815
+ * - `create-user`: a brand-new user record is about to be created.
5816
+ * - `link-account`: a new provider account is about to be linked to an
5817
+ * already-existing user.
5818
+ * - `sign-in`: an existing OAuth or SSO user is signing in again. This is the
5819
+ * one case where the provider can assert *changed* data, so the hook receives
5820
+ * the fresh provider email and profile (not the stored row), letting a domain
5821
+ * or org policy reject a user whose provider identity moved out of bounds.
5822
+ *
5823
+ * Non-provider returning sign-ins are not re-validated: they carry only the
5824
+ * stored row, which has not changed since `create-user` gated it. Use the admin
5825
+ * plugin's ban controls or a `databaseHooks.session.create.before` hook to
5826
+ * block those.
5827
+ */
5828
+ type ValidateUserInfoAction = "create-user" | "link-account" | "sign-in";
5829
+ /**
5830
+ * The authentication method that produced the incoming user info. The named
5831
+ * methods cover Better Auth's built-ins; the open `string` keeps it extensible
5832
+ * for plugins (for example `"scim"`).
5833
+ */
5834
+ type ValidateUserInfoMethod = "oauth" | "sso-oidc" | "sso-saml" | "email-password" | "magic-link" | "email-otp" | "anonymous" | "siwe" | "phone-number" | "admin" | (string & {});
5835
+ /** OAuth-specific provisioning context; present only when `method` is `"oauth"`. */
5836
+ type ValidateUserInfoOAuthInfo = {
5837
+ /** The social or generic OAuth provider id (e.g. `"google"`). */providerId: string; /** The raw provider profile (userinfo or id-token claims), unmapped. */
5838
+ profile?: Record<string, unknown> | undefined;
5839
+ };
5840
+ /** SSO-specific provisioning context; present for OIDC and SAML SSO methods. */
5841
+ type ValidateUserInfoSSOInfo = {
5842
+ /** The configured SSO provider id. */providerId: string; /** The raw OIDC claims or SAML assertion attributes, unmapped. */
5843
+ profile?: Record<string, unknown> | undefined;
5844
+ };
5845
+ /** Provisioning origin passed to `createUser`; the creation seam adds `action: "create-user"` to build {@link ValidateUserInfoSource}. */
5846
+ type UserProvisioningSource = {
5847
+ method: ValidateUserInfoMethod; /** Provider id and raw profile; present iff `method` is `"oauth"`. */
5848
+ oauth?: ValidateUserInfoOAuthInfo | undefined; /** Provider id and raw profile; present iff `method` is `"sso-oidc"` or `"sso-saml"`. */
5849
+ sso?: ValidateUserInfoSSOInfo | undefined;
5850
+ };
5851
+ /**
5852
+ * The context passed to `validateUserInfo`: the lifecycle
5853
+ * {@link ValidateUserInfoAction}, the {@link ValidateUserInfoMethod}, and (for
5854
+ * OAuth/SSO provider methods) protocol-specific provider metadata.
5855
+ *
5856
+ * ```ts
5857
+ * // Scope to one OAuth provider:
5858
+ * if (source.oauth?.providerId !== "google") return;
5859
+ * // Branch on the method:
5860
+ * if (source.method === "anonymous") return { error: "no_anonymous" };
5861
+ * // Inspect SSO claims:
5862
+ * if (source.method === "sso-saml" && source.sso?.profile?.department !== "eng") {
5863
+ * return { error: "invalid_department" };
5864
+ * }
5865
+ * ```
5866
+ */
5867
+ type ValidateUserInfoSource = UserProvisioningSource & {
5868
+ action: ValidateUserInfoAction;
5869
+ };
5870
+ type ValidateUserInfoResult = {
5871
+ /** A short, machine-readable rejection code, surfaced to the client. */error: string;
5872
+ /**
5873
+ * A human-readable reason, surfaced to the client. Do not put sensitive
5874
+ * details here.
5875
+ */
5876
+ errorDescription?: string | undefined;
5877
+ };
5312
5878
  /**
5313
5879
  * Configuration for dynamic base URL resolution.
5314
5880
  * Allows Better Auth to work with multiple domains (e.g., Vercel preview deployments).
@@ -5439,12 +6005,13 @@ type BetterAuthAdvancedOptions = {
5439
6005
  */
5440
6006
  disableIpTracking?: boolean;
5441
6007
  /**
5442
- * IPv6 subnet prefix length for rate limiting.
5443
- * IPv6 addresses will be normalized to this subnet.
6008
+ * IPv6 prefix length used to collapse addresses before rate-limit keying.
6009
+ * Any integer from 0 to 128 is accepted; common values are 32, 48, 56, 64, 128.
6010
+ * Out-of-range values fall back to safe behavior (negative -> mask all, > 128 -> no mask).
5444
6011
  *
5445
6012
  * @default 64
5446
6013
  */
5447
- ipv6Subnet?: 128 | 64 | 48 | 32;
6014
+ ipv6Subnet?: number;
5448
6015
  } | undefined;
5449
6016
  /**
5450
6017
  * Force cookies to always use the `Secure` attribute. By default,
@@ -5970,6 +6537,30 @@ type BetterAuthOptions = {
5970
6537
  * User configuration
5971
6538
  */
5972
6539
  user?: (BetterAuthDBOptions<"user", keyof BaseUser> & {
6540
+ /**
6541
+ * Gate which identities Better Auth admits. Called just before
6542
+ * `create-user`, `link-account`, and (for OAuth) `sign-in`, across
6543
+ * every authentication method, including stateless setups with no
6544
+ * persistent database. On `sign-in` the hook receives the *fresh*
6545
+ * provider email and profile, so a domain policy can reject a user
6546
+ * whose provider identity moved out of bounds.
6547
+ *
6548
+ * Non-provider returning sign-ins are not re-validated; use the admin
6549
+ * plugin's ban controls or a `databaseHooks.session.create.before`
6550
+ * hook for those.
6551
+ *
6552
+ * Return nothing to allow; return `{ error }` to reject. Browser flows
6553
+ * redirect to the configured error URL; programmatic flows surface a
6554
+ * `403`.
6555
+ *
6556
+ * TODO: rename to `validateUser` (and the `ValidateUserInfo*` types).
6557
+ * "UserInfo" is the OIDC term and misleads for the email/password,
6558
+ * SIWE, phone, and admin methods.
6559
+ */
6560
+ validateUserInfo?: (data: {
6561
+ user: Partial<User> & Record<string, unknown>;
6562
+ source: ValidateUserInfoSource;
6563
+ }, context: GenericEndpointContext) => Awaitable<void | ValidateUserInfoResult>;
5973
6564
  /**
5974
6565
  * Changing email configuration
5975
6566
  */
@@ -6193,6 +6784,25 @@ type BetterAuthOptions = {
6193
6784
  * @default false
6194
6785
  */
6195
6786
  disableImplicitLinking?: boolean;
6787
+ /**
6788
+ * Require the existing local user row to have
6789
+ * `emailVerified: true` before implicit account linking
6790
+ * uses the IdP's `email_verified` claim as ownership
6791
+ * proof. Defaults to `true` so an attacker who
6792
+ * pre-registers an unverified account at a victim's
6793
+ * email cannot have the victim's OAuth identity linked
6794
+ * into the attacker-owned row on first sign-in. Set to
6795
+ * `false` for backward compatibility on apps whose
6796
+ * users sign up via OAuth without verifying their email
6797
+ * locally; understand the takeover risk before doing
6798
+ * so.
6799
+ *
6800
+ * @default true
6801
+ *
6802
+ * @deprecated The option will be removed on the next
6803
+ * minor; the gate will become unconditional.
6804
+ */
6805
+ requireLocalEmailVerified?: boolean;
6196
6806
  /**
6197
6807
  * List of trusted providers. Can be a static array or a function
6198
6808
  * that returns providers dynamically. The function is called
@@ -6230,7 +6840,11 @@ type BetterAuthOptions = {
6230
6840
  */
6231
6841
  allowUnlinkingAll?: boolean;
6232
6842
  /**
6233
- * If enabled (true), this will update the user information based on the newly linked account
6843
+ * When enabled, linking an account copies the provider's profile onto
6844
+ * the local user, matching the fields persisted on sign-up (`name`,
6845
+ * `image`, and any `mapProfileToUser` fields). The local `email` and
6846
+ * `emailVerified` are never changed, so a link cannot rebind the
6847
+ * account's identity.
6234
6848
  *
6235
6849
  * @default false
6236
6850
  */
@@ -6263,7 +6877,7 @@ type BetterAuthOptions = {
6263
6877
  * - "cookie": Store state in an encrypted cookie (stateless)
6264
6878
  * - "database": Store state in the database
6265
6879
  *
6266
- * @default "cookie"
6880
+ * @default "database" when `database` or `secondaryStorage` is configured, "cookie" otherwise
6267
6881
  */
6268
6882
  storeStateStrategy?: "database" | "cookie";
6269
6883
  /**
@@ -6772,6 +7386,18 @@ interface SecondaryStorage {
6772
7386
  * @returns - Value of the key
6773
7387
  */
6774
7388
  get: (key: string) => Awaitable<unknown>;
7389
+ /**
7390
+ * Atomically get a value and delete it from storage.
7391
+ *
7392
+ * This is optional for backwards compatibility with existing secondary
7393
+ * storage implementations. Single-use credential consumers use it when
7394
+ * present to avoid a read-then-delete race.
7395
+ *
7396
+ * TODO(secondary-storage-atomic-consume): make this required in the next
7397
+ * breaking release, or require database-backed verification storage for
7398
+ * security-sensitive consume paths.
7399
+ */
7400
+ getAndDelete?: (key: string) => Awaitable<unknown>;
6775
7401
  set: (
6776
7402
  /**
6777
7403
  * Key to store
@@ -7069,6 +7695,7 @@ declare const requestAuthOptionsSchema: z.ZodObject<{
7069
7695
  disableRedirect: z.ZodOptional<z.ZodBoolean>;
7070
7696
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
7071
7697
  requestSignUp: z.ZodOptional<z.ZodBoolean>;
7698
+ additionalParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
7072
7699
  additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
7073
7700
  }, z.core.$strip>;
7074
7701
  type ElectronRequestAuthOptions = z.infer<typeof requestAuthOptionsSchema>;