@gatwech/core 0.0.1-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.
Files changed (109) hide show
  1. package/.turbo/turbo-build.log +42 -0
  2. package/dist/api/index.d.mts +3 -0
  3. package/dist/api/index.mjs +26 -0
  4. package/dist/async_hooks/index.d.mts +2 -0
  5. package/dist/async_hooks/index.mjs +3 -0
  6. package/dist/async_hooks-BrLqUNsE.mjs +18 -0
  7. package/dist/context/index.d.mts +44 -0
  8. package/dist/context/index.mjs +4 -0
  9. package/dist/context-DxzHfoWW.mjs +108 -0
  10. package/dist/db/adapter/index.d.mts +3 -0
  11. package/dist/db/adapter/index.mjs +1 -0
  12. package/dist/db/index.d.mts +3 -0
  13. package/dist/db/index.mjs +61 -0
  14. package/dist/env/index.d.mts +2 -0
  15. package/dist/env/index.mjs +3 -0
  16. package/dist/env-JMSMESs1.mjs +245 -0
  17. package/dist/error/index.d.mts +35 -0
  18. package/dist/error/index.mjs +4 -0
  19. package/dist/error-41YsFQ8b.mjs +45 -0
  20. package/dist/index-CRg-E-VF.d.mts +7 -0
  21. package/dist/index-DLP-K0uY.d.mts +82 -0
  22. package/dist/index-DjrJweYn.d.mts +7312 -0
  23. package/dist/index.d.mts +3 -0
  24. package/dist/index.mjs +1 -0
  25. package/dist/oauth2/index.d.mts +3 -0
  26. package/dist/oauth2/index.mjs +3 -0
  27. package/dist/oauth2-DyI7_CNv.mjs +235 -0
  28. package/dist/social-providers/index.d.mts +3 -0
  29. package/dist/social-providers/index.mjs +2513 -0
  30. package/dist/utils/index.d.mts +9 -0
  31. package/dist/utils/index.mjs +3 -0
  32. package/dist/utils-BFQCAfNW.mjs +7 -0
  33. package/package.json +131 -0
  34. package/src/api/index.ts +57 -0
  35. package/src/async_hooks/index.ts +35 -0
  36. package/src/context/endpoint-context.ts +48 -0
  37. package/src/context/index.ts +21 -0
  38. package/src/context/request-state.test.ts +346 -0
  39. package/src/context/request-state.ts +75 -0
  40. package/src/context/transaction.ts +72 -0
  41. package/src/db/adapter/index.ts +466 -0
  42. package/src/db/index.ts +50 -0
  43. package/src/db/plugin.ts +11 -0
  44. package/src/db/schema/account.ts +34 -0
  45. package/src/db/schema/rate-limit.ts +21 -0
  46. package/src/db/schema/session.ts +17 -0
  47. package/src/db/schema/shared.ts +7 -0
  48. package/src/db/schema/user.ts +16 -0
  49. package/src/db/schema/verification.ts +15 -0
  50. package/src/db/type.ts +180 -0
  51. package/src/env/color-depth.ts +172 -0
  52. package/src/env/env-impl.ts +124 -0
  53. package/src/env/index.ts +23 -0
  54. package/src/env/logger.test.ts +33 -0
  55. package/src/env/logger.ts +145 -0
  56. package/src/error/codes.ts +31 -0
  57. package/src/error/index.ts +11 -0
  58. package/src/index.ts +1 -0
  59. package/src/oauth2/client-credentials-token.ts +102 -0
  60. package/src/oauth2/create-authorization-url.ts +85 -0
  61. package/src/oauth2/index.ts +21 -0
  62. package/src/oauth2/oauth-provider.ts +211 -0
  63. package/src/oauth2/refresh-access-token.ts +124 -0
  64. package/src/oauth2/utils.ts +36 -0
  65. package/src/oauth2/validate-authorization-code.ts +154 -0
  66. package/src/social-providers/apple.ts +213 -0
  67. package/src/social-providers/atlassian.ts +132 -0
  68. package/src/social-providers/cognito.ts +269 -0
  69. package/src/social-providers/discord.ts +169 -0
  70. package/src/social-providers/dropbox.ts +112 -0
  71. package/src/social-providers/facebook.ts +204 -0
  72. package/src/social-providers/figma.ts +115 -0
  73. package/src/social-providers/github.ts +154 -0
  74. package/src/social-providers/gitlab.ts +152 -0
  75. package/src/social-providers/google.ts +171 -0
  76. package/src/social-providers/huggingface.ts +118 -0
  77. package/src/social-providers/index.ts +124 -0
  78. package/src/social-providers/kakao.ts +178 -0
  79. package/src/social-providers/kick.ts +92 -0
  80. package/src/social-providers/line.ts +169 -0
  81. package/src/social-providers/linear.ts +120 -0
  82. package/src/social-providers/linkedin.ts +110 -0
  83. package/src/social-providers/microsoft-entra-id.ts +245 -0
  84. package/src/social-providers/naver.ts +112 -0
  85. package/src/social-providers/notion.ts +108 -0
  86. package/src/social-providers/paybin.ts +122 -0
  87. package/src/social-providers/paypal.ts +263 -0
  88. package/src/social-providers/polar.ts +107 -0
  89. package/src/social-providers/reddit.ts +122 -0
  90. package/src/social-providers/roblox.ts +110 -0
  91. package/src/social-providers/salesforce.ts +159 -0
  92. package/src/social-providers/slack.ts +111 -0
  93. package/src/social-providers/spotify.ts +93 -0
  94. package/src/social-providers/tiktok.ts +210 -0
  95. package/src/social-providers/twitch.ts +111 -0
  96. package/src/social-providers/twitter.ts +198 -0
  97. package/src/social-providers/vk.ts +126 -0
  98. package/src/social-providers/zoom.ts +217 -0
  99. package/src/types/context.ts +269 -0
  100. package/src/types/cookie.ts +7 -0
  101. package/src/types/helper.ts +6 -0
  102. package/src/types/index.ts +21 -0
  103. package/src/types/init-options.ts +1346 -0
  104. package/src/types/plugin-client.ts +100 -0
  105. package/src/types/plugin.ts +158 -0
  106. package/src/utils/error-codes.ts +51 -0
  107. package/src/utils/index.ts +1 -0
  108. package/tsconfig.json +7 -0
  109. package/tsdown.config.ts +20 -0
