@ereo/auth 0.1.29 → 0.1.31
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/auth.d.ts.map +1 -1
- package/dist/index.js +45 -20
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +39 -20
- package/package.json +3 -3
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAmC,MAAM,YAAY,CAAC;AAMnG,6CAA6C;AAC7C,MAAM,WAAW,IAAI;IACnB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,uBAAuB;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAwB;AACxB,MAAM,WAAW,OAAO;IACtB,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,yBAAyB;IACzB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,IAAI,CAAC;IA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H,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC7B,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAcjG;AAMD;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAeR;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3D,OAAO,CAAC,OAAO,CAAC,CAwBlB"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/providers/index.ts
|
|
3
|
+
var DEFAULT_TIMEOUT = 1e4;
|
|
4
|
+
async function fetchWithTimeout(url, init = {}, timeoutMs = DEFAULT_TIMEOUT) {
|
|
5
|
+
const controller = new AbortController;
|
|
6
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
7
|
+
try {
|
|
8
|
+
return await fetch(url, { ...init, signal: controller.signal });
|
|
9
|
+
} catch (error) {
|
|
10
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
11
|
+
throw new Error(`OAuth request to ${url} timed out after ${timeoutMs}ms`);
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
} finally {
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
3
18
|
function credentials(config) {
|
|
4
19
|
return {
|
|
5
20
|
id: config.id || "credentials",
|
|
@@ -9,6 +24,7 @@ function credentials(config) {
|
|
|
9
24
|
};
|
|
10
25
|
}
|
|
11
26
|
function github(config) {
|
|
27
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
12
28
|
const baseUrl = config.enterprise?.baseUrl || "https://github.com";
|
|
13
29
|
const apiBaseUrl = config.enterprise?.baseUrl ? `${config.enterprise.baseUrl}/api/v3` : "https://api.github.com";
|
|
14
30
|
const authorizationUrl = config.authorizationUrl || `${baseUrl}/login/oauth/authorize`;
|
|
@@ -26,7 +42,7 @@ function github(config) {
|
|
|
26
42
|
const code = credentials2.code;
|
|
27
43
|
if (!code)
|
|
28
44
|
return null;
|
|
29
|
-
const tokenResponse = await
|
|
45
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
30
46
|
method: "POST",
|
|
31
47
|
headers: {
|
|
32
48
|
Accept: "application/json",
|
|
@@ -42,7 +58,7 @@ function github(config) {
|
|
|
42
58
|
const tokenData = await tokenResponse.json();
|
|
43
59
|
if (!tokenData.access_token)
|
|
44
60
|
return null;
|
|
45
|
-
const userResponse = await
|
|
61
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
46
62
|
headers: {
|
|
47
63
|
Authorization: `token ${tokenData.access_token}`,
|
|
48
64
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -52,7 +68,7 @@ function github(config) {
|
|
|
52
68
|
const user = await userResponse.json();
|
|
53
69
|
let email = user.email;
|
|
54
70
|
if (!email) {
|
|
55
|
-
const emailsResponse = await
|
|
71
|
+
const emailsResponse = await oauthFetch(`${apiBaseUrl}/user/emails`, {
|
|
56
72
|
headers: {
|
|
57
73
|
Authorization: `token ${tokenData.access_token}`,
|
|
58
74
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -82,7 +98,7 @@ function github(config) {
|
|
|
82
98
|
},
|
|
83
99
|
async handleCallback(params) {
|
|
84
100
|
const { code, redirectUri } = params;
|
|
85
|
-
const tokenResponse = await
|
|
101
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
86
102
|
method: "POST",
|
|
87
103
|
headers: {
|
|
88
104
|
Accept: "application/json",
|
|
@@ -98,7 +114,7 @@ function github(config) {
|
|
|
98
114
|
const tokenData = await tokenResponse.json();
|
|
99
115
|
if (!tokenData.access_token)
|
|
100
116
|
return null;
|
|
101
|
-
const userResponse = await
|
|
117
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
102
118
|
headers: {
|
|
103
119
|
Authorization: `token ${tokenData.access_token}`,
|
|
104
120
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -108,7 +124,7 @@ function github(config) {
|
|
|
108
124
|
const user = await userResponse.json();
|
|
109
125
|
let email = user.email;
|
|
110
126
|
if (!email) {
|
|
111
|
-
const emailsResponse = await
|
|
127
|
+
const emailsResponse = await oauthFetch(`${apiBaseUrl}/user/emails`, {
|
|
112
128
|
headers: {
|
|
113
129
|
Authorization: `token ${tokenData.access_token}`,
|
|
114
130
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -130,6 +146,7 @@ function github(config) {
|
|
|
130
146
|
};
|
|
131
147
|
}
|
|
132
148
|
function google(config) {
|
|
149
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
133
150
|
const authorizationUrl = config.authorizationUrl || "https://accounts.google.com/o/oauth2/v2/auth";
|
|
134
151
|
const tokenUrl = config.tokenUrl || "https://oauth2.googleapis.com/token";
|
|
135
152
|
const userInfoUrl = config.userInfoUrl || "https://www.googleapis.com/oauth2/v2/userinfo";
|
|
@@ -145,7 +162,7 @@ function google(config) {
|
|
|
145
162
|
const code = credentials2.code;
|
|
146
163
|
if (!code)
|
|
147
164
|
return null;
|
|
148
|
-
const tokenResponse = await
|
|
165
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
149
166
|
method: "POST",
|
|
150
167
|
headers: {
|
|
151
168
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -161,7 +178,7 @@ function google(config) {
|
|
|
161
178
|
const tokenData = await tokenResponse.json();
|
|
162
179
|
if (!tokenData.access_token)
|
|
163
180
|
return null;
|
|
164
|
-
const userResponse = await
|
|
181
|
+
const userResponse = await oauthFetch(`${userInfoUrl}?access_token=${tokenData.access_token}`);
|
|
165
182
|
const user = await userResponse.json();
|
|
166
183
|
if (config.hostedDomain && user.hd !== config.hostedDomain) {
|
|
167
184
|
return null;
|
|
@@ -191,7 +208,7 @@ function google(config) {
|
|
|
191
208
|
},
|
|
192
209
|
async handleCallback(params) {
|
|
193
210
|
const { code, redirectUri } = params;
|
|
194
|
-
const tokenResponse = await
|
|
211
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
195
212
|
method: "POST",
|
|
196
213
|
headers: {
|
|
197
214
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -207,7 +224,7 @@ function google(config) {
|
|
|
207
224
|
const tokenData = await tokenResponse.json();
|
|
208
225
|
if (!tokenData.access_token)
|
|
209
226
|
return null;
|
|
210
|
-
const userResponse = await
|
|
227
|
+
const userResponse = await oauthFetch(`${userInfoUrl}?access_token=${tokenData.access_token}`);
|
|
211
228
|
const user = await userResponse.json();
|
|
212
229
|
if (config.hostedDomain && user.hd !== config.hostedDomain) {
|
|
213
230
|
return null;
|
|
@@ -223,6 +240,7 @@ function google(config) {
|
|
|
223
240
|
};
|
|
224
241
|
}
|
|
225
242
|
function discord(config) {
|
|
243
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
226
244
|
const authorizationUrl = config.authorizationUrl || "https://discord.com/api/oauth2/authorize";
|
|
227
245
|
const tokenUrl = config.tokenUrl || "https://discord.com/api/oauth2/token";
|
|
228
246
|
const userInfoUrl = config.userInfoUrl || "https://discord.com/api/users/@me";
|
|
@@ -238,7 +256,7 @@ function discord(config) {
|
|
|
238
256
|
const code = credentials2.code;
|
|
239
257
|
if (!code)
|
|
240
258
|
return null;
|
|
241
|
-
const tokenResponse = await
|
|
259
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
242
260
|
method: "POST",
|
|
243
261
|
headers: {
|
|
244
262
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -254,14 +272,14 @@ function discord(config) {
|
|
|
254
272
|
const tokenData = await tokenResponse.json();
|
|
255
273
|
if (!tokenData.access_token)
|
|
256
274
|
return null;
|
|
257
|
-
const userResponse = await
|
|
275
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
258
276
|
headers: {
|
|
259
277
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
260
278
|
}
|
|
261
279
|
});
|
|
262
280
|
const user = await userResponse.json();
|
|
263
281
|
if (config.guildId) {
|
|
264
|
-
const guildsResponse = await
|
|
282
|
+
const guildsResponse = await oauthFetch("https://discord.com/api/users/@me/guilds", {
|
|
265
283
|
headers: {
|
|
266
284
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
267
285
|
}
|
|
@@ -292,7 +310,7 @@ function discord(config) {
|
|
|
292
310
|
},
|
|
293
311
|
async handleCallback(params) {
|
|
294
312
|
const { code, redirectUri } = params;
|
|
295
|
-
const tokenResponse = await
|
|
313
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
296
314
|
method: "POST",
|
|
297
315
|
headers: {
|
|
298
316
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -308,14 +326,14 @@ function discord(config) {
|
|
|
308
326
|
const tokenData = await tokenResponse.json();
|
|
309
327
|
if (!tokenData.access_token)
|
|
310
328
|
return null;
|
|
311
|
-
const userResponse = await
|
|
329
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
312
330
|
headers: {
|
|
313
331
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
314
332
|
}
|
|
315
333
|
});
|
|
316
334
|
const user = await userResponse.json();
|
|
317
335
|
if (config.guildId) {
|
|
318
|
-
const guildsResponse = await
|
|
336
|
+
const guildsResponse = await oauthFetch("https://discord.com/api/users/@me/guilds", {
|
|
319
337
|
headers: {
|
|
320
338
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
321
339
|
}
|
|
@@ -337,6 +355,7 @@ function discord(config) {
|
|
|
337
355
|
};
|
|
338
356
|
}
|
|
339
357
|
function oauth(config) {
|
|
358
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
340
359
|
const scope = config.scope || [];
|
|
341
360
|
return {
|
|
342
361
|
id: config.id,
|
|
@@ -349,7 +368,7 @@ function oauth(config) {
|
|
|
349
368
|
const code = credentials2.code;
|
|
350
369
|
if (!code || !config.tokenUrl)
|
|
351
370
|
return null;
|
|
352
|
-
const tokenResponse = await
|
|
371
|
+
const tokenResponse = await oauthFetch(config.tokenUrl, {
|
|
353
372
|
method: "POST",
|
|
354
373
|
headers: {
|
|
355
374
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -369,7 +388,7 @@ function oauth(config) {
|
|
|
369
388
|
if (!userInfoUrl) {
|
|
370
389
|
return null;
|
|
371
390
|
}
|
|
372
|
-
const userResponse = await
|
|
391
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
373
392
|
headers: {
|
|
374
393
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
375
394
|
}
|
|
@@ -404,7 +423,7 @@ function oauth(config) {
|
|
|
404
423
|
if (!config.tokenUrl) {
|
|
405
424
|
throw new Error(`Token URL not configured for provider: ${config.id}`);
|
|
406
425
|
}
|
|
407
|
-
const tokenResponse = await
|
|
426
|
+
const tokenResponse = await oauthFetch(config.tokenUrl, {
|
|
408
427
|
method: "POST",
|
|
409
428
|
headers: {
|
|
410
429
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -424,7 +443,7 @@ function oauth(config) {
|
|
|
424
443
|
if (!userInfoUrl) {
|
|
425
444
|
return null;
|
|
426
445
|
}
|
|
427
|
-
const userResponse = await
|
|
446
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
428
447
|
headers: {
|
|
429
448
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
430
449
|
}
|
|
@@ -992,6 +1011,7 @@ function getOAuthUrl(context, providerId, redirectUri) {
|
|
|
992
1011
|
throw new Error(`OAuth provider not found or not configured: ${providerId}`);
|
|
993
1012
|
}
|
|
994
1013
|
const state = base64UrlEncode(crypto.getRandomValues(new Uint8Array(32)));
|
|
1014
|
+
context.set("__oauth_state", state);
|
|
995
1015
|
return provider.getAuthorizationUrl(state, redirectUri);
|
|
996
1016
|
}
|
|
997
1017
|
async function handleOAuthCallback(context, providerId, params) {
|
|
@@ -1001,6 +1021,11 @@ async function handleOAuthCallback(context, providerId, params) {
|
|
|
1001
1021
|
if (!provider || provider.type !== "oauth" || !provider.handleCallback) {
|
|
1002
1022
|
throw new Error(`OAuth provider not found or not configured: ${providerId}`);
|
|
1003
1023
|
}
|
|
1024
|
+
const storedState = context.get("__oauth_state");
|
|
1025
|
+
if (!storedState || storedState !== params.state) {
|
|
1026
|
+
throw new Error("OAuth state mismatch: possible CSRF attack");
|
|
1027
|
+
}
|
|
1028
|
+
context.set("__oauth_state", undefined);
|
|
1004
1029
|
const user = await provider.handleCallback(params);
|
|
1005
1030
|
if (!user) {
|
|
1006
1031
|
throw new Error("OAuth authentication failed");
|
|
@@ -29,6 +29,8 @@ export interface OAuthConfig {
|
|
|
29
29
|
tokenUrl?: string;
|
|
30
30
|
/** User info URL */
|
|
31
31
|
userInfoUrl?: string;
|
|
32
|
+
/** Timeout in milliseconds for OAuth HTTP requests (default: 10000) */
|
|
33
|
+
timeout?: number;
|
|
32
34
|
}
|
|
33
35
|
/** GitHub OAuth configuration */
|
|
34
36
|
export interface GitHubConfig extends OAuthConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CAoCtD;AAMD,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACnD,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAazD"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/providers/index.ts
|
|
3
|
+
var DEFAULT_TIMEOUT = 1e4;
|
|
4
|
+
async function fetchWithTimeout(url, init = {}, timeoutMs = DEFAULT_TIMEOUT) {
|
|
5
|
+
const controller = new AbortController;
|
|
6
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
7
|
+
try {
|
|
8
|
+
return await fetch(url, { ...init, signal: controller.signal });
|
|
9
|
+
} catch (error) {
|
|
10
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
11
|
+
throw new Error(`OAuth request to ${url} timed out after ${timeoutMs}ms`);
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
} finally {
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
3
18
|
function credentials(config) {
|
|
4
19
|
return {
|
|
5
20
|
id: config.id || "credentials",
|
|
@@ -9,6 +24,7 @@ function credentials(config) {
|
|
|
9
24
|
};
|
|
10
25
|
}
|
|
11
26
|
function github(config) {
|
|
27
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
12
28
|
const baseUrl = config.enterprise?.baseUrl || "https://github.com";
|
|
13
29
|
const apiBaseUrl = config.enterprise?.baseUrl ? `${config.enterprise.baseUrl}/api/v3` : "https://api.github.com";
|
|
14
30
|
const authorizationUrl = config.authorizationUrl || `${baseUrl}/login/oauth/authorize`;
|
|
@@ -26,7 +42,7 @@ function github(config) {
|
|
|
26
42
|
const code = credentials2.code;
|
|
27
43
|
if (!code)
|
|
28
44
|
return null;
|
|
29
|
-
const tokenResponse = await
|
|
45
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
30
46
|
method: "POST",
|
|
31
47
|
headers: {
|
|
32
48
|
Accept: "application/json",
|
|
@@ -42,7 +58,7 @@ function github(config) {
|
|
|
42
58
|
const tokenData = await tokenResponse.json();
|
|
43
59
|
if (!tokenData.access_token)
|
|
44
60
|
return null;
|
|
45
|
-
const userResponse = await
|
|
61
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
46
62
|
headers: {
|
|
47
63
|
Authorization: `token ${tokenData.access_token}`,
|
|
48
64
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -52,7 +68,7 @@ function github(config) {
|
|
|
52
68
|
const user = await userResponse.json();
|
|
53
69
|
let email = user.email;
|
|
54
70
|
if (!email) {
|
|
55
|
-
const emailsResponse = await
|
|
71
|
+
const emailsResponse = await oauthFetch(`${apiBaseUrl}/user/emails`, {
|
|
56
72
|
headers: {
|
|
57
73
|
Authorization: `token ${tokenData.access_token}`,
|
|
58
74
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -82,7 +98,7 @@ function github(config) {
|
|
|
82
98
|
},
|
|
83
99
|
async handleCallback(params) {
|
|
84
100
|
const { code, redirectUri } = params;
|
|
85
|
-
const tokenResponse = await
|
|
101
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
86
102
|
method: "POST",
|
|
87
103
|
headers: {
|
|
88
104
|
Accept: "application/json",
|
|
@@ -98,7 +114,7 @@ function github(config) {
|
|
|
98
114
|
const tokenData = await tokenResponse.json();
|
|
99
115
|
if (!tokenData.access_token)
|
|
100
116
|
return null;
|
|
101
|
-
const userResponse = await
|
|
117
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
102
118
|
headers: {
|
|
103
119
|
Authorization: `token ${tokenData.access_token}`,
|
|
104
120
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -108,7 +124,7 @@ function github(config) {
|
|
|
108
124
|
const user = await userResponse.json();
|
|
109
125
|
let email = user.email;
|
|
110
126
|
if (!email) {
|
|
111
|
-
const emailsResponse = await
|
|
127
|
+
const emailsResponse = await oauthFetch(`${apiBaseUrl}/user/emails`, {
|
|
112
128
|
headers: {
|
|
113
129
|
Authorization: `token ${tokenData.access_token}`,
|
|
114
130
|
"User-Agent": "EreoJS-Auth",
|
|
@@ -130,6 +146,7 @@ function github(config) {
|
|
|
130
146
|
};
|
|
131
147
|
}
|
|
132
148
|
function google(config) {
|
|
149
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
133
150
|
const authorizationUrl = config.authorizationUrl || "https://accounts.google.com/o/oauth2/v2/auth";
|
|
134
151
|
const tokenUrl = config.tokenUrl || "https://oauth2.googleapis.com/token";
|
|
135
152
|
const userInfoUrl = config.userInfoUrl || "https://www.googleapis.com/oauth2/v2/userinfo";
|
|
@@ -145,7 +162,7 @@ function google(config) {
|
|
|
145
162
|
const code = credentials2.code;
|
|
146
163
|
if (!code)
|
|
147
164
|
return null;
|
|
148
|
-
const tokenResponse = await
|
|
165
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
149
166
|
method: "POST",
|
|
150
167
|
headers: {
|
|
151
168
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -161,7 +178,7 @@ function google(config) {
|
|
|
161
178
|
const tokenData = await tokenResponse.json();
|
|
162
179
|
if (!tokenData.access_token)
|
|
163
180
|
return null;
|
|
164
|
-
const userResponse = await
|
|
181
|
+
const userResponse = await oauthFetch(`${userInfoUrl}?access_token=${tokenData.access_token}`);
|
|
165
182
|
const user = await userResponse.json();
|
|
166
183
|
if (config.hostedDomain && user.hd !== config.hostedDomain) {
|
|
167
184
|
return null;
|
|
@@ -191,7 +208,7 @@ function google(config) {
|
|
|
191
208
|
},
|
|
192
209
|
async handleCallback(params) {
|
|
193
210
|
const { code, redirectUri } = params;
|
|
194
|
-
const tokenResponse = await
|
|
211
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
195
212
|
method: "POST",
|
|
196
213
|
headers: {
|
|
197
214
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -207,7 +224,7 @@ function google(config) {
|
|
|
207
224
|
const tokenData = await tokenResponse.json();
|
|
208
225
|
if (!tokenData.access_token)
|
|
209
226
|
return null;
|
|
210
|
-
const userResponse = await
|
|
227
|
+
const userResponse = await oauthFetch(`${userInfoUrl}?access_token=${tokenData.access_token}`);
|
|
211
228
|
const user = await userResponse.json();
|
|
212
229
|
if (config.hostedDomain && user.hd !== config.hostedDomain) {
|
|
213
230
|
return null;
|
|
@@ -223,6 +240,7 @@ function google(config) {
|
|
|
223
240
|
};
|
|
224
241
|
}
|
|
225
242
|
function discord(config) {
|
|
243
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
226
244
|
const authorizationUrl = config.authorizationUrl || "https://discord.com/api/oauth2/authorize";
|
|
227
245
|
const tokenUrl = config.tokenUrl || "https://discord.com/api/oauth2/token";
|
|
228
246
|
const userInfoUrl = config.userInfoUrl || "https://discord.com/api/users/@me";
|
|
@@ -238,7 +256,7 @@ function discord(config) {
|
|
|
238
256
|
const code = credentials2.code;
|
|
239
257
|
if (!code)
|
|
240
258
|
return null;
|
|
241
|
-
const tokenResponse = await
|
|
259
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
242
260
|
method: "POST",
|
|
243
261
|
headers: {
|
|
244
262
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -254,14 +272,14 @@ function discord(config) {
|
|
|
254
272
|
const tokenData = await tokenResponse.json();
|
|
255
273
|
if (!tokenData.access_token)
|
|
256
274
|
return null;
|
|
257
|
-
const userResponse = await
|
|
275
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
258
276
|
headers: {
|
|
259
277
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
260
278
|
}
|
|
261
279
|
});
|
|
262
280
|
const user = await userResponse.json();
|
|
263
281
|
if (config.guildId) {
|
|
264
|
-
const guildsResponse = await
|
|
282
|
+
const guildsResponse = await oauthFetch("https://discord.com/api/users/@me/guilds", {
|
|
265
283
|
headers: {
|
|
266
284
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
267
285
|
}
|
|
@@ -292,7 +310,7 @@ function discord(config) {
|
|
|
292
310
|
},
|
|
293
311
|
async handleCallback(params) {
|
|
294
312
|
const { code, redirectUri } = params;
|
|
295
|
-
const tokenResponse = await
|
|
313
|
+
const tokenResponse = await oauthFetch(tokenUrl, {
|
|
296
314
|
method: "POST",
|
|
297
315
|
headers: {
|
|
298
316
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -308,14 +326,14 @@ function discord(config) {
|
|
|
308
326
|
const tokenData = await tokenResponse.json();
|
|
309
327
|
if (!tokenData.access_token)
|
|
310
328
|
return null;
|
|
311
|
-
const userResponse = await
|
|
329
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
312
330
|
headers: {
|
|
313
331
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
314
332
|
}
|
|
315
333
|
});
|
|
316
334
|
const user = await userResponse.json();
|
|
317
335
|
if (config.guildId) {
|
|
318
|
-
const guildsResponse = await
|
|
336
|
+
const guildsResponse = await oauthFetch("https://discord.com/api/users/@me/guilds", {
|
|
319
337
|
headers: {
|
|
320
338
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
321
339
|
}
|
|
@@ -337,6 +355,7 @@ function discord(config) {
|
|
|
337
355
|
};
|
|
338
356
|
}
|
|
339
357
|
function oauth(config) {
|
|
358
|
+
const oauthFetch = (url, init) => fetchWithTimeout(url, init, config.timeout);
|
|
340
359
|
const scope = config.scope || [];
|
|
341
360
|
return {
|
|
342
361
|
id: config.id,
|
|
@@ -349,7 +368,7 @@ function oauth(config) {
|
|
|
349
368
|
const code = credentials2.code;
|
|
350
369
|
if (!code || !config.tokenUrl)
|
|
351
370
|
return null;
|
|
352
|
-
const tokenResponse = await
|
|
371
|
+
const tokenResponse = await oauthFetch(config.tokenUrl, {
|
|
353
372
|
method: "POST",
|
|
354
373
|
headers: {
|
|
355
374
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -369,7 +388,7 @@ function oauth(config) {
|
|
|
369
388
|
if (!userInfoUrl) {
|
|
370
389
|
return null;
|
|
371
390
|
}
|
|
372
|
-
const userResponse = await
|
|
391
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
373
392
|
headers: {
|
|
374
393
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
375
394
|
}
|
|
@@ -404,7 +423,7 @@ function oauth(config) {
|
|
|
404
423
|
if (!config.tokenUrl) {
|
|
405
424
|
throw new Error(`Token URL not configured for provider: ${config.id}`);
|
|
406
425
|
}
|
|
407
|
-
const tokenResponse = await
|
|
426
|
+
const tokenResponse = await oauthFetch(config.tokenUrl, {
|
|
408
427
|
method: "POST",
|
|
409
428
|
headers: {
|
|
410
429
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -424,7 +443,7 @@ function oauth(config) {
|
|
|
424
443
|
if (!userInfoUrl) {
|
|
425
444
|
return null;
|
|
426
445
|
}
|
|
427
|
-
const userResponse = await
|
|
446
|
+
const userResponse = await oauthFetch(userInfoUrl, {
|
|
428
447
|
headers: {
|
|
429
448
|
Authorization: `Bearer ${tokenData.access_token}`
|
|
430
449
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ereo/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Ereo Team",
|
|
6
6
|
"homepage": "https://ereo.dev",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ereo/core": "^0.1.
|
|
41
|
-
"@ereo/router": "^0.1.
|
|
40
|
+
"@ereo/core": "^0.1.31",
|
|
41
|
+
"@ereo/router": "^0.1.31"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/bun": "^1.1.0",
|