antarctic 0.4.0 → 0.6.0
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 +20 -0
- package/dist/auth.js +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/providers/42.d.ts +3 -3
- package/dist/providers/42.js +9 -6
- package/dist/providers/amazon-cognito.d.ts +3 -3
- package/dist/providers/amazon-cognito.js +9 -6
- package/dist/providers/anilist.d.ts +3 -3
- package/dist/providers/anilist.js +9 -6
- package/dist/providers/apple.d.ts +3 -3
- package/dist/providers/apple.js +9 -6
- package/dist/providers/atlassian.d.ts +3 -3
- package/dist/providers/atlassian.js +9 -6
- package/dist/providers/auth0.d.ts +3 -3
- package/dist/providers/auth0.js +9 -6
- package/dist/providers/authentik.d.ts +3 -3
- package/dist/providers/authentik.js +9 -6
- package/dist/providers/autodesk.d.ts +3 -3
- package/dist/providers/autodesk.js +9 -6
- package/dist/providers/battlenet.d.ts +3 -3
- package/dist/providers/battlenet.js +9 -6
- package/dist/providers/bitbucket.d.ts +3 -3
- package/dist/providers/bitbucket.js +9 -6
- package/dist/providers/box.d.ts +3 -3
- package/dist/providers/box.js +9 -6
- package/dist/providers/bungie.d.ts +3 -3
- package/dist/providers/bungie.js +9 -6
- package/dist/providers/coinbase.d.ts +3 -3
- package/dist/providers/coinbase.js +9 -6
- package/dist/providers/discord.d.ts +3 -3
- package/dist/providers/discord.js +9 -6
- package/dist/providers/donation-alerts.d.ts +3 -3
- package/dist/providers/donation-alerts.js +9 -6
- package/dist/providers/dribbble.d.ts +3 -3
- package/dist/providers/dribbble.js +9 -6
- package/dist/providers/dropbox.d.ts +3 -3
- package/dist/providers/dropbox.js +9 -6
- package/dist/providers/epicgames.d.ts +3 -3
- package/dist/providers/epicgames.js +9 -6
- package/dist/providers/etsy.d.ts +3 -3
- package/dist/providers/etsy.js +9 -6
- package/dist/providers/facebook.d.ts +3 -3
- package/dist/providers/facebook.js +9 -6
- package/dist/providers/figma.d.ts +3 -3
- package/dist/providers/figma.js +9 -6
- package/dist/providers/gitea.d.ts +3 -3
- package/dist/providers/gitea.js +9 -6
- package/dist/providers/github.d.ts +3 -3
- package/dist/providers/github.js +9 -6
- package/dist/providers/gitlab.d.ts +3 -3
- package/dist/providers/gitlab.js +9 -6
- package/dist/providers/google.d.ts +3 -3
- package/dist/providers/google.js +9 -6
- package/dist/providers/intuit.d.ts +3 -3
- package/dist/providers/intuit.js +9 -6
- package/dist/providers/kakao.d.ts +3 -3
- package/dist/providers/kakao.js +9 -6
- package/dist/providers/keycloak.d.ts +3 -3
- package/dist/providers/keycloak.js +9 -6
- package/dist/providers/kick.d.ts +3 -3
- package/dist/providers/kick.js +9 -6
- package/dist/providers/lichess.d.ts +3 -3
- package/dist/providers/lichess.js +9 -6
- package/dist/providers/line.d.ts +3 -3
- package/dist/providers/line.js +9 -6
- package/dist/providers/linear.d.ts +3 -3
- package/dist/providers/linear.js +9 -6
- package/dist/providers/linkedin.d.ts +3 -3
- package/dist/providers/linkedin.js +9 -6
- package/dist/providers/mastodon.d.ts +3 -3
- package/dist/providers/mastodon.js +9 -6
- package/dist/providers/mercadolibre.d.ts +3 -3
- package/dist/providers/mercadolibre.js +9 -6
- package/dist/providers/mercadopago.d.ts +3 -3
- package/dist/providers/mercadopago.js +9 -6
- package/dist/providers/microsoft-entra-id.d.ts +3 -3
- package/dist/providers/microsoft-entra-id.js +9 -6
- package/dist/providers/myanimelist.d.ts +3 -3
- package/dist/providers/myanimelist.js +9 -6
- package/dist/providers/naver.d.ts +3 -3
- package/dist/providers/naver.js +9 -6
- package/dist/providers/notion.d.ts +3 -3
- package/dist/providers/notion.js +9 -6
- package/dist/providers/okta.d.ts +3 -3
- package/dist/providers/okta.js +9 -6
- package/dist/providers/osu.d.ts +3 -3
- package/dist/providers/osu.js +9 -6
- package/dist/providers/patreon.d.ts +3 -3
- package/dist/providers/patreon.js +9 -6
- package/dist/providers/polar.d.ts +3 -3
- package/dist/providers/polar.js +9 -6
- package/dist/providers/reddit.d.ts +3 -3
- package/dist/providers/reddit.js +9 -6
- package/dist/providers/roblox.d.ts +3 -3
- package/dist/providers/roblox.js +9 -6
- package/dist/providers/salesforce.d.ts +3 -3
- package/dist/providers/salesforce.js +9 -6
- package/dist/providers/shikimori.d.ts +3 -3
- package/dist/providers/shikimori.js +9 -6
- package/dist/providers/slack.d.ts +3 -3
- package/dist/providers/slack.js +9 -6
- package/dist/providers/spotify.d.ts +3 -3
- package/dist/providers/spotify.js +9 -6
- package/dist/providers/startgg.d.ts +3 -3
- package/dist/providers/startgg.js +9 -6
- package/dist/providers/strava.d.ts +3 -3
- package/dist/providers/strava.js +9 -6
- package/dist/providers/tiktok.d.ts +3 -3
- package/dist/providers/tiktok.js +9 -6
- package/dist/providers/tiltify.d.ts +3 -3
- package/dist/providers/tiltify.js +9 -6
- package/dist/providers/tumblr.d.ts +3 -3
- package/dist/providers/tumblr.js +9 -6
- package/dist/providers/twitch.d.ts +3 -3
- package/dist/providers/twitch.js +9 -6
- package/dist/providers/twitter.d.ts +3 -3
- package/dist/providers/twitter.js +9 -6
- package/dist/providers/vk.d.ts +3 -3
- package/dist/providers/vk.js +9 -6
- package/dist/providers/withings.d.ts +3 -3
- package/dist/providers/withings.js +9 -6
- package/dist/providers/workos.d.ts +3 -3
- package/dist/providers/workos.js +9 -6
- package/dist/providers/yahoo.d.ts +3 -3
- package/dist/providers/yahoo.js +9 -6
- package/dist/providers/yandex.d.ts +3 -3
- package/dist/providers/yandex.js +9 -6
- package/dist/providers/zoom.d.ts +3 -3
- package/dist/providers/zoom.js +9 -6
- package/package.json +1 -1
- package/readme.md +12 -2
package/dist/providers/tumblr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://www.tumblr.com/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.tumblr.com/v2/oauth2/token";
|
|
5
5
|
const userEndpoint = "https://api.tumblr.com/v2/user/info";
|
|
@@ -36,13 +36,14 @@ export class Tumblr {
|
|
|
36
36
|
const auth = requireAuthConfig(this.auth);
|
|
37
37
|
const state = generateOAuthState();
|
|
38
38
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const payload = {};
|
|
40
|
+
await saveOAuthState(auth.store, state, payload);
|
|
41
|
+
return { url, state, payload };
|
|
41
42
|
}
|
|
42
|
-
async getUser(query) {
|
|
43
|
+
async getUser(query, saved) {
|
|
43
44
|
const auth = requireAuthConfig(this.auth);
|
|
44
45
|
const { code, state } = parseCallbackQuery(query);
|
|
45
|
-
await
|
|
46
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
46
47
|
const tokens = await this.validateAuthorizationCode(code);
|
|
47
48
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
48
49
|
let user = {};
|
|
@@ -57,7 +58,9 @@ export class Tumblr {
|
|
|
57
58
|
id: profileId(user.name),
|
|
58
59
|
name: profileString(user.name),
|
|
59
60
|
email: null,
|
|
60
|
-
image: null
|
|
61
|
+
image: null,
|
|
62
|
+
raw: user,
|
|
63
|
+
...extractOAuthTokens(tokens)
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
66
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface TwitchOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Twitch {
|
|
@@ -12,6 +12,6 @@ export declare class Twitch {
|
|
|
12
12
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
13
13
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
14
14
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
15
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
16
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
15
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
package/dist/providers/twitch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Does not support HTTP Basic Auth scheme.
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
3
|
-
import {
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://id.twitch.tv/oauth2/authorize";
|
|
5
5
|
const tokenEndpoint = "https://id.twitch.tv/oauth2/token";
|
|
6
6
|
const userEndpoint = "https://api.twitch.tv/helix/users";
|
|
@@ -64,13 +64,14 @@ export class Twitch {
|
|
|
64
64
|
const auth = requireAuthConfig(this.auth);
|
|
65
65
|
const state = generateOAuthState();
|
|
66
66
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const payload = {};
|
|
68
|
+
await saveOAuthState(auth.store, state, payload);
|
|
69
|
+
return { url, state, payload };
|
|
69
70
|
}
|
|
70
|
-
async getUser(query) {
|
|
71
|
+
async getUser(query, saved) {
|
|
71
72
|
const auth = requireAuthConfig(this.auth);
|
|
72
73
|
const { code, state } = parseCallbackQuery(query);
|
|
73
|
-
await
|
|
74
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
74
75
|
const tokens = await this.validateAuthorizationCode(code);
|
|
75
76
|
// Helix requires the Client-Id header alongside the user access token.
|
|
76
77
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken(), {
|
|
@@ -85,7 +86,9 @@ export class Twitch {
|
|
|
85
86
|
id: profileId(user.id),
|
|
86
87
|
name: profileString(user.display_name) ?? profileString(user.login),
|
|
87
88
|
email: profileString(user.email),
|
|
88
|
-
image: profileString(user.profile_image_url)
|
|
89
|
+
image: profileString(user.profile_image_url),
|
|
90
|
+
raw: user,
|
|
91
|
+
...extractOAuthTokens(tokens)
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface TwitterOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Twitter {
|
|
@@ -11,6 +11,6 @@ export declare class Twitter {
|
|
|
11
11
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
revokeToken(token: string): Promise<void>;
|
|
14
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://twitter.com/i/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.twitter.com/2/oauth2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://api.twitter.com/2/oauth2/revoke";
|
|
@@ -38,13 +38,14 @@ export class Twitter {
|
|
|
38
38
|
const state = generateOAuthState();
|
|
39
39
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
40
40
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const payload = { codeVerifier };
|
|
42
|
+
await saveOAuthState(auth.store, state, payload);
|
|
43
|
+
return { url, state, payload };
|
|
43
44
|
}
|
|
44
|
-
async getUser(query) {
|
|
45
|
+
async getUser(query, saved) {
|
|
45
46
|
const auth = requireAuthConfig(this.auth);
|
|
46
47
|
const { code, state } = parseCallbackQuery(query);
|
|
47
|
-
const stored = await
|
|
48
|
+
const stored = await resolveOAuthState(auth.store, state, saved);
|
|
48
49
|
if (typeof stored.codeVerifier !== "string") {
|
|
49
50
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
50
51
|
}
|
|
@@ -61,7 +62,9 @@ export class Twitter {
|
|
|
61
62
|
id: profileId(user.id),
|
|
62
63
|
name: profileString(user.name) ?? profileString(user.username),
|
|
63
64
|
email: null,
|
|
64
|
-
image: profileString(user.profile_image_url)
|
|
65
|
+
image: profileString(user.profile_image_url),
|
|
66
|
+
raw: user,
|
|
67
|
+
...extractOAuthTokens(tokens)
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
}
|
package/dist/providers/vk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface VKOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class VK {
|
|
@@ -11,6 +11,6 @@ export declare class VK {
|
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
13
13
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
14
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
package/dist/providers/vk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://oauth.vk.com/authorize";
|
|
4
4
|
const tokenEndpoint = "https://oauth.vk.com/access_token";
|
|
5
5
|
const userEndpoint = "https://api.vk.com/method/users.get";
|
|
@@ -52,13 +52,14 @@ export class VK {
|
|
|
52
52
|
const auth = requireAuthConfig(this.auth);
|
|
53
53
|
const state = generateOAuthState();
|
|
54
54
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const payload = {};
|
|
56
|
+
await saveOAuthState(auth.store, state, payload);
|
|
57
|
+
return { url, state, payload };
|
|
57
58
|
}
|
|
58
|
-
async getUser(query) {
|
|
59
|
+
async getUser(query, saved) {
|
|
59
60
|
const auth = requireAuthConfig(this.auth);
|
|
60
61
|
const { code, state } = parseCallbackQuery(query);
|
|
61
|
-
await
|
|
62
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
62
63
|
const tokens = await this.validateAuthorizationCode(code);
|
|
63
64
|
const url = new URL(userEndpoint);
|
|
64
65
|
url.searchParams.set("v", "5.199");
|
|
@@ -76,7 +77,9 @@ export class VK {
|
|
|
76
77
|
id: profileId(user.id),
|
|
77
78
|
name: nameParts.length > 0 ? nameParts.join(" ") : null,
|
|
78
79
|
email,
|
|
79
|
-
image: profileString(user.photo_200)
|
|
80
|
+
image: profileString(user.photo_200),
|
|
81
|
+
raw: user,
|
|
82
|
+
...extractOAuthTokens(tokens)
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface WithingsOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Withings {
|
|
@@ -11,6 +11,6 @@ export declare class Withings {
|
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
13
13
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
14
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArcticFetchError, createOAuth2Request, createOAuth2RequestError, UnexpectedErrorResponseBodyError, UnexpectedResponseError } from "../request.js";
|
|
2
2
|
import { OAuth2Tokens } from "../oauth2.js";
|
|
3
|
-
import {
|
|
3
|
+
import { extractOAuthTokens, generateOAuthState, parseCallbackQuery, profileId, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://account.withings.com/oauth2_user/authorize2";
|
|
5
5
|
const tokenEndpoint = "https://wbsapi.withings.net/v2/oauth2";
|
|
6
6
|
const envPrefix = "WITHINGS";
|
|
@@ -55,13 +55,14 @@ export class Withings {
|
|
|
55
55
|
const auth = requireAuthConfig(this.auth);
|
|
56
56
|
const state = generateOAuthState();
|
|
57
57
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const payload = {};
|
|
59
|
+
await saveOAuthState(auth.store, state, payload);
|
|
60
|
+
return { url, state, payload };
|
|
60
61
|
}
|
|
61
|
-
async getUser(query) {
|
|
62
|
+
async getUser(query, saved) {
|
|
62
63
|
const auth = requireAuthConfig(this.auth);
|
|
63
64
|
const { code, state } = parseCallbackQuery(query);
|
|
64
|
-
await
|
|
65
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
65
66
|
const tokens = await this.validateAuthorizationCode(code);
|
|
66
67
|
// Withings has no profile API; the token response only carries the user id.
|
|
67
68
|
const data = tokens.data;
|
|
@@ -69,7 +70,9 @@ export class Withings {
|
|
|
69
70
|
id: profileId(data.userid),
|
|
70
71
|
name: null,
|
|
71
72
|
email: null,
|
|
72
|
-
image: null
|
|
73
|
+
image: null,
|
|
74
|
+
raw: data,
|
|
75
|
+
...extractOAuthTokens(tokens)
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface WorkOSOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class WorkOS {
|
|
@@ -11,6 +11,6 @@ export declare class WorkOS {
|
|
|
11
11
|
constructor(clientId: string, clientSecret: string | null, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, codeVerifier: string | null): Promise<URL>;
|
|
13
13
|
validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
|
|
14
|
-
getAuthorizationURL(): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
package/dist/providers/workos.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, saveOAuthState } from "../auth.js";
|
|
3
3
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
4
4
|
const authorizationEndpoint = "https://api.workos.com/sso/authorize";
|
|
5
5
|
const tokenEndpoint = "https://api.workos.com/sso/token";
|
|
@@ -57,13 +57,14 @@ export class WorkOS {
|
|
|
57
57
|
const state = generateOAuthState();
|
|
58
58
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
59
59
|
const url = await this.createAuthorizationURL(state, codeVerifier);
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const payload = { codeVerifier };
|
|
61
|
+
await saveOAuthState(auth.store, state, payload);
|
|
62
|
+
return { url, state, payload };
|
|
62
63
|
}
|
|
63
|
-
async getUser(query) {
|
|
64
|
+
async getUser(query, saved) {
|
|
64
65
|
const auth = requireAuthConfig(this.auth);
|
|
65
66
|
const { code, state } = parseCallbackQuery(query);
|
|
66
|
-
const stored = await
|
|
67
|
+
const stored = await resolveOAuthState(auth.store, state, saved);
|
|
67
68
|
if (typeof stored.codeVerifier !== "string") {
|
|
68
69
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
69
70
|
}
|
|
@@ -76,7 +77,9 @@ export class WorkOS {
|
|
|
76
77
|
id: profileId(profile.id),
|
|
77
78
|
name: profileString(profile.name) ?? (fullName !== "" ? fullName : null),
|
|
78
79
|
email: profileString(profile.email),
|
|
79
|
-
image: profileString(profile.profile_picture_url)
|
|
80
|
+
image: profileString(profile.profile_picture_url),
|
|
81
|
+
raw: profile,
|
|
82
|
+
...extractOAuthTokens(tokens)
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface YahooOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Yahoo {
|
|
@@ -10,6 +10,6 @@ export declare class Yahoo {
|
|
|
10
10
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
14
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
13
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|
package/dist/providers/yahoo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
2
|
import { decodeIdToken } from "../oidc.js";
|
|
3
|
-
import {
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://api.login.yahoo.com/oauth2/request_auth";
|
|
5
5
|
const tokenEndpoint = "https://api.login.yahoo.com/oauth2/get_token";
|
|
6
6
|
const userinfoEndpoint = "https://api.login.yahoo.com/openid/v1/userinfo";
|
|
@@ -37,13 +37,14 @@ export class Yahoo {
|
|
|
37
37
|
const auth = requireAuthConfig(this.auth);
|
|
38
38
|
const state = generateOAuthState();
|
|
39
39
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const payload = {};
|
|
41
|
+
await saveOAuthState(auth.store, state, payload);
|
|
42
|
+
return { url, state, payload };
|
|
42
43
|
}
|
|
43
|
-
async getUser(query) {
|
|
44
|
+
async getUser(query, saved) {
|
|
44
45
|
const auth = requireAuthConfig(this.auth);
|
|
45
46
|
const { code, state } = parseCallbackQuery(query);
|
|
46
|
-
await
|
|
47
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
47
48
|
const tokens = await this.validateAuthorizationCode(code);
|
|
48
49
|
let claims;
|
|
49
50
|
if ("id_token" in tokens.data) {
|
|
@@ -59,7 +60,9 @@ export class Yahoo {
|
|
|
59
60
|
id: profileId(claims.sub),
|
|
60
61
|
name: profileString(claims.name) ?? (fullName !== "" ? fullName : null),
|
|
61
62
|
email: profileString(claims.email),
|
|
62
|
-
image: profileString(claims.picture)
|
|
63
|
+
image: profileString(claims.picture),
|
|
64
|
+
raw: claims,
|
|
65
|
+
...extractOAuthTokens(tokens)
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface YandexOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Yandex {
|
|
@@ -10,6 +10,6 @@ export declare class Yandex {
|
|
|
10
10
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
14
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
13
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|
package/dist/providers/yandex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://oauth.yandex.com/authorize";
|
|
4
4
|
const tokenEndpoint = "https://oauth.yandex.com/token";
|
|
5
5
|
const userEndpoint = "https://login.yandex.ru/info?format=json";
|
|
@@ -36,13 +36,14 @@ export class Yandex {
|
|
|
36
36
|
const auth = requireAuthConfig(this.auth);
|
|
37
37
|
const state = generateOAuthState();
|
|
38
38
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const payload = {};
|
|
40
|
+
await saveOAuthState(auth.store, state, payload);
|
|
41
|
+
return { url, state, payload };
|
|
41
42
|
}
|
|
42
|
-
async getUser(query) {
|
|
43
|
+
async getUser(query, saved) {
|
|
43
44
|
const auth = requireAuthConfig(this.auth);
|
|
44
45
|
const { code, state } = parseCallbackQuery(query);
|
|
45
|
-
await
|
|
46
|
+
await resolveOAuthState(auth.store, state, saved);
|
|
46
47
|
const tokens = await this.validateAuthorizationCode(code);
|
|
47
48
|
const accessToken = tokens.accessToken();
|
|
48
49
|
// Yandex expects the "OAuth" scheme instead of "Bearer".
|
|
@@ -60,7 +61,9 @@ export class Yandex {
|
|
|
60
61
|
profileString(profile.display_name) ??
|
|
61
62
|
profileString(profile.login),
|
|
62
63
|
email: profileString(profile.default_email),
|
|
63
|
-
image
|
|
64
|
+
image,
|
|
65
|
+
raw: profile,
|
|
66
|
+
...extractOAuthTokens(tokens)
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
}
|
package/dist/providers/zoom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface ZoomOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Zoom {
|
|
@@ -11,6 +11,6 @@ export declare class Zoom {
|
|
|
11
11
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
revokeToken(token: string): Promise<void>;
|
|
14
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
package/dist/providers/zoom.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://zoom.us/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://zoom.us/oauth/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://zoom.us/oauth/revoke";
|
|
@@ -41,13 +41,14 @@ export class Zoom {
|
|
|
41
41
|
const state = generateOAuthState();
|
|
42
42
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
43
43
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const payload = { codeVerifier };
|
|
45
|
+
await saveOAuthState(auth.store, state, payload);
|
|
46
|
+
return { url, state, payload };
|
|
46
47
|
}
|
|
47
|
-
async getUser(query) {
|
|
48
|
+
async getUser(query, saved) {
|
|
48
49
|
const auth = requireAuthConfig(this.auth);
|
|
49
50
|
const { code, state } = parseCallbackQuery(query);
|
|
50
|
-
const stored = await
|
|
51
|
+
const stored = await resolveOAuthState(auth.store, state, saved);
|
|
51
52
|
if (typeof stored.codeVerifier !== "string") {
|
|
52
53
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
53
54
|
}
|
|
@@ -60,7 +61,9 @@ export class Zoom {
|
|
|
60
61
|
id: profileId(profile.id),
|
|
61
62
|
name: profileString(profile.display_name) ?? (fullName !== "" ? fullName : null),
|
|
62
63
|
email: profileString(profile.email),
|
|
63
|
-
image: profileString(profile.pic_url)
|
|
64
|
+
image: profileString(profile.pic_url),
|
|
65
|
+
raw: profile,
|
|
66
|
+
...extractOAuthTokens(tokens)
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -22,14 +22,24 @@ const scopes = ["read:user", "user:email"];
|
|
|
22
22
|
const github = new auth.GitHub({ store, scopes });
|
|
23
23
|
|
|
24
24
|
// Redirect the user here to sign in.
|
|
25
|
-
const url = await github.getAuthorizationURL();
|
|
25
|
+
const { url } = await github.getAuthorizationURL();
|
|
26
26
|
|
|
27
27
|
// In the OAuth callback route:
|
|
28
28
|
const user = await github.getUser(request.url);
|
|
29
29
|
// { id: "1", name: "The Octocat", email: "octocat@github.com", image: "https://..." }
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
`
|
|
32
|
+
`getAuthorizationURL()` returns `{ url, state, payload }`. The state and payload are already in the store, so you only need `url` unless you would rather persist them yourself.
|
|
33
|
+
|
|
34
|
+
`getUser()` accepts the callback query as a full URL, a query string, a `URLSearchParams`, or a plain object. It validates the `state`, exchanges the code (with PKCE where the provider supports it), fetches the profile, deletes the consumed state, and returns the user along with the tokens: `{ id, name, email, image, raw, accessToken, refreshToken, scopes }`.
|
|
35
|
+
|
|
36
|
+
Pass the state back as a second argument to skip the store entirely, for example when you keep it in a signed cookie:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const { url, state, payload } = await github.getAuthorizationURL();
|
|
40
|
+
// ...later, in the callback route
|
|
41
|
+
const user = await github.getUser(request.url, { state, payload });
|
|
42
|
+
```
|
|
33
43
|
|
|
34
44
|
Options resolve as `explicit > environment > provider default`. Every option except `store` can come from the environment, named after the provider:
|
|
35
45
|
|