@@ -0,0 +1,145 @@
1
+ import { getColorDepth } from "./color-depth";
2
+
3
+ export const TTY_COLORS = {
4
+ reset: "\x1b[0m",
5
+ bright: "\x1b[1m",
6
+ dim: "\x1b[2m",
7
+ undim: "\x1b[22m",
8
+ underscore: "\x1b[4m",
9
+ blink: "\x1b[5m",
10
+ reverse: "\x1b[7m",
11
+ hidden: "\x1b[8m",
12
+ fg: {
13
+ black: "\x1b[30m",
14
+ red: "\x1b[31m",
15
+ green: "\x1b[32m",
16
+ yellow: "\x1b[33m",
17
+ blue: "\x1b[34m",
18
+ magenta: "\x1b[35m",
19
+ cyan: "\x1b[36m",
20
+ white: "\x1b[37m",
21
+ },
22
+ bg: {
23
+ black: "\x1b[40m",
24
+ red: "\x1b[41m",
25
+ green: "\x1b[42m",
26
+ yellow: "\x1b[43m",
27
+ blue: "\x1b[44m",
28
+ magenta: "\x1b[45m",
29
+ cyan: "\x1b[46m",
30
+ white: "\x1b[47m",
31
+ },
32
+ } as const;
33
+
34
+ export type LogLevel = "info" | "success" | "warn" | "error" | "debug";
35
+
36
+ export const levels = ["info", "success", "warn", "error", "debug"] as const;
37
+
38
+ export function shouldPublishLog(
39
+ currentLogLevel: LogLevel,
40
+ logLevel: LogLevel
41
+ ): boolean {
42
+ return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
43
+ }
44
+
45
+ export interface Logger {
46
+ disabled?: boolean | undefined;
47
+ disableColors?: boolean | undefined;
48
+ level?: Exclude<LogLevel, "success"> | undefined;
49
+ log?:
50
+ | ((
51
+ level: Exclude<LogLevel, "success">,
52
+ message: string,
53
+ ...args: any[]
54
+ ) => void)
55
+ | undefined;
56
+ }
57
+
58
+ export type LogHandlerParams =
59
+ Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest]
60
+ ? Rest
61
+ : never;
62
+
63
+ const levelColors: Record<LogLevel, string> = {
64
+ info: TTY_COLORS.fg.blue,
65
+ success: TTY_COLORS.fg.green,
66
+ warn: TTY_COLORS.fg.yellow,
67
+ error: TTY_COLORS.fg.red,
68
+ debug: TTY_COLORS.fg.magenta,
69
+ };
70
+
71
+ const formatMessage = (
72
+ level: LogLevel,
73
+ message: string,
74
+ colorsEnabled: boolean
75
+ ): string => {
76
+ const timestamp = new Date().toISOString();
77
+
78
+ if (colorsEnabled) {
79
+ return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${
80
+ levelColors[level]
81
+ }${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${
82
+ TTY_COLORS.reset
83
+ } ${message}`;
84
+ }
85
+
86
+ return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
87
+ };
88
+
89
+ export type InternalLogger = {
90
+ [K in LogLevel]: (...params: LogHandlerParams) => void;
91
+ } & {
92
+ get level(): LogLevel;
93
+ };
94
+
95
+ export const createLogger = (options?: Logger | undefined): InternalLogger => {
96
+ const enabled = options?.disabled !== true;
97
+ const logLevel = options?.level ?? "error";
98
+
99
+ const isDisableColorsSpecified = options?.disableColors !== undefined;
100
+ const colorsEnabled = isDisableColorsSpecified
101
+ ? !options.disableColors
102
+ : getColorDepth() !== 1;
103
+
104
+ const LogFunc = (
105
+ level: LogLevel,
106
+ message: string,
107
+ args: any[] = []
108
+ ): void => {
109
+ if (!enabled || !shouldPublishLog(logLevel, level)) {
110
+ return;
111
+ }
112
+
113
+ const formattedMessage = formatMessage(level, message, colorsEnabled);
114
+
115
+ if (!options || typeof options.log !== "function") {
116
+ if (level === "error") {
117
+ console.error(formattedMessage, ...args);
118
+ } else if (level === "warn") {
119
+ console.warn(formattedMessage, ...args);
120
+ } else {
121
+ console.log(formattedMessage, ...args);
122
+ }
123
+ return;
124
+ }
125
+
126
+ options.log(level === "success" ? "info" : level, message, ...args);
127
+ };
128
+
129
+ const logger = Object.fromEntries(
130
+ levels.map((level) => [
131
+ level,
132
+ (...[message, ...args]: LogHandlerParams) =>
133
+ LogFunc(level, message, args),
134
+ ])
135
+ ) as Record<LogLevel, (...params: LogHandlerParams) => void>;
136
+
137
+ return {
138
+ ...logger,
139
+ get level() {
140
+ return logLevel;
141
+ },
142
+ };
143
+ };
144
+
145
+ export const logger = createLogger();
@@ -0,0 +1,31 @@
1
+ import { defineErrorCodes } from "../utils";
2
+
3
+ export const BASE_ERROR_CODES = defineErrorCodes({
4
+ USER_NOT_FOUND: "User not found",
5
+ FAILED_TO_CREATE_USER: "Failed to create user",
6
+ FAILED_TO_CREATE_SESSION: "Failed to create session",
7
+ FAILED_TO_UPDATE_USER: "Failed to update user",
8
+ FAILED_TO_GET_SESSION: "Failed to get session",
9
+ INVALID_PASSWORD: "Invalid password",
10
+ INVALID_EMAIL: "Invalid email",
11
+ INVALID_EMAIL_OR_PASSWORD: "Invalid email or password",
12
+ SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked",
13
+ PROVIDER_NOT_FOUND: "Provider not found",
14
+ INVALID_TOKEN: "Invalid token",
15
+ ID_TOKEN_NOT_SUPPORTED: "id_token not supported",
16
+ FAILED_TO_GET_USER_INFO: "Failed to get user info",
17
+ USER_EMAIL_NOT_FOUND: "User email not found",
18
+ EMAIL_NOT_VERIFIED: "Email not verified",
19
+ PASSWORD_TOO_SHORT: "Password too short",
20
+ PASSWORD_TOO_LONG: "Password too long",
21
+ USER_ALREADY_EXISTS: "User already exists.",
22
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:
23
+ "User already exists. Use another email.",
24
+ EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated",
25
+ CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found",
26
+ SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.",
27
+ FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account",
28
+ ACCOUNT_NOT_FOUND: "Account not found",
29
+ USER_ALREADY_HAS_PASSWORD:
30
+ "User already has a password. Provide that to delete the account.",
31
+ });
@@ -0,0 +1,11 @@
1
+ export class PayvoAuthError extends Error {
2
+ constructor(message: string, cause?: string | undefined) {
3
+ super(message);
4
+ this.name = "PayvoAuthError";
5
+ this.message = message;
6
+ this.cause = cause;
7
+ this.stack = "";
8
+ }
9
+ }
10
+
11
+ export { BASE_ERROR_CODES } from "./codes";
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1,102 @@
1
+ import { base64Url } from "@gatwech/utils/base64";
2
+ import { betterFetch } from "@better-fetch/fetch";
3
+ import type { OAuth2Tokens, ProviderOptions } from "./oauth-provider";
4
+
5
+ export function createClientCredentialsTokenRequest({
6
+ options,
7
+ scope,
8
+ authentication,
9
+ resource,
10
+ }: {
11
+ options: ProviderOptions & { clientSecret: string };
12
+ scope?: string | undefined;
13
+ authentication?: ("basic" | "post") | undefined;
14
+ resource?: (string | string[]) | undefined;
15
+ }) {
16
+ const body = new URLSearchParams();
17
+ const headers: Record<string, any> = {
18
+ "content-type": "application/x-www-form-urlencoded",
19
+ accept: "application/json",
20
+ };
21
+
22
+ body.set("grant_type", "client_credentials");
23
+ scope && body.set("scope", scope);
24
+ if (resource) {
25
+ if (typeof resource === "string") {
26
+ body.append("resource", resource);
27
+ } else {
28
+ for (const _resource of resource) {
29
+ body.append("resource", _resource);
30
+ }
31
+ }
32
+ }
33
+ if (authentication === "basic") {
34
+ const primaryClientId = Array.isArray(options.clientId)
35
+ ? options.clientId[0]
36
+ : options.clientId;
37
+ const encodedCredentials = base64Url.encode(
38
+ `${primaryClientId}:${options.clientSecret}`
39
+ );
40
+ headers["authorization"] = `Basic ${encodedCredentials}`;
41
+ } else {
42
+ const primaryClientId = Array.isArray(options.clientId)
43
+ ? options.clientId[0]
44
+ : options.clientId;
45
+ body.set("client_id", primaryClientId);
46
+ body.set("client_secret", options.clientSecret);
47
+ }
48
+
49
+ return {
50
+ body,
51
+ headers,
52
+ };
53
+ }
54
+
55
+ export async function clientCredentialsToken({
56
+ options,
57
+ tokenEndpoint,
58
+ scope,
59
+ authentication,
60
+ resource,
61
+ }: {
62
+ options: ProviderOptions & { clientSecret: string };
63
+ tokenEndpoint: string;
64
+ scope: string;
65
+ authentication?: ("basic" | "post") | undefined;
66
+ resource?: (string | string[]) | undefined;
67
+ }): Promise<OAuth2Tokens> {
68
+ const { body, headers } = createClientCredentialsTokenRequest({
69
+ options,
70
+ scope,
71
+ authentication,
72
+ resource,
73
+ });
74
+
75
+ const { data, error } = await betterFetch<{
76
+ access_token: string;
77
+ expires_in?: number | undefined;
78
+ token_type?: string | undefined;
79
+ scope?: string | undefined;
80
+ }>(tokenEndpoint, {
81
+ method: "POST",
82
+ body,
83
+ headers,
84
+ });
85
+ if (error) {
86
+ throw error;
87
+ }
88
+ const tokens: OAuth2Tokens = {
89
+ accessToken: data.access_token,
90
+ tokenType: data.token_type,
91
+ scopes: data.scope?.split(" "),
92
+ };
93
+
94
+ if (data.expires_in) {
95
+ const now = new Date();
96
+ tokens.accessTokenExpiresAt = new Date(
97
+ now.getTime() + data.expires_in * 1000
98
+ );
99
+ }
100
+
101
+ return tokens;
102
+ }
@@ -0,0 +1,85 @@
1
+ import type { ProviderOptions } from "./index";
2
+ import { generateCodeChallenge } from "./utils";
3
+
4
+ export async function createAuthorizationURL({
5
+ id,
6
+ options,
7
+ authorizationEndpoint,
8
+ state,
9
+ codeVerifier,
10
+ scopes,
11
+ claims,
12
+ redirectURI,
13
+ duration,
14
+ prompt,
15
+ accessType,
16
+ responseType,
17
+ display,
18
+ loginHint,
19
+ hd,
20
+ responseMode,
21
+ additionalParams,
22
+ scopeJoiner,
23
+ }: {
24
+ id: string;
25
+ options: ProviderOptions;
26
+ redirectURI: string;
27
+ authorizationEndpoint: string;
28
+ state: string;
29
+ codeVerifier?: string | undefined;
30
+ scopes: string[];
31
+ claims?: string[] | undefined;
32
+ duration?: string | undefined;
33
+ prompt?: string | undefined;
34
+ accessType?: string | undefined;
35
+ responseType?: string | undefined;
36
+ display?: string | undefined;
37
+ loginHint?: string | undefined;
38
+ hd?: string | undefined;
39
+ responseMode?: string | undefined;
40
+ additionalParams?: Record<string, string> | undefined;
41
+ scopeJoiner?: string | undefined;
42
+ }) {
43
+ const url = new URL(authorizationEndpoint);
44
+ url.searchParams.set("response_type", responseType || "code");
45
+ const primaryClientId = Array.isArray(options.clientId)
46
+ ? options.clientId[0]
47
+ : options.clientId;
48
+ url.searchParams.set("client_id", primaryClientId);
49
+ url.searchParams.set("state", state);
50
+ url.searchParams.set("scope", scopes.join(scopeJoiner || " "));
51
+ url.searchParams.set("redirect_uri", options.redirectURI || redirectURI);
52
+ duration && url.searchParams.set("duration", duration);
53
+ display && url.searchParams.set("display", display);
54
+ loginHint && url.searchParams.set("login_hint", loginHint);
55
+ prompt && url.searchParams.set("prompt", prompt);
56
+ hd && url.searchParams.set("hd", hd);
57
+ accessType && url.searchParams.set("access_type", accessType);
58
+ responseMode && url.searchParams.set("response_mode", responseMode);
59
+ if (codeVerifier) {
60
+ const codeChallenge = await generateCodeChallenge(codeVerifier);
61
+ url.searchParams.set("code_challenge_method", "S256");
62
+ url.searchParams.set("code_challenge", codeChallenge);
63
+ }
64
+ if (claims) {
65
+ const claimsObj = claims.reduce(
66
+ (acc, claim) => {
67
+ acc[claim] = null;
68
+ return acc;
69
+ },
70
+ {} as Record<string, null>,
71
+ );
72
+ url.searchParams.set(
73
+ "claims",
74
+ JSON.stringify({
75
+ id_token: { email: null, email_verified: null, ...claimsObj },
76
+ }),
77
+ );
78
+ }
79
+ if (additionalParams) {
80
+ Object.entries(additionalParams).forEach(([key, value]) => {
81
+ url.searchParams.set(key, value);
82
+ });
83
+ }
84
+ return url;
85
+ }
@@ -0,0 +1,21 @@
1
+ export {
2
+ clientCredentialsToken,
3
+ createClientCredentialsTokenRequest,
4
+ } from "./client-credentials-token";
5
+ export { createAuthorizationURL } from "./create-authorization-url";
6
+ export type {
7
+ OAuth2Tokens,
8
+ OAuth2UserInfo,
9
+ OAuthProvider,
10
+ ProviderOptions,
11
+ } from "./oauth-provider";
12
+ export {
13
+ createRefreshAccessTokenRequest,
14
+ refreshAccessToken,
15
+ } from "./refresh-access-token";
16
+ export { generateCodeChallenge, getOAuth2Tokens } from "./utils";
17
+ export {
18
+ createAuthorizationCodeRequest,
19
+ validateAuthorizationCode,
20
+ validateToken,
21
+ } from "./validate-authorization-code";
@@ -0,0 +1,211 @@
1
+ import type { LiteralString } from "../types";
2
+
3
+ export interface OAuth2Tokens {
4
+ tokenType?: string | undefined;
5
+ accessToken?: string | undefined;
6
+ refreshToken?: string | undefined;
7
+ accessTokenExpiresAt?: Date | undefined;
8
+ refreshTokenExpiresAt?: Date | undefined;
9
+ scopes?: string[] | undefined;
10
+ idToken?: string | undefined;
11
+ }
12
+
13
+ export type OAuth2UserInfo = {
14
+ id: string | number;
15
+ name?: string | undefined;
16
+ email?: (string | null) | undefined;
17
+ image?: string | undefined;
18
+ emailVerified: boolean;
19
+ };
20
+
21
+ export interface OAuthProvider<
22
+ T extends Record<string, any> = Record<string, any>,
23
+ O extends Record<string, any> = Partial<ProviderOptions>,
24
+ > {
25
+ id: LiteralString;
26
+ createAuthorizationURL: (data: {
27
+ state: string;
28
+ codeVerifier: string;
29
+ scopes?: string[] | undefined;
30
+ redirectURI: string;
31
+ display?: string | undefined;
32
+ loginHint?: string | undefined;
33
+ }) => Promise<URL> | URL;
34
+ name: string;
35
+ validateAuthorizationCode: (data: {
36
+ code: string;
37
+ redirectURI: string;
38
+ codeVerifier?: string | undefined;
39
+ deviceId?: string | undefined;
40
+ }) => Promise<OAuth2Tokens>;
41
+ getUserInfo: (
42
+ token: OAuth2Tokens & {
43
+ /**
44
+ * The user object from the provider
45
+ * This is only available for some providers like Apple
46
+ */
47
+ user?:
48
+ | {
49
+ name?: {
50
+ firstName?: string;
51
+ lastName?: string;
52
+ };
53
+ email?: string;
54
+ }
55
+ | undefined;
56
+ },
57
+ ) => Promise<{
58
+ user: OAuth2UserInfo;
59
+ data: T;
60
+ } | null>;
61
+ /**
62
+ * Custom function to refresh a token
63
+ */
64
+ refreshAccessToken?:
65
+ | ((refreshToken: string) => Promise<OAuth2Tokens>)
66
+ | undefined;
67
+ revokeToken?: ((token: string) => Promise<void>) | undefined;
68
+ /**
69
+ * Verify the id token
70
+ * @param token - The id token
71
+ * @param nonce - The nonce
72
+ * @returns True if the id token is valid, false otherwise
73
+ */
74
+ verifyIdToken?:
75
+ | ((token: string, nonce?: string) => Promise<boolean>)
76
+ | undefined;
77
+ /**
78
+ * Disable implicit sign up for new users. When set to true for the provider,
79
+ * sign-in need to be called with with requestSignUp as true to create new users.
80
+ */
81
+ disableImplicitSignUp?: boolean | undefined;
82
+ /**
83
+ * Disable sign up for new users.
84
+ */
85
+ disableSignUp?: boolean | undefined;
86
+ /**
87
+ * Options for the provider
88
+ */
89
+ options?: O | undefined;
90
+ }
91
+
92
+ export type ProviderOptions<Profile extends Record<string, any> = any> = {
93
+ /**
94
+ * The client ID of your application.
95
+ *
96
+ * This is usually a string but can be any type depending on the provider.
97
+ */
98
+ clientId?: unknown | undefined;
99
+ /**
100
+ * The client secret of your application
101
+ */
102
+ clientSecret?: string | undefined;
103
+ /**
104
+ * The scopes you want to request from the provider
105
+ */
106
+ scope?: string[] | undefined;
107
+ /**
108
+ * Remove default scopes of the provider
109
+ */
110
+ disableDefaultScope?: boolean | undefined;
111
+ /**
112
+ * The redirect URL for your application. This is where the provider will
113
+ * redirect the user after the sign in process. Make sure this URL is
114
+ * whitelisted in the provider's dashboard.
115
+ */
116
+ redirectURI?: string | undefined;
117
+ /**
118
+ * The client key of your application
119
+ * Tiktok Social Provider uses this field instead of clientId
120
+ */
121
+ clientKey?: string | undefined;
122
+ /**
123
+ * Disable provider from allowing users to sign in
124
+ * with this provider with an id token sent from the
125
+ * client.
126
+ */
127
+ disableIdTokenSignIn?: boolean | undefined;
128
+ /**
129
+ * verifyIdToken function to verify the id token
130
+ */
131
+ verifyIdToken?:
132
+ | ((token: string, nonce?: string) => Promise<boolean>)
133
+ | undefined;
134
+ /**
135
+ * Custom function to get user info from the provider
136
+ */
137
+ getUserInfo?:
138
+ | ((token: OAuth2Tokens) => Promise<{
139
+ user: {
140
+ id: string;
141
+ name?: string;
142
+ email?: string | null;
143
+ image?: string;
144
+ emailVerified: boolean;
145
+ [key: string]: any;
146
+ };
147
+ data: any;
148
+ }>)
149
+ | undefined;
150
+ /**
151
+ * Custom function to refresh a token
152
+ */
153
+ refreshAccessToken?:
154
+ | ((refreshToken: string) => Promise<OAuth2Tokens>)
155
+ | undefined;
156
+ /**
157
+ * Custom function to map the provider profile to a
158
+ * user.
159
+ */
160
+ mapProfileToUser?:
161
+ | ((profile: Profile) =>
162
+ | {
163
+ id?: string;
164
+ name?: string;
165
+ email?: string | null;
166
+ image?: string;
167
+ emailVerified?: boolean;
168
+ [key: string]: any;
169
+ }
170
+ | Promise<{
171
+ id?: string;
172
+ name?: string;
173
+ email?: string | null;
174
+ image?: string;
175
+ emailVerified?: boolean;
176
+ [key: string]: any;
177
+ }>)
178
+ | undefined;
179
+ /**
180
+ * Disable implicit sign up for new users. When set to true for the provider,
181
+ * sign-in need to be called with with requestSignUp as true to create new users.
182
+ */
183
+ disableImplicitSignUp?: boolean | undefined;
184
+ /**
185
+ * Disable sign up for new users.
186
+ */
187
+ disableSignUp?: boolean | undefined;
188
+ /**
189
+ * The prompt to use for the authorization code request
190
+ */
191
+ prompt?:
192
+ | (
193
+ | "select_account"
194
+ | "consent"
195
+ | "login"
196
+ | "none"
197
+ | "select_account consent"
198
+ )
199
+ | undefined;
200
+ /**
201
+ * The response mode to use for the authorization code request
202
+ */
203
+ responseMode?: ("query" | "form_post") | undefined;
204
+ /**
205
+ * If enabled, the user info will be overridden with the provider user info
206
+ * This is useful if you want to use the provider user info to update the user info
207
+ *
208
+ * @default false
209
+ */
210
+ overrideUserInfoOnSignIn?: boolean | undefined;
211
+ };