@depup/better-auth__core 1.6.23-depup.2
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/LICENSE.md +20 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/api/index.d.mts +281 -0
- package/dist/api/index.mjs +92 -0
- package/dist/async_hooks/index.d.mts +6 -0
- package/dist/async_hooks/index.mjs +20 -0
- package/dist/async_hooks/pure.index.d.mts +6 -0
- package/dist/async_hooks/pure.index.mjs +33 -0
- package/dist/context/endpoint-context.d.mts +18 -0
- package/dist/context/endpoint-context.mjs +29 -0
- package/dist/context/global.d.mts +6 -0
- package/dist/context/global.mjs +36 -0
- package/dist/context/index.d.mts +5 -0
- package/dist/context/index.mjs +5 -0
- package/dist/context/request-state.d.mts +27 -0
- package/dist/context/request-state.mjs +47 -0
- package/dist/context/transaction.d.mts +27 -0
- package/dist/context/transaction.mjs +96 -0
- package/dist/db/adapter/factory.d.mts +17 -0
- package/dist/db/adapter/factory.mjs +905 -0
- package/dist/db/adapter/get-default-field-name.d.mts +18 -0
- package/dist/db/adapter/get-default-field-name.mjs +36 -0
- package/dist/db/adapter/get-default-model-name.d.mts +12 -0
- package/dist/db/adapter/get-default-model-name.mjs +30 -0
- package/dist/db/adapter/get-field-attributes.d.mts +26 -0
- package/dist/db/adapter/get-field-attributes.mjs +37 -0
- package/dist/db/adapter/get-field-name.d.mts +18 -0
- package/dist/db/adapter/get-field-name.mjs +31 -0
- package/dist/db/adapter/get-id-field.d.mts +36 -0
- package/dist/db/adapter/get-id-field.mjs +64 -0
- package/dist/db/adapter/get-model-name.d.mts +12 -0
- package/dist/db/adapter/get-model-name.mjs +21 -0
- package/dist/db/adapter/index.d.mts +615 -0
- package/dist/db/adapter/index.mjs +24 -0
- package/dist/db/adapter/types.d.mts +105 -0
- package/dist/db/adapter/utils.d.mts +7 -0
- package/dist/db/adapter/utils.mjs +37 -0
- package/dist/db/get-tables.d.mts +6 -0
- package/dist/db/get-tables.mjs +266 -0
- package/dist/db/index.d.mts +10 -0
- package/dist/db/index.mjs +8 -0
- package/dist/db/plugin.d.mts +12 -0
- package/dist/db/schema/account.d.mts +28 -0
- package/dist/db/schema/account.mjs +17 -0
- package/dist/db/schema/rate-limit.d.mts +18 -0
- package/dist/db/schema/rate-limit.mjs +9 -0
- package/dist/db/schema/session.d.mts +23 -0
- package/dist/db/schema/session.mjs +12 -0
- package/dist/db/schema/shared.d.mts +10 -0
- package/dist/db/schema/shared.mjs +9 -0
- package/dist/db/schema/user.d.mts +22 -0
- package/dist/db/schema/user.mjs +11 -0
- package/dist/db/schema/verification.d.mts +21 -0
- package/dist/db/schema/verification.mjs +10 -0
- package/dist/db/type.d.mts +194 -0
- package/dist/env/color-depth.d.mts +4 -0
- package/dist/env/color-depth.mjs +86 -0
- package/dist/env/env-impl.d.mts +32 -0
- package/dist/env/env-impl.mjs +81 -0
- package/dist/env/index.d.mts +4 -0
- package/dist/env/index.mjs +4 -0
- package/dist/env/logger.d.mts +48 -0
- package/dist/env/logger.mjs +79 -0
- package/dist/error/codes.d.mts +69 -0
- package/dist/error/codes.mjs +55 -0
- package/dist/error/index.d.mts +26 -0
- package/dist/error/index.mjs +27 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +1 -0
- package/dist/instrumentation/api.mjs +12 -0
- package/dist/instrumentation/attributes.d.mts +11 -0
- package/dist/instrumentation/attributes.mjs +10 -0
- package/dist/instrumentation/index.d.mts +3 -0
- package/dist/instrumentation/index.mjs +3 -0
- package/dist/instrumentation/noop.mjs +42 -0
- package/dist/instrumentation/pure.index.d.mts +7 -0
- package/dist/instrumentation/pure.index.mjs +7 -0
- package/dist/instrumentation/tracer.d.mts +13 -0
- package/dist/instrumentation/tracer.mjs +53 -0
- package/dist/oauth2/client-credentials-token.d.mts +56 -0
- package/dist/oauth2/client-credentials-token.mjs +64 -0
- package/dist/oauth2/create-authorization-url.d.mts +44 -0
- package/dist/oauth2/create-authorization-url.mjs +41 -0
- package/dist/oauth2/index.d.mts +8 -0
- package/dist/oauth2/index.mjs +7 -0
- package/dist/oauth2/oauth-provider.d.mts +192 -0
- package/dist/oauth2/refresh-access-token.d.mts +54 -0
- package/dist/oauth2/refresh-access-token.mjs +73 -0
- package/dist/oauth2/reject-redirects.mjs +60 -0
- package/dist/oauth2/utils.d.mts +24 -0
- package/dist/oauth2/utils.mjs +48 -0
- package/dist/oauth2/validate-authorization-code.d.mts +85 -0
- package/dist/oauth2/validate-authorization-code.mjs +86 -0
- package/dist/oauth2/verify.d.mts +65 -0
- package/dist/oauth2/verify.mjs +202 -0
- package/dist/social-providers/apple.d.mts +133 -0
- package/dist/social-providers/apple.mjs +117 -0
- package/dist/social-providers/atlassian.d.mts +70 -0
- package/dist/social-providers/atlassian.mjs +80 -0
- package/dist/social-providers/cognito.d.mts +85 -0
- package/dist/social-providers/cognito.mjs +162 -0
- package/dist/social-providers/discord.d.mts +124 -0
- package/dist/social-providers/discord.mjs +62 -0
- package/dist/social-providers/dropbox.d.mts +69 -0
- package/dist/social-providers/dropbox.mjs +72 -0
- package/dist/social-providers/facebook.d.mts +79 -0
- package/dist/social-providers/facebook.mjs +157 -0
- package/dist/social-providers/figma.d.mts +61 -0
- package/dist/social-providers/figma.mjs +83 -0
- package/dist/social-providers/github.d.mts +102 -0
- package/dist/social-providers/github.mjs +92 -0
- package/dist/social-providers/gitlab.d.mts +123 -0
- package/dist/social-providers/gitlab.mjs +79 -0
- package/dist/social-providers/google.d.mts +123 -0
- package/dist/social-providers/google.mjs +137 -0
- package/dist/social-providers/huggingface.d.mts +83 -0
- package/dist/social-providers/huggingface.mjs +73 -0
- package/dist/social-providers/index.d.mts +1834 -0
- package/dist/social-providers/index.mjs +78 -0
- package/dist/social-providers/kakao.d.mts +161 -0
- package/dist/social-providers/kakao.mjs +70 -0
- package/dist/social-providers/kick.d.mts +73 -0
- package/dist/social-providers/kick.mjs +68 -0
- package/dist/social-providers/line.d.mts +105 -0
- package/dist/social-providers/line.mjs +110 -0
- package/dist/social-providers/linear.d.mts +68 -0
- package/dist/social-providers/linear.mjs +85 -0
- package/dist/social-providers/linkedin.d.mts +67 -0
- package/dist/social-providers/linkedin.mjs +73 -0
- package/dist/social-providers/microsoft-entra-id.d.mts +174 -0
- package/dist/social-providers/microsoft-entra-id.mjs +152 -0
- package/dist/social-providers/naver.d.mts +92 -0
- package/dist/social-providers/naver.mjs +65 -0
- package/dist/social-providers/notion.d.mts +64 -0
- package/dist/social-providers/notion.mjs +72 -0
- package/dist/social-providers/paybin.d.mts +71 -0
- package/dist/social-providers/paybin.mjs +81 -0
- package/dist/social-providers/paypal.d.mts +131 -0
- package/dist/social-providers/paypal.mjs +188 -0
- package/dist/social-providers/polar.d.mts +74 -0
- package/dist/social-providers/polar.mjs +71 -0
- package/dist/social-providers/railway.d.mts +65 -0
- package/dist/social-providers/railway.mjs +74 -0
- package/dist/social-providers/reddit.d.mts +62 -0
- package/dist/social-providers/reddit.mjs +81 -0
- package/dist/social-providers/roblox.d.mts +70 -0
- package/dist/social-providers/roblox.mjs +57 -0
- package/dist/social-providers/salesforce.d.mts +79 -0
- package/dist/social-providers/salesforce.mjs +87 -0
- package/dist/social-providers/slack.d.mts +83 -0
- package/dist/social-providers/slack.mjs +66 -0
- package/dist/social-providers/spotify.d.mts +63 -0
- package/dist/social-providers/spotify.mjs +69 -0
- package/dist/social-providers/tiktok.d.mts +168 -0
- package/dist/social-providers/tiktok.mjs +60 -0
- package/dist/social-providers/twitch.d.mts +79 -0
- package/dist/social-providers/twitch.mjs +75 -0
- package/dist/social-providers/twitter.d.mts +126 -0
- package/dist/social-providers/twitter.mjs +85 -0
- package/dist/social-providers/vercel.d.mts +62 -0
- package/dist/social-providers/vercel.mjs +58 -0
- package/dist/social-providers/vk.d.mts +70 -0
- package/dist/social-providers/vk.mjs +81 -0
- package/dist/social-providers/wechat.d.mts +113 -0
- package/dist/social-providers/wechat.mjs +81 -0
- package/dist/social-providers/zoom.d.mts +163 -0
- package/dist/social-providers/zoom.mjs +69 -0
- package/dist/types/context.d.mts +319 -0
- package/dist/types/cookie.d.mts +15 -0
- package/dist/types/helper.d.mts +10 -0
- package/dist/types/index.d.mts +9 -0
- package/dist/types/init-options.d.mts +1430 -0
- package/dist/types/plugin-client.d.mts +123 -0
- package/dist/types/plugin.d.mts +124 -0
- package/dist/types/secret.d.mts +11 -0
- package/dist/utils/async.d.mts +22 -0
- package/dist/utils/async.mjs +32 -0
- package/dist/utils/db.d.mts +9 -0
- package/dist/utils/db.mjs +15 -0
- package/dist/utils/deprecate.d.mts +9 -0
- package/dist/utils/deprecate.mjs +16 -0
- package/dist/utils/error-codes.d.mts +13 -0
- package/dist/utils/error-codes.mjs +10 -0
- package/dist/utils/fetch-metadata.d.mts +4 -0
- package/dist/utils/fetch-metadata.mjs +6 -0
- package/dist/utils/host.d.mts +147 -0
- package/dist/utils/host.mjs +295 -0
- package/dist/utils/id.d.mts +4 -0
- package/dist/utils/id.mjs +7 -0
- package/dist/utils/ip.d.mts +77 -0
- package/dist/utils/ip.mjs +230 -0
- package/dist/utils/is-api-error.d.mts +6 -0
- package/dist/utils/is-api-error.mjs +8 -0
- package/dist/utils/json.d.mts +4 -0
- package/dist/utils/json.mjs +41 -0
- package/dist/utils/redirect-uri.d.mts +20 -0
- package/dist/utils/redirect-uri.mjs +48 -0
- package/dist/utils/string.d.mts +8 -0
- package/dist/utils/string.mjs +25 -0
- package/dist/utils/url.d.mts +37 -0
- package/dist/utils/url.mjs +61 -0
- package/package.json +216 -0
- package/src/api/index.ts +185 -0
- package/src/async_hooks/index.ts +40 -0
- package/src/async_hooks/pure.index.ts +46 -0
- package/src/context/endpoint-context.ts +50 -0
- package/src/context/global.ts +57 -0
- package/src/context/index.ts +23 -0
- package/src/context/request-state.ts +91 -0
- package/src/context/transaction.ts +169 -0
- package/src/db/adapter/factory.ts +1740 -0
- package/src/db/adapter/get-default-field-name.ts +59 -0
- package/src/db/adapter/get-default-model-name.ts +51 -0
- package/src/db/adapter/get-field-attributes.ts +62 -0
- package/src/db/adapter/get-field-name.ts +43 -0
- package/src/db/adapter/get-id-field.ts +150 -0
- package/src/db/adapter/get-model-name.ts +36 -0
- package/src/db/adapter/index.ts +656 -0
- package/src/db/adapter/types.ts +134 -0
- package/src/db/adapter/utils.ts +61 -0
- package/src/db/get-tables.ts +304 -0
- package/src/db/index.ts +43 -0
- package/src/db/plugin.ts +11 -0
- package/src/db/schema/account.ts +47 -0
- package/src/db/schema/rate-limit.ts +36 -0
- package/src/db/schema/session.ts +29 -0
- package/src/db/schema/shared.ts +7 -0
- package/src/db/schema/user.ts +31 -0
- package/src/db/schema/verification.ts +28 -0
- package/src/db/type.ts +360 -0
- package/src/env/color-depth.ts +172 -0
- package/src/env/env-impl.ts +123 -0
- package/src/env/index.ts +23 -0
- package/src/env/logger.ts +145 -0
- package/src/error/codes.ts +72 -0
- package/src/error/index.ts +44 -0
- package/src/index.ts +1 -0
- package/src/instrumentation/api.ts +17 -0
- package/src/instrumentation/attributes.ts +22 -0
- package/src/instrumentation/index.ts +2 -0
- package/src/instrumentation/noop.ts +74 -0
- package/src/instrumentation/pure.index.ts +31 -0
- package/src/instrumentation/tracer.ts +95 -0
- package/src/oauth2/client-credentials-token.ts +126 -0
- package/src/oauth2/create-authorization-url.ts +89 -0
- package/src/oauth2/index.ts +34 -0
- package/src/oauth2/oauth-provider.ts +222 -0
- package/src/oauth2/refresh-access-token.ts +157 -0
- package/src/oauth2/reject-redirects.ts +70 -0
- package/src/oauth2/utils.ts +70 -0
- package/src/oauth2/validate-authorization-code.ts +190 -0
- package/src/oauth2/verify.ts +408 -0
- package/src/social-providers/apple.ts +249 -0
- package/src/social-providers/atlassian.ts +133 -0
- package/src/social-providers/cognito.ts +281 -0
- package/src/social-providers/discord.ts +170 -0
- package/src/social-providers/dropbox.ts +112 -0
- package/src/social-providers/facebook.ts +288 -0
- package/src/social-providers/figma.ts +118 -0
- package/src/social-providers/github.ts +184 -0
- package/src/social-providers/gitlab.ts +155 -0
- package/src/social-providers/google.ts +263 -0
- package/src/social-providers/huggingface.ts +119 -0
- package/src/social-providers/index.ts +132 -0
- package/src/social-providers/kakao.ts +179 -0
- package/src/social-providers/kick.ts +109 -0
- package/src/social-providers/line.ts +169 -0
- package/src/social-providers/linear.ts +121 -0
- package/src/social-providers/linkedin.ts +110 -0
- package/src/social-providers/microsoft-entra-id.ts +391 -0
- package/src/social-providers/naver.ts +113 -0
- package/src/social-providers/notion.ts +108 -0
- package/src/social-providers/paybin.ts +118 -0
- package/src/social-providers/paypal.ts +371 -0
- package/src/social-providers/polar.ts +111 -0
- package/src/social-providers/railway.ts +100 -0
- package/src/social-providers/reddit.ts +126 -0
- package/src/social-providers/roblox.ts +112 -0
- package/src/social-providers/salesforce.ts +159 -0
- package/src/social-providers/slack.ts +112 -0
- package/src/social-providers/spotify.ts +94 -0
- package/src/social-providers/tiktok.ts +211 -0
- package/src/social-providers/twitch.ts +112 -0
- package/src/social-providers/twitter.ts +199 -0
- package/src/social-providers/vercel.ts +87 -0
- package/src/social-providers/vk.ts +125 -0
- package/src/social-providers/wechat.ts +220 -0
- package/src/social-providers/zoom.ts +230 -0
- package/src/types/context.ts +460 -0
- package/src/types/cookie.ts +10 -0
- package/src/types/helper.ts +27 -0
- package/src/types/index.ts +40 -0
- package/src/types/init-options.ts +1679 -0
- package/src/types/plugin-client.ts +143 -0
- package/src/types/plugin.ts +163 -0
- package/src/types/secret.ts +8 -0
- package/src/utils/async.ts +53 -0
- package/src/utils/db.ts +20 -0
- package/src/utils/deprecate.ts +21 -0
- package/src/utils/error-codes.ts +68 -0
- package/src/utils/fetch-metadata.ts +3 -0
- package/src/utils/host.ts +416 -0
- package/src/utils/id.ts +5 -0
- package/src/utils/ip.ts +395 -0
- package/src/utils/is-api-error.ts +10 -0
- package/src/utils/json.ts +56 -0
- package/src/utils/redirect-uri.ts +54 -0
- package/src/utils/string.ts +40 -0
- package/src/utils/url.ts +77 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
2
|
+
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
3
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
4
|
+
//#region src/social-providers/roblox.ts
|
|
5
|
+
const roblox = (options) => {
|
|
6
|
+
const tokenEndpoint = "https://apis.roblox.com/oauth/v1/token";
|
|
7
|
+
return {
|
|
8
|
+
id: "roblox",
|
|
9
|
+
name: "Roblox",
|
|
10
|
+
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
11
|
+
const _scopes = options.disableDefaultScope ? [] : ["openid", "profile"];
|
|
12
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
13
|
+
if (scopes) _scopes.push(...scopes);
|
|
14
|
+
return new URL(`https://apis.roblox.com/oauth/v1/authorize?scope=${_scopes.join("+")}&response_type=code&client_id=${options.clientId}&redirect_uri=${encodeURIComponent(options.redirectURI || redirectURI)}&state=${state}&prompt=${options.prompt || "select_account consent"}`);
|
|
15
|
+
},
|
|
16
|
+
validateAuthorizationCode: async ({ code, redirectURI }) => {
|
|
17
|
+
return validateAuthorizationCode({
|
|
18
|
+
code,
|
|
19
|
+
redirectURI: options.redirectURI || redirectURI,
|
|
20
|
+
options,
|
|
21
|
+
tokenEndpoint,
|
|
22
|
+
authentication: "post"
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
26
|
+
return refreshAccessToken({
|
|
27
|
+
refreshToken,
|
|
28
|
+
options: {
|
|
29
|
+
clientId: options.clientId,
|
|
30
|
+
clientKey: options.clientKey,
|
|
31
|
+
clientSecret: options.clientSecret
|
|
32
|
+
},
|
|
33
|
+
tokenEndpoint
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
async getUserInfo(token) {
|
|
37
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
38
|
+
const { data: profile, error } = await betterFetch("https://apis.roblox.com/oauth/v1/userinfo", { headers: { authorization: `Bearer ${token.accessToken}` } });
|
|
39
|
+
if (error) return null;
|
|
40
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
41
|
+
return {
|
|
42
|
+
user: {
|
|
43
|
+
id: profile.sub,
|
|
44
|
+
name: profile.nickname || profile.preferred_username || "",
|
|
45
|
+
image: profile.picture,
|
|
46
|
+
email: profile.preferred_username || null,
|
|
47
|
+
emailVerified: false,
|
|
48
|
+
...userMap
|
|
49
|
+
},
|
|
50
|
+
data: { ...profile }
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
options
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { roblox };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/salesforce.d.ts
|
|
3
|
+
interface SalesforceProfile {
|
|
4
|
+
sub: string;
|
|
5
|
+
user_id: string;
|
|
6
|
+
organization_id: string;
|
|
7
|
+
preferred_username?: string | undefined;
|
|
8
|
+
email: string;
|
|
9
|
+
email_verified?: boolean | undefined;
|
|
10
|
+
name: string;
|
|
11
|
+
given_name?: string | undefined;
|
|
12
|
+
family_name?: string | undefined;
|
|
13
|
+
zoneinfo?: string | undefined;
|
|
14
|
+
photos?: {
|
|
15
|
+
picture?: string;
|
|
16
|
+
thumbnail?: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
interface SalesforceOptions extends ProviderOptions<SalesforceProfile> {
|
|
20
|
+
clientId: string;
|
|
21
|
+
environment?: ("sandbox" | "production") | undefined;
|
|
22
|
+
loginUrl?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Override the redirect URI if auto-detection fails.
|
|
25
|
+
* Should match the Callback URL configured in your Salesforce Connected App.
|
|
26
|
+
* @example "http://localhost:3000/api/auth/callback/salesforce"
|
|
27
|
+
*/
|
|
28
|
+
redirectURI?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
declare const salesforce: (options: SalesforceOptions) => {
|
|
31
|
+
id: "salesforce";
|
|
32
|
+
name: string;
|
|
33
|
+
createAuthorizationURL({
|
|
34
|
+
state,
|
|
35
|
+
scopes,
|
|
36
|
+
codeVerifier,
|
|
37
|
+
redirectURI
|
|
38
|
+
}: {
|
|
39
|
+
state: string;
|
|
40
|
+
codeVerifier: string;
|
|
41
|
+
scopes?: string[] | undefined;
|
|
42
|
+
redirectURI: string;
|
|
43
|
+
display?: string | undefined;
|
|
44
|
+
loginHint?: string | undefined;
|
|
45
|
+
}): Promise<URL>;
|
|
46
|
+
validateAuthorizationCode: ({
|
|
47
|
+
code,
|
|
48
|
+
codeVerifier,
|
|
49
|
+
redirectURI
|
|
50
|
+
}: {
|
|
51
|
+
code: string;
|
|
52
|
+
redirectURI: string;
|
|
53
|
+
codeVerifier?: string | undefined;
|
|
54
|
+
deviceId?: string | undefined;
|
|
55
|
+
}) => Promise<OAuth2Tokens>;
|
|
56
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
57
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
58
|
+
user?: {
|
|
59
|
+
name?: {
|
|
60
|
+
firstName?: string;
|
|
61
|
+
lastName?: string;
|
|
62
|
+
};
|
|
63
|
+
email?: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
user: {
|
|
67
|
+
id: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
email?: string | null;
|
|
70
|
+
image?: string;
|
|
71
|
+
emailVerified: boolean;
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
};
|
|
74
|
+
data: any;
|
|
75
|
+
} | null>;
|
|
76
|
+
options: SalesforceOptions;
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { SalesforceOptions, SalesforceProfile, salesforce };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BetterAuthError } from "../error/index.mjs";
|
|
2
|
+
import { logger } from "../env/logger.mjs";
|
|
3
|
+
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
4
|
+
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
5
|
+
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
6
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
7
|
+
//#region src/social-providers/salesforce.ts
|
|
8
|
+
const salesforce = (options) => {
|
|
9
|
+
const isSandbox = (options.environment ?? "production") === "sandbox";
|
|
10
|
+
const authorizationEndpoint = options.loginUrl ? `https://${options.loginUrl}/services/oauth2/authorize` : isSandbox ? "https://test.salesforce.com/services/oauth2/authorize" : "https://login.salesforce.com/services/oauth2/authorize";
|
|
11
|
+
const tokenEndpoint = options.loginUrl ? `https://${options.loginUrl}/services/oauth2/token` : isSandbox ? "https://test.salesforce.com/services/oauth2/token" : "https://login.salesforce.com/services/oauth2/token";
|
|
12
|
+
const userInfoEndpoint = options.loginUrl ? `https://${options.loginUrl}/services/oauth2/userinfo` : isSandbox ? "https://test.salesforce.com/services/oauth2/userinfo" : "https://login.salesforce.com/services/oauth2/userinfo";
|
|
13
|
+
return {
|
|
14
|
+
id: "salesforce",
|
|
15
|
+
name: "Salesforce",
|
|
16
|
+
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI }) {
|
|
17
|
+
if (!options.clientId || !options.clientSecret) {
|
|
18
|
+
logger.error("Client Id and Client Secret are required for Salesforce. Make sure to provide them in the options.");
|
|
19
|
+
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
20
|
+
}
|
|
21
|
+
if (!codeVerifier) throw new BetterAuthError("codeVerifier is required for Salesforce");
|
|
22
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
23
|
+
"openid",
|
|
24
|
+
"email",
|
|
25
|
+
"profile"
|
|
26
|
+
];
|
|
27
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
28
|
+
if (scopes) _scopes.push(...scopes);
|
|
29
|
+
return createAuthorizationURL({
|
|
30
|
+
id: "salesforce",
|
|
31
|
+
options,
|
|
32
|
+
authorizationEndpoint,
|
|
33
|
+
scopes: _scopes,
|
|
34
|
+
state,
|
|
35
|
+
codeVerifier,
|
|
36
|
+
redirectURI: options.redirectURI || redirectURI
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
40
|
+
return validateAuthorizationCode({
|
|
41
|
+
code,
|
|
42
|
+
codeVerifier,
|
|
43
|
+
redirectURI: options.redirectURI || redirectURI,
|
|
44
|
+
options,
|
|
45
|
+
tokenEndpoint
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
49
|
+
return refreshAccessToken({
|
|
50
|
+
refreshToken,
|
|
51
|
+
options: {
|
|
52
|
+
clientId: options.clientId,
|
|
53
|
+
clientSecret: options.clientSecret
|
|
54
|
+
},
|
|
55
|
+
tokenEndpoint
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
async getUserInfo(token) {
|
|
59
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
60
|
+
try {
|
|
61
|
+
const { data: user } = await betterFetch(userInfoEndpoint, { headers: { Authorization: `Bearer ${token.accessToken}` } });
|
|
62
|
+
if (!user) {
|
|
63
|
+
logger.error("Failed to fetch user info from Salesforce");
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const userMap = await options.mapProfileToUser?.(user);
|
|
67
|
+
return {
|
|
68
|
+
user: {
|
|
69
|
+
id: user.user_id,
|
|
70
|
+
name: user.name,
|
|
71
|
+
email: user.email,
|
|
72
|
+
image: user.photos?.picture || user.photos?.thumbnail,
|
|
73
|
+
emailVerified: user.email_verified ?? false,
|
|
74
|
+
...userMap
|
|
75
|
+
},
|
|
76
|
+
data: user
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logger.error("Failed to fetch user info from Salesforce:", error);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
options
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { salesforce };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/slack.d.ts
|
|
3
|
+
interface SlackProfile extends Record<string, any> {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
sub: string;
|
|
6
|
+
"https://slack.com/user_id": string;
|
|
7
|
+
"https://slack.com/team_id": string;
|
|
8
|
+
email: string;
|
|
9
|
+
email_verified: boolean;
|
|
10
|
+
date_email_verified: number;
|
|
11
|
+
name: string;
|
|
12
|
+
picture: string;
|
|
13
|
+
given_name: string;
|
|
14
|
+
family_name: string;
|
|
15
|
+
locale: string;
|
|
16
|
+
"https://slack.com/team_name": string;
|
|
17
|
+
"https://slack.com/team_domain": string;
|
|
18
|
+
"https://slack.com/user_image_24": string;
|
|
19
|
+
"https://slack.com/user_image_32": string;
|
|
20
|
+
"https://slack.com/user_image_48": string;
|
|
21
|
+
"https://slack.com/user_image_72": string;
|
|
22
|
+
"https://slack.com/user_image_192": string;
|
|
23
|
+
"https://slack.com/user_image_512": string;
|
|
24
|
+
"https://slack.com/team_image_34": string;
|
|
25
|
+
"https://slack.com/team_image_44": string;
|
|
26
|
+
"https://slack.com/team_image_68": string;
|
|
27
|
+
"https://slack.com/team_image_88": string;
|
|
28
|
+
"https://slack.com/team_image_102": string;
|
|
29
|
+
"https://slack.com/team_image_132": string;
|
|
30
|
+
"https://slack.com/team_image_230": string;
|
|
31
|
+
"https://slack.com/team_image_default": boolean;
|
|
32
|
+
}
|
|
33
|
+
interface SlackOptions extends ProviderOptions<SlackProfile> {
|
|
34
|
+
clientId: string;
|
|
35
|
+
}
|
|
36
|
+
declare const slack: (options: SlackOptions) => {
|
|
37
|
+
id: "slack";
|
|
38
|
+
name: string;
|
|
39
|
+
createAuthorizationURL({
|
|
40
|
+
state,
|
|
41
|
+
scopes,
|
|
42
|
+
redirectURI
|
|
43
|
+
}: {
|
|
44
|
+
state: string;
|
|
45
|
+
codeVerifier: string;
|
|
46
|
+
scopes?: string[] | undefined;
|
|
47
|
+
redirectURI: string;
|
|
48
|
+
display?: string | undefined;
|
|
49
|
+
loginHint?: string | undefined;
|
|
50
|
+
}): URL;
|
|
51
|
+
validateAuthorizationCode: ({
|
|
52
|
+
code,
|
|
53
|
+
redirectURI
|
|
54
|
+
}: {
|
|
55
|
+
code: string;
|
|
56
|
+
redirectURI: string;
|
|
57
|
+
codeVerifier?: string | undefined;
|
|
58
|
+
deviceId?: string | undefined;
|
|
59
|
+
}) => Promise<OAuth2Tokens>;
|
|
60
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
61
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
62
|
+
user?: {
|
|
63
|
+
name?: {
|
|
64
|
+
firstName?: string;
|
|
65
|
+
lastName?: string;
|
|
66
|
+
};
|
|
67
|
+
email?: string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
user: {
|
|
71
|
+
id: string;
|
|
72
|
+
name?: string;
|
|
73
|
+
email?: string | null;
|
|
74
|
+
image?: string;
|
|
75
|
+
emailVerified: boolean;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
data: any;
|
|
79
|
+
} | null>;
|
|
80
|
+
options: SlackOptions;
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { SlackOptions, SlackProfile, slack };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
2
|
+
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
3
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
4
|
+
//#region src/social-providers/slack.ts
|
|
5
|
+
const slack = (options) => {
|
|
6
|
+
const tokenEndpoint = "https://slack.com/api/openid.connect.token";
|
|
7
|
+
return {
|
|
8
|
+
id: "slack",
|
|
9
|
+
name: "Slack",
|
|
10
|
+
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
11
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
12
|
+
"openid",
|
|
13
|
+
"profile",
|
|
14
|
+
"email"
|
|
15
|
+
];
|
|
16
|
+
if (scopes) _scopes.push(...scopes);
|
|
17
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
18
|
+
const url = new URL("https://slack.com/openid/connect/authorize");
|
|
19
|
+
url.searchParams.set("scope", _scopes.join(" "));
|
|
20
|
+
url.searchParams.set("response_type", "code");
|
|
21
|
+
url.searchParams.set("client_id", options.clientId);
|
|
22
|
+
url.searchParams.set("redirect_uri", options.redirectURI || redirectURI);
|
|
23
|
+
url.searchParams.set("state", state);
|
|
24
|
+
return url;
|
|
25
|
+
},
|
|
26
|
+
validateAuthorizationCode: async ({ code, redirectURI }) => {
|
|
27
|
+
return validateAuthorizationCode({
|
|
28
|
+
code,
|
|
29
|
+
redirectURI,
|
|
30
|
+
options,
|
|
31
|
+
tokenEndpoint
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
35
|
+
return refreshAccessToken({
|
|
36
|
+
refreshToken,
|
|
37
|
+
options: {
|
|
38
|
+
clientId: options.clientId,
|
|
39
|
+
clientKey: options.clientKey,
|
|
40
|
+
clientSecret: options.clientSecret
|
|
41
|
+
},
|
|
42
|
+
tokenEndpoint
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
async getUserInfo(token) {
|
|
46
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
47
|
+
const { data: profile, error } = await betterFetch("https://slack.com/api/openid.connect.userInfo", { headers: { authorization: `Bearer ${token.accessToken}` } });
|
|
48
|
+
if (error) return null;
|
|
49
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
50
|
+
return {
|
|
51
|
+
user: {
|
|
52
|
+
id: profile["https://slack.com/user_id"],
|
|
53
|
+
name: profile.name || "",
|
|
54
|
+
email: profile.email,
|
|
55
|
+
emailVerified: profile.email_verified,
|
|
56
|
+
image: profile.picture || profile["https://slack.com/user_image_512"],
|
|
57
|
+
...userMap
|
|
58
|
+
},
|
|
59
|
+
data: profile
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
options
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { slack };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/spotify.d.ts
|
|
3
|
+
interface SpotifyProfile {
|
|
4
|
+
id: string;
|
|
5
|
+
display_name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
images: {
|
|
8
|
+
url: string;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
interface SpotifyOptions extends ProviderOptions<SpotifyProfile> {
|
|
12
|
+
clientId: string;
|
|
13
|
+
}
|
|
14
|
+
declare const spotify: (options: SpotifyOptions) => {
|
|
15
|
+
id: "spotify";
|
|
16
|
+
name: string;
|
|
17
|
+
createAuthorizationURL({
|
|
18
|
+
state,
|
|
19
|
+
scopes,
|
|
20
|
+
codeVerifier,
|
|
21
|
+
redirectURI
|
|
22
|
+
}: {
|
|
23
|
+
state: string;
|
|
24
|
+
codeVerifier: string;
|
|
25
|
+
scopes?: string[] | undefined;
|
|
26
|
+
redirectURI: string;
|
|
27
|
+
display?: string | undefined;
|
|
28
|
+
loginHint?: string | undefined;
|
|
29
|
+
}): Promise<URL>;
|
|
30
|
+
validateAuthorizationCode: ({
|
|
31
|
+
code,
|
|
32
|
+
codeVerifier,
|
|
33
|
+
redirectURI
|
|
34
|
+
}: {
|
|
35
|
+
code: string;
|
|
36
|
+
redirectURI: string;
|
|
37
|
+
codeVerifier?: string | undefined;
|
|
38
|
+
deviceId?: string | undefined;
|
|
39
|
+
}) => Promise<OAuth2Tokens>;
|
|
40
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
41
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
42
|
+
user?: {
|
|
43
|
+
name?: {
|
|
44
|
+
firstName?: string;
|
|
45
|
+
lastName?: string;
|
|
46
|
+
};
|
|
47
|
+
email?: string;
|
|
48
|
+
} | undefined;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
user: {
|
|
51
|
+
id: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
email?: string | null;
|
|
54
|
+
image?: string;
|
|
55
|
+
emailVerified: boolean;
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
58
|
+
data: any;
|
|
59
|
+
} | null>;
|
|
60
|
+
options: SpotifyOptions;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { SpotifyOptions, SpotifyProfile, spotify };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
2
|
+
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
3
|
+
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
4
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
5
|
+
//#region src/social-providers/spotify.ts
|
|
6
|
+
const spotify = (options) => {
|
|
7
|
+
const tokenEndpoint = "https://accounts.spotify.com/api/token";
|
|
8
|
+
return {
|
|
9
|
+
id: "spotify",
|
|
10
|
+
name: "Spotify",
|
|
11
|
+
createAuthorizationURL({ state, scopes, codeVerifier, redirectURI }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : ["user-read-email"];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
|
+
return createAuthorizationURL({
|
|
16
|
+
id: "spotify",
|
|
17
|
+
options,
|
|
18
|
+
authorizationEndpoint: "https://accounts.spotify.com/authorize",
|
|
19
|
+
scopes: _scopes,
|
|
20
|
+
state,
|
|
21
|
+
codeVerifier,
|
|
22
|
+
redirectURI
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
26
|
+
return validateAuthorizationCode({
|
|
27
|
+
code,
|
|
28
|
+
codeVerifier,
|
|
29
|
+
redirectURI,
|
|
30
|
+
options,
|
|
31
|
+
tokenEndpoint
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
35
|
+
return refreshAccessToken({
|
|
36
|
+
refreshToken,
|
|
37
|
+
options: {
|
|
38
|
+
clientId: options.clientId,
|
|
39
|
+
clientKey: options.clientKey,
|
|
40
|
+
clientSecret: options.clientSecret
|
|
41
|
+
},
|
|
42
|
+
tokenEndpoint
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
async getUserInfo(token) {
|
|
46
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
47
|
+
const { data: profile, error } = await betterFetch("https://api.spotify.com/v1/me", {
|
|
48
|
+
method: "GET",
|
|
49
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
50
|
+
});
|
|
51
|
+
if (error) return null;
|
|
52
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
53
|
+
return {
|
|
54
|
+
user: {
|
|
55
|
+
id: profile.id,
|
|
56
|
+
name: profile.display_name,
|
|
57
|
+
email: profile.email,
|
|
58
|
+
image: profile.images[0]?.url,
|
|
59
|
+
emailVerified: false,
|
|
60
|
+
...userMap
|
|
61
|
+
},
|
|
62
|
+
data: profile
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
options
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { spotify };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/tiktok.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* [More info](https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/)
|
|
5
|
+
*/
|
|
6
|
+
interface TiktokProfile extends Record<string, any> {
|
|
7
|
+
data: {
|
|
8
|
+
user: {
|
|
9
|
+
/**
|
|
10
|
+
* The unique identification of the user in the current application.Open id
|
|
11
|
+
* for the client.
|
|
12
|
+
*
|
|
13
|
+
* To return this field, add `fields=open_id` in the user profile request's query parameter.
|
|
14
|
+
*/
|
|
15
|
+
open_id: string;
|
|
16
|
+
/**
|
|
17
|
+
* The unique identification of the user across different apps for the same developer.
|
|
18
|
+
* For example, if a partner has X number of clients,
|
|
19
|
+
* it will get X number of open_id for the same TikTok user,
|
|
20
|
+
* but one persistent union_id for the particular user.
|
|
21
|
+
*
|
|
22
|
+
* To return this field, add `fields=union_id` in the user profile request's query parameter.
|
|
23
|
+
*/
|
|
24
|
+
union_id?: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* User's profile image.
|
|
27
|
+
*
|
|
28
|
+
* To return this field, add `fields=avatar_url` in the user profile request's query parameter.
|
|
29
|
+
*/
|
|
30
|
+
avatar_url?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* User`s profile image in 100x100 size.
|
|
33
|
+
*
|
|
34
|
+
* To return this field, add `fields=avatar_url_100` in the user profile request's query parameter.
|
|
35
|
+
*/
|
|
36
|
+
avatar_url_100?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* User's profile image with higher resolution
|
|
39
|
+
*
|
|
40
|
+
* To return this field, add `fields=avatar_url_100` in the user profile request's query parameter.
|
|
41
|
+
*/
|
|
42
|
+
avatar_large_url: string;
|
|
43
|
+
/**
|
|
44
|
+
* User's profile name
|
|
45
|
+
*
|
|
46
|
+
* To return this field, add `fields=display_name` in the user profile request's query parameter.
|
|
47
|
+
*/
|
|
48
|
+
display_name: string;
|
|
49
|
+
/**
|
|
50
|
+
* User's username.
|
|
51
|
+
*
|
|
52
|
+
* To return this field, add `fields=username` in the user profile request's query parameter.
|
|
53
|
+
*/
|
|
54
|
+
username: string; /** @note Email is currently unsupported by TikTok */
|
|
55
|
+
email?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* User's bio description if there is a valid one.
|
|
58
|
+
*
|
|
59
|
+
* To return this field, add `fields=bio_description` in the user profile request's query parameter.
|
|
60
|
+
*/
|
|
61
|
+
bio_description?: string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The link to user's TikTok profile page.
|
|
64
|
+
*
|
|
65
|
+
* To return this field, add `fields=profile_deep_link` in the user profile request's query parameter.
|
|
66
|
+
*/
|
|
67
|
+
profile_deep_link?: string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Whether TikTok has provided a verified badge to the account after confirming
|
|
70
|
+
* that it belongs to the user it represents.
|
|
71
|
+
*
|
|
72
|
+
* To return this field, add `fields=is_verified` in the user profile request's query parameter.
|
|
73
|
+
*/
|
|
74
|
+
is_verified?: boolean | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* User's followers count.
|
|
77
|
+
*
|
|
78
|
+
* To return this field, add `fields=follower_count` in the user profile request's query parameter.
|
|
79
|
+
*/
|
|
80
|
+
follower_count?: number | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The number of accounts that the user is following.
|
|
83
|
+
*
|
|
84
|
+
* To return this field, add `fields=following_count` in the user profile request's query parameter.
|
|
85
|
+
*/
|
|
86
|
+
following_count?: number | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The total number of likes received by the user across all of their videos.
|
|
89
|
+
*
|
|
90
|
+
* To return this field, add `fields=likes_count` in the user profile request's query parameter.
|
|
91
|
+
*/
|
|
92
|
+
likes_count?: number | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* The total number of publicly posted videos by the user.
|
|
95
|
+
*
|
|
96
|
+
* To return this field, add `fields=video_count` in the user profile request's query parameter.
|
|
97
|
+
*/
|
|
98
|
+
video_count?: number | undefined;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
error?: {
|
|
102
|
+
/**
|
|
103
|
+
* The error category in string.
|
|
104
|
+
*/
|
|
105
|
+
code?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The error message in string.
|
|
108
|
+
*/
|
|
109
|
+
message?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The error message in string.
|
|
112
|
+
*/
|
|
113
|
+
log_id?: string;
|
|
114
|
+
} | undefined;
|
|
115
|
+
}
|
|
116
|
+
interface TiktokOptions extends ProviderOptions {
|
|
117
|
+
clientId?: never | undefined;
|
|
118
|
+
clientSecret: string;
|
|
119
|
+
clientKey: string;
|
|
120
|
+
}
|
|
121
|
+
declare const tiktok: (options: TiktokOptions) => {
|
|
122
|
+
id: "tiktok";
|
|
123
|
+
name: string;
|
|
124
|
+
createAuthorizationURL({
|
|
125
|
+
state,
|
|
126
|
+
scopes,
|
|
127
|
+
redirectURI
|
|
128
|
+
}: {
|
|
129
|
+
state: string;
|
|
130
|
+
codeVerifier: string;
|
|
131
|
+
scopes?: string[] | undefined;
|
|
132
|
+
redirectURI: string;
|
|
133
|
+
display?: string | undefined;
|
|
134
|
+
loginHint?: string | undefined;
|
|
135
|
+
}): URL;
|
|
136
|
+
validateAuthorizationCode: ({
|
|
137
|
+
code,
|
|
138
|
+
redirectURI
|
|
139
|
+
}: {
|
|
140
|
+
code: string;
|
|
141
|
+
redirectURI: string;
|
|
142
|
+
codeVerifier?: string | undefined;
|
|
143
|
+
deviceId?: string | undefined;
|
|
144
|
+
}) => Promise<OAuth2Tokens>;
|
|
145
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
146
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
147
|
+
user?: {
|
|
148
|
+
name?: {
|
|
149
|
+
firstName?: string;
|
|
150
|
+
lastName?: string;
|
|
151
|
+
};
|
|
152
|
+
email?: string;
|
|
153
|
+
} | undefined;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
user: {
|
|
156
|
+
id: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
email?: string | null;
|
|
159
|
+
image?: string;
|
|
160
|
+
emailVerified: boolean;
|
|
161
|
+
[key: string]: any;
|
|
162
|
+
};
|
|
163
|
+
data: any;
|
|
164
|
+
} | null>;
|
|
165
|
+
options: TiktokOptions;
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
export { TiktokOptions, TiktokProfile, tiktok };
|