@better-auth/core 1.4.0-beta.13 → 1.4.0-beta.15
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 +34 -58
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +2 -6
- package/dist/api/index.d.ts +2 -6
- package/dist/api/index.js +1 -1
- package/dist/async_hooks/index.d.cts +1 -1
- package/dist/async_hooks/index.d.ts +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.cts +14 -18
- package/dist/context/index.d.ts +14 -18
- package/dist/context/index.js +1 -1
- package/dist/{context-Bm0rm76r.js → context-BAOGRjRS.js} +30 -30
- package/dist/{context-7VgEbfs3.cjs → context-BRDf96na.cjs} +29 -29
- package/dist/db/adapter/index.d.cts +2 -6
- package/dist/db/adapter/index.d.ts +2 -6
- package/dist/db/index.cjs +17 -17
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +17 -17
- package/dist/env/index.d.cts +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/error/index.d.cts +1 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/{index-D5uj-vER.d.ts → index-B_YiOlcX.d.cts} +9 -9
- package/dist/index-Bab6W0hG.d.ts +7155 -0
- package/dist/index-CGS5U4X6.d.cts +7155 -0
- package/dist/{index-Dy_s5RNc.d.cts → index-CSISZQGm.d.ts} +9 -9
- package/dist/index.d.cts +3 -65
- package/dist/index.d.ts +3 -65
- package/dist/oauth2/index.cjs +1 -1
- package/dist/oauth2/index.d.cts +2 -2
- package/dist/oauth2/index.d.ts +2 -2
- package/dist/oauth2/index.js +1 -1
- package/dist/{oauth2-C8-hfKTF.cjs → oauth2-C4Pt8KMZ.cjs} +87 -87
- package/dist/{oauth2-CjVUvPq7.js → oauth2-CP3eVHS_.js} +88 -88
- package/dist/social-providers/index.cjs +963 -888
- package/dist/social-providers/index.d.cts +3 -4
- package/dist/social-providers/index.d.ts +3 -4
- package/dist/social-providers/index.js +1023 -948
- package/package.json +4 -3
- package/src/api/index.ts +3 -3
- package/src/context/endpoint-context.ts +1 -1
- package/src/context/index.ts +7 -7
- package/src/context/transaction.ts +2 -2
- package/src/db/adapter/index.ts +146 -128
- package/src/db/index.ts +11 -11
- package/src/db/plugin.ts +3 -3
- package/src/db/type.ts +47 -41
- package/src/env/index.ts +9 -9
- package/src/env/logger.test.ts +2 -2
- package/src/env/logger.ts +11 -9
- package/src/error/index.ts +1 -1
- package/src/oauth2/client-credentials-token.ts +9 -9
- package/src/oauth2/create-authorization-url.ts +12 -12
- package/src/oauth2/index.ts +10 -11
- package/src/oauth2/oauth-provider.ts +91 -74
- package/src/oauth2/refresh-access-token.ts +12 -12
- package/src/oauth2/validate-authorization-code.ts +13 -13
- package/src/social-providers/apple.ts +6 -6
- package/src/social-providers/atlassian.ts +23 -18
- package/src/social-providers/cognito.ts +17 -14
- package/src/social-providers/discord.ts +6 -6
- package/src/social-providers/dropbox.ts +3 -3
- package/src/social-providers/facebook.ts +10 -7
- package/src/social-providers/figma.ts +8 -5
- package/src/social-providers/github.ts +2 -2
- package/src/social-providers/gitlab.ts +7 -7
- package/src/social-providers/google.ts +15 -12
- package/src/social-providers/huggingface.ts +25 -23
- package/src/social-providers/index.ts +29 -26
- package/src/social-providers/kakao.ts +39 -39
- package/src/social-providers/kick.ts +3 -3
- package/src/social-providers/line.ts +10 -10
- package/src/social-providers/linear.ts +4 -4
- package/src/social-providers/linkedin.ts +3 -3
- package/src/social-providers/microsoft-entra-id.ts +15 -13
- package/src/social-providers/naver.ts +3 -3
- package/src/social-providers/notion.ts +9 -7
- package/src/social-providers/paybin.ts +122 -0
- package/src/social-providers/paypal.ts +29 -27
- package/src/social-providers/polar.ts +20 -18
- package/src/social-providers/reddit.ts +4 -4
- package/src/social-providers/roblox.ts +11 -8
- package/src/social-providers/salesforce.ts +22 -17
- package/src/social-providers/slack.ts +3 -3
- package/src/social-providers/spotify.ts +3 -3
- package/src/social-providers/tiktok.ts +30 -28
- package/src/social-providers/twitch.ts +6 -6
- package/src/social-providers/twitter.ts +47 -43
- package/src/social-providers/vk.ts +11 -10
- package/src/social-providers/zoom.ts +15 -13
- package/src/types/context.ts +23 -17
- package/src/types/index.ts +11 -10
- package/src/types/init-options.ts +1037 -932
- package/src/types/plugin-client.ts +44 -13
- package/src/types/plugin.ts +66 -52
- package/dist/helper-BH5srn6K.d.ts +0 -6
- package/dist/helper-ChPUVnMr.d.cts +0 -6
- package/dist/index-BCxkjvux.d.cts +0 -344
- package/dist/index-CZCOI9An.d.ts +0 -344
- package/dist/index-Cg7SVnu9.d.cts +0 -4645
- package/dist/index-DQNPxXof.d.ts +0 -262
- package/dist/index-DXj1sY8B.d.cts +0 -1772
- package/dist/index-DgTKobWC.d.ts +0 -1772
- package/dist/index-RfHoxHB4.d.ts +0 -4531
- package/dist/index-daoIWR6L.d.cts +0 -262
- /package/dist/{index-CR-gJyzm.d.ts → index-BzepAavo.d.cts} +0 -0
- /package/dist/{index-CilaMiAm.d.cts → index-DT7CRnvv.d.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BetterAuthPlugin } from "./plugin";
|
|
2
1
|
import type {
|
|
3
2
|
BetterFetch,
|
|
4
3
|
BetterFetchOption,
|
|
5
4
|
BetterFetchPlugin,
|
|
6
5
|
} from "@better-fetch/fetch";
|
|
6
|
+
import type { Atom, WritableAtom } from "nanostores";
|
|
7
7
|
import type { LiteralString } from "./helper";
|
|
8
8
|
import type { BetterAuthOptions } from "./init-options";
|
|
9
|
-
import type {
|
|
9
|
+
import type { BetterAuthPlugin } from "./plugin";
|
|
10
10
|
|
|
11
11
|
export interface ClientStore {
|
|
12
12
|
notify: (signal: string) => void;
|
|
@@ -19,13 +19,44 @@ export type ClientAtomListener = {
|
|
|
19
19
|
signal: "$sessionSignal" | Omit<string, "$sessionSignal">;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
export interface RevalidateOptions {
|
|
23
|
+
/**
|
|
24
|
+
* A time interval (in seconds) after which the session will be re-fetched.
|
|
25
|
+
* If set to `0` (default), the session is not polled.
|
|
26
|
+
*
|
|
27
|
+
* This helps prevent session expiry during idle periods by periodically
|
|
28
|
+
* refreshing the session.
|
|
29
|
+
*
|
|
30
|
+
* @default 0
|
|
31
|
+
*/
|
|
32
|
+
refetchInterval?: number | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Automatically refetch the session when the user switches back to the window/tab.
|
|
35
|
+
* This option activates this behavior if set to `true` (default).
|
|
36
|
+
*
|
|
37
|
+
* Prevents expired sessions when users switch tabs and come back later.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
refetchOnWindowFocus?: boolean | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Set to `false` to stop polling when the device has no internet access
|
|
44
|
+
* (determined by `navigator.onLine`).
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
47
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
|
|
48
|
+
*/
|
|
49
|
+
refetchWhenOffline?: boolean | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
22
52
|
export interface BetterAuthClientOptions {
|
|
23
|
-
fetchOptions?: BetterFetchOption;
|
|
24
|
-
plugins?: BetterAuthClientPlugin[];
|
|
25
|
-
baseURL?: string;
|
|
26
|
-
basePath?: string;
|
|
27
|
-
disableDefaultFetchPlugins?: boolean;
|
|
28
|
-
$InferAuth?: BetterAuthOptions;
|
|
53
|
+
fetchOptions?: BetterFetchOption | undefined;
|
|
54
|
+
plugins?: BetterAuthClientPlugin[] | undefined;
|
|
55
|
+
baseURL?: string | undefined;
|
|
56
|
+
basePath?: string | undefined;
|
|
57
|
+
disableDefaultFetchPlugins?: boolean | undefined;
|
|
58
|
+
$InferAuth?: BetterAuthOptions | undefined;
|
|
59
|
+
sessionOptions?: RevalidateOptions | undefined;
|
|
29
60
|
}
|
|
30
61
|
|
|
31
62
|
export interface BetterAuthClientPlugin {
|
|
@@ -34,7 +65,7 @@ export interface BetterAuthClientPlugin {
|
|
|
34
65
|
* only used for type inference. don't pass the
|
|
35
66
|
* actual plugin
|
|
36
67
|
*/
|
|
37
|
-
$InferServerPlugin?: BetterAuthPlugin;
|
|
68
|
+
$InferServerPlugin?: BetterAuthPlugin | undefined;
|
|
38
69
|
/**
|
|
39
70
|
* Custom actions
|
|
40
71
|
*/
|
|
@@ -50,20 +81,20 @@ export interface BetterAuthClientPlugin {
|
|
|
50
81
|
* State atoms that'll be resolved by each framework
|
|
51
82
|
* auth store.
|
|
52
83
|
*/
|
|
53
|
-
getAtoms?: ($fetch: BetterFetch) => Record<string, Atom<any
|
|
84
|
+
getAtoms?: (($fetch: BetterFetch) => Record<string, Atom<any>>) | undefined;
|
|
54
85
|
/**
|
|
55
86
|
* specify path methods for server plugin inferred
|
|
56
87
|
* endpoints to force a specific method.
|
|
57
88
|
*/
|
|
58
|
-
pathMethods?: Record<string, "POST" | "GET"
|
|
89
|
+
pathMethods?: Record<string, "POST" | "GET"> | undefined;
|
|
59
90
|
/**
|
|
60
91
|
* Better fetch plugins
|
|
61
92
|
*/
|
|
62
|
-
fetchPlugins?: BetterFetchPlugin[];
|
|
93
|
+
fetchPlugins?: BetterFetchPlugin[] | undefined;
|
|
63
94
|
/**
|
|
64
95
|
* a list of recaller based on a matcher function.
|
|
65
96
|
* The signal name needs to match a signal in this
|
|
66
97
|
* plugin or any plugin the user might have added.
|
|
67
98
|
*/
|
|
68
|
-
atomListeners?: ClientAtomListener[];
|
|
99
|
+
atomListeners?: ClientAtomListener[] | undefined;
|
|
69
100
|
}
|
package/src/types/plugin.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Migration } from "kysely";
|
|
2
|
-
import type { AuthContext } from "./context";
|
|
3
1
|
import type {
|
|
4
2
|
Endpoint,
|
|
5
3
|
EndpointContext,
|
|
6
4
|
InputContext,
|
|
7
5
|
Middleware,
|
|
8
6
|
} from "better-call";
|
|
7
|
+
import type { Migration } from "kysely";
|
|
8
|
+
import type { AuthMiddleware } from "../api";
|
|
9
9
|
import type { BetterAuthPluginDBSchema } from "../db";
|
|
10
|
+
import type { AuthContext } from "./context";
|
|
10
11
|
import type { LiteralString } from "./helper";
|
|
11
12
|
import type { BetterAuthOptions } from "./init-options";
|
|
12
|
-
import type { AuthMiddleware } from "../api";
|
|
13
13
|
|
|
14
14
|
type Awaitable<T> = T | Promise<T>;
|
|
15
15
|
type DeepPartial<T> = T extends Function
|
|
@@ -23,8 +23,8 @@ export type HookEndpointContext = Partial<
|
|
|
23
23
|
> & {
|
|
24
24
|
path: string;
|
|
25
25
|
context: AuthContext & {
|
|
26
|
-
returned?: unknown;
|
|
27
|
-
responseHeaders?: Headers;
|
|
26
|
+
returned?: unknown | undefined;
|
|
27
|
+
responseHeaders?: Headers | undefined;
|
|
28
28
|
};
|
|
29
29
|
headers?: Headers | undefined;
|
|
30
30
|
};
|
|
@@ -35,48 +35,60 @@ export type BetterAuthPlugin = {
|
|
|
35
35
|
* The init function is called when the plugin is initialized.
|
|
36
36
|
* You can return a new context or modify the existing context.
|
|
37
37
|
*/
|
|
38
|
-
init?:
|
|
39
|
-
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
middlewares?: {
|
|
49
|
-
path: string;
|
|
50
|
-
middleware: Middleware;
|
|
51
|
-
}[];
|
|
52
|
-
onRequest?: (
|
|
53
|
-
request: Request,
|
|
54
|
-
ctx: AuthContext,
|
|
55
|
-
) => Promise<
|
|
38
|
+
init?:
|
|
39
|
+
| ((ctx: AuthContext) =>
|
|
40
|
+
| Awaitable<{
|
|
41
|
+
context?: DeepPartial<Omit<AuthContext, "options">>;
|
|
42
|
+
options?: Partial<BetterAuthOptions>;
|
|
43
|
+
}>
|
|
44
|
+
| void
|
|
45
|
+
| Promise<void>)
|
|
46
|
+
| undefined;
|
|
47
|
+
endpoints?:
|
|
56
48
|
| {
|
|
57
|
-
|
|
49
|
+
[key: string]: Endpoint;
|
|
58
50
|
}
|
|
51
|
+
| undefined;
|
|
52
|
+
middlewares?:
|
|
53
|
+
| {
|
|
54
|
+
path: string;
|
|
55
|
+
middleware: Middleware;
|
|
56
|
+
}[]
|
|
57
|
+
| undefined;
|
|
58
|
+
onRequest?:
|
|
59
|
+
| ((
|
|
60
|
+
request: Request,
|
|
61
|
+
ctx: AuthContext,
|
|
62
|
+
) => Promise<
|
|
63
|
+
| {
|
|
64
|
+
response: Response;
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
request: Request;
|
|
68
|
+
}
|
|
69
|
+
| void
|
|
70
|
+
>)
|
|
71
|
+
| undefined;
|
|
72
|
+
onResponse?:
|
|
73
|
+
| ((
|
|
74
|
+
response: Response,
|
|
75
|
+
ctx: AuthContext,
|
|
76
|
+
) => Promise<{
|
|
77
|
+
response: Response;
|
|
78
|
+
} | void>)
|
|
79
|
+
| undefined;
|
|
80
|
+
hooks?:
|
|
59
81
|
| {
|
|
60
|
-
|
|
82
|
+
before?: {
|
|
83
|
+
matcher: (context: HookEndpointContext) => boolean;
|
|
84
|
+
handler: AuthMiddleware;
|
|
85
|
+
}[];
|
|
86
|
+
after?: {
|
|
87
|
+
matcher: (context: HookEndpointContext) => boolean;
|
|
88
|
+
handler: AuthMiddleware;
|
|
89
|
+
}[];
|
|
61
90
|
}
|
|
62
|
-
|
|
|
63
|
-
>;
|
|
64
|
-
onResponse?: (
|
|
65
|
-
response: Response,
|
|
66
|
-
ctx: AuthContext,
|
|
67
|
-
) => Promise<{
|
|
68
|
-
response: Response;
|
|
69
|
-
} | void>;
|
|
70
|
-
hooks?: {
|
|
71
|
-
before?: {
|
|
72
|
-
matcher: (context: HookEndpointContext) => boolean;
|
|
73
|
-
handler: AuthMiddleware;
|
|
74
|
-
}[];
|
|
75
|
-
after?: {
|
|
76
|
-
matcher: (context: HookEndpointContext) => boolean;
|
|
77
|
-
handler: AuthMiddleware;
|
|
78
|
-
}[];
|
|
79
|
-
};
|
|
91
|
+
| undefined;
|
|
80
92
|
/**
|
|
81
93
|
* Schema the plugin needs
|
|
82
94
|
*
|
|
@@ -104,7 +116,7 @@ export type BetterAuthPlugin = {
|
|
|
104
116
|
* } as AuthPluginSchema
|
|
105
117
|
* ```
|
|
106
118
|
*/
|
|
107
|
-
schema?: BetterAuthPluginDBSchema;
|
|
119
|
+
schema?: BetterAuthPluginDBSchema | undefined;
|
|
108
120
|
/**
|
|
109
121
|
* The migrations of the plugin. If you define schema that will automatically create
|
|
110
122
|
* migrations for you.
|
|
@@ -112,7 +124,7 @@ export type BetterAuthPlugin = {
|
|
|
112
124
|
* ⚠️ Only uses this if you dont't want to use the schema option and you disabled migrations for
|
|
113
125
|
* the tables.
|
|
114
126
|
*/
|
|
115
|
-
migrations?: Record<string, Migration
|
|
127
|
+
migrations?: Record<string, Migration> | undefined;
|
|
116
128
|
/**
|
|
117
129
|
* The options of the plugin
|
|
118
130
|
*/
|
|
@@ -120,17 +132,19 @@ export type BetterAuthPlugin = {
|
|
|
120
132
|
/**
|
|
121
133
|
* types to be inferred
|
|
122
134
|
*/
|
|
123
|
-
$Infer?: Record<string, any
|
|
135
|
+
$Infer?: Record<string, any> | undefined;
|
|
124
136
|
/**
|
|
125
137
|
* The rate limit rules to apply to specific paths.
|
|
126
138
|
*/
|
|
127
|
-
rateLimit?:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
rateLimit?:
|
|
140
|
+
| {
|
|
141
|
+
window: number;
|
|
142
|
+
max: number;
|
|
143
|
+
pathMatcher: (path: string) => boolean;
|
|
144
|
+
}[]
|
|
145
|
+
| undefined;
|
|
132
146
|
/**
|
|
133
147
|
* The error codes returned by the plugin
|
|
134
148
|
*/
|
|
135
|
-
$ERROR_CODES?: Record<string, string
|
|
149
|
+
$ERROR_CODES?: Record<string, string> | undefined;
|
|
136
150
|
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/types/helper.d.ts
|
|
2
|
-
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
3
|
-
type LiteralString = "" | (string & Record<never, never>);
|
|
4
|
-
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { LiteralUnion as n, LiteralString as t };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/types/helper.d.ts
|
|
2
|
-
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
3
|
-
type LiteralString = "" | (string & Record<never, never>);
|
|
4
|
-
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
5
|
-
//#endregion
|
|
6
|
-
export { LiteralUnion as n, LiteralString as t };
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { t as LiteralString } from "./helper-ChPUVnMr.cjs";
|
|
2
|
-
import * as jose0 from "jose";
|
|
3
|
-
|
|
4
|
-
//#region src/oauth2/oauth-provider.d.ts
|
|
5
|
-
interface OAuth2Tokens {
|
|
6
|
-
tokenType?: string;
|
|
7
|
-
accessToken?: string;
|
|
8
|
-
refreshToken?: string;
|
|
9
|
-
accessTokenExpiresAt?: Date;
|
|
10
|
-
refreshTokenExpiresAt?: Date;
|
|
11
|
-
scopes?: string[];
|
|
12
|
-
idToken?: string;
|
|
13
|
-
}
|
|
14
|
-
type OAuth2UserInfo = {
|
|
15
|
-
id: string | number;
|
|
16
|
-
name?: string;
|
|
17
|
-
email?: string | null;
|
|
18
|
-
image?: string;
|
|
19
|
-
emailVerified: boolean;
|
|
20
|
-
};
|
|
21
|
-
interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
|
|
22
|
-
id: LiteralString;
|
|
23
|
-
createAuthorizationURL: (data: {
|
|
24
|
-
state: string;
|
|
25
|
-
codeVerifier: string;
|
|
26
|
-
scopes?: string[];
|
|
27
|
-
redirectURI: string;
|
|
28
|
-
display?: string;
|
|
29
|
-
loginHint?: string;
|
|
30
|
-
}) => Promise<URL> | URL;
|
|
31
|
-
name: string;
|
|
32
|
-
validateAuthorizationCode: (data: {
|
|
33
|
-
code: string;
|
|
34
|
-
redirectURI: string;
|
|
35
|
-
codeVerifier?: string;
|
|
36
|
-
deviceId?: string;
|
|
37
|
-
}) => Promise<OAuth2Tokens>;
|
|
38
|
-
getUserInfo: (token: OAuth2Tokens & {
|
|
39
|
-
/**
|
|
40
|
-
* The user object from the provider
|
|
41
|
-
* This is only available for some providers like Apple
|
|
42
|
-
*/
|
|
43
|
-
user?: {
|
|
44
|
-
name?: {
|
|
45
|
-
firstName?: string;
|
|
46
|
-
lastName?: string;
|
|
47
|
-
};
|
|
48
|
-
email?: string;
|
|
49
|
-
};
|
|
50
|
-
}) => Promise<{
|
|
51
|
-
user: OAuth2UserInfo;
|
|
52
|
-
data: T;
|
|
53
|
-
} | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Custom function to refresh a token
|
|
56
|
-
*/
|
|
57
|
-
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
58
|
-
revokeToken?: (token: string) => Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Verify the id token
|
|
61
|
-
* @param token - The id token
|
|
62
|
-
* @param nonce - The nonce
|
|
63
|
-
* @returns True if the id token is valid, false otherwise
|
|
64
|
-
*/
|
|
65
|
-
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
66
|
-
/**
|
|
67
|
-
* Disable implicit sign up for new users. When set to true for the provider,
|
|
68
|
-
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
69
|
-
*/
|
|
70
|
-
disableImplicitSignUp?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Disable sign up for new users.
|
|
73
|
-
*/
|
|
74
|
-
disableSignUp?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Options for the provider
|
|
77
|
-
*/
|
|
78
|
-
options?: O;
|
|
79
|
-
}
|
|
80
|
-
type ProviderOptions<Profile extends Record<string, any> = any> = {
|
|
81
|
-
/**
|
|
82
|
-
* The client ID of your application.
|
|
83
|
-
*
|
|
84
|
-
* This is usually a string but can be any type depending on the provider.
|
|
85
|
-
*/
|
|
86
|
-
clientId?: unknown;
|
|
87
|
-
/**
|
|
88
|
-
* The client secret of your application
|
|
89
|
-
*/
|
|
90
|
-
clientSecret?: string;
|
|
91
|
-
/**
|
|
92
|
-
* The scopes you want to request from the provider
|
|
93
|
-
*/
|
|
94
|
-
scope?: string[];
|
|
95
|
-
/**
|
|
96
|
-
* Remove default scopes of the provider
|
|
97
|
-
*/
|
|
98
|
-
disableDefaultScope?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* The redirect URL for your application. This is where the provider will
|
|
101
|
-
* redirect the user after the sign in process. Make sure this URL is
|
|
102
|
-
* whitelisted in the provider's dashboard.
|
|
103
|
-
*/
|
|
104
|
-
redirectURI?: string;
|
|
105
|
-
/**
|
|
106
|
-
* The client key of your application
|
|
107
|
-
* Tiktok Social Provider uses this field instead of clientId
|
|
108
|
-
*/
|
|
109
|
-
clientKey?: string;
|
|
110
|
-
/**
|
|
111
|
-
* Disable provider from allowing users to sign in
|
|
112
|
-
* with this provider with an id token sent from the
|
|
113
|
-
* client.
|
|
114
|
-
*/
|
|
115
|
-
disableIdTokenSignIn?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* verifyIdToken function to verify the id token
|
|
118
|
-
*/
|
|
119
|
-
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
120
|
-
/**
|
|
121
|
-
* Custom function to get user info from the provider
|
|
122
|
-
*/
|
|
123
|
-
getUserInfo?: (token: OAuth2Tokens) => Promise<{
|
|
124
|
-
user: {
|
|
125
|
-
id: string;
|
|
126
|
-
name?: string;
|
|
127
|
-
email?: string | null;
|
|
128
|
-
image?: string;
|
|
129
|
-
emailVerified: boolean;
|
|
130
|
-
[key: string]: any;
|
|
131
|
-
};
|
|
132
|
-
data: any;
|
|
133
|
-
}>;
|
|
134
|
-
/**
|
|
135
|
-
* Custom function to refresh a token
|
|
136
|
-
*/
|
|
137
|
-
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
138
|
-
/**
|
|
139
|
-
* Custom function to map the provider profile to a
|
|
140
|
-
* user.
|
|
141
|
-
*/
|
|
142
|
-
mapProfileToUser?: (profile: Profile) => {
|
|
143
|
-
id?: string;
|
|
144
|
-
name?: string;
|
|
145
|
-
email?: string | null;
|
|
146
|
-
image?: string;
|
|
147
|
-
emailVerified?: boolean;
|
|
148
|
-
[key: string]: any;
|
|
149
|
-
} | Promise<{
|
|
150
|
-
id?: string;
|
|
151
|
-
name?: string;
|
|
152
|
-
email?: string | null;
|
|
153
|
-
image?: string;
|
|
154
|
-
emailVerified?: boolean;
|
|
155
|
-
[key: string]: any;
|
|
156
|
-
}>;
|
|
157
|
-
/**
|
|
158
|
-
* Disable implicit sign up for new users. When set to true for the provider,
|
|
159
|
-
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
160
|
-
*/
|
|
161
|
-
disableImplicitSignUp?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Disable sign up for new users.
|
|
164
|
-
*/
|
|
165
|
-
disableSignUp?: boolean;
|
|
166
|
-
/**
|
|
167
|
-
* The prompt to use for the authorization code request
|
|
168
|
-
*/
|
|
169
|
-
prompt?: "select_account" | "consent" | "login" | "none" | "select_account consent";
|
|
170
|
-
/**
|
|
171
|
-
* The response mode to use for the authorization code request
|
|
172
|
-
*/
|
|
173
|
-
responseMode?: "query" | "form_post";
|
|
174
|
-
/**
|
|
175
|
-
* If enabled, the user info will be overridden with the provider user info
|
|
176
|
-
* This is useful if you want to use the provider user info to update the user info
|
|
177
|
-
*
|
|
178
|
-
* @default false
|
|
179
|
-
*/
|
|
180
|
-
overrideUserInfoOnSignIn?: boolean;
|
|
181
|
-
};
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/oauth2/utils.d.ts
|
|
184
|
-
declare function getOAuth2Tokens(data: Record<string, any>): OAuth2Tokens;
|
|
185
|
-
declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/oauth2/create-authorization-url.d.ts
|
|
188
|
-
declare function createAuthorizationURL({
|
|
189
|
-
id,
|
|
190
|
-
options,
|
|
191
|
-
authorizationEndpoint,
|
|
192
|
-
state,
|
|
193
|
-
codeVerifier,
|
|
194
|
-
scopes,
|
|
195
|
-
claims,
|
|
196
|
-
redirectURI,
|
|
197
|
-
duration,
|
|
198
|
-
prompt,
|
|
199
|
-
accessType,
|
|
200
|
-
responseType,
|
|
201
|
-
display,
|
|
202
|
-
loginHint,
|
|
203
|
-
hd,
|
|
204
|
-
responseMode,
|
|
205
|
-
additionalParams,
|
|
206
|
-
scopeJoiner
|
|
207
|
-
}: {
|
|
208
|
-
id: string;
|
|
209
|
-
options: ProviderOptions;
|
|
210
|
-
redirectURI: string;
|
|
211
|
-
authorizationEndpoint: string;
|
|
212
|
-
state: string;
|
|
213
|
-
codeVerifier?: string;
|
|
214
|
-
scopes: string[];
|
|
215
|
-
claims?: string[];
|
|
216
|
-
duration?: string;
|
|
217
|
-
prompt?: string;
|
|
218
|
-
accessType?: string;
|
|
219
|
-
responseType?: string;
|
|
220
|
-
display?: string;
|
|
221
|
-
loginHint?: string;
|
|
222
|
-
hd?: string;
|
|
223
|
-
responseMode?: string;
|
|
224
|
-
additionalParams?: Record<string, string>;
|
|
225
|
-
scopeJoiner?: string;
|
|
226
|
-
}): Promise<URL>;
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/oauth2/validate-authorization-code.d.ts
|
|
229
|
-
declare function createAuthorizationCodeRequest({
|
|
230
|
-
code,
|
|
231
|
-
codeVerifier,
|
|
232
|
-
redirectURI,
|
|
233
|
-
options,
|
|
234
|
-
authentication,
|
|
235
|
-
deviceId,
|
|
236
|
-
headers,
|
|
237
|
-
additionalParams,
|
|
238
|
-
resource
|
|
239
|
-
}: {
|
|
240
|
-
code: string;
|
|
241
|
-
redirectURI: string;
|
|
242
|
-
options: Partial<ProviderOptions>;
|
|
243
|
-
codeVerifier?: string;
|
|
244
|
-
deviceId?: string;
|
|
245
|
-
authentication?: "basic" | "post";
|
|
246
|
-
headers?: Record<string, string>;
|
|
247
|
-
additionalParams?: Record<string, string>;
|
|
248
|
-
resource?: string | string[];
|
|
249
|
-
}): {
|
|
250
|
-
body: URLSearchParams;
|
|
251
|
-
headers: Record<string, any>;
|
|
252
|
-
};
|
|
253
|
-
declare function validateAuthorizationCode({
|
|
254
|
-
code,
|
|
255
|
-
codeVerifier,
|
|
256
|
-
redirectURI,
|
|
257
|
-
options,
|
|
258
|
-
tokenEndpoint,
|
|
259
|
-
authentication,
|
|
260
|
-
deviceId,
|
|
261
|
-
headers,
|
|
262
|
-
additionalParams,
|
|
263
|
-
resource
|
|
264
|
-
}: {
|
|
265
|
-
code: string;
|
|
266
|
-
redirectURI: string;
|
|
267
|
-
options: Partial<ProviderOptions>;
|
|
268
|
-
codeVerifier?: string;
|
|
269
|
-
deviceId?: string;
|
|
270
|
-
tokenEndpoint: string;
|
|
271
|
-
authentication?: "basic" | "post";
|
|
272
|
-
headers?: Record<string, string>;
|
|
273
|
-
additionalParams?: Record<string, string>;
|
|
274
|
-
resource?: string | string[];
|
|
275
|
-
}): Promise<OAuth2Tokens>;
|
|
276
|
-
declare function validateToken(token: string, jwksEndpoint: string): Promise<jose0.JWTVerifyResult<jose0.JWTPayload>>;
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/oauth2/refresh-access-token.d.ts
|
|
279
|
-
declare function createRefreshAccessTokenRequest({
|
|
280
|
-
refreshToken,
|
|
281
|
-
options,
|
|
282
|
-
authentication,
|
|
283
|
-
extraParams,
|
|
284
|
-
resource
|
|
285
|
-
}: {
|
|
286
|
-
refreshToken: string;
|
|
287
|
-
options: Partial<ProviderOptions>;
|
|
288
|
-
authentication?: "basic" | "post";
|
|
289
|
-
extraParams?: Record<string, string>;
|
|
290
|
-
resource?: string | string[];
|
|
291
|
-
}): {
|
|
292
|
-
body: URLSearchParams;
|
|
293
|
-
headers: Record<string, any>;
|
|
294
|
-
};
|
|
295
|
-
declare function refreshAccessToken({
|
|
296
|
-
refreshToken,
|
|
297
|
-
options,
|
|
298
|
-
tokenEndpoint,
|
|
299
|
-
authentication,
|
|
300
|
-
extraParams
|
|
301
|
-
}: {
|
|
302
|
-
refreshToken: string;
|
|
303
|
-
options: Partial<ProviderOptions>;
|
|
304
|
-
tokenEndpoint: string;
|
|
305
|
-
authentication?: "basic" | "post";
|
|
306
|
-
extraParams?: Record<string, string>;
|
|
307
|
-
/** @deprecated always "refresh_token" */
|
|
308
|
-
grantType?: string;
|
|
309
|
-
}): Promise<OAuth2Tokens>;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/oauth2/client-credentials-token.d.ts
|
|
312
|
-
declare function createClientCredentialsTokenRequest({
|
|
313
|
-
options,
|
|
314
|
-
scope,
|
|
315
|
-
authentication,
|
|
316
|
-
resource
|
|
317
|
-
}: {
|
|
318
|
-
options: ProviderOptions & {
|
|
319
|
-
clientSecret: string;
|
|
320
|
-
};
|
|
321
|
-
scope?: string;
|
|
322
|
-
authentication?: "basic" | "post";
|
|
323
|
-
resource?: string | string[];
|
|
324
|
-
}): {
|
|
325
|
-
body: URLSearchParams;
|
|
326
|
-
headers: Record<string, any>;
|
|
327
|
-
};
|
|
328
|
-
declare function clientCredentialsToken({
|
|
329
|
-
options,
|
|
330
|
-
tokenEndpoint,
|
|
331
|
-
scope,
|
|
332
|
-
authentication,
|
|
333
|
-
resource
|
|
334
|
-
}: {
|
|
335
|
-
options: ProviderOptions & {
|
|
336
|
-
clientSecret: string;
|
|
337
|
-
};
|
|
338
|
-
tokenEndpoint: string;
|
|
339
|
-
scope: string;
|
|
340
|
-
authentication?: "basic" | "post";
|
|
341
|
-
resource?: string | string[];
|
|
342
|
-
}): Promise<OAuth2Tokens>;
|
|
343
|
-
//#endregion
|
|
344
|
-
export { createAuthorizationCodeRequest as a, createAuthorizationURL as c, OAuth2Tokens as d, OAuth2UserInfo as f, refreshAccessToken as i, generateCodeChallenge as l, ProviderOptions as m, createClientCredentialsTokenRequest as n, validateAuthorizationCode as o, OAuthProvider as p, createRefreshAccessTokenRequest as r, validateToken as s, clientCredentialsToken as t, getOAuth2Tokens as u };
|