antarctic 0.5.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 +19 -11
- package/dist/auth.js +16 -23
- package/dist/index.d.ts +1 -1
- package/dist/providers/42.d.ts +4 -4
- package/dist/providers/42.js +9 -8
- package/dist/providers/amazon-cognito.d.ts +4 -4
- package/dist/providers/amazon-cognito.js +9 -8
- package/dist/providers/anilist.d.ts +4 -4
- package/dist/providers/anilist.js +10 -9
- package/dist/providers/apple.d.ts +3 -3
- package/dist/providers/apple.js +8 -7
- package/dist/providers/atlassian.d.ts +4 -4
- package/dist/providers/atlassian.js +9 -8
- package/dist/providers/auth0.d.ts +4 -4
- package/dist/providers/auth0.js +9 -8
- package/dist/providers/authentik.d.ts +4 -4
- package/dist/providers/authentik.js +9 -8
- package/dist/providers/autodesk.d.ts +4 -4
- package/dist/providers/autodesk.js +9 -8
- package/dist/providers/battlenet.d.ts +4 -4
- package/dist/providers/battlenet.js +9 -8
- package/dist/providers/bitbucket.d.ts +4 -4
- package/dist/providers/bitbucket.js +10 -9
- package/dist/providers/box.d.ts +4 -4
- package/dist/providers/box.js +9 -8
- package/dist/providers/bungie.d.ts +4 -4
- package/dist/providers/bungie.js +9 -8
- package/dist/providers/coinbase.d.ts +4 -4
- package/dist/providers/coinbase.js +9 -8
- package/dist/providers/discord.d.ts +4 -4
- package/dist/providers/discord.js +9 -8
- package/dist/providers/donation-alerts.d.ts +4 -4
- package/dist/providers/donation-alerts.js +9 -8
- package/dist/providers/dribbble.d.ts +4 -4
- package/dist/providers/dribbble.js +9 -8
- package/dist/providers/dropbox.d.ts +4 -4
- package/dist/providers/dropbox.js +9 -8
- package/dist/providers/epicgames.d.ts +4 -4
- package/dist/providers/epicgames.js +9 -8
- package/dist/providers/etsy.d.ts +4 -4
- package/dist/providers/etsy.js +8 -7
- package/dist/providers/facebook.d.ts +4 -4
- package/dist/providers/facebook.js +9 -8
- package/dist/providers/figma.d.ts +4 -4
- package/dist/providers/figma.js +9 -8
- package/dist/providers/gitea.d.ts +4 -4
- package/dist/providers/gitea.js +9 -8
- package/dist/providers/github.d.ts +4 -4
- package/dist/providers/github.js +9 -8
- package/dist/providers/gitlab.d.ts +4 -4
- package/dist/providers/gitlab.js +9 -8
- package/dist/providers/google.d.ts +4 -4
- package/dist/providers/google.js +9 -8
- package/dist/providers/intuit.d.ts +4 -4
- package/dist/providers/intuit.js +9 -8
- package/dist/providers/kakao.d.ts +4 -4
- package/dist/providers/kakao.js +9 -8
- package/dist/providers/keycloak.d.ts +4 -4
- package/dist/providers/keycloak.js +9 -8
- package/dist/providers/kick.d.ts +4 -4
- package/dist/providers/kick.js +9 -8
- package/dist/providers/lichess.d.ts +4 -4
- package/dist/providers/lichess.js +9 -8
- package/dist/providers/line.d.ts +4 -4
- package/dist/providers/line.js +9 -8
- package/dist/providers/linear.d.ts +4 -4
- package/dist/providers/linear.js +9 -8
- package/dist/providers/linkedin.d.ts +4 -4
- package/dist/providers/linkedin.js +9 -8
- package/dist/providers/mastodon.d.ts +4 -4
- package/dist/providers/mastodon.js +9 -8
- package/dist/providers/mercadolibre.d.ts +4 -4
- package/dist/providers/mercadolibre.js +10 -9
- package/dist/providers/mercadopago.d.ts +4 -4
- package/dist/providers/mercadopago.js +10 -9
- package/dist/providers/microsoft-entra-id.d.ts +4 -4
- package/dist/providers/microsoft-entra-id.js +9 -8
- package/dist/providers/myanimelist.d.ts +4 -4
- package/dist/providers/myanimelist.js +10 -9
- package/dist/providers/naver.d.ts +4 -4
- package/dist/providers/naver.js +10 -9
- package/dist/providers/notion.d.ts +4 -4
- package/dist/providers/notion.js +10 -9
- package/dist/providers/okta.d.ts +4 -4
- package/dist/providers/okta.js +9 -8
- package/dist/providers/osu.d.ts +4 -4
- package/dist/providers/osu.js +9 -8
- package/dist/providers/patreon.d.ts +4 -4
- package/dist/providers/patreon.js +9 -8
- package/dist/providers/polar.d.ts +4 -4
- package/dist/providers/polar.js +9 -8
- package/dist/providers/reddit.d.ts +4 -4
- package/dist/providers/reddit.js +9 -8
- package/dist/providers/roblox.d.ts +4 -4
- package/dist/providers/roblox.js +9 -8
- package/dist/providers/salesforce.d.ts +4 -4
- package/dist/providers/salesforce.js +9 -8
- package/dist/providers/shikimori.d.ts +4 -4
- package/dist/providers/shikimori.js +10 -9
- package/dist/providers/slack.d.ts +4 -4
- package/dist/providers/slack.js +9 -8
- package/dist/providers/spotify.d.ts +4 -4
- package/dist/providers/spotify.js +9 -8
- package/dist/providers/startgg.d.ts +4 -4
- package/dist/providers/startgg.js +8 -7
- package/dist/providers/strava.d.ts +4 -4
- package/dist/providers/strava.js +9 -8
- package/dist/providers/tiktok.d.ts +4 -4
- package/dist/providers/tiktok.js +9 -8
- package/dist/providers/tiltify.d.ts +4 -4
- package/dist/providers/tiltify.js +9 -8
- package/dist/providers/tumblr.d.ts +4 -4
- package/dist/providers/tumblr.js +9 -8
- package/dist/providers/twitch.d.ts +4 -4
- package/dist/providers/twitch.js +9 -8
- package/dist/providers/twitter.d.ts +4 -4
- package/dist/providers/twitter.js +9 -8
- package/dist/providers/vk.d.ts +4 -4
- package/dist/providers/vk.js +9 -8
- package/dist/providers/withings.d.ts +4 -4
- package/dist/providers/withings.js +9 -8
- package/dist/providers/workos.d.ts +4 -4
- package/dist/providers/workos.js +10 -9
- package/dist/providers/yahoo.d.ts +4 -4
- package/dist/providers/yahoo.js +9 -8
- package/dist/providers/yandex.d.ts +4 -4
- package/dist/providers/yandex.js +9 -8
- package/dist/providers/zoom.d.ts +4 -4
- package/dist/providers/zoom.js +9 -8
- package/package.json +2 -1
- package/readme.md +0 -155
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeChallengeMethod, OAuth2Client } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://accounts.spotify.com/authorize";
|
|
4
4
|
const tokenEndpoint = "https://accounts.spotify.com/api/token";
|
|
5
5
|
const userEndpoint = "https://api.spotify.com/v1/me";
|
|
@@ -8,7 +8,7 @@ const defaultScopes = ["user-read-email", "user-read-private"];
|
|
|
8
8
|
export class Spotify {
|
|
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, { redirectURI: true });
|
|
14
14
|
this.client = new OAuth2Client(this.auth.clientId, this.auth.clientSecret, this.auth.redirectURI);
|
|
@@ -40,13 +40,13 @@ export class Spotify {
|
|
|
40
40
|
const state = generateOAuthState();
|
|
41
41
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
42
42
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
43
|
-
|
|
44
|
-
return url;
|
|
43
|
+
const payload = { codeVerifier };
|
|
44
|
+
return { url, state, payload };
|
|
45
45
|
}
|
|
46
|
-
async getUser(query) {
|
|
47
|
-
|
|
46
|
+
async getUser(query, saved) {
|
|
47
|
+
requireAuthConfig(this.auth);
|
|
48
48
|
const { code, state } = parseCallbackQuery(query);
|
|
49
|
-
const stored =
|
|
49
|
+
const stored = resolveOAuthState(state, saved);
|
|
50
50
|
if (typeof stored.codeVerifier !== "string") {
|
|
51
51
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
52
52
|
}
|
|
@@ -62,7 +62,8 @@ export class Spotify {
|
|
|
62
62
|
name: profileString(profile.display_name),
|
|
63
63
|
email: profileString(profile.email),
|
|
64
64
|
image,
|
|
65
|
-
raw: profile
|
|
65
|
+
raw: profile,
|
|
66
|
+
...extractOAuthTokens(tokens)
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -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 StartGGOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class StartGG {
|
|
@@ -7,11 +7,11 @@ export declare class StartGG {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: StartGGOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
13
13
|
validateAuthorizationCode(code: string, scopes: string[]): Promise<OAuth2Tokens>;
|
|
14
14
|
refreshAccessToken(refreshToken: string, scopes: 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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://start.gg/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.start.gg/oauth/access_token";
|
|
5
5
|
const refreshEndpoint = "https://api.start.gg/oauth/refresh";
|
|
@@ -59,7 +59,7 @@ export class StartGG {
|
|
|
59
59
|
clientSecret;
|
|
60
60
|
redirectURI;
|
|
61
61
|
auth = null;
|
|
62
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
62
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
63
63
|
if (typeof clientIdOrOptions === "object") {
|
|
64
64
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
65
65
|
clientSecret: true,
|
|
@@ -119,13 +119,13 @@ export class StartGG {
|
|
|
119
119
|
const state = generateOAuthState();
|
|
120
120
|
const resolved = resolveScopes(scopes, auth, defaultScopes);
|
|
121
121
|
const url = this.createAuthorizationURL(state, resolved);
|
|
122
|
-
|
|
123
|
-
return url;
|
|
122
|
+
const payload = { scopes: resolved };
|
|
123
|
+
return { url, state, payload };
|
|
124
124
|
}
|
|
125
|
-
async getUser(query) {
|
|
125
|
+
async getUser(query, saved) {
|
|
126
126
|
const auth = requireAuthConfig(this.auth);
|
|
127
127
|
const { code, state } = parseCallbackQuery(query);
|
|
128
|
-
const stored =
|
|
128
|
+
const stored = resolveOAuthState(state, saved);
|
|
129
129
|
const tokens = await this.validateAuthorizationCode(code, stored.scopes ?? resolveScopes(undefined, auth, defaultScopes));
|
|
130
130
|
const profile = await fetchCurrentUser(tokens.accessToken());
|
|
131
131
|
let image = null;
|
|
@@ -138,7 +138,8 @@ export class StartGG {
|
|
|
138
138
|
name: profileString(profile.name),
|
|
139
139
|
email: profileString(profile.email),
|
|
140
140
|
image,
|
|
141
|
-
raw: profile
|
|
141
|
+
raw: profile,
|
|
142
|
+
...extractOAuthTokens(tokens)
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
145
|
}
|
|
@@ -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 StravaOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Strava {
|
|
@@ -7,11 +7,11 @@ export declare class Strava {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: StravaOptions);
|
|
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
|
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/strava.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://www.strava.com/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.strava.com/api/v3/oauth/token";
|
|
5
5
|
const userEndpoint = "https://www.strava.com/api/v3/athlete";
|
|
@@ -10,7 +10,7 @@ export class Strava {
|
|
|
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,
|
|
@@ -63,13 +63,13 @@ export class Strava {
|
|
|
63
63
|
const auth = requireAuthConfig(this.auth);
|
|
64
64
|
const state = generateOAuthState();
|
|
65
65
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
66
|
-
|
|
67
|
-
return url;
|
|
66
|
+
const payload = {};
|
|
67
|
+
return { url, state, payload };
|
|
68
68
|
}
|
|
69
|
-
async getUser(query) {
|
|
70
|
-
|
|
69
|
+
async getUser(query, saved) {
|
|
70
|
+
requireAuthConfig(this.auth);
|
|
71
71
|
const { code, state } = parseCallbackQuery(query);
|
|
72
|
-
|
|
72
|
+
resolveOAuthState(state, saved);
|
|
73
73
|
const tokens = await this.validateAuthorizationCode(code);
|
|
74
74
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
75
75
|
const firstName = profileString(profile.firstname);
|
|
@@ -80,7 +80,8 @@ export class Strava {
|
|
|
80
80
|
name: name !== "" ? name : null,
|
|
81
81
|
email: null,
|
|
82
82
|
image: profileString(profile.profile),
|
|
83
|
-
raw: profile
|
|
83
|
+
raw: profile,
|
|
84
|
+
...extractOAuthTokens(tokens)
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -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 TikTokOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class TikTok {
|
|
@@ -7,12 +7,12 @@ export declare class TikTok {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: TikTokOptions);
|
|
11
11
|
constructor(clientKey: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
13
13
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
14
14
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
15
15
|
revokeToken(token: string): Promise<void>;
|
|
16
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
17
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
16
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
17
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
18
18
|
}
|
package/dist/providers/tiktok.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } from "../request.js";
|
|
3
|
-
import {
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://www.tiktok.com/v2/auth/authorize";
|
|
5
5
|
const tokenEndpoint = "https://open.tiktokapis.com/v2/oauth/token/";
|
|
6
6
|
const tokenRevocationEndpoint = "https://open.tiktokapis.com/v2/oauth/revoke/";
|
|
@@ -12,7 +12,7 @@ export class TikTok {
|
|
|
12
12
|
clientSecret;
|
|
13
13
|
redirectURI;
|
|
14
14
|
auth = null;
|
|
15
|
-
constructor(clientKeyOrOptions, clientSecret, redirectURI) {
|
|
15
|
+
constructor(clientKeyOrOptions = {}, clientSecret, redirectURI) {
|
|
16
16
|
if (typeof clientKeyOrOptions === "object") {
|
|
17
17
|
this.auth = resolveAuthConfig(envPrefix, clientKeyOrOptions, {
|
|
18
18
|
clientSecret: true,
|
|
@@ -77,13 +77,13 @@ export class TikTok {
|
|
|
77
77
|
const state = generateOAuthState();
|
|
78
78
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
79
79
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
80
|
-
|
|
81
|
-
return url;
|
|
80
|
+
const payload = { codeVerifier };
|
|
81
|
+
return { url, state, payload };
|
|
82
82
|
}
|
|
83
|
-
async getUser(query) {
|
|
84
|
-
|
|
83
|
+
async getUser(query, saved) {
|
|
84
|
+
requireAuthConfig(this.auth);
|
|
85
85
|
const { code, state } = parseCallbackQuery(query);
|
|
86
|
-
const stored =
|
|
86
|
+
const stored = resolveOAuthState(state, saved);
|
|
87
87
|
if (typeof stored.codeVerifier !== "string") {
|
|
88
88
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
89
89
|
}
|
|
@@ -104,7 +104,8 @@ export class TikTok {
|
|
|
104
104
|
name: profileString(user.display_name),
|
|
105
105
|
email: null,
|
|
106
106
|
image: profileString(user.avatar_url),
|
|
107
|
-
raw: user
|
|
107
|
+
raw: user,
|
|
108
|
+
...extractOAuthTokens(tokens)
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -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 TiltifyOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Tiltify {
|
|
@@ -7,11 +7,11 @@ export declare class Tiltify {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: TiltifyOptions);
|
|
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
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://v5api.tiltify.com/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://v5api.tiltify.com/oauth/token";
|
|
5
5
|
const userEndpoint = "https://v5api.tiltify.com/api/public/current-user";
|
|
@@ -10,7 +10,7 @@ export class Tiltify {
|
|
|
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,
|
|
@@ -62,13 +62,13 @@ export class Tiltify {
|
|
|
62
62
|
const auth = requireAuthConfig(this.auth);
|
|
63
63
|
const state = generateOAuthState();
|
|
64
64
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
65
|
-
|
|
66
|
-
return url;
|
|
65
|
+
const payload = {};
|
|
66
|
+
return { url, state, payload };
|
|
67
67
|
}
|
|
68
|
-
async getUser(query) {
|
|
69
|
-
|
|
68
|
+
async getUser(query, saved) {
|
|
69
|
+
requireAuthConfig(this.auth);
|
|
70
70
|
const { code, state } = parseCallbackQuery(query);
|
|
71
|
-
|
|
71
|
+
resolveOAuthState(state, saved);
|
|
72
72
|
const tokens = await this.validateAuthorizationCode(code);
|
|
73
73
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
74
74
|
let user = {};
|
|
@@ -85,7 +85,8 @@ export class Tiltify {
|
|
|
85
85
|
name: profileString(user.username),
|
|
86
86
|
email: null,
|
|
87
87
|
image,
|
|
88
|
-
raw: user
|
|
88
|
+
raw: user,
|
|
89
|
+
...extractOAuthTokens(tokens)
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
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 TumblrOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Tumblr {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: TumblrOptions);
|
|
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
|
-
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/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 } 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";
|
|
@@ -8,7 +8,7 @@ const defaultScopes = ["basic"];
|
|
|
8
8
|
export class Tumblr {
|
|
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,
|
|
@@ -36,13 +36,13 @@ 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
|
-
return url;
|
|
39
|
+
const payload = {};
|
|
40
|
+
return { url, state, payload };
|
|
41
41
|
}
|
|
42
|
-
async getUser(query) {
|
|
43
|
-
|
|
42
|
+
async getUser(query, saved) {
|
|
43
|
+
requireAuthConfig(this.auth);
|
|
44
44
|
const { code, state } = parseCallbackQuery(query);
|
|
45
|
-
|
|
45
|
+
resolveOAuthState(state, saved);
|
|
46
46
|
const tokens = await this.validateAuthorizationCode(code);
|
|
47
47
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
48
48
|
let user = {};
|
|
@@ -58,7 +58,8 @@ export class Tumblr {
|
|
|
58
58
|
name: profileString(user.name),
|
|
59
59
|
email: null,
|
|
60
60
|
image: null,
|
|
61
|
-
raw: user
|
|
61
|
+
raw: user,
|
|
62
|
+
...extractOAuthTokens(tokens)
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -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 {
|
|
@@ -7,11 +7,11 @@ export declare class Twitch {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: TwitchOptions);
|
|
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
|
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 } 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";
|
|
@@ -11,7 +11,7 @@ export class Twitch {
|
|
|
11
11
|
clientSecret;
|
|
12
12
|
redirectURI;
|
|
13
13
|
auth = null;
|
|
14
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
14
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
15
15
|
if (typeof clientIdOrOptions === "object") {
|
|
16
16
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
17
17
|
clientSecret: true,
|
|
@@ -64,13 +64,13 @@ 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
|
-
return url;
|
|
67
|
+
const payload = {};
|
|
68
|
+
return { url, state, payload };
|
|
69
69
|
}
|
|
70
|
-
async getUser(query) {
|
|
71
|
-
|
|
70
|
+
async getUser(query, saved) {
|
|
71
|
+
requireAuthConfig(this.auth);
|
|
72
72
|
const { code, state } = parseCallbackQuery(query);
|
|
73
|
-
|
|
73
|
+
resolveOAuthState(state, saved);
|
|
74
74
|
const tokens = await this.validateAuthorizationCode(code);
|
|
75
75
|
// Helix requires the Client-Id header alongside the user access token.
|
|
76
76
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken(), {
|
|
@@ -86,7 +86,8 @@ export class Twitch {
|
|
|
86
86
|
name: profileString(user.display_name) ?? profileString(user.login),
|
|
87
87
|
email: profileString(user.email),
|
|
88
88
|
image: profileString(user.profile_image_url),
|
|
89
|
-
raw: user
|
|
89
|
+
raw: user,
|
|
90
|
+
...extractOAuthTokens(tokens)
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
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 {
|
|
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
|
-
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 } 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);
|
|
@@ -38,13 +38,13 @@ 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
|
-
return url;
|
|
41
|
+
const payload = { codeVerifier };
|
|
42
|
+
return { url, state, payload };
|
|
43
43
|
}
|
|
44
|
-
async getUser(query) {
|
|
45
|
-
|
|
44
|
+
async getUser(query, saved) {
|
|
45
|
+
requireAuthConfig(this.auth);
|
|
46
46
|
const { code, state } = parseCallbackQuery(query);
|
|
47
|
-
const stored =
|
|
47
|
+
const stored = resolveOAuthState(state, saved);
|
|
48
48
|
if (typeof stored.codeVerifier !== "string") {
|
|
49
49
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
50
50
|
}
|
|
@@ -62,7 +62,8 @@ export class Twitter {
|
|
|
62
62
|
name: profileString(user.name) ?? profileString(user.username),
|
|
63
63
|
email: null,
|
|
64
64
|
image: profileString(user.profile_image_url),
|
|
65
|
-
raw: user
|
|
65
|
+
raw: user,
|
|
66
|
+
...extractOAuthTokens(tokens)
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
}
|
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 {
|
|
@@ -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
|
-
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 } 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,
|
|
@@ -52,13 +52,13 @@ 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
|
-
return url;
|
|
55
|
+
const payload = {};
|
|
56
|
+
return { url, state, payload };
|
|
57
57
|
}
|
|
58
|
-
async getUser(query) {
|
|
59
|
-
|
|
58
|
+
async getUser(query, saved) {
|
|
59
|
+
requireAuthConfig(this.auth);
|
|
60
60
|
const { code, state } = parseCallbackQuery(query);
|
|
61
|
-
|
|
61
|
+
resolveOAuthState(state, saved);
|
|
62
62
|
const tokens = await this.validateAuthorizationCode(code);
|
|
63
63
|
const url = new URL(userEndpoint);
|
|
64
64
|
url.searchParams.set("v", "5.199");
|
|
@@ -77,7 +77,8 @@ export class VK {
|
|
|
77
77
|
name: nameParts.length > 0 ? nameParts.join(" ") : null,
|
|
78
78
|
email,
|
|
79
79
|
image: profileString(user.photo_200),
|
|
80
|
-
raw: user
|
|
80
|
+
raw: user,
|
|
81
|
+
...extractOAuthTokens(tokens)
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -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 {
|
|
@@ -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
|
-
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
|
}
|