@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,92 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/naver.d.ts
|
|
3
|
+
interface NaverProfile {
|
|
4
|
+
/** API response result code */
|
|
5
|
+
resultcode: string;
|
|
6
|
+
/** API response message */
|
|
7
|
+
message: string;
|
|
8
|
+
response: {
|
|
9
|
+
/** Unique Naver user identifier */id: string; /** User nickname */
|
|
10
|
+
nickname: string; /** User real name */
|
|
11
|
+
name: string; /** User email address */
|
|
12
|
+
email: string; /** Gender (F: female, M: male, U: unknown) */
|
|
13
|
+
gender: string; /** Age range */
|
|
14
|
+
age: string; /** Birthday (MM-DD format) */
|
|
15
|
+
birthday: string; /** Birth year */
|
|
16
|
+
birthyear: string; /** Profile image URL */
|
|
17
|
+
profile_image: string; /** Mobile phone number */
|
|
18
|
+
mobile: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface NaverOptions extends ProviderOptions<NaverProfile> {
|
|
22
|
+
clientId: string;
|
|
23
|
+
}
|
|
24
|
+
declare const naver: (options: NaverOptions) => {
|
|
25
|
+
id: "naver";
|
|
26
|
+
name: string;
|
|
27
|
+
createAuthorizationURL({
|
|
28
|
+
state,
|
|
29
|
+
scopes,
|
|
30
|
+
redirectURI
|
|
31
|
+
}: {
|
|
32
|
+
state: string;
|
|
33
|
+
codeVerifier: string;
|
|
34
|
+
scopes?: string[] | undefined;
|
|
35
|
+
redirectURI: string;
|
|
36
|
+
display?: string | undefined;
|
|
37
|
+
loginHint?: string | undefined;
|
|
38
|
+
}): Promise<URL>;
|
|
39
|
+
validateAuthorizationCode: ({
|
|
40
|
+
code,
|
|
41
|
+
redirectURI
|
|
42
|
+
}: {
|
|
43
|
+
code: string;
|
|
44
|
+
redirectURI: string;
|
|
45
|
+
codeVerifier?: string | undefined;
|
|
46
|
+
deviceId?: string | undefined;
|
|
47
|
+
}) => Promise<OAuth2Tokens>;
|
|
48
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
49
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
50
|
+
user?: {
|
|
51
|
+
name?: {
|
|
52
|
+
firstName?: string;
|
|
53
|
+
lastName?: string;
|
|
54
|
+
};
|
|
55
|
+
email?: string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
user: {
|
|
59
|
+
id: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
email?: string | null;
|
|
62
|
+
image?: string;
|
|
63
|
+
emailVerified: boolean;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
};
|
|
66
|
+
data: any;
|
|
67
|
+
} | {
|
|
68
|
+
user: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
email: string;
|
|
72
|
+
image: string;
|
|
73
|
+
emailVerified: boolean;
|
|
74
|
+
} | {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
email: string | null;
|
|
78
|
+
image: string;
|
|
79
|
+
emailVerified: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
email: string | null;
|
|
84
|
+
image: string;
|
|
85
|
+
emailVerified: boolean;
|
|
86
|
+
};
|
|
87
|
+
data: NaverProfile;
|
|
88
|
+
} | null>;
|
|
89
|
+
options: NaverOptions;
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { NaverOptions, NaverProfile, naver };
|
|
@@ -0,0 +1,65 @@
|
|
|
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/naver.ts
|
|
6
|
+
const naver = (options) => {
|
|
7
|
+
const tokenEndpoint = "https://nid.naver.com/oauth2.0/token";
|
|
8
|
+
return {
|
|
9
|
+
id: "naver",
|
|
10
|
+
name: "Naver",
|
|
11
|
+
createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : ["profile", "email"];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
|
+
return createAuthorizationURL({
|
|
16
|
+
id: "naver",
|
|
17
|
+
options,
|
|
18
|
+
authorizationEndpoint: "https://nid.naver.com/oauth2.0/authorize",
|
|
19
|
+
scopes: _scopes,
|
|
20
|
+
state,
|
|
21
|
+
redirectURI
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
validateAuthorizationCode: async ({ code, redirectURI }) => {
|
|
25
|
+
return validateAuthorizationCode({
|
|
26
|
+
code,
|
|
27
|
+
redirectURI,
|
|
28
|
+
options,
|
|
29
|
+
tokenEndpoint
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
33
|
+
return refreshAccessToken({
|
|
34
|
+
refreshToken,
|
|
35
|
+
options: {
|
|
36
|
+
clientId: options.clientId,
|
|
37
|
+
clientKey: options.clientKey,
|
|
38
|
+
clientSecret: options.clientSecret
|
|
39
|
+
},
|
|
40
|
+
tokenEndpoint
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async getUserInfo(token) {
|
|
44
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
45
|
+
const { data: profile, error } = await betterFetch("https://openapi.naver.com/v1/nid/me", { headers: { Authorization: `Bearer ${token.accessToken}` } });
|
|
46
|
+
if (error || !profile || profile.resultcode !== "00") return null;
|
|
47
|
+
const userMap = await options.mapProfileToUser?.(profile);
|
|
48
|
+
const res = profile.response || {};
|
|
49
|
+
return {
|
|
50
|
+
user: {
|
|
51
|
+
id: res.id,
|
|
52
|
+
name: res.name || res.nickname || "",
|
|
53
|
+
email: res.email,
|
|
54
|
+
image: res.profile_image,
|
|
55
|
+
emailVerified: false,
|
|
56
|
+
...userMap
|
|
57
|
+
},
|
|
58
|
+
data: profile
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
options
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { naver };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/notion.d.ts
|
|
3
|
+
interface NotionProfile {
|
|
4
|
+
object: "user";
|
|
5
|
+
id: string;
|
|
6
|
+
type: "person" | "bot";
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
avatar_url?: string | undefined;
|
|
9
|
+
person?: {
|
|
10
|
+
email?: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface NotionOptions extends ProviderOptions<NotionProfile> {
|
|
14
|
+
clientId: string;
|
|
15
|
+
}
|
|
16
|
+
declare const notion: (options: NotionOptions) => {
|
|
17
|
+
id: "notion";
|
|
18
|
+
name: string;
|
|
19
|
+
createAuthorizationURL({
|
|
20
|
+
state,
|
|
21
|
+
scopes,
|
|
22
|
+
loginHint,
|
|
23
|
+
redirectURI
|
|
24
|
+
}: {
|
|
25
|
+
state: string;
|
|
26
|
+
codeVerifier: string;
|
|
27
|
+
scopes?: string[] | undefined;
|
|
28
|
+
redirectURI: string;
|
|
29
|
+
display?: string | undefined;
|
|
30
|
+
loginHint?: string | undefined;
|
|
31
|
+
}): Promise<URL>;
|
|
32
|
+
validateAuthorizationCode: ({
|
|
33
|
+
code,
|
|
34
|
+
redirectURI
|
|
35
|
+
}: {
|
|
36
|
+
code: string;
|
|
37
|
+
redirectURI: string;
|
|
38
|
+
codeVerifier?: string | undefined;
|
|
39
|
+
deviceId?: string | undefined;
|
|
40
|
+
}) => Promise<OAuth2Tokens>;
|
|
41
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
42
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
43
|
+
user?: {
|
|
44
|
+
name?: {
|
|
45
|
+
firstName?: string;
|
|
46
|
+
lastName?: string;
|
|
47
|
+
};
|
|
48
|
+
email?: string;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
user: {
|
|
52
|
+
id: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
email?: string | null;
|
|
55
|
+
image?: string;
|
|
56
|
+
emailVerified: boolean;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
59
|
+
data: any;
|
|
60
|
+
} | null>;
|
|
61
|
+
options: NotionOptions;
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { NotionOptions, NotionProfile, notion };
|
|
@@ -0,0 +1,72 @@
|
|
|
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/notion.ts
|
|
6
|
+
const notion = (options) => {
|
|
7
|
+
const tokenEndpoint = "https://api.notion.com/v1/oauth/token";
|
|
8
|
+
return {
|
|
9
|
+
id: "notion",
|
|
10
|
+
name: "Notion",
|
|
11
|
+
createAuthorizationURL({ state, scopes, loginHint, redirectURI }) {
|
|
12
|
+
const _scopes = options.disableDefaultScope ? [] : [];
|
|
13
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
14
|
+
if (scopes) _scopes.push(...scopes);
|
|
15
|
+
return createAuthorizationURL({
|
|
16
|
+
id: "notion",
|
|
17
|
+
options,
|
|
18
|
+
authorizationEndpoint: "https://api.notion.com/v1/oauth/authorize",
|
|
19
|
+
scopes: _scopes,
|
|
20
|
+
state,
|
|
21
|
+
redirectURI,
|
|
22
|
+
loginHint,
|
|
23
|
+
additionalParams: { owner: "user" }
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
validateAuthorizationCode: async ({ code, redirectURI }) => {
|
|
27
|
+
return validateAuthorizationCode({
|
|
28
|
+
code,
|
|
29
|
+
redirectURI,
|
|
30
|
+
options,
|
|
31
|
+
tokenEndpoint,
|
|
32
|
+
authentication: "basic"
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
36
|
+
return refreshAccessToken({
|
|
37
|
+
refreshToken,
|
|
38
|
+
options: {
|
|
39
|
+
clientId: options.clientId,
|
|
40
|
+
clientKey: options.clientKey,
|
|
41
|
+
clientSecret: options.clientSecret
|
|
42
|
+
},
|
|
43
|
+
tokenEndpoint
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
async getUserInfo(token) {
|
|
47
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
48
|
+
const { data: profile, error } = await betterFetch("https://api.notion.com/v1/users/me", { headers: {
|
|
49
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
50
|
+
"Notion-Version": "2022-06-28"
|
|
51
|
+
} });
|
|
52
|
+
if (error || !profile) return null;
|
|
53
|
+
const userProfile = profile.bot?.owner?.user;
|
|
54
|
+
if (!userProfile) return null;
|
|
55
|
+
const userMap = await options.mapProfileToUser?.(userProfile);
|
|
56
|
+
return {
|
|
57
|
+
user: {
|
|
58
|
+
id: userProfile.id,
|
|
59
|
+
name: userProfile.name || "",
|
|
60
|
+
email: userProfile.person?.email || null,
|
|
61
|
+
image: userProfile.avatar_url,
|
|
62
|
+
emailVerified: false,
|
|
63
|
+
...userMap
|
|
64
|
+
},
|
|
65
|
+
data: userProfile
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
options
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { notion };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/paybin.d.ts
|
|
3
|
+
interface PaybinProfile {
|
|
4
|
+
sub: string;
|
|
5
|
+
email: string;
|
|
6
|
+
email_verified?: boolean | undefined;
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
preferred_username?: string | undefined;
|
|
9
|
+
picture?: string | undefined;
|
|
10
|
+
given_name?: string | undefined;
|
|
11
|
+
family_name?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface PaybinOptions extends ProviderOptions<PaybinProfile> {
|
|
14
|
+
clientId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The issuer URL of your Paybin OAuth server
|
|
17
|
+
* @default "https://idp.paybin.io"
|
|
18
|
+
*/
|
|
19
|
+
issuer?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
declare const paybin: (options: PaybinOptions) => {
|
|
22
|
+
id: "paybin";
|
|
23
|
+
name: string;
|
|
24
|
+
createAuthorizationURL({
|
|
25
|
+
state,
|
|
26
|
+
scopes,
|
|
27
|
+
codeVerifier,
|
|
28
|
+
redirectURI,
|
|
29
|
+
loginHint
|
|
30
|
+
}: {
|
|
31
|
+
state: string;
|
|
32
|
+
codeVerifier: string;
|
|
33
|
+
scopes?: string[] | undefined;
|
|
34
|
+
redirectURI: string;
|
|
35
|
+
display?: string | undefined;
|
|
36
|
+
loginHint?: string | undefined;
|
|
37
|
+
}): Promise<URL>;
|
|
38
|
+
validateAuthorizationCode: ({
|
|
39
|
+
code,
|
|
40
|
+
codeVerifier,
|
|
41
|
+
redirectURI
|
|
42
|
+
}: {
|
|
43
|
+
code: string;
|
|
44
|
+
redirectURI: string;
|
|
45
|
+
codeVerifier?: string | undefined;
|
|
46
|
+
deviceId?: string | undefined;
|
|
47
|
+
}) => Promise<OAuth2Tokens>;
|
|
48
|
+
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
49
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
50
|
+
user?: {
|
|
51
|
+
name?: {
|
|
52
|
+
firstName?: string;
|
|
53
|
+
lastName?: string;
|
|
54
|
+
};
|
|
55
|
+
email?: string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
user: {
|
|
59
|
+
id: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
email?: string | null;
|
|
62
|
+
image?: string;
|
|
63
|
+
emailVerified: boolean;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
};
|
|
66
|
+
data: any;
|
|
67
|
+
} | null>;
|
|
68
|
+
options: PaybinOptions;
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { PaybinOptions, PaybinProfile, paybin };
|
|
@@ -0,0 +1,81 @@
|
|
|
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 { decodeJwt } from "jose";
|
|
7
|
+
//#region src/social-providers/paybin.ts
|
|
8
|
+
const paybin = (options) => {
|
|
9
|
+
const issuer = options.issuer || "https://idp.paybin.io";
|
|
10
|
+
const authorizationEndpoint = `${issuer}/oauth2/authorize`;
|
|
11
|
+
const tokenEndpoint = `${issuer}/oauth2/token`;
|
|
12
|
+
return {
|
|
13
|
+
id: "paybin",
|
|
14
|
+
name: "Paybin",
|
|
15
|
+
async createAuthorizationURL({ state, scopes, codeVerifier, redirectURI, loginHint }) {
|
|
16
|
+
if (!options.clientId || !options.clientSecret) {
|
|
17
|
+
logger.error("Client Id and Client Secret is required for Paybin. Make sure to provide them in the options.");
|
|
18
|
+
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
19
|
+
}
|
|
20
|
+
if (!codeVerifier) throw new BetterAuthError("codeVerifier is required for Paybin");
|
|
21
|
+
const _scopes = options.disableDefaultScope ? [] : [
|
|
22
|
+
"openid",
|
|
23
|
+
"email",
|
|
24
|
+
"profile"
|
|
25
|
+
];
|
|
26
|
+
if (options.scope) _scopes.push(...options.scope);
|
|
27
|
+
if (scopes) _scopes.push(...scopes);
|
|
28
|
+
return await createAuthorizationURL({
|
|
29
|
+
id: "paybin",
|
|
30
|
+
options,
|
|
31
|
+
authorizationEndpoint,
|
|
32
|
+
scopes: _scopes,
|
|
33
|
+
state,
|
|
34
|
+
codeVerifier,
|
|
35
|
+
redirectURI,
|
|
36
|
+
prompt: options.prompt,
|
|
37
|
+
loginHint
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
41
|
+
return validateAuthorizationCode({
|
|
42
|
+
code,
|
|
43
|
+
codeVerifier,
|
|
44
|
+
redirectURI,
|
|
45
|
+
options,
|
|
46
|
+
tokenEndpoint
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
refreshAccessToken: options.refreshAccessToken ? options.refreshAccessToken : async (refreshToken) => {
|
|
50
|
+
return refreshAccessToken({
|
|
51
|
+
refreshToken,
|
|
52
|
+
options: {
|
|
53
|
+
clientId: options.clientId,
|
|
54
|
+
clientKey: options.clientKey,
|
|
55
|
+
clientSecret: options.clientSecret
|
|
56
|
+
},
|
|
57
|
+
tokenEndpoint
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
async getUserInfo(token) {
|
|
61
|
+
if (options.getUserInfo) return options.getUserInfo(token);
|
|
62
|
+
if (!token.idToken) return null;
|
|
63
|
+
const user = decodeJwt(token.idToken);
|
|
64
|
+
const userMap = await options.mapProfileToUser?.(user);
|
|
65
|
+
return {
|
|
66
|
+
user: {
|
|
67
|
+
id: user.sub,
|
|
68
|
+
name: user.name || user.preferred_username || "",
|
|
69
|
+
email: user.email,
|
|
70
|
+
image: user.picture,
|
|
71
|
+
emailVerified: user.email_verified || false,
|
|
72
|
+
...userMap
|
|
73
|
+
},
|
|
74
|
+
data: user
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
options
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { paybin };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
2
|
+
//#region src/social-providers/paypal.d.ts
|
|
3
|
+
interface PayPalProfile {
|
|
4
|
+
sub?: string | undefined;
|
|
5
|
+
user_id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
given_name: string;
|
|
8
|
+
family_name: string;
|
|
9
|
+
middle_name?: string | undefined;
|
|
10
|
+
picture?: string | undefined;
|
|
11
|
+
email: string;
|
|
12
|
+
email_verified: boolean;
|
|
13
|
+
gender?: string | undefined;
|
|
14
|
+
birthdate?: string | undefined;
|
|
15
|
+
zoneinfo?: string | undefined;
|
|
16
|
+
locale?: string | undefined;
|
|
17
|
+
phone_number?: string | undefined;
|
|
18
|
+
address?: {
|
|
19
|
+
street_address?: string;
|
|
20
|
+
locality?: string;
|
|
21
|
+
region?: string;
|
|
22
|
+
postal_code?: string;
|
|
23
|
+
country?: string;
|
|
24
|
+
} | undefined;
|
|
25
|
+
verified_account?: boolean | undefined;
|
|
26
|
+
account_type?: string | undefined;
|
|
27
|
+
age_range?: string | undefined;
|
|
28
|
+
payer_id?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
interface PayPalTokenResponse {
|
|
31
|
+
scope?: string | undefined;
|
|
32
|
+
access_token: string;
|
|
33
|
+
refresh_token?: string | undefined;
|
|
34
|
+
token_type: "Bearer";
|
|
35
|
+
id_token?: string | undefined;
|
|
36
|
+
expires_in: number;
|
|
37
|
+
nonce?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
interface PayPalOptions extends ProviderOptions<PayPalProfile> {
|
|
40
|
+
clientId: string;
|
|
41
|
+
/**
|
|
42
|
+
* PayPal environment - 'sandbox' for testing, 'live' for production
|
|
43
|
+
* @default 'sandbox'
|
|
44
|
+
*/
|
|
45
|
+
environment?: ("sandbox" | "live") | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to request shipping address information
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
requestShippingAddress?: boolean | undefined;
|
|
51
|
+
}
|
|
52
|
+
declare const paypal: (options: PayPalOptions) => {
|
|
53
|
+
id: "paypal";
|
|
54
|
+
name: string;
|
|
55
|
+
createAuthorizationURL({
|
|
56
|
+
state,
|
|
57
|
+
codeVerifier,
|
|
58
|
+
redirectURI
|
|
59
|
+
}: {
|
|
60
|
+
state: string;
|
|
61
|
+
codeVerifier: string;
|
|
62
|
+
scopes?: string[] | undefined;
|
|
63
|
+
redirectURI: string;
|
|
64
|
+
display?: string | undefined;
|
|
65
|
+
loginHint?: string | undefined;
|
|
66
|
+
}): Promise<URL>;
|
|
67
|
+
validateAuthorizationCode: ({
|
|
68
|
+
code,
|
|
69
|
+
redirectURI
|
|
70
|
+
}: {
|
|
71
|
+
code: string;
|
|
72
|
+
redirectURI: string;
|
|
73
|
+
codeVerifier?: string | undefined;
|
|
74
|
+
deviceId?: string | undefined;
|
|
75
|
+
}) => Promise<{
|
|
76
|
+
accessToken: string;
|
|
77
|
+
refreshToken: string | undefined;
|
|
78
|
+
accessTokenExpiresAt: Date | undefined;
|
|
79
|
+
idToken: string | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
refreshAccessToken: ((refreshToken: string) => Promise<OAuth2Tokens>) | ((refreshToken: string) => Promise<{
|
|
82
|
+
accessToken: any;
|
|
83
|
+
refreshToken: any;
|
|
84
|
+
accessTokenExpiresAt: Date | undefined;
|
|
85
|
+
}>);
|
|
86
|
+
verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
|
|
87
|
+
getUserInfo(token: OAuth2Tokens & {
|
|
88
|
+
user?: {
|
|
89
|
+
name?: {
|
|
90
|
+
firstName?: string;
|
|
91
|
+
lastName?: string;
|
|
92
|
+
};
|
|
93
|
+
email?: string;
|
|
94
|
+
} | undefined;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
user: {
|
|
97
|
+
id: string;
|
|
98
|
+
name?: string;
|
|
99
|
+
email?: string | null;
|
|
100
|
+
image?: string;
|
|
101
|
+
emailVerified: boolean;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
104
|
+
data: any;
|
|
105
|
+
} | {
|
|
106
|
+
user: {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
email: string;
|
|
110
|
+
image: string | undefined;
|
|
111
|
+
emailVerified: boolean;
|
|
112
|
+
} | {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
email: string | null;
|
|
116
|
+
image: string;
|
|
117
|
+
emailVerified: boolean;
|
|
118
|
+
} | {
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
email: string | null;
|
|
122
|
+
image: string;
|
|
123
|
+
emailVerified: boolean;
|
|
124
|
+
};
|
|
125
|
+
data: PayPalProfile;
|
|
126
|
+
} | null>;
|
|
127
|
+
options: PayPalOptions;
|
|
128
|
+
};
|
|
129
|
+
declare const getPayPalPublicKey: (kid: string, jwksUri: string) => Promise<Uint8Array<ArrayBufferLike> | CryptoKey>;
|
|
130
|
+
//#endregion
|
|
131
|
+
export { PayPalOptions, PayPalProfile, PayPalTokenResponse, getPayPalPublicKey, paypal };
|