antarctic 0.6.0 → 0.7.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/README.md +252 -0
- package/dist/auth.d.ts +1 -12
- package/dist/auth.js +7 -34
- package/dist/index.d.ts +1 -1
- package/dist/providers/42.d.ts +2 -2
- package/dist/providers/42.js +4 -5
- package/dist/providers/amazon-cognito.d.ts +2 -2
- package/dist/providers/amazon-cognito.js +4 -5
- package/dist/providers/anilist.d.ts +2 -2
- package/dist/providers/anilist.js +5 -6
- package/dist/providers/apple.d.ts +1 -1
- package/dist/providers/apple.js +3 -4
- package/dist/providers/atlassian.d.ts +2 -2
- package/dist/providers/atlassian.js +4 -5
- package/dist/providers/auth0.d.ts +2 -2
- package/dist/providers/auth0.js +4 -5
- package/dist/providers/authentik.d.ts +2 -2
- package/dist/providers/authentik.js +4 -5
- package/dist/providers/autodesk.d.ts +2 -2
- package/dist/providers/autodesk.js +4 -5
- package/dist/providers/battlenet.d.ts +2 -2
- package/dist/providers/battlenet.js +4 -5
- package/dist/providers/bitbucket.d.ts +2 -2
- package/dist/providers/bitbucket.js +5 -6
- package/dist/providers/box.d.ts +2 -2
- package/dist/providers/box.js +4 -5
- package/dist/providers/bungie.d.ts +2 -2
- package/dist/providers/bungie.js +4 -5
- package/dist/providers/coinbase.d.ts +2 -2
- package/dist/providers/coinbase.js +4 -5
- package/dist/providers/discord.d.ts +2 -2
- package/dist/providers/discord.js +4 -5
- package/dist/providers/donation-alerts.d.ts +2 -2
- package/dist/providers/donation-alerts.js +4 -5
- package/dist/providers/dribbble.d.ts +2 -2
- package/dist/providers/dribbble.js +4 -5
- package/dist/providers/dropbox.d.ts +2 -2
- package/dist/providers/dropbox.js +4 -5
- package/dist/providers/epicgames.d.ts +2 -2
- package/dist/providers/epicgames.js +4 -5
- package/dist/providers/etsy.d.ts +2 -2
- package/dist/providers/etsy.js +3 -4
- package/dist/providers/facebook.d.ts +2 -2
- package/dist/providers/facebook.js +4 -5
- package/dist/providers/figma.d.ts +2 -2
- package/dist/providers/figma.js +4 -5
- package/dist/providers/gitea.d.ts +2 -2
- package/dist/providers/gitea.js +4 -5
- package/dist/providers/github.d.ts +2 -2
- package/dist/providers/github.js +4 -5
- package/dist/providers/gitlab.d.ts +2 -2
- package/dist/providers/gitlab.js +4 -5
- package/dist/providers/google.d.ts +2 -2
- package/dist/providers/google.js +4 -5
- package/dist/providers/intuit.d.ts +2 -2
- package/dist/providers/intuit.js +4 -5
- package/dist/providers/kakao.d.ts +2 -2
- package/dist/providers/kakao.js +4 -5
- package/dist/providers/keycloak.d.ts +2 -2
- package/dist/providers/keycloak.js +4 -5
- package/dist/providers/kick.d.ts +2 -2
- package/dist/providers/kick.js +4 -5
- package/dist/providers/lichess.d.ts +2 -2
- package/dist/providers/lichess.js +4 -5
- package/dist/providers/line.d.ts +2 -2
- package/dist/providers/line.js +4 -5
- package/dist/providers/linear.d.ts +2 -2
- package/dist/providers/linear.js +4 -5
- package/dist/providers/linkedin.d.ts +2 -2
- package/dist/providers/linkedin.js +4 -5
- package/dist/providers/mastodon.d.ts +2 -2
- package/dist/providers/mastodon.js +4 -5
- package/dist/providers/mercadolibre.d.ts +2 -2
- package/dist/providers/mercadolibre.js +5 -6
- package/dist/providers/mercadopago.d.ts +2 -2
- package/dist/providers/mercadopago.js +5 -6
- package/dist/providers/microsoft-entra-id.d.ts +2 -2
- package/dist/providers/microsoft-entra-id.js +4 -5
- package/dist/providers/myanimelist.d.ts +2 -2
- package/dist/providers/myanimelist.js +5 -6
- package/dist/providers/naver.d.ts +2 -2
- package/dist/providers/naver.js +5 -6
- package/dist/providers/notion.d.ts +2 -2
- package/dist/providers/notion.js +5 -6
- package/dist/providers/okta.d.ts +2 -2
- package/dist/providers/okta.js +4 -5
- package/dist/providers/osu.d.ts +2 -2
- package/dist/providers/osu.js +4 -5
- package/dist/providers/patreon.d.ts +2 -2
- package/dist/providers/patreon.js +4 -5
- package/dist/providers/polar.d.ts +2 -2
- package/dist/providers/polar.js +4 -5
- package/dist/providers/reddit.d.ts +2 -2
- package/dist/providers/reddit.js +4 -5
- package/dist/providers/roblox.d.ts +2 -2
- package/dist/providers/roblox.js +4 -5
- package/dist/providers/salesforce.d.ts +2 -2
- package/dist/providers/salesforce.js +4 -5
- package/dist/providers/shikimori.d.ts +2 -2
- package/dist/providers/shikimori.js +5 -6
- package/dist/providers/slack.d.ts +2 -2
- package/dist/providers/slack.js +4 -5
- package/dist/providers/spotify.d.ts +2 -2
- package/dist/providers/spotify.js +4 -5
- package/dist/providers/startgg.d.ts +2 -2
- package/dist/providers/startgg.js +3 -4
- package/dist/providers/strava.d.ts +2 -2
- package/dist/providers/strava.js +4 -5
- package/dist/providers/tiktok.d.ts +2 -2
- package/dist/providers/tiktok.js +4 -5
- package/dist/providers/tiltify.d.ts +2 -2
- package/dist/providers/tiltify.js +4 -5
- package/dist/providers/tumblr.d.ts +2 -2
- package/dist/providers/tumblr.js +4 -5
- package/dist/providers/twitch.d.ts +2 -2
- package/dist/providers/twitch.js +4 -5
- package/dist/providers/twitter.d.ts +2 -2
- package/dist/providers/twitter.js +4 -5
- package/dist/providers/vk.d.ts +2 -2
- package/dist/providers/vk.js +4 -5
- package/dist/providers/withings.d.ts +2 -2
- package/dist/providers/withings.js +4 -5
- package/dist/providers/workos.d.ts +2 -2
- package/dist/providers/workos.js +5 -6
- package/dist/providers/yahoo.d.ts +2 -2
- package/dist/providers/yahoo.js +4 -5
- package/dist/providers/yandex.d.ts +2 -2
- package/dist/providers/yandex.js +4 -5
- package/dist/providers/zoom.d.ts +2 -2
- package/dist/providers/zoom.js +4 -5
- package/package.json +2 -1
- package/readme.md +0 -165
|
@@ -5,12 +5,12 @@ export interface TwitterOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Twitter {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: TwitterOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string | null, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
11
11
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
revokeToken(token: string): Promise<void>;
|
|
14
14
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["users.read", "tweet.read"];
|
|
|
9
9
|
export class Twitter {
|
|
10
10
|
client;
|
|
11
11
|
auth = null;
|
|
12
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
12
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
13
13
|
if (typeof clientIdOrOptions === "object") {
|
|
14
14
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, { redirectURI: true });
|
|
15
15
|
this.client = new OAuth2Client(this.auth.clientId, this.auth.clientSecret, this.auth.redirectURI);
|
|
@@ -39,13 +39,12 @@ export class Twitter {
|
|
|
39
39
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
40
40
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
41
41
|
const payload = { codeVerifier };
|
|
42
|
-
await saveOAuthState(auth.store, state, payload);
|
|
43
42
|
return { url, state, payload };
|
|
44
43
|
}
|
|
45
44
|
async getUser(query, saved) {
|
|
46
|
-
|
|
45
|
+
requireAuthConfig(this.auth);
|
|
47
46
|
const { code, state } = parseCallbackQuery(query);
|
|
48
|
-
const stored =
|
|
47
|
+
const stored = resolveOAuthState(state, saved);
|
|
49
48
|
if (typeof stored.codeVerifier !== "string") {
|
|
50
49
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
51
50
|
}
|
package/dist/providers/vk.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export declare class VK {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: VKOptions);
|
|
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
14
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -10,7 +10,7 @@ export class VK {
|
|
|
10
10
|
clientSecret;
|
|
11
11
|
redirectURI;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
13
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
14
14
|
if (typeof clientIdOrOptions === "object") {
|
|
15
15
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
16
16
|
clientSecret: true,
|
|
@@ -53,13 +53,12 @@ export class VK {
|
|
|
53
53
|
const state = generateOAuthState();
|
|
54
54
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
55
55
|
const payload = {};
|
|
56
|
-
await saveOAuthState(auth.store, state, payload);
|
|
57
56
|
return { url, state, payload };
|
|
58
57
|
}
|
|
59
58
|
async getUser(query, saved) {
|
|
60
|
-
|
|
59
|
+
requireAuthConfig(this.auth);
|
|
61
60
|
const { code, state } = parseCallbackQuery(query);
|
|
62
|
-
|
|
61
|
+
resolveOAuthState(state, saved);
|
|
63
62
|
const tokens = await this.validateAuthorizationCode(code);
|
|
64
63
|
const url = new URL(userEndpoint);
|
|
65
64
|
url.searchParams.set("v", "5.199");
|
|
@@ -7,10 +7,10 @@ export declare class Withings {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: WithingsOptions);
|
|
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
14
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, generateOAuthState, parseCallbackQuery, profileId, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, generateOAuthState, parseCallbackQuery, profileId, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -10,7 +10,7 @@ export class Withings {
|
|
|
10
10
|
clientSecret;
|
|
11
11
|
redirectURI;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
13
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
14
14
|
if (typeof clientIdOrOptions === "object") {
|
|
15
15
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
16
16
|
clientSecret: true,
|
|
@@ -56,13 +56,12 @@ export class Withings {
|
|
|
56
56
|
const state = generateOAuthState();
|
|
57
57
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
58
58
|
const payload = {};
|
|
59
|
-
await saveOAuthState(auth.store, state, payload);
|
|
60
59
|
return { url, state, payload };
|
|
61
60
|
}
|
|
62
61
|
async getUser(query, saved) {
|
|
63
|
-
|
|
62
|
+
requireAuthConfig(this.auth);
|
|
64
63
|
const { code, state } = parseCallbackQuery(query);
|
|
65
|
-
|
|
64
|
+
resolveOAuthState(state, saved);
|
|
66
65
|
const tokens = await this.validateAuthorizationCode(code);
|
|
67
66
|
// Withings has no profile API; the token response only carries the user id.
|
|
68
67
|
const data = tokens.data;
|
|
@@ -7,10 +7,10 @@ export declare class WorkOS {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: WorkOSOptions);
|
|
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
14
|
getAuthorizationURL(): Promise<AuthorizationRequest>;
|
|
15
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } 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";
|
|
@@ -10,7 +10,7 @@ export class WorkOS {
|
|
|
10
10
|
clientSecret;
|
|
11
11
|
redirectURI;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
13
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
14
14
|
if (typeof clientIdOrOptions === "object") {
|
|
15
15
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, { redirectURI: true });
|
|
16
16
|
this.clientId = this.auth.clientId;
|
|
@@ -53,18 +53,17 @@ export class WorkOS {
|
|
|
53
53
|
return tokens;
|
|
54
54
|
}
|
|
55
55
|
async getAuthorizationURL() {
|
|
56
|
-
|
|
56
|
+
requireAuthConfig(this.auth);
|
|
57
57
|
const state = generateOAuthState();
|
|
58
58
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
59
59
|
const url = await this.createAuthorizationURL(state, codeVerifier);
|
|
60
60
|
const payload = { codeVerifier };
|
|
61
|
-
await saveOAuthState(auth.store, state, payload);
|
|
62
61
|
return { url, state, payload };
|
|
63
62
|
}
|
|
64
63
|
async getUser(query, saved) {
|
|
65
|
-
|
|
64
|
+
requireAuthConfig(this.auth);
|
|
66
65
|
const { code, state } = parseCallbackQuery(query);
|
|
67
|
-
const stored =
|
|
66
|
+
const stored = resolveOAuthState(state, saved);
|
|
68
67
|
if (typeof stored.codeVerifier !== "string") {
|
|
69
68
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
70
69
|
}
|
|
@@ -5,11 +5,11 @@ export interface YahooOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Yahoo {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: YahooOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["openid", "profile", "email"];
|
|
|
9
9
|
export class Yahoo {
|
|
10
10
|
client;
|
|
11
11
|
auth = null;
|
|
12
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
12
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
13
13
|
if (typeof clientIdOrOptions === "object") {
|
|
14
14
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
15
15
|
clientSecret: true,
|
|
@@ -38,13 +38,12 @@ export class Yahoo {
|
|
|
38
38
|
const state = generateOAuthState();
|
|
39
39
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
40
40
|
const payload = {};
|
|
41
|
-
await saveOAuthState(auth.store, state, payload);
|
|
42
41
|
return { url, state, payload };
|
|
43
42
|
}
|
|
44
43
|
async getUser(query, saved) {
|
|
45
|
-
|
|
44
|
+
requireAuthConfig(this.auth);
|
|
46
45
|
const { code, state } = parseCallbackQuery(query);
|
|
47
|
-
|
|
46
|
+
resolveOAuthState(state, saved);
|
|
48
47
|
const tokens = await this.validateAuthorizationCode(code);
|
|
49
48
|
let claims;
|
|
50
49
|
if ("id_token" in tokens.data) {
|
|
@@ -5,11 +5,11 @@ export interface YandexOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Yandex {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: YandexOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -8,7 +8,7 @@ const defaultScopes = ["login:info", "login:email", "login:avatar"];
|
|
|
8
8
|
export class Yandex {
|
|
9
9
|
client;
|
|
10
10
|
auth = null;
|
|
11
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
11
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
12
12
|
if (typeof clientIdOrOptions === "object") {
|
|
13
13
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
14
14
|
clientSecret: true,
|
|
@@ -37,13 +37,12 @@ export class Yandex {
|
|
|
37
37
|
const state = generateOAuthState();
|
|
38
38
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
39
39
|
const payload = {};
|
|
40
|
-
await saveOAuthState(auth.store, state, payload);
|
|
41
40
|
return { url, state, payload };
|
|
42
41
|
}
|
|
43
42
|
async getUser(query, saved) {
|
|
44
|
-
|
|
43
|
+
requireAuthConfig(this.auth);
|
|
45
44
|
const { code, state } = parseCallbackQuery(query);
|
|
46
|
-
|
|
45
|
+
resolveOAuthState(state, saved);
|
|
47
46
|
const tokens = await this.validateAuthorizationCode(code);
|
|
48
47
|
const accessToken = tokens.accessToken();
|
|
49
48
|
// Yandex expects the "OAuth" scheme instead of "Bearer".
|
package/dist/providers/zoom.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ export interface ZoomOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Zoom {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: ZoomOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
11
11
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
revokeToken(token: string): Promise<void>;
|
|
14
14
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } 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";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["user:read:user"];
|
|
|
9
9
|
export class Zoom {
|
|
10
10
|
client;
|
|
11
11
|
auth = null;
|
|
12
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
12
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
13
13
|
if (typeof clientIdOrOptions === "object") {
|
|
14
14
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
15
15
|
clientSecret: true,
|
|
@@ -42,13 +42,12 @@ export class Zoom {
|
|
|
42
42
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
43
43
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
44
44
|
const payload = { codeVerifier };
|
|
45
|
-
await saveOAuthState(auth.store, state, payload);
|
|
46
45
|
return { url, state, payload };
|
|
47
46
|
}
|
|
48
47
|
async getUser(query, saved) {
|
|
49
|
-
|
|
48
|
+
requireAuthConfig(this.auth);
|
|
50
49
|
const { code, state } = parseCallbackQuery(query);
|
|
51
|
-
const stored =
|
|
50
|
+
const stored = resolveOAuthState(state, saved);
|
|
52
51
|
if (typeof stored.codeVerifier !== "string") {
|
|
53
52
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
54
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antarctic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "High-level OAuth 2.0 clients for popular providers, forked from Arctic",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"pilcrowOnPaper (author of Arctic, which Antarctic is a fork of)"
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
|
+
"homepage": "https://antarcticjs.dev",
|
|
23
24
|
"repository": {
|
|
24
25
|
"type": "git",
|
|
25
26
|
"url": "git+https://github.com/franciscop/antarctic.git"
|
package/readme.md
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Antarctic
|
|
2
|
-
|
|
3
|
-
Antarctic is a fork of [Arctic](https://arcticjs.dev) by [pilcrowOnPaper](https://github.com/pilcrowOnPaper), adding a high level auth layer on top of its OAuth 2.0 clients. Only the authorization code flow is supported. Built on top of the Fetch API, it's light weight, fully-typed, and runtime-agnostic.
|
|
4
|
-
|
|
5
|
-
All of the OAuth 2.0 clients and provider coverage are Arctic's work. If you only need those, use [Arctic](https://arcticjs.dev) directly. See [credits](#credits).
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
npm install antarctic
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## High-level API
|
|
12
|
-
|
|
13
|
-
Construct a provider with an options object and get two methods that handle the whole flow: `getAuthorizationURL()` and `getUser()`. State and PKCE values are generated for you and kept in a [polystore](https://polystore.dev) compatible key-value store.
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import * as auth from "antarctic";
|
|
17
|
-
import kv from "polystore";
|
|
18
|
-
|
|
19
|
-
const store = kv(new Map());
|
|
20
|
-
const scopes = ["read:user", "user:email"];
|
|
21
|
-
|
|
22
|
-
const github = new auth.GitHub({ store, scopes });
|
|
23
|
-
|
|
24
|
-
// Redirect the user here to sign in.
|
|
25
|
-
const { url } = await github.getAuthorizationURL();
|
|
26
|
-
|
|
27
|
-
// In the OAuth callback route:
|
|
28
|
-
const user = await github.getUser(request.url);
|
|
29
|
-
// { id: "1", name: "The Octocat", email: "octocat@github.com", image: "https://..." }
|
|
30
|
-
```
|
|
31
|
-
|
|
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
|
-
```
|
|
43
|
-
|
|
44
|
-
Options resolve as `explicit > environment > provider default`. Every option except `store` can come from the environment, named after the provider:
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
GITHUB_CLIENT_ID
|
|
48
|
-
GITHUB_CLIENT_SECRET
|
|
49
|
-
GITHUB_REDIRECT_URI
|
|
50
|
-
GITHUB_SCOPES
|
|
51
|
-
|
|
52
|
-
GOOGLE_CLIENT_ID
|
|
53
|
-
...
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
`GITHUB_SCOPES` takes a list separated by commas, whitespace, or both. Scopes resolve as `argument > constructor > environment > provider default`, where the provider default is the minimal set that yields a full profile:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
await github.getAuthorizationURL(["repo"]); // overrides the constructor and the environment
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
The environment is read when the provider is constructed, so load your `.env` file first. See the [documentation](https://documentation.page/github/franciscop/antarctic/) for the details.
|
|
63
|
-
|
|
64
|
-
Errors thrown by the high-level layer: `InvalidOAuthStateError`, `InvalidOAuthCallbackError`, `OAuthConfigurationError`, and `OAuthProviderError`.
|
|
65
|
-
|
|
66
|
-
Sessions, cookies, and your user database remain your responsibility: take the returned user and plug it into your framework of choice.
|
|
67
|
-
|
|
68
|
-
## Low-level API
|
|
69
|
-
|
|
70
|
-
Arctic's low level API remains available on the same objects, including the positional constructors. It is unchanged except that PKCE providers build the URL asynchronously, so `createAuthorizationURL()` returns a promise for them:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
import * as arctic from "antarctic";
|
|
74
|
-
|
|
75
|
-
const github = new arctic.GitHub(clientId, clientSecret, redirectURI);
|
|
76
|
-
|
|
77
|
-
const state = arctic.generateState();
|
|
78
|
-
const scopes = ["user:email"];
|
|
79
|
-
const authorizationURL = github.createAuthorizationURL(state, scopes);
|
|
80
|
-
|
|
81
|
-
// ...
|
|
82
|
-
|
|
83
|
-
const tokens = await github.validateAuthorizationCode(code);
|
|
84
|
-
const accessToken = tokens.accessToken();
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
> Antarctic only supports providers that follow the OAuth 2.0 spec (including PKCE and token revocation).
|
|
88
|
-
|
|
89
|
-
## Credits
|
|
90
|
-
|
|
91
|
-
Antarctic is a fork of [Arctic](https://github.com/pilcrowonpaper/arctic), created and maintained by [pilcrowOnPaper](https://github.com/pilcrowOnPaper). The OAuth 2.0 clients, the provider implementations, the docs those pages grew from, and the design that makes all of it consistent are their work. Antarctic adds one layer on top: `getAuthorizationURL()`, `getUser()`, and the option resolution around them.
|
|
92
|
-
|
|
93
|
-
Arctic is MIT licensed. Antarctic keeps that license and the original copyright notice, and adds its own for the new work. See [LICENSE](./LICENSE).
|
|
94
|
-
|
|
95
|
-
If you only need the OAuth 2.0 clients without the high level layer, use [Arctic](https://arcticjs.dev) directly. Please report provider issues that are not specific to Antarctic's additions upstream, where they benefit everyone.
|
|
96
|
-
|
|
97
|
-
## Semver
|
|
98
|
-
|
|
99
|
-
Antarctic does not strictly follow semantic versioning. While we aim to only introduce breaking changes in major versions, we may introduce them in a minor update if a provider updates their API in a non-backward compatible way. However, they will never be introduced in a patch update.
|
|
100
|
-
|
|
101
|
-
## Supported providers
|
|
102
|
-
|
|
103
|
-
- 42 School
|
|
104
|
-
- Amazon Cognito
|
|
105
|
-
- AniList
|
|
106
|
-
- Apple
|
|
107
|
-
- Atlassian
|
|
108
|
-
- Auth0
|
|
109
|
-
- Authentik
|
|
110
|
-
- Autodesk Platform Services
|
|
111
|
-
- Battle.net
|
|
112
|
-
- Bitbucket
|
|
113
|
-
- Box
|
|
114
|
-
- Bungie
|
|
115
|
-
- Coinbase
|
|
116
|
-
- Discord
|
|
117
|
-
- DonationAlerts
|
|
118
|
-
- Dribbble
|
|
119
|
-
- Dropbox
|
|
120
|
-
- Etsy
|
|
121
|
-
- Epic Games
|
|
122
|
-
- Facebook
|
|
123
|
-
- Figma
|
|
124
|
-
- Gitea
|
|
125
|
-
- GitHub
|
|
126
|
-
- GitLab
|
|
127
|
-
- Google
|
|
128
|
-
- Intuit
|
|
129
|
-
- Kakao
|
|
130
|
-
- KeyCloak
|
|
131
|
-
- Kick
|
|
132
|
-
- Lichess
|
|
133
|
-
- Line
|
|
134
|
-
- Linear
|
|
135
|
-
- LinkedIn
|
|
136
|
-
- Mastodon
|
|
137
|
-
- MercadoLibre
|
|
138
|
-
- MercadoPago
|
|
139
|
-
- Microsoft Entra ID
|
|
140
|
-
- MyAnimeList
|
|
141
|
-
- Naver
|
|
142
|
-
- Notion
|
|
143
|
-
- Okta
|
|
144
|
-
- osu!
|
|
145
|
-
- Patreon
|
|
146
|
-
- Polar
|
|
147
|
-
- Reddit
|
|
148
|
-
- Roblox
|
|
149
|
-
- Salesforce
|
|
150
|
-
- Shikimori
|
|
151
|
-
- Slack
|
|
152
|
-
- Spotify
|
|
153
|
-
- Start.gg
|
|
154
|
-
- Strava
|
|
155
|
-
- Synology
|
|
156
|
-
- TikTok
|
|
157
|
-
- Tiltify
|
|
158
|
-
- Tumblr
|
|
159
|
-
- Twitch
|
|
160
|
-
- Twitter
|
|
161
|
-
- VK
|
|
162
|
-
- WorkOS
|
|
163
|
-
- Yahoo
|
|
164
|
-
- Yandex
|
|
165
|
-
- Zoom
|