@better-auth/core 1.5.4 → 1.5.6
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/dist/api/index.d.mts +0 -3
- package/dist/context/endpoint-context.d.mts +0 -1
- package/dist/context/global.mjs +1 -1
- package/dist/db/adapter/factory.d.mts +0 -2
- package/dist/db/adapter/factory.mjs +53 -20
- package/dist/db/adapter/factory.mjs.map +1 -1
- package/dist/db/adapter/get-field-attributes.d.mts +0 -3
- package/dist/db/adapter/get-id-field.d.mts +0 -3
- package/dist/db/adapter/get-id-field.mjs +2 -2
- package/dist/db/adapter/get-id-field.mjs.map +1 -1
- package/dist/db/adapter/index.d.mts +0 -2
- package/dist/db/adapter/types.d.mts +0 -2
- package/dist/db/get-tables.d.mts +0 -2
- package/dist/db/schema/account.d.mts +0 -1
- package/dist/db/schema/rate-limit.d.mts +0 -1
- package/dist/db/schema/session.d.mts +0 -1
- package/dist/db/schema/user.d.mts +0 -1
- package/dist/db/schema/verification.d.mts +0 -1
- package/dist/db/type.d.mts +0 -1
- package/dist/instrumentation/attributes.d.mts +12 -0
- package/dist/instrumentation/attributes.mjs +13 -0
- package/dist/instrumentation/attributes.mjs.map +1 -0
- package/dist/instrumentation/index.d.mts +3 -0
- package/dist/instrumentation/index.mjs +4 -0
- package/dist/instrumentation/tracer.d.mts +14 -0
- package/dist/instrumentation/tracer.mjs +37 -0
- package/dist/instrumentation/tracer.mjs.map +1 -0
- package/dist/oauth2/client-credentials-token.d.mts +0 -1
- package/dist/oauth2/create-authorization-url.d.mts +0 -3
- package/dist/oauth2/oauth-provider.d.mts +0 -2
- package/dist/oauth2/refresh-access-token.d.mts +0 -1
- package/dist/oauth2/validate-authorization-code.d.mts +0 -2
- package/dist/social-providers/apple.d.mts +0 -2
- package/dist/social-providers/apple.mjs +1 -1
- package/dist/social-providers/apple.mjs.map +1 -1
- package/dist/social-providers/atlassian.d.mts +0 -2
- package/dist/social-providers/atlassian.mjs +3 -2
- package/dist/social-providers/atlassian.mjs.map +1 -1
- package/dist/social-providers/cognito.d.mts +0 -2
- package/dist/social-providers/discord.d.mts +0 -2
- package/dist/social-providers/discord.mjs +3 -2
- package/dist/social-providers/discord.mjs.map +1 -1
- package/dist/social-providers/dropbox.d.mts +0 -2
- package/dist/social-providers/facebook.d.mts +0 -2
- package/dist/social-providers/figma.d.mts +0 -2
- package/dist/social-providers/figma.mjs +3 -2
- package/dist/social-providers/figma.mjs.map +1 -1
- package/dist/social-providers/github.d.mts +0 -2
- package/dist/social-providers/github.mjs +1 -1
- package/dist/social-providers/github.mjs.map +1 -1
- package/dist/social-providers/gitlab.d.mts +0 -2
- package/dist/social-providers/google.d.mts +0 -2
- package/dist/social-providers/huggingface.d.mts +0 -2
- package/dist/social-providers/huggingface.mjs +3 -2
- package/dist/social-providers/huggingface.mjs.map +1 -1
- package/dist/social-providers/index.d.mts +61 -3
- package/dist/social-providers/index.mjs +4 -2
- package/dist/social-providers/index.mjs.map +1 -1
- package/dist/social-providers/kakao.d.mts +0 -2
- package/dist/social-providers/kakao.mjs +3 -2
- package/dist/social-providers/kakao.mjs.map +1 -1
- package/dist/social-providers/kick.d.mts +0 -2
- package/dist/social-providers/line.d.mts +0 -2
- package/dist/social-providers/linear.d.mts +0 -2
- package/dist/social-providers/linkedin.d.mts +0 -2
- package/dist/social-providers/microsoft-entra-id.d.mts +0 -2
- package/dist/social-providers/naver.d.mts +0 -2
- package/dist/social-providers/naver.mjs +3 -2
- package/dist/social-providers/naver.mjs.map +1 -1
- package/dist/social-providers/notion.d.mts +0 -2
- package/dist/social-providers/paybin.d.mts +0 -2
- package/dist/social-providers/paypal.d.mts +0 -2
- package/dist/social-providers/polar.d.mts +0 -2
- package/dist/social-providers/polar.mjs +3 -2
- package/dist/social-providers/polar.mjs.map +1 -1
- package/dist/social-providers/railway.d.mts +0 -2
- package/dist/social-providers/reddit.d.mts +0 -2
- package/dist/social-providers/roblox.d.mts +0 -2
- package/dist/social-providers/roblox.mjs +3 -2
- package/dist/social-providers/roblox.mjs.map +1 -1
- package/dist/social-providers/salesforce.d.mts +0 -2
- package/dist/social-providers/slack.d.mts +0 -2
- package/dist/social-providers/slack.mjs +3 -2
- package/dist/social-providers/slack.mjs.map +1 -1
- package/dist/social-providers/spotify.d.mts +0 -2
- package/dist/social-providers/spotify.mjs +3 -2
- package/dist/social-providers/spotify.mjs.map +1 -1
- package/dist/social-providers/tiktok.d.mts +0 -2
- package/dist/social-providers/tiktok.mjs +3 -2
- package/dist/social-providers/tiktok.mjs.map +1 -1
- package/dist/social-providers/twitch.d.mts +0 -2
- package/dist/social-providers/twitch.mjs +3 -2
- package/dist/social-providers/twitch.mjs.map +1 -1
- package/dist/social-providers/twitter.d.mts +0 -2
- package/dist/social-providers/twitter.mjs +3 -2
- package/dist/social-providers/twitter.mjs.map +1 -1
- package/dist/social-providers/vercel.d.mts +0 -2
- package/dist/social-providers/vk.d.mts +0 -2
- package/dist/social-providers/vk.mjs +3 -2
- package/dist/social-providers/vk.mjs.map +1 -1
- package/dist/social-providers/wechat.d.mts +114 -0
- package/dist/social-providers/wechat.mjs +84 -0
- package/dist/social-providers/wechat.mjs.map +1 -0
- package/dist/social-providers/zoom.d.mts +0 -2
- package/dist/types/context.d.mts +0 -2
- package/dist/types/init-options.d.mts +0 -1
- package/dist/types/plugin.d.mts +0 -1
- package/dist/utils/db.d.mts +0 -2
- package/dist/utils/fetch-metadata.d.mts +5 -0
- package/dist/utils/fetch-metadata.mjs +8 -0
- package/dist/utils/fetch-metadata.mjs.map +1 -0
- package/package.json +15 -2
- package/src/db/adapter/factory.ts +119 -47
- package/src/db/adapter/get-id-field.test.ts +222 -0
- package/src/db/adapter/get-id-field.ts +15 -4
- package/src/instrumentation/attributes.ts +22 -0
- package/src/instrumentation/index.ts +2 -0
- package/src/instrumentation/instrumentation.test.ts +139 -0
- package/src/instrumentation/tracer.ts +62 -0
- package/src/social-providers/apple.ts +1 -1
- package/src/social-providers/atlassian.ts +3 -2
- package/src/social-providers/discord.ts +3 -2
- package/src/social-providers/figma.ts +3 -2
- package/src/social-providers/github.ts +1 -1
- package/src/social-providers/huggingface.ts +3 -2
- package/src/social-providers/index.ts +3 -0
- package/src/social-providers/kakao.ts +3 -2
- package/src/social-providers/naver.ts +3 -2
- package/src/social-providers/polar.ts +3 -2
- package/src/social-providers/roblox.ts +3 -2
- package/src/social-providers/slack.ts +3 -2
- package/src/social-providers/spotify.ts +3 -2
- package/src/social-providers/tiktok.ts +3 -2
- package/src/social-providers/twitch.ts +3 -2
- package/src/social-providers/twitter.ts +3 -2
- package/src/social-providers/vk.ts +3 -2
- package/src/social-providers/wechat.ts +213 -0
- package/src/utils/fetch-metadata.test.ts +28 -0
- package/src/utils/fetch-metadata.ts +3 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { trace } from "@opentelemetry/api";
|
|
2
|
+
import {
|
|
3
|
+
InMemorySpanExporter,
|
|
4
|
+
SimpleSpanProcessor,
|
|
5
|
+
} from "@opentelemetry/sdk-trace-base";
|
|
6
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
7
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
8
|
+
import { withSpan } from ".";
|
|
9
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME } from "./attributes";
|
|
10
|
+
|
|
11
|
+
describe("instrumentation", () => {
|
|
12
|
+
let provider: NodeTracerProvider;
|
|
13
|
+
let exporter: InMemorySpanExporter;
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
exporter = new InMemorySpanExporter();
|
|
17
|
+
provider = new NodeTracerProvider({
|
|
18
|
+
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
19
|
+
});
|
|
20
|
+
trace.setGlobalTracerProvider(provider);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterAll(async () => {
|
|
24
|
+
await provider.shutdown();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
exporter.reset();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("creates a span with name and attributes for sync function", () => {
|
|
32
|
+
const result = withSpan(
|
|
33
|
+
"test.sync",
|
|
34
|
+
{
|
|
35
|
+
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
36
|
+
[ATTR_DB_COLLECTION_NAME]: "user",
|
|
37
|
+
},
|
|
38
|
+
() => 42,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(result).toBe(42);
|
|
42
|
+
|
|
43
|
+
const spans = exporter.getFinishedSpans();
|
|
44
|
+
expect(spans).toHaveLength(1);
|
|
45
|
+
expect(spans[0]?.name).toBe("test.sync");
|
|
46
|
+
expect(spans[0]?.attributes).toMatchObject({
|
|
47
|
+
[ATTR_DB_OPERATION_NAME]: "findOne",
|
|
48
|
+
[ATTR_DB_COLLECTION_NAME]: "user",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("creates a span for async function", async () => {
|
|
53
|
+
const result = await withSpan(
|
|
54
|
+
"test.async",
|
|
55
|
+
{ endpoint: "getSession" },
|
|
56
|
+
async () => {
|
|
57
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
58
|
+
return "session-id";
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(result).toBe("session-id");
|
|
63
|
+
|
|
64
|
+
const spans = exporter.getFinishedSpans();
|
|
65
|
+
expect(spans).toHaveLength(1);
|
|
66
|
+
expect(spans[0]?.name).toBe("test.async");
|
|
67
|
+
expect(spans[0]?.attributes).toMatchObject({ endpoint: "getSession" });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("records error status and exception when sync function throws", () => {
|
|
71
|
+
const err = new Error("sync failure");
|
|
72
|
+
|
|
73
|
+
expect(() =>
|
|
74
|
+
withSpan("test.sync.error", { foo: "bar" }, () => {
|
|
75
|
+
throw err;
|
|
76
|
+
}),
|
|
77
|
+
).toThrow("sync failure");
|
|
78
|
+
|
|
79
|
+
const spans = exporter.getFinishedSpans();
|
|
80
|
+
expect(spans).toHaveLength(1);
|
|
81
|
+
expect(spans[0]?.name).toBe("test.sync.error");
|
|
82
|
+
expect(spans[0]?.status).toMatchObject({
|
|
83
|
+
code: 2,
|
|
84
|
+
message: "sync failure",
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("records error status and exception when async function rejects", async () => {
|
|
89
|
+
const err = new Error("async failure");
|
|
90
|
+
|
|
91
|
+
await expect(
|
|
92
|
+
withSpan("test.async.error", { baz: 1 }, async () => {
|
|
93
|
+
await Promise.resolve();
|
|
94
|
+
throw err;
|
|
95
|
+
}),
|
|
96
|
+
).rejects.toThrow("async failure");
|
|
97
|
+
|
|
98
|
+
const spans = exporter.getFinishedSpans();
|
|
99
|
+
expect(spans).toHaveLength(1);
|
|
100
|
+
expect(spans[0]?.name).toBe("test.async.error");
|
|
101
|
+
expect(spans[0]?.status).toMatchObject({
|
|
102
|
+
code: 2,
|
|
103
|
+
message: "async failure",
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("creates multiple sequential spans", () => {
|
|
108
|
+
void withSpan("first", { order: 1 }, () => 1);
|
|
109
|
+
void withSpan("second", { order: 2 }, () => 2);
|
|
110
|
+
|
|
111
|
+
const spans = exporter.getFinishedSpans();
|
|
112
|
+
expect(spans).toHaveLength(2);
|
|
113
|
+
expect(spans.map((s) => s.name)).toEqual(
|
|
114
|
+
expect.arrayContaining(["first", "second"]),
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("creates nested spans when withSpan is composed", () => {
|
|
119
|
+
const result = withSpan("outer", { depth: 0 }, () => {
|
|
120
|
+
return withSpan("inner", { depth: 1 }, () => "ok");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(result).toBe("ok");
|
|
124
|
+
|
|
125
|
+
const spans = exporter.getFinishedSpans();
|
|
126
|
+
expect(spans).toHaveLength(2);
|
|
127
|
+
expect(spans.map((s) => s.name).sort()).toEqual(["inner", "outer"]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("uses better-auth instrumentation scope", () => {
|
|
131
|
+
void withSpan("scope.check", {}, () => undefined);
|
|
132
|
+
|
|
133
|
+
const spans = exporter.getFinishedSpans();
|
|
134
|
+
expect(spans).toHaveLength(1);
|
|
135
|
+
|
|
136
|
+
const span = spans[0];
|
|
137
|
+
expect(span?.instrumentationLibrary?.name).toBe("better-auth");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
2
|
+
|
|
3
|
+
const INSTRUMENTATION_SCOPE = "better-auth";
|
|
4
|
+
const INSTRUMENTATION_VERSION = import.meta.env?.BETTER_AUTH_VERSION ?? "1.0.0";
|
|
5
|
+
|
|
6
|
+
const tracer = trace.getTracer(INSTRUMENTATION_SCOPE, INSTRUMENTATION_VERSION);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a child span whose lifetime is bound to the execution of the given function
|
|
10
|
+
*
|
|
11
|
+
* @param name - The name of the span.
|
|
12
|
+
* @param attributes - The attributes of the span.
|
|
13
|
+
* @param fn - The function to execute within the span.
|
|
14
|
+
* @returns The result of the function.
|
|
15
|
+
*/
|
|
16
|
+
export function withSpan<T>(
|
|
17
|
+
name: string,
|
|
18
|
+
attributes: Record<string, string | number | boolean>,
|
|
19
|
+
fn: () => T,
|
|
20
|
+
): T;
|
|
21
|
+
export function withSpan<T>(
|
|
22
|
+
name: string,
|
|
23
|
+
attributes: Record<string, string | number | boolean>,
|
|
24
|
+
fn: () => Promise<T>,
|
|
25
|
+
): Promise<T>;
|
|
26
|
+
export function withSpan<T>(
|
|
27
|
+
name: string,
|
|
28
|
+
attributes: Record<string, string | number | boolean>,
|
|
29
|
+
fn: () => T | Promise<T>,
|
|
30
|
+
): T | Promise<T> {
|
|
31
|
+
return tracer.startActiveSpan(name, { attributes }, (span) => {
|
|
32
|
+
try {
|
|
33
|
+
const result = fn();
|
|
34
|
+
if (result instanceof Promise) {
|
|
35
|
+
return result
|
|
36
|
+
.then((value) => {
|
|
37
|
+
span.end();
|
|
38
|
+
return value;
|
|
39
|
+
})
|
|
40
|
+
.catch((err) => {
|
|
41
|
+
span.recordException(err);
|
|
42
|
+
span.setStatus({
|
|
43
|
+
code: SpanStatusCode.ERROR,
|
|
44
|
+
message: String(err.message ?? err),
|
|
45
|
+
});
|
|
46
|
+
span.end();
|
|
47
|
+
throw err;
|
|
48
|
+
}) as Promise<T>;
|
|
49
|
+
}
|
|
50
|
+
span.end();
|
|
51
|
+
return result;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
span.recordException(err as Error);
|
|
54
|
+
span.setStatus({
|
|
55
|
+
code: SpanStatusCode.ERROR,
|
|
56
|
+
message: String((err as Error)?.message ?? err),
|
|
57
|
+
});
|
|
58
|
+
span.end();
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -30,6 +30,7 @@ export interface AtlassianOptions extends ProviderOptions<AtlassianProfile> {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const atlassian = (options: AtlassianOptions) => {
|
|
33
|
+
const tokenEndpoint = "https://auth.atlassian.com/oauth/token";
|
|
33
34
|
return {
|
|
34
35
|
id: "atlassian",
|
|
35
36
|
name: "Atlassian",
|
|
@@ -70,7 +71,7 @@ export const atlassian = (options: AtlassianOptions) => {
|
|
|
70
71
|
codeVerifier,
|
|
71
72
|
redirectURI,
|
|
72
73
|
options,
|
|
73
|
-
tokenEndpoint
|
|
74
|
+
tokenEndpoint,
|
|
74
75
|
});
|
|
75
76
|
},
|
|
76
77
|
|
|
@@ -83,7 +84,7 @@ export const atlassian = (options: AtlassianOptions) => {
|
|
|
83
84
|
clientId: options.clientId,
|
|
84
85
|
clientSecret: options.clientSecret,
|
|
85
86
|
},
|
|
86
|
-
tokenEndpoint
|
|
87
|
+
tokenEndpoint,
|
|
87
88
|
});
|
|
88
89
|
},
|
|
89
90
|
|
|
@@ -80,6 +80,7 @@ export interface DiscordOptions extends ProviderOptions<DiscordProfile> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export const discord = (options: DiscordOptions) => {
|
|
83
|
+
const tokenEndpoint = "https://discord.com/api/oauth2/token";
|
|
83
84
|
return {
|
|
84
85
|
id: "discord",
|
|
85
86
|
name: "Discord",
|
|
@@ -109,7 +110,7 @@ export const discord = (options: DiscordOptions) => {
|
|
|
109
110
|
code,
|
|
110
111
|
redirectURI,
|
|
111
112
|
options,
|
|
112
|
-
tokenEndpoint
|
|
113
|
+
tokenEndpoint,
|
|
113
114
|
});
|
|
114
115
|
},
|
|
115
116
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -122,7 +123,7 @@ export const discord = (options: DiscordOptions) => {
|
|
|
122
123
|
clientKey: options.clientKey,
|
|
123
124
|
clientSecret: options.clientSecret,
|
|
124
125
|
},
|
|
125
|
-
tokenEndpoint
|
|
126
|
+
tokenEndpoint,
|
|
126
127
|
});
|
|
127
128
|
},
|
|
128
129
|
async getUserInfo(token) {
|
|
@@ -20,6 +20,7 @@ export interface FigmaOptions extends ProviderOptions<FigmaProfile> {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const figma = (options: FigmaOptions) => {
|
|
23
|
+
const tokenEndpoint = "https://api.figma.com/v1/oauth/token";
|
|
23
24
|
return {
|
|
24
25
|
id: "figma",
|
|
25
26
|
name: "Figma",
|
|
@@ -56,7 +57,7 @@ export const figma = (options: FigmaOptions) => {
|
|
|
56
57
|
codeVerifier,
|
|
57
58
|
redirectURI,
|
|
58
59
|
options,
|
|
59
|
-
tokenEndpoint
|
|
60
|
+
tokenEndpoint,
|
|
60
61
|
authentication: "basic",
|
|
61
62
|
});
|
|
62
63
|
},
|
|
@@ -70,7 +71,7 @@ export const figma = (options: FigmaOptions) => {
|
|
|
70
71
|
clientKey: options.clientKey,
|
|
71
72
|
clientSecret: options.clientSecret,
|
|
72
73
|
},
|
|
73
|
-
tokenEndpoint
|
|
74
|
+
tokenEndpoint,
|
|
74
75
|
authentication: "basic",
|
|
75
76
|
});
|
|
76
77
|
},
|
|
@@ -126,7 +126,7 @@ export const github = (options: GithubOptions) => {
|
|
|
126
126
|
clientKey: options.clientKey,
|
|
127
127
|
clientSecret: options.clientSecret,
|
|
128
128
|
},
|
|
129
|
-
tokenEndpoint
|
|
129
|
+
tokenEndpoint,
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
132
|
async getUserInfo(token) {
|
|
@@ -43,6 +43,7 @@ export interface HuggingFaceOptions
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export const huggingface = (options: HuggingFaceOptions) => {
|
|
46
|
+
const tokenEndpoint = "https://huggingface.co/oauth/token";
|
|
46
47
|
return {
|
|
47
48
|
id: "huggingface",
|
|
48
49
|
name: "Hugging Face",
|
|
@@ -68,7 +69,7 @@ export const huggingface = (options: HuggingFaceOptions) => {
|
|
|
68
69
|
codeVerifier,
|
|
69
70
|
redirectURI,
|
|
70
71
|
options,
|
|
71
|
-
tokenEndpoint
|
|
72
|
+
tokenEndpoint,
|
|
72
73
|
});
|
|
73
74
|
},
|
|
74
75
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -81,7 +82,7 @@ export const huggingface = (options: HuggingFaceOptions) => {
|
|
|
81
82
|
clientKey: options.clientKey,
|
|
82
83
|
clientSecret: options.clientSecret,
|
|
83
84
|
},
|
|
84
|
-
tokenEndpoint
|
|
85
|
+
tokenEndpoint,
|
|
85
86
|
});
|
|
86
87
|
},
|
|
87
88
|
async getUserInfo(token) {
|
|
@@ -33,6 +33,7 @@ import { twitch } from "./twitch";
|
|
|
33
33
|
import { twitter } from "./twitter";
|
|
34
34
|
import { vercel } from "./vercel";
|
|
35
35
|
import { vk } from "./vk";
|
|
36
|
+
import { wechat } from "./wechat";
|
|
36
37
|
import { zoom } from "./zoom";
|
|
37
38
|
|
|
38
39
|
export const socialProviders = {
|
|
@@ -70,6 +71,7 @@ export const socialProviders = {
|
|
|
70
71
|
polar,
|
|
71
72
|
railway,
|
|
72
73
|
vercel,
|
|
74
|
+
wechat,
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
export const socialProviderList = Object.keys(socialProviders) as [
|
|
@@ -126,6 +128,7 @@ export * from "./twitch";
|
|
|
126
128
|
export * from "./twitter";
|
|
127
129
|
export * from "./vercel";
|
|
128
130
|
export * from "./vk";
|
|
131
|
+
export * from "./wechat";
|
|
129
132
|
export * from "./zoom";
|
|
130
133
|
|
|
131
134
|
export type SocialProviderList = typeof socialProviderList;
|
|
@@ -102,6 +102,7 @@ export interface KakaoOptions extends ProviderOptions<KakaoProfile> {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export const kakao = (options: KakaoOptions) => {
|
|
105
|
+
const tokenEndpoint = "https://kauth.kakao.com/oauth/token";
|
|
105
106
|
return {
|
|
106
107
|
id: "kakao",
|
|
107
108
|
name: "Kakao",
|
|
@@ -125,7 +126,7 @@ export const kakao = (options: KakaoOptions) => {
|
|
|
125
126
|
code,
|
|
126
127
|
redirectURI,
|
|
127
128
|
options,
|
|
128
|
-
tokenEndpoint
|
|
129
|
+
tokenEndpoint,
|
|
129
130
|
});
|
|
130
131
|
},
|
|
131
132
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -138,7 +139,7 @@ export const kakao = (options: KakaoOptions) => {
|
|
|
138
139
|
clientKey: options.clientKey,
|
|
139
140
|
clientSecret: options.clientSecret,
|
|
140
141
|
},
|
|
141
|
-
tokenEndpoint
|
|
142
|
+
tokenEndpoint,
|
|
142
143
|
});
|
|
143
144
|
},
|
|
144
145
|
async getUserInfo(token) {
|
|
@@ -40,6 +40,7 @@ export interface NaverOptions extends ProviderOptions<NaverProfile> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const naver = (options: NaverOptions) => {
|
|
43
|
+
const tokenEndpoint = "https://nid.naver.com/oauth2.0/token";
|
|
43
44
|
return {
|
|
44
45
|
id: "naver",
|
|
45
46
|
name: "Naver",
|
|
@@ -61,7 +62,7 @@ export const naver = (options: NaverOptions) => {
|
|
|
61
62
|
code,
|
|
62
63
|
redirectURI,
|
|
63
64
|
options,
|
|
64
|
-
tokenEndpoint
|
|
65
|
+
tokenEndpoint,
|
|
65
66
|
});
|
|
66
67
|
},
|
|
67
68
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -74,7 +75,7 @@ export const naver = (options: NaverOptions) => {
|
|
|
74
75
|
clientKey: options.clientKey,
|
|
75
76
|
clientSecret: options.clientSecret,
|
|
76
77
|
},
|
|
77
|
-
tokenEndpoint
|
|
78
|
+
tokenEndpoint,
|
|
78
79
|
});
|
|
79
80
|
},
|
|
80
81
|
async getUserInfo(token) {
|
|
@@ -33,6 +33,7 @@ export interface PolarProfile {
|
|
|
33
33
|
export interface PolarOptions extends ProviderOptions<PolarProfile> {}
|
|
34
34
|
|
|
35
35
|
export const polar = (options: PolarOptions) => {
|
|
36
|
+
const tokenEndpoint = "https://api.polar.sh/v1/oauth2/token";
|
|
36
37
|
return {
|
|
37
38
|
id: "polar",
|
|
38
39
|
name: "Polar",
|
|
@@ -59,7 +60,7 @@ export const polar = (options: PolarOptions) => {
|
|
|
59
60
|
codeVerifier,
|
|
60
61
|
redirectURI,
|
|
61
62
|
options,
|
|
62
|
-
tokenEndpoint
|
|
63
|
+
tokenEndpoint,
|
|
63
64
|
});
|
|
64
65
|
},
|
|
65
66
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -72,7 +73,7 @@ export const polar = (options: PolarOptions) => {
|
|
|
72
73
|
clientKey: options.clientKey,
|
|
73
74
|
clientSecret: options.clientSecret,
|
|
74
75
|
},
|
|
75
|
-
tokenEndpoint
|
|
76
|
+
tokenEndpoint,
|
|
76
77
|
});
|
|
77
78
|
},
|
|
78
79
|
async getUserInfo(token) {
|
|
@@ -33,6 +33,7 @@ export interface RobloxOptions extends ProviderOptions<RobloxProfile> {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const roblox = (options: RobloxOptions) => {
|
|
36
|
+
const tokenEndpoint = "https://apis.roblox.com/oauth/v1/token";
|
|
36
37
|
return {
|
|
37
38
|
id: "roblox",
|
|
38
39
|
name: "Roblox",
|
|
@@ -55,7 +56,7 @@ export const roblox = (options: RobloxOptions) => {
|
|
|
55
56
|
code,
|
|
56
57
|
redirectURI: options.redirectURI || redirectURI,
|
|
57
58
|
options,
|
|
58
|
-
tokenEndpoint
|
|
59
|
+
tokenEndpoint,
|
|
59
60
|
authentication: "post",
|
|
60
61
|
});
|
|
61
62
|
},
|
|
@@ -69,7 +70,7 @@ export const roblox = (options: RobloxOptions) => {
|
|
|
69
70
|
clientKey: options.clientKey,
|
|
70
71
|
clientSecret: options.clientSecret,
|
|
71
72
|
},
|
|
72
|
-
tokenEndpoint
|
|
73
|
+
tokenEndpoint,
|
|
73
74
|
});
|
|
74
75
|
},
|
|
75
76
|
async getUserInfo(token) {
|
|
@@ -38,6 +38,7 @@ export interface SlackOptions extends ProviderOptions<SlackProfile> {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export const slack = (options: SlackOptions) => {
|
|
41
|
+
const tokenEndpoint = "https://slack.com/api/openid.connect.token";
|
|
41
42
|
return {
|
|
42
43
|
id: "slack",
|
|
43
44
|
name: "Slack",
|
|
@@ -60,7 +61,7 @@ export const slack = (options: SlackOptions) => {
|
|
|
60
61
|
code,
|
|
61
62
|
redirectURI,
|
|
62
63
|
options,
|
|
63
|
-
tokenEndpoint
|
|
64
|
+
tokenEndpoint,
|
|
64
65
|
});
|
|
65
66
|
},
|
|
66
67
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -73,7 +74,7 @@ export const slack = (options: SlackOptions) => {
|
|
|
73
74
|
clientKey: options.clientKey,
|
|
74
75
|
clientSecret: options.clientSecret,
|
|
75
76
|
},
|
|
76
|
-
tokenEndpoint
|
|
77
|
+
tokenEndpoint,
|
|
77
78
|
});
|
|
78
79
|
},
|
|
79
80
|
async getUserInfo(token) {
|
|
@@ -20,6 +20,7 @@ export interface SpotifyOptions extends ProviderOptions<SpotifyProfile> {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const spotify = (options: SpotifyOptions) => {
|
|
23
|
+
const tokenEndpoint = "https://accounts.spotify.com/api/token";
|
|
23
24
|
return {
|
|
24
25
|
id: "spotify",
|
|
25
26
|
name: "Spotify",
|
|
@@ -43,7 +44,7 @@ export const spotify = (options: SpotifyOptions) => {
|
|
|
43
44
|
codeVerifier,
|
|
44
45
|
redirectURI,
|
|
45
46
|
options,
|
|
46
|
-
tokenEndpoint
|
|
47
|
+
tokenEndpoint,
|
|
47
48
|
});
|
|
48
49
|
},
|
|
49
50
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -56,7 +57,7 @@ export const spotify = (options: SpotifyOptions) => {
|
|
|
56
57
|
clientKey: options.clientKey,
|
|
57
58
|
clientSecret: options.clientSecret,
|
|
58
59
|
},
|
|
59
|
-
tokenEndpoint
|
|
60
|
+
tokenEndpoint,
|
|
60
61
|
});
|
|
61
62
|
},
|
|
62
63
|
async getUserInfo(token) {
|
|
@@ -127,6 +127,7 @@ export interface TiktokOptions extends ProviderOptions {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export const tiktok = (options: TiktokOptions) => {
|
|
130
|
+
const tokenEndpoint = "https://open.tiktokapis.com/v2/oauth/token/";
|
|
130
131
|
return {
|
|
131
132
|
id: "tiktok",
|
|
132
133
|
name: "TikTok",
|
|
@@ -151,7 +152,7 @@ export const tiktok = (options: TiktokOptions) => {
|
|
|
151
152
|
clientKey: options.clientKey,
|
|
152
153
|
clientSecret: options.clientSecret,
|
|
153
154
|
},
|
|
154
|
-
tokenEndpoint
|
|
155
|
+
tokenEndpoint,
|
|
155
156
|
});
|
|
156
157
|
},
|
|
157
158
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -162,7 +163,7 @@ export const tiktok = (options: TiktokOptions) => {
|
|
|
162
163
|
options: {
|
|
163
164
|
clientSecret: options.clientSecret,
|
|
164
165
|
},
|
|
165
|
-
tokenEndpoint
|
|
166
|
+
tokenEndpoint,
|
|
166
167
|
authentication: "post",
|
|
167
168
|
extraParams: {
|
|
168
169
|
client_key: options.clientKey,
|
|
@@ -38,6 +38,7 @@ export interface TwitchOptions extends ProviderOptions<TwitchProfile> {
|
|
|
38
38
|
claims?: string[] | undefined;
|
|
39
39
|
}
|
|
40
40
|
export const twitch = (options: TwitchOptions) => {
|
|
41
|
+
const tokenEndpoint = "https://id.twitch.tv/oauth2/token";
|
|
41
42
|
return {
|
|
42
43
|
id: "twitch",
|
|
43
44
|
name: "Twitch",
|
|
@@ -67,7 +68,7 @@ export const twitch = (options: TwitchOptions) => {
|
|
|
67
68
|
code,
|
|
68
69
|
redirectURI,
|
|
69
70
|
options,
|
|
70
|
-
tokenEndpoint
|
|
71
|
+
tokenEndpoint,
|
|
71
72
|
});
|
|
72
73
|
},
|
|
73
74
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -80,7 +81,7 @@ export const twitch = (options: TwitchOptions) => {
|
|
|
80
81
|
clientKey: options.clientKey,
|
|
81
82
|
clientSecret: options.clientSecret,
|
|
82
83
|
},
|
|
83
|
-
tokenEndpoint
|
|
84
|
+
tokenEndpoint,
|
|
84
85
|
});
|
|
85
86
|
},
|
|
86
87
|
async getUserInfo(token) {
|
|
@@ -104,6 +104,7 @@ export interface TwitterOption extends ProviderOptions<TwitterProfile> {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export const twitter = (options: TwitterOption) => {
|
|
107
|
+
const tokenEndpoint = "https://api.x.com/2/oauth2/token";
|
|
107
108
|
return {
|
|
108
109
|
id: "twitter",
|
|
109
110
|
name: "Twitter",
|
|
@@ -130,7 +131,7 @@ export const twitter = (options: TwitterOption) => {
|
|
|
130
131
|
authentication: "basic",
|
|
131
132
|
redirectURI,
|
|
132
133
|
options,
|
|
133
|
-
tokenEndpoint
|
|
134
|
+
tokenEndpoint,
|
|
134
135
|
});
|
|
135
136
|
},
|
|
136
137
|
|
|
@@ -145,7 +146,7 @@ export const twitter = (options: TwitterOption) => {
|
|
|
145
146
|
clientSecret: options.clientSecret,
|
|
146
147
|
},
|
|
147
148
|
authentication: "basic",
|
|
148
|
-
tokenEndpoint
|
|
149
|
+
tokenEndpoint,
|
|
149
150
|
});
|
|
150
151
|
},
|
|
151
152
|
async getUserInfo(token) {
|
|
@@ -26,6 +26,7 @@ export interface VkOption extends ProviderOptions {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const vk = (options: VkOption) => {
|
|
29
|
+
const tokenEndpoint = "https://id.vk.com/oauth2/auth";
|
|
29
30
|
return {
|
|
30
31
|
id: "vk",
|
|
31
32
|
name: "VK",
|
|
@@ -57,7 +58,7 @@ export const vk = (options: VkOption) => {
|
|
|
57
58
|
redirectURI: options.redirectURI || redirectURI,
|
|
58
59
|
options,
|
|
59
60
|
deviceId,
|
|
60
|
-
tokenEndpoint
|
|
61
|
+
tokenEndpoint,
|
|
61
62
|
});
|
|
62
63
|
},
|
|
63
64
|
refreshAccessToken: options.refreshAccessToken
|
|
@@ -70,7 +71,7 @@ export const vk = (options: VkOption) => {
|
|
|
70
71
|
clientKey: options.clientKey,
|
|
71
72
|
clientSecret: options.clientSecret,
|
|
72
73
|
},
|
|
73
|
-
tokenEndpoint
|
|
74
|
+
tokenEndpoint,
|
|
74
75
|
});
|
|
75
76
|
},
|
|
76
77
|
async getUserInfo(data) {
|