@better-auth/core 1.4.2 → 1.4.4-beta.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/.turbo/turbo-build.log +10 -10
- package/dist/api/index.d.mts +1 -1
- package/dist/context/index.d.mts +2 -2
- package/dist/db/adapter/index.d.mts +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/{index-BlxTbL2l.d.mts → index-B3xax_KQ.d.mts} +125 -17
- package/dist/index.d.mts +1 -1
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/{oauth2-DmgZmPEg.mjs → oauth2-B2XPHgx5.mjs} +1 -1
- package/dist/social-providers/index.d.mts +2 -2
- package/dist/social-providers/index.mjs +58 -3
- package/package.json +10 -4
- package/src/oauth2/create-authorization-url.ts +4 -2
- package/src/social-providers/index.ts +3 -0
- package/src/social-providers/vercel.ts +87 -0
- package/src/types/init-options.ts +14 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.4.
|
|
2
|
+
> @better-auth/core@1.4.4-beta.1 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.16.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.16.6[22m powered by rolldown [2mv1.0.0-beta.51[22m
|
|
6
6
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts, src/db/index.ts, src/db/adapter/index.ts, src/async_hooks/index.ts, src/context/index.ts, src/env/index.ts, src/oauth2/index.ts, src/api/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/error/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m 79.87 kB[22m [2m│ gzip: 10.31 kB[22m
|
|
11
11
|
[34mℹ[39m [2mdist/[22m[1mdb/index.mjs[22m [2m 1.58 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
12
12
|
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 0.83 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
13
13
|
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 0.74 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
[34mℹ[39m [2mdist/[22m[1mutils/index.mjs[22m [2m 0.09 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
19
19
|
[34mℹ[39m [2mdist/[22m[1mdb/adapter/index.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
20
20
|
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
21
|
-
[34mℹ[39m [2mdist/[22moauth2-
|
|
21
|
+
[34mℹ[39m [2mdist/[22moauth2-B2XPHgx5.mjs [2m 9.19 kB[22m [2m│ gzip: 2.13 kB[22m
|
|
22
22
|
[34mℹ[39m [2mdist/[22menv-DwlNAN_D.mjs [2m 7.67 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
23
23
|
[34mℹ[39m [2mdist/[22mcontext-DgQ9XGBl.mjs [2m 3.89 kB[22m [2m│ gzip: 1.00 kB[22m
|
|
24
24
|
[34mℹ[39m [2mdist/[22merror-BhAKg8LX.mjs [2m 1.77 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
25
25
|
[34mℹ[39m [2mdist/[22masync_hooks-BfRfbd1J.mjs [2m 0.87 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
26
26
|
[34mℹ[39m [2mdist/[22mutils-C5EN75oV.mjs [2m 0.13 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
27
|
-
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m 3.
|
|
28
|
-
[34mℹ[39m [2mdist/[22m[32m[1mcontext/index.d.mts[22m[39m [2m 3.
|
|
27
|
+
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m 3.87 kB[22m [2m│ gzip: 1.20 kB[22m
|
|
28
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcontext/index.d.mts[22m[39m [2m 3.04 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
29
29
|
[34mℹ[39m [2mdist/[22m[32m[1merror/index.d.mts[22m[39m [2m 1.84 kB[22m [2m│ gzip: 0.72 kB[22m
|
|
30
|
-
[34mℹ[39m [2mdist/[22m[32m[1mdb/index.d.mts[22m[39m [2m 1.01 kB[22m [2m│ gzip: 0.
|
|
30
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdb/index.d.mts[22m[39m [2m 1.01 kB[22m [2m│ gzip: 0.37 kB[22m
|
|
31
31
|
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.87 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
32
32
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/index.d.mts[22m[39m [2m 0.84 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
33
33
|
[34mℹ[39m [2mdist/[22m[32m[1moauth2/index.d.mts[22m[39m [2m 0.79 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/adapter/index.d.mts[22m[39m [2m 0.53 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
36
36
|
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 0.29 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
37
37
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/index.d.mts[22m[39m [2m 0.14 kB[22m [2m│ gzip: 0.10 kB[22m
|
|
38
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
38
|
+
[34mℹ[39m [2mdist/[22m[32mindex-B3xax_KQ.d.mts[39m [2m207.91 kB[22m [2m│ gzip: 32.59 kB[22m
|
|
39
39
|
[34mℹ[39m [2mdist/[22m[32mindex-CdubV7uy.d.mts[39m [2m 3.31 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
40
40
|
[34mℹ[39m [2mdist/[22m[32mindex-DgwIISs7.d.mts[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
41
|
-
[34mℹ[39m 31 files, total:
|
|
42
|
-
[32m✔[39m Build complete in [
|
|
41
|
+
[34mℹ[39m 31 files, total: 333.26 kB
|
|
42
|
+
[32m✔[39m Build complete in [32m4495ms[39m
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-
|
|
1
|
+
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../index-CdubV7uy.mjs";
|
|
3
3
|
export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Qn as DBTransactionAdapter, f as AuthContext, qn as DBAdapter } from "../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../index-CdubV7uy.mjs";
|
|
3
3
|
import { t as AsyncLocalStorage } from "../index-DgwIISs7.mjs";
|
|
4
4
|
import { EndpointContext, InputContext } from "better-call";
|
|
@@ -12,7 +12,7 @@ type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<s
|
|
|
12
12
|
*
|
|
13
13
|
* It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
|
|
14
14
|
*/
|
|
15
|
-
declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<
|
|
15
|
+
declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<any>>;
|
|
16
16
|
declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
|
|
17
17
|
declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
|
|
18
18
|
//#endregion
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $n as JoinConfig, Gn as CleanedWhere, Jn as DBAdapterDebugLogOption, Kn as CustomAdapter, Qn as DBTransactionAdapter, Xn as DBAdapterInstance, Yn as DBAdapterFactoryConfig, Zn as DBAdapterSchemaCreation, er as JoinOption, qn as DBAdapter, tr as Where } from "../../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../../index-CdubV7uy.mjs";
|
|
3
3
|
export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as DBFieldType, Er as SecondaryStorage, Sr as DBFieldAttributeConfig, Tr as DBPrimitive, _r as Account, ar as FieldAttributeConfig, br as BetterAuthDBSchema, cr as Verification, dr as userSchema, fr as coreSchema, gr as rateLimitSchema, hr as RateLimit, ir as FieldAttribute, lr as verificationSchema, mr as sessionSchema, nr as AuthPluginSchema, or as FieldType, pr as Session, rr as BetterAuthDbSchema, sr as Primitive, ur as User, vr as accountSchema, wr as DBPreservedModels, xr as DBFieldAttribute, yr as BetterAuthPluginDBSchema } from "../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../index-CdubV7uy.mjs";
|
|
3
3
|
export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
|
@@ -2,7 +2,6 @@ import { i as Logger, o as createLogger } from "./index-CdubV7uy.mjs";
|
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { BetterFetch, BetterFetchOption, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
4
4
|
import * as jose0 from "jose";
|
|
5
|
-
import * as better_call0 from "better-call";
|
|
6
5
|
import { CookieOptions, Endpoint, EndpointContext, EndpointOptions, InputContext, Middleware } from "better-call";
|
|
7
6
|
import { StandardSchemaV1, StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
|
|
8
7
|
import { Database } from "bun:sqlite";
|
|
@@ -1010,7 +1009,7 @@ declare function createAuthorizationURL({
|
|
|
1010
1009
|
authorizationEndpoint: string;
|
|
1011
1010
|
state: string;
|
|
1012
1011
|
codeVerifier?: string | undefined;
|
|
1013
|
-
scopes
|
|
1012
|
+
scopes?: string[] | undefined;
|
|
1014
1013
|
claims?: string[] | undefined;
|
|
1015
1014
|
duration?: string | undefined;
|
|
1016
1015
|
prompt?: string | undefined;
|
|
@@ -4159,6 +4158,66 @@ declare const polar: (options: PolarOptions) => {
|
|
|
4159
4158
|
options: PolarOptions;
|
|
4160
4159
|
};
|
|
4161
4160
|
//#endregion
|
|
4161
|
+
//#region src/social-providers/vercel.d.ts
|
|
4162
|
+
interface VercelProfile {
|
|
4163
|
+
sub: string;
|
|
4164
|
+
name?: string;
|
|
4165
|
+
preferred_username?: string;
|
|
4166
|
+
email?: string;
|
|
4167
|
+
email_verified?: boolean;
|
|
4168
|
+
picture?: string;
|
|
4169
|
+
}
|
|
4170
|
+
interface VercelOptions extends ProviderOptions<VercelProfile> {
|
|
4171
|
+
clientId: string;
|
|
4172
|
+
}
|
|
4173
|
+
declare const vercel: (options: VercelOptions) => {
|
|
4174
|
+
id: "vercel";
|
|
4175
|
+
name: string;
|
|
4176
|
+
createAuthorizationURL({
|
|
4177
|
+
state,
|
|
4178
|
+
scopes,
|
|
4179
|
+
codeVerifier,
|
|
4180
|
+
redirectURI
|
|
4181
|
+
}: {
|
|
4182
|
+
state: string;
|
|
4183
|
+
codeVerifier: string;
|
|
4184
|
+
scopes?: string[] | undefined;
|
|
4185
|
+
redirectURI: string;
|
|
4186
|
+
display?: string | undefined;
|
|
4187
|
+
loginHint?: string | undefined;
|
|
4188
|
+
}): Promise<URL>;
|
|
4189
|
+
validateAuthorizationCode: ({
|
|
4190
|
+
code,
|
|
4191
|
+
codeVerifier,
|
|
4192
|
+
redirectURI
|
|
4193
|
+
}: {
|
|
4194
|
+
code: string;
|
|
4195
|
+
redirectURI: string;
|
|
4196
|
+
codeVerifier?: string | undefined;
|
|
4197
|
+
deviceId?: string | undefined;
|
|
4198
|
+
}) => Promise<OAuth2Tokens>;
|
|
4199
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
4200
|
+
user?: {
|
|
4201
|
+
name?: {
|
|
4202
|
+
firstName?: string;
|
|
4203
|
+
lastName?: string;
|
|
4204
|
+
};
|
|
4205
|
+
email?: string;
|
|
4206
|
+
} | undefined;
|
|
4207
|
+
}): Promise<{
|
|
4208
|
+
user: {
|
|
4209
|
+
id: string;
|
|
4210
|
+
name?: string;
|
|
4211
|
+
email?: string | null;
|
|
4212
|
+
image?: string;
|
|
4213
|
+
emailVerified: boolean;
|
|
4214
|
+
[key: string]: any;
|
|
4215
|
+
};
|
|
4216
|
+
data: any;
|
|
4217
|
+
} | null>;
|
|
4218
|
+
options: VercelOptions;
|
|
4219
|
+
};
|
|
4220
|
+
//#endregion
|
|
4162
4221
|
//#region src/social-providers/index.d.ts
|
|
4163
4222
|
declare const socialProviders: {
|
|
4164
4223
|
apple: (options: AppleOptions) => {
|
|
@@ -5788,6 +5847,53 @@ declare const socialProviders: {
|
|
|
5788
5847
|
} | null>;
|
|
5789
5848
|
options: PolarOptions;
|
|
5790
5849
|
};
|
|
5850
|
+
vercel: (options: VercelOptions) => {
|
|
5851
|
+
id: "vercel";
|
|
5852
|
+
name: string;
|
|
5853
|
+
createAuthorizationURL({
|
|
5854
|
+
state,
|
|
5855
|
+
scopes,
|
|
5856
|
+
codeVerifier,
|
|
5857
|
+
redirectURI
|
|
5858
|
+
}: {
|
|
5859
|
+
state: string;
|
|
5860
|
+
codeVerifier: string;
|
|
5861
|
+
scopes?: string[] | undefined;
|
|
5862
|
+
redirectURI: string;
|
|
5863
|
+
display?: string | undefined;
|
|
5864
|
+
loginHint?: string | undefined;
|
|
5865
|
+
}): Promise<URL>;
|
|
5866
|
+
validateAuthorizationCode: ({
|
|
5867
|
+
code,
|
|
5868
|
+
codeVerifier,
|
|
5869
|
+
redirectURI
|
|
5870
|
+
}: {
|
|
5871
|
+
code: string;
|
|
5872
|
+
redirectURI: string;
|
|
5873
|
+
codeVerifier?: string | undefined;
|
|
5874
|
+
deviceId?: string | undefined;
|
|
5875
|
+
}) => Promise<OAuth2Tokens>;
|
|
5876
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
5877
|
+
user?: {
|
|
5878
|
+
name?: {
|
|
5879
|
+
firstName?: string;
|
|
5880
|
+
lastName?: string;
|
|
5881
|
+
};
|
|
5882
|
+
email?: string;
|
|
5883
|
+
} | undefined;
|
|
5884
|
+
}): Promise<{
|
|
5885
|
+
user: {
|
|
5886
|
+
id: string;
|
|
5887
|
+
name?: string;
|
|
5888
|
+
email?: string | null;
|
|
5889
|
+
image?: string;
|
|
5890
|
+
emailVerified: boolean;
|
|
5891
|
+
[key: string]: any;
|
|
5892
|
+
};
|
|
5893
|
+
data: any;
|
|
5894
|
+
} | null>;
|
|
5895
|
+
options: VercelOptions;
|
|
5896
|
+
};
|
|
5791
5897
|
};
|
|
5792
5898
|
declare const socialProviderList: ["github", ...(keyof typeof socialProviders)[]];
|
|
5793
5899
|
declare const SocialProviderListEnum: z.ZodType<SocialProviderList[number] | (string & {})>;
|
|
@@ -6111,6 +6217,19 @@ type BetterAuthAdvancedOptions = {
|
|
|
6111
6217
|
*/
|
|
6112
6218
|
generateId?: GenerateIdFn | false | "serial" | "uuid";
|
|
6113
6219
|
} | undefined;
|
|
6220
|
+
/**
|
|
6221
|
+
* Trusted proxy headers
|
|
6222
|
+
*
|
|
6223
|
+
* - `x-forwarded-host`
|
|
6224
|
+
* - `x-forwarded-proto`
|
|
6225
|
+
*
|
|
6226
|
+
* If set to `true` and no `baseURL` option is provided, we will use the headers to infer the
|
|
6227
|
+
* base URL.
|
|
6228
|
+
*
|
|
6229
|
+
* ⚠︎ This may expose your application to security vulnerabilities if not
|
|
6230
|
+
* used correctly. Please use this with caution.
|
|
6231
|
+
*/
|
|
6232
|
+
trustedProxyHeaders?: boolean | undefined;
|
|
6114
6233
|
};
|
|
6115
6234
|
type BetterAuthOptions = {
|
|
6116
6235
|
/**
|
|
@@ -7336,21 +7455,10 @@ interface BetterAuthClientPlugin {
|
|
|
7336
7455
|
}
|
|
7337
7456
|
//#endregion
|
|
7338
7457
|
//#region src/api/index.d.ts
|
|
7339
|
-
declare const optionsMiddleware:
|
|
7340
|
-
declare const createAuthMiddleware:
|
|
7341
|
-
|
|
7342
|
-
returned?: unknown | undefined;
|
|
7343
|
-
responseHeaders?: Headers | undefined;
|
|
7344
|
-
}>) => Promise<R>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R>;
|
|
7345
|
-
<Options extends better_call0.MiddlewareOptions, R_1>(handler: (ctx: better_call0.MiddlewareContext<Options, AuthContext & {
|
|
7346
|
-
returned?: unknown | undefined;
|
|
7347
|
-
responseHeaders?: Headers | undefined;
|
|
7348
|
-
}>) => Promise<R_1>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R_1>;
|
|
7349
|
-
};
|
|
7350
|
-
declare const createAuthEndpoint: <Path extends string, Opts extends EndpointOptions, R>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, AuthContext>) => Promise<R>) => better_call0.StrictEndpoint<Path, Opts & {
|
|
7351
|
-
use: any[];
|
|
7352
|
-
}, R>;
|
|
7458
|
+
declare const optionsMiddleware: any;
|
|
7459
|
+
declare const createAuthMiddleware: any;
|
|
7460
|
+
declare const createAuthEndpoint: <Path extends string, Opts extends EndpointOptions, R>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, AuthContext>) => Promise<R>) => any;
|
|
7353
7461
|
type AuthEndpoint = ReturnType<typeof createAuthEndpoint>;
|
|
7354
7462
|
type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
|
|
7355
7463
|
//#endregion
|
|
7356
|
-
export {
|
|
7464
|
+
export { AccountStatus as $, JoinConfig as $n, GoogleProfile as $t, PolarOptions as A, BetterAuthCookies as An, linear as At, LineIdTokenPayload as B, createClientCredentialsTokenRequest as Bn, TwitchOptions as Bt, SocialProviderListEnum as C, AppleNonConformUser as Cn, DBFieldType as Cr, gitlab as Ct, VercelOptions as D, getApplePublicKey as Dn, LinearOptions as Dt, socialProviders as E, apple as En, SecondaryStorage as Er, linkedin as Et, PayPalTokenResponse as F, getOAuth2Tokens as Fn, DropboxProfile as Ft, NaverProfile as G, CleanedWhere as Gn, spotify as Gt, LineUserInfo as H, OAuth2UserInfo as Hn, twitch as Ht, paypal as I, createRefreshAccessTokenRequest as In, dropbox as It, KakaoProfile as J, DBAdapterDebugLogOption as Jn, slack as Jt, naver as K, CustomAdapter as Kn, SlackOptions as Kt, PaybinOptions as L, refreshAccessToken as Ln, TwitterOption as Lt, polar as M, validateAuthorizationCode as Mn, KickProfile as Mt, PayPalOptions as N, validateToken as Nn, kick as Nt, VercelProfile as O, LiteralString as On, LinearProfile as Ot, PayPalProfile as P, generateCodeChallenge as Pn, DropboxOptions as Pt, notion as Q, DBTransactionAdapter as Qn, GoogleOptions as Qt, PaybinProfile as R, createAuthorizationURL as Rn, TwitterProfile as Rt, SocialProviderList as S, atlassian as Sn, DBFieldAttributeConfig as Sr, GitlabProfile as St, socialProviderList as T, AppleProfile as Tn, DBPrimitive as Tr, LinkedInProfile as Tt, line as U, OAuthProvider as Un, SpotifyOptions as Ut, LineOptions as V, OAuth2Tokens as Vn, TwitchProfile as Vt, NaverOptions as W, ProviderOptions as Wn, SpotifyProfile as Wt, NotionOptions as X, DBAdapterInstance as Xn, HuggingFaceProfile as Xt, kakao as Y, DBAdapterFactoryConfig as Yn, HuggingFaceOptions as Yt, NotionProfile as Z, DBAdapterSchemaCreation as Zn, huggingface as Zt, BetterAuthRateLimitOptions as _, CognitoProfile as _n, Account as _r, reddit as _t, optionsMiddleware as a, GithubProfile as an, FieldAttributeConfig as ar, zoom as at, HookEndpointContext as b, AtlassianOptions as bn, BetterAuthDBSchema as br, tiktok as bt, BetterAuthClientPlugin as c, FigmaProfile as cn, Verification as cr, vk as ct, ClientStore as d, FacebookProfile as dn, userSchema as dr, salesforce as dt, google as en, JoinOption as er, LoginType as et, AuthContext as f, facebook as fn, coreSchema as fr, RobloxOptions as ft, BetterAuthOptions as g, CognitoOptions as gn, rateLimitSchema as gr, RedditProfile as gt, BetterAuthAdvancedOptions as h, discord as hn, RateLimit as hr, RedditOptions as ht, createAuthMiddleware as i, GithubOptions as in, FieldAttribute as ir, ZoomProfile as it, PolarProfile as j, createAuthorizationCodeRequest as jn, KickOptions as jt, vercel as k, LiteralUnion as kn, LinearUser as kt, ClientAtomListener as l, figma as ln, verificationSchema as lr, SalesforceOptions as lt, InternalAdapter as m, DiscordProfile as mn, sessionSchema as mr, roblox as mt, AuthMiddleware as n, MicrosoftOptions as nn, AuthPluginSchema as nr, PronounOption as nt, StandardSchemaV1$1 as o, github as on, FieldType as or, VkOption as ot, GenericEndpointContext as p, DiscordOptions as pn, Session as pr, RobloxProfile as pt, KakaoOptions as q, DBAdapter as qn, SlackProfile as qt, createAuthEndpoint as r, microsoft as rn, BetterAuthDbSchema as rr, ZoomOptions as rt, BetterAuthClientOptions as s, FigmaOptions as sn, Primitive$1 as sr, VkProfile as st, AuthEndpoint as t, MicrosoftEntraIDProfile as tn, Where as tr, PhoneNumber as tt, ClientFetchOption as u, FacebookOptions as un, User as ur, SalesforceProfile as ut, GenerateIdFn as v, cognito as vn, accountSchema as vr, TiktokOptions as vt, SocialProviders as w, AppleOptions as wn, DBPreservedModels as wr, LinkedInOptions as wt, SocialProvider as x, AtlassianProfile as xn, DBFieldAttribute as xr, GitlabOptions as xt, BetterAuthPlugin as y, getCognitoPublicKey as yn, BetterAuthPluginDBSchema as yr, TiktokProfile as yt, paybin as z, clientCredentialsToken as zn, twitter as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as BetterAuthCookies, On as LiteralString, _ as BetterAuthRateLimitOptions, b as HookEndpointContext, c as BetterAuthClientPlugin, d as ClientStore, f as AuthContext, g as BetterAuthOptions, h as BetterAuthAdvancedOptions, kn as LiteralUnion, l as ClientAtomListener, m as InternalAdapter, o as StandardSchemaV1, p as GenericEndpointContext, s as BetterAuthClientOptions, u as ClientFetchOption, v as GenerateIdFn, y as BetterAuthPlugin } from "./index-B3xax_KQ.mjs";
|
|
2
2
|
import "./index-CdubV7uy.mjs";
|
|
3
3
|
export { AuthContext, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, StandardSchemaV1 };
|
package/dist/oauth2/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as createClientCredentialsTokenRequest, Fn as getOAuth2Tokens, Hn as OAuth2UserInfo, In as createRefreshAccessTokenRequest, Ln as refreshAccessToken, Mn as validateAuthorizationCode, Nn as validateToken, Pn as generateCodeChallenge, Rn as createAuthorizationURL, Un as OAuthProvider, Vn as OAuth2Tokens, Wn as ProviderOptions, jn as createAuthorizationCodeRequest, zn as clientCredentialsToken } from "../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../index-CdubV7uy.mjs";
|
|
3
3
|
export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
package/dist/oauth2/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-
|
|
1
|
+
import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-B2XPHgx5.mjs";
|
|
2
2
|
|
|
3
3
|
export { clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
|
@@ -83,7 +83,7 @@ async function createAuthorizationURL({ id, options, authorizationEndpoint, stat
|
|
|
83
83
|
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
84
84
|
url.searchParams.set("client_id", primaryClientId);
|
|
85
85
|
url.searchParams.set("state", state);
|
|
86
|
-
url.searchParams.set("scope", scopes.join(scopeJoiner || " "));
|
|
86
|
+
if (scopes) url.searchParams.set("scope", scopes.join(scopeJoiner || " "));
|
|
87
87
|
url.searchParams.set("redirect_uri", options.redirectURI || redirectURI);
|
|
88
88
|
duration && url.searchParams.set("duration", duration);
|
|
89
89
|
display && url.searchParams.set("display", display);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AccountStatus, $t as GoogleProfile, A as PolarOptions, At as linear, B as LineIdTokenPayload, Bt as TwitchOptions, C as SocialProviderListEnum, Cn as AppleNonConformUser, Ct as gitlab, D as VercelOptions, Dn as getApplePublicKey, Dt as LinearOptions, E as socialProviders, En as apple, Et as linkedin, F as PayPalTokenResponse, Ft as DropboxProfile, G as NaverProfile, Gt as spotify, H as LineUserInfo, Ht as twitch, I as paypal, It as dropbox, J as KakaoProfile, Jt as slack, K as naver, Kt as SlackOptions, L as PaybinOptions, Lt as TwitterOption, M as polar, Mt as KickProfile, N as PayPalOptions, Nt as kick, O as VercelProfile, Ot as LinearProfile, P as PayPalProfile, Pt as DropboxOptions, Q as notion, Qt as GoogleOptions, R as PaybinProfile, Rt as TwitterProfile, S as SocialProviderList, Sn as atlassian, St as GitlabProfile, T as socialProviderList, Tn as AppleProfile, Tt as LinkedInProfile, U as line, Ut as SpotifyOptions, V as LineOptions, Vt as TwitchProfile, W as NaverOptions, Wt as SpotifyProfile, X as NotionOptions, Xt as HuggingFaceProfile, Y as kakao, Yt as HuggingFaceOptions, Z as NotionProfile, Zt as huggingface, _n as CognitoProfile, _t as reddit, an as GithubProfile, at as zoom, bn as AtlassianOptions, bt as tiktok, cn as FigmaProfile, ct as vk, dn as FacebookProfile, dt as salesforce, en as google, et as LoginType, fn as facebook, ft as RobloxOptions, gn as CognitoOptions, gt as RedditProfile, hn as discord, ht as RedditOptions, in as GithubOptions, it as ZoomProfile, j as PolarProfile, jt as KickOptions, k as vercel, kt as LinearUser, ln as figma, lt as SalesforceOptions, mn as DiscordProfile, mt as roblox, nn as MicrosoftOptions, nt as PronounOption, on as github, ot as VkOption, pn as DiscordOptions, pt as RobloxProfile, q as KakaoOptions, qt as SlackProfile, rn as microsoft, rt as ZoomOptions, sn as FigmaOptions, st as VkProfile, tn as MicrosoftEntraIDProfile, tt as PhoneNumber, un as FacebookOptions, ut as SalesforceProfile, vn as cognito, vt as TiktokOptions, w as SocialProviders, wn as AppleOptions, wt as LinkedInOptions, x as SocialProvider, xn as AtlassianProfile, xt as GitlabOptions, yn as getCognitoPublicKey, yt as TiktokProfile, z as paybin, zt as twitter } from "../index-B3xax_KQ.mjs";
|
|
2
2
|
import "../index-CdubV7uy.mjs";
|
|
3
|
-
export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
|
|
3
|
+
export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VercelOptions, VercelProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vercel, vk, zoom };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as logger } from "../env-DwlNAN_D.mjs";
|
|
2
|
-
import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-
|
|
2
|
+
import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-B2XPHgx5.mjs";
|
|
3
3
|
import "../utils-C5EN75oV.mjs";
|
|
4
4
|
import { t as BetterAuthError } from "../error-BhAKg8LX.mjs";
|
|
5
5
|
import * as z from "zod";
|
|
@@ -2341,6 +2341,60 @@ const twitter = (options) => {
|
|
|
2341
2341
|
};
|
|
2342
2342
|
};
|
|
2343
2343
|
|
|
2344
|
+
//#endregion
|
|
2345
|
+
//#region src/social-providers/vercel.ts
|
|
2346
|
+
const vercel = (options) => {
|
|
2347
|
+
return {
|
|
2348
|
+
id: "vercel",
|
|
2349
|
+
name: "Vercel",
|
|
2350
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI }) {
|
|
2351
|
+
if (!codeVerifier) throw new BetterAuthError("codeVerifier is required for Vercel");
|
|
2352
|
+
let _scopes = void 0;
|
|
2353
|
+
if (options.scope !== void 0 || scopes !== void 0) {
|
|
2354
|
+
_scopes = [];
|
|
2355
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
2356
|
+
if (scopes) _scopes.push(...scopes);
|
|
2357
|
+
}
|
|
2358
|
+
return createAuthorizationURL({
|
|
2359
|
+
id: "vercel",
|
|
2360
|
+
options,
|
|
2361
|
+
authorizationEndpoint: "https://vercel.com/oauth/authorize",
|
|
2362
|
+
scopes: _scopes,
|
|
2363
|
+
state,
|
|
2364
|
+
codeVerifier,
|
|
2365
|
+
redirectURI
|
|
2366
|
+
});
|
|
2367
|
+
},
|
|
2368
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
2369
|
+
return validateAuthorizationCode({
|
|
2370
|
+
code,
|
|
2371
|
+
codeVerifier,
|
|
2372
|
+
redirectURI,
|
|
2373
|
+
options,
|
|
2374
|
+
tokenEndpoint: "https://api.vercel.com/login/oauth/token"
|
|
2375
|
+
});
|
|
2376
|
+
},
|
|
2377
|
+
async getUserInfo(token) {
|
|
2378
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
2379
|
+
const { data: profile, error } = await betterFetch("https://api.vercel.com/login/oauth/userinfo", { headers: { Authorization: `Bearer ${token.accessToken}` } });
|
|
2380
|
+
if (error || !profile) return null;
|
|
2381
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
2382
|
+
return {
|
|
2383
|
+
user: {
|
|
2384
|
+
id: profile.sub,
|
|
2385
|
+
name: profile.name ?? profile.preferred_username,
|
|
2386
|
+
email: profile.email,
|
|
2387
|
+
image: profile.picture,
|
|
2388
|
+
emailVerified: profile.email_verified ?? false,
|
|
2389
|
+
...userMap
|
|
2390
|
+
},
|
|
2391
|
+
data: profile
|
|
2392
|
+
};
|
|
2393
|
+
},
|
|
2394
|
+
options
|
|
2395
|
+
};
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2344
2398
|
//#endregion
|
|
2345
2399
|
//#region src/social-providers/vk.ts
|
|
2346
2400
|
const vk = (options) => {
|
|
@@ -2516,10 +2570,11 @@ const socialProviders = {
|
|
|
2516
2570
|
line,
|
|
2517
2571
|
paybin,
|
|
2518
2572
|
paypal,
|
|
2519
|
-
polar
|
|
2573
|
+
polar,
|
|
2574
|
+
vercel
|
|
2520
2575
|
};
|
|
2521
2576
|
const socialProviderList = Object.keys(socialProviders);
|
|
2522
2577
|
const SocialProviderListEnum = z.enum(socialProviderList).or(z.string());
|
|
2523
2578
|
|
|
2524
2579
|
//#endregion
|
|
2525
|
-
export { SocialProviderListEnum, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
|
|
2580
|
+
export { SocialProviderListEnum, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vercel, vk, zoom };
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4-beta.1",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/better-auth/better-auth",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
6
11
|
"main": "./dist/index.mjs",
|
|
7
12
|
"module": "./dist/index.mjs",
|
|
8
13
|
"exports": {
|
|
@@ -103,12 +108,12 @@
|
|
|
103
108
|
"@better-auth/utils": "0.3.0",
|
|
104
109
|
"@better-fetch/fetch": "1.1.18",
|
|
105
110
|
"@types/better-sqlite3": "^7.6.13",
|
|
106
|
-
"better-call": "1.1.
|
|
111
|
+
"better-call": "1.1.1",
|
|
107
112
|
"better-sqlite3": "^12.4.1",
|
|
108
113
|
"jose": "^6.1.0",
|
|
109
114
|
"kysely": "^0.28.5",
|
|
110
115
|
"nanostores": "^1.0.1",
|
|
111
|
-
"tsdown": "^0.16.
|
|
116
|
+
"tsdown": "^0.16.6"
|
|
112
117
|
},
|
|
113
118
|
"dependencies": {
|
|
114
119
|
"@standard-schema/spec": "^1.0.0",
|
|
@@ -117,7 +122,7 @@
|
|
|
117
122
|
"peerDependencies": {
|
|
118
123
|
"@better-auth/utils": "0.3.0",
|
|
119
124
|
"@better-fetch/fetch": "1.1.18",
|
|
120
|
-
"better-call": "1.1.
|
|
125
|
+
"better-call": "1.1.1",
|
|
121
126
|
"jose": "^6.1.0",
|
|
122
127
|
"kysely": "^0.28.5",
|
|
123
128
|
"nanostores": "^1.0.1"
|
|
@@ -125,6 +130,7 @@
|
|
|
125
130
|
"scripts": {
|
|
126
131
|
"build": "tsdown",
|
|
127
132
|
"dev": "tsdown --watch",
|
|
133
|
+
"lint:package": "publint run --strict",
|
|
128
134
|
"typecheck": "tsc --project tsconfig.json",
|
|
129
135
|
"test": "vitest"
|
|
130
136
|
}
|
|
@@ -27,7 +27,7 @@ export async function createAuthorizationURL({
|
|
|
27
27
|
authorizationEndpoint: string;
|
|
28
28
|
state: string;
|
|
29
29
|
codeVerifier?: string | undefined;
|
|
30
|
-
scopes
|
|
30
|
+
scopes?: string[] | undefined;
|
|
31
31
|
claims?: string[] | undefined;
|
|
32
32
|
duration?: string | undefined;
|
|
33
33
|
prompt?: string | undefined;
|
|
@@ -47,7 +47,9 @@ export async function createAuthorizationURL({
|
|
|
47
47
|
: options.clientId;
|
|
48
48
|
url.searchParams.set("client_id", primaryClientId);
|
|
49
49
|
url.searchParams.set("state", state);
|
|
50
|
-
|
|
50
|
+
if (scopes) {
|
|
51
|
+
url.searchParams.set("scope", scopes.join(scopeJoiner || " "));
|
|
52
|
+
}
|
|
51
53
|
url.searchParams.set("redirect_uri", options.redirectURI || redirectURI);
|
|
52
54
|
duration && url.searchParams.set("duration", duration);
|
|
53
55
|
display && url.searchParams.set("display", display);
|
|
@@ -29,6 +29,7 @@ import { spotify } from "./spotify";
|
|
|
29
29
|
import { tiktok } from "./tiktok";
|
|
30
30
|
import { twitch } from "./twitch";
|
|
31
31
|
import { twitter } from "./twitter";
|
|
32
|
+
import { vercel } from "./vercel";
|
|
32
33
|
import { vk } from "./vk";
|
|
33
34
|
import { zoom } from "./zoom";
|
|
34
35
|
|
|
@@ -65,6 +66,7 @@ export const socialProviders = {
|
|
|
65
66
|
paybin,
|
|
66
67
|
paypal,
|
|
67
68
|
polar,
|
|
69
|
+
vercel,
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
export const socialProviderList = Object.keys(socialProviders) as [
|
|
@@ -118,6 +120,7 @@ export * from "./spotify";
|
|
|
118
120
|
export * from "./tiktok";
|
|
119
121
|
export * from "./twitch";
|
|
120
122
|
export * from "./twitter";
|
|
123
|
+
export * from "./vercel";
|
|
121
124
|
export * from "./vk";
|
|
122
125
|
export * from "./zoom";
|
|
123
126
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { BetterAuthError } from "../error";
|
|
3
|
+
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
4
|
+
import { createAuthorizationURL, validateAuthorizationCode } from "../oauth2";
|
|
5
|
+
|
|
6
|
+
export interface VercelProfile {
|
|
7
|
+
sub: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
preferred_username?: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
email_verified?: boolean;
|
|
12
|
+
picture?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface VercelOptions extends ProviderOptions<VercelProfile> {
|
|
16
|
+
clientId: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const vercel = (options: VercelOptions) => {
|
|
20
|
+
return {
|
|
21
|
+
id: "vercel",
|
|
22
|
+
name: "Vercel",
|
|
23
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI }) {
|
|
24
|
+
if (!codeVerifier) {
|
|
25
|
+
throw new BetterAuthError("codeVerifier is required for Vercel");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let _scopes: string[] | undefined = undefined;
|
|
29
|
+
if (options.scope !== undefined || scopes !== undefined) {
|
|
30
|
+
_scopes = [];
|
|
31
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
32
|
+
if (scopes) _scopes.push(...scopes);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return createAuthorizationURL({
|
|
36
|
+
id: "vercel",
|
|
37
|
+
options,
|
|
38
|
+
authorizationEndpoint: "https://vercel.com/oauth/authorize",
|
|
39
|
+
scopes: _scopes,
|
|
40
|
+
state,
|
|
41
|
+
codeVerifier,
|
|
42
|
+
redirectURI,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
46
|
+
return validateAuthorizationCode({
|
|
47
|
+
code,
|
|
48
|
+
codeVerifier,
|
|
49
|
+
redirectURI,
|
|
50
|
+
options,
|
|
51
|
+
tokenEndpoint: "https://api.vercel.com/login/oauth/token",
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
async getUserInfo(token) {
|
|
55
|
+
if (options.getUserInfo) {
|
|
56
|
+
return options.getUserInfo(token);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { data: profile, error } = await betterFetch<VercelProfile>(
|
|
60
|
+
"https://api.vercel.com/login/oauth/userinfo",
|
|
61
|
+
{
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (error || !profile) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
73
|
+
return {
|
|
74
|
+
user: {
|
|
75
|
+
id: profile.sub,
|
|
76
|
+
name: profile.name ?? profile.preferred_username,
|
|
77
|
+
email: profile.email,
|
|
78
|
+
image: profile.picture,
|
|
79
|
+
emailVerified: profile.email_verified ?? false,
|
|
80
|
+
...userMap,
|
|
81
|
+
},
|
|
82
|
+
data: profile,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
options,
|
|
86
|
+
} satisfies OAuthProvider<VercelProfile>;
|
|
87
|
+
};
|
|
@@ -257,6 +257,20 @@ export type BetterAuthAdvancedOptions = {
|
|
|
257
257
|
generateId?: GenerateIdFn | false | "serial" | "uuid";
|
|
258
258
|
}
|
|
259
259
|
| undefined;
|
|
260
|
+
/**
|
|
261
|
+
* Trusted proxy headers
|
|
262
|
+
*
|
|
263
|
+
|
|
264
|
+
* - `x-forwarded-host`
|
|
265
|
+
* - `x-forwarded-proto`
|
|
266
|
+
*
|
|
267
|
+
* If set to `true` and no `baseURL` option is provided, we will use the headers to infer the
|
|
268
|
+
* base URL.
|
|
269
|
+
*
|
|
270
|
+
* ⚠︎ This may expose your application to security vulnerabilities if not
|
|
271
|
+
* used correctly. Please use this with caution.
|
|
272
|
+
*/
|
|
273
|
+
trustedProxyHeaders?: boolean | undefined;
|
|
260
274
|
};
|
|
261
275
|
|
|
262
276
|
export type BetterAuthOptions = {
|