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
package/dist/providers/polar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } from "../request.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://polar.sh/oauth2/authorize";
|
|
5
5
|
const tokenEndpoint = "https://api.polar.sh/v1/oauth2/token";
|
|
6
6
|
const tokenRevocationEndpoint = "https://api.polar.sh/v1/oauth2/revoke";
|
|
@@ -13,7 +13,7 @@ export class Polar {
|
|
|
13
13
|
clientSecret;
|
|
14
14
|
redirectURI;
|
|
15
15
|
auth = null;
|
|
16
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
16
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
17
17
|
if (typeof clientIdOrOptions === "object") {
|
|
18
18
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, { redirectURI: true });
|
|
19
19
|
this.clientId = this.auth.clientId;
|
|
@@ -78,13 +78,12 @@ export class Polar {
|
|
|
78
78
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
79
79
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
80
80
|
const payload = { codeVerifier };
|
|
81
|
-
await saveOAuthState(auth.store, state, payload);
|
|
82
81
|
return { url, state, payload };
|
|
83
82
|
}
|
|
84
83
|
async getUser(query, saved) {
|
|
85
|
-
|
|
84
|
+
requireAuthConfig(this.auth);
|
|
86
85
|
const { code, state } = parseCallbackQuery(query);
|
|
87
|
-
const stored =
|
|
86
|
+
const stored = resolveOAuthState(state, saved);
|
|
88
87
|
if (typeof stored.codeVerifier !== "string") {
|
|
89
88
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
90
89
|
}
|
|
@@ -5,11 +5,11 @@ export interface RedditOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Reddit {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: RedditOptions);
|
|
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/reddit.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://www.reddit.com/api/v1/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.reddit.com/api/v1/access_token";
|
|
5
5
|
const userEndpoint = "https://oauth.reddit.com/api/v1/me";
|
|
@@ -8,7 +8,7 @@ const defaultScopes = ["identity"];
|
|
|
8
8
|
export class Reddit {
|
|
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 Reddit {
|
|
|
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 profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
49
48
|
return {
|
|
@@ -5,12 +5,12 @@ export interface RobloxOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Roblox {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: RobloxOptions);
|
|
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
|
}
|
package/dist/providers/roblox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
2
|
import { decodeIdToken } from "../oidc.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://apis.roblox.com/oauth/v1/authorize";
|
|
5
5
|
const tokenEndpoint = "https://apis.roblox.com/oauth/v1/token";
|
|
6
6
|
const tokenRevocationEndpoint = "https://apis.roblox.com/oauth/v1/token/revoke";
|
|
@@ -10,7 +10,7 @@ const defaultScopes = ["openid", "profile"];
|
|
|
10
10
|
export class Roblox {
|
|
11
11
|
client;
|
|
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.client = new OAuth2Client(this.auth.clientId, this.auth.clientSecret, this.auth.redirectURI);
|
|
@@ -40,13 +40,12 @@ export class Roblox {
|
|
|
40
40
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
41
41
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
42
42
|
const payload = { codeVerifier };
|
|
43
|
-
await saveOAuthState(auth.store, state, payload);
|
|
44
43
|
return { url, state, payload };
|
|
45
44
|
}
|
|
46
45
|
async getUser(query, saved) {
|
|
47
|
-
|
|
46
|
+
requireAuthConfig(this.auth);
|
|
48
47
|
const { code, state } = parseCallbackQuery(query);
|
|
49
|
-
const stored =
|
|
48
|
+
const stored = resolveOAuthState(state, saved);
|
|
50
49
|
if (typeof stored.codeVerifier !== "string") {
|
|
51
50
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
52
51
|
}
|
|
@@ -10,12 +10,12 @@ export declare class Salesforce {
|
|
|
10
10
|
private userinfoEndpoint;
|
|
11
11
|
private client;
|
|
12
12
|
private auth;
|
|
13
|
-
constructor(options
|
|
13
|
+
constructor(options?: SalesforceOptions);
|
|
14
14
|
constructor(domain: string, clientId: string, clientSecret: string | null, redirectURI: string);
|
|
15
15
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
16
16
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
17
17
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
18
18
|
revokeToken(token: string): Promise<void>;
|
|
19
19
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
20
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
20
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
2
|
import { decodeIdToken } from "../oidc.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const envPrefix = "SALESFORCE";
|
|
5
5
|
const defaultScopes = ["openid", "profile", "email"];
|
|
6
6
|
export class Salesforce {
|
|
@@ -10,7 +10,7 @@ export class Salesforce {
|
|
|
10
10
|
userinfoEndpoint;
|
|
11
11
|
client;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(domainOrOptions, clientId, clientSecret, redirectURI) {
|
|
13
|
+
constructor(domainOrOptions = {}, clientId, clientSecret, redirectURI) {
|
|
14
14
|
let domain;
|
|
15
15
|
if (typeof domainOrOptions === "object") {
|
|
16
16
|
this.auth = resolveAuthConfig(envPrefix, domainOrOptions, { redirectURI: true });
|
|
@@ -47,13 +47,12 @@ export class Salesforce {
|
|
|
47
47
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
48
48
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
49
49
|
const payload = { codeVerifier };
|
|
50
|
-
await saveOAuthState(auth.store, state, payload);
|
|
51
50
|
return { url, state, payload };
|
|
52
51
|
}
|
|
53
52
|
async getUser(query, saved) {
|
|
54
|
-
|
|
53
|
+
requireAuthConfig(this.auth);
|
|
55
54
|
const { code, state } = parseCallbackQuery(query);
|
|
56
|
-
const stored =
|
|
55
|
+
const stored = resolveOAuthState(state, saved);
|
|
57
56
|
if (typeof stored.codeVerifier !== "string") {
|
|
58
57
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
59
58
|
}
|
|
@@ -7,11 +7,11 @@ export declare class Shikimori {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: ShikimoriOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string): URL;
|
|
13
13
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
14
14
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
15
15
|
getAuthorizationURL(): Promise<AuthorizationRequest>;
|
|
16
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://shikimori.one/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://shikimori.one/oauth/token";
|
|
5
5
|
const userEndpoint = "https://shikimori.one/api/users/whoami";
|
|
@@ -9,7 +9,7 @@ export class Shikimori {
|
|
|
9
9
|
clientSecret;
|
|
10
10
|
redirectURI;
|
|
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,
|
|
@@ -55,17 +55,16 @@ export class Shikimori {
|
|
|
55
55
|
return tokens;
|
|
56
56
|
}
|
|
57
57
|
async getAuthorizationURL() {
|
|
58
|
-
|
|
58
|
+
requireAuthConfig(this.auth);
|
|
59
59
|
const state = generateOAuthState();
|
|
60
60
|
const url = this.createAuthorizationURL(state);
|
|
61
61
|
const payload = {};
|
|
62
|
-
await saveOAuthState(auth.store, state, payload);
|
|
63
62
|
return { url, state, payload };
|
|
64
63
|
}
|
|
65
64
|
async getUser(query, saved) {
|
|
66
|
-
|
|
65
|
+
requireAuthConfig(this.auth);
|
|
67
66
|
const { code, state } = parseCallbackQuery(query);
|
|
68
|
-
|
|
67
|
+
resolveOAuthState(state, saved);
|
|
69
68
|
const tokens = await this.validateAuthorizationCode(code);
|
|
70
69
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
71
70
|
let image = null;
|
|
@@ -5,10 +5,10 @@ export interface SlackOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Slack {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: SlackOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string | null);
|
|
10
10
|
createAuthorizationURL(state: string, scopes: string[]): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
13
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
13
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
14
14
|
}
|
package/dist/providers/slack.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, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://slack.com/openid/connect/authorize";
|
|
5
5
|
const tokenEndpoint = "https://slack.com/api/openid.connect.token";
|
|
6
6
|
const userinfoEndpoint = "https://slack.com/api/openid.connect.userInfo";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["openid", "profile", "email"];
|
|
|
9
9
|
export class Slack {
|
|
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, { clientSecret: true });
|
|
15
15
|
this.client = new OAuth2Client(this.auth.clientId, this.auth.clientSecret, this.auth.redirectURI);
|
|
@@ -31,13 +31,12 @@ export class Slack {
|
|
|
31
31
|
const state = generateOAuthState();
|
|
32
32
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
33
33
|
const payload = {};
|
|
34
|
-
await saveOAuthState(auth.store, state, payload);
|
|
35
34
|
return { url, state, payload };
|
|
36
35
|
}
|
|
37
36
|
async getUser(query, saved) {
|
|
38
|
-
|
|
37
|
+
requireAuthConfig(this.auth);
|
|
39
38
|
const { code, state } = parseCallbackQuery(query);
|
|
40
|
-
|
|
39
|
+
resolveOAuthState(state, saved);
|
|
41
40
|
const tokens = await this.validateAuthorizationCode(code);
|
|
42
41
|
let claims;
|
|
43
42
|
if ("id_token" in tokens.data) {
|
|
@@ -5,11 +5,11 @@ export interface SpotifyOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Spotify {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: SpotifyOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string | null, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): Promise<URL>;
|
|
11
11
|
validateAuthorizationCode(code: string, codeVerifier: string | null): 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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeChallengeMethod, OAuth2Client } 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://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);
|
|
@@ -41,13 +41,12 @@ export class Spotify {
|
|
|
41
41
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
42
42
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
43
43
|
const payload = { codeVerifier };
|
|
44
|
-
await saveOAuthState(auth.store, state, payload);
|
|
45
44
|
return { url, state, payload };
|
|
46
45
|
}
|
|
47
46
|
async getUser(query, saved) {
|
|
48
|
-
|
|
47
|
+
requireAuthConfig(this.auth);
|
|
49
48
|
const { code, state } = parseCallbackQuery(query);
|
|
50
|
-
const stored =
|
|
49
|
+
const stored = resolveOAuthState(state, saved);
|
|
51
50
|
if (typeof stored.codeVerifier !== "string") {
|
|
52
51
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
53
52
|
}
|
|
@@ -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
15
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import { extractOAuthTokens, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
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,
|
|
@@ -120,13 +120,12 @@ export class StartGG {
|
|
|
120
120
|
const resolved = resolveScopes(scopes, auth, defaultScopes);
|
|
121
121
|
const url = this.createAuthorizationURL(state, resolved);
|
|
122
122
|
const payload = { scopes: resolved };
|
|
123
|
-
await saveOAuthState(auth.store, state, payload);
|
|
124
123
|
return { url, state, payload };
|
|
125
124
|
}
|
|
126
125
|
async getUser(query, saved) {
|
|
127
126
|
const auth = requireAuthConfig(this.auth);
|
|
128
127
|
const { code, state } = parseCallbackQuery(query);
|
|
129
|
-
const stored =
|
|
128
|
+
const stored = resolveOAuthState(state, saved);
|
|
130
129
|
const tokens = await this.validateAuthorizationCode(code, stored.scopes ?? resolveScopes(undefined, auth, defaultScopes));
|
|
131
130
|
const profile = await fetchCurrentUser(tokens.accessToken());
|
|
132
131
|
let image = null;
|
|
@@ -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
15
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { 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://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,
|
|
@@ -64,13 +64,12 @@ export class Strava {
|
|
|
64
64
|
const state = generateOAuthState();
|
|
65
65
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
66
66
|
const payload = {};
|
|
67
|
-
await saveOAuthState(auth.store, state, payload);
|
|
68
67
|
return { url, state, payload };
|
|
69
68
|
}
|
|
70
69
|
async getUser(query, saved) {
|
|
71
|
-
|
|
70
|
+
requireAuthConfig(this.auth);
|
|
72
71
|
const { code, state } = parseCallbackQuery(query);
|
|
73
|
-
|
|
72
|
+
resolveOAuthState(state, saved);
|
|
74
73
|
const tokens = await this.validateAuthorizationCode(code);
|
|
75
74
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
76
75
|
const firstName = profileString(profile.firstname);
|
|
@@ -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
16
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
17
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
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,
|
|
@@ -78,13 +78,12 @@ export class TikTok {
|
|
|
78
78
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
79
79
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
80
80
|
const payload = { codeVerifier };
|
|
81
|
-
await saveOAuthState(auth.store, state, payload);
|
|
82
81
|
return { url, state, payload };
|
|
83
82
|
}
|
|
84
83
|
async getUser(query, saved) {
|
|
85
|
-
|
|
84
|
+
requireAuthConfig(this.auth);
|
|
86
85
|
const { code, state } = parseCallbackQuery(query);
|
|
87
|
-
const stored =
|
|
86
|
+
const stored = resolveOAuthState(state, saved);
|
|
88
87
|
if (typeof stored.codeVerifier !== "string") {
|
|
89
88
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
90
89
|
}
|
|
@@ -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
15
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.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://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,
|
|
@@ -63,13 +63,12 @@ export class Tiltify {
|
|
|
63
63
|
const state = generateOAuthState();
|
|
64
64
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
65
65
|
const payload = {};
|
|
66
|
-
await saveOAuthState(auth.store, state, payload);
|
|
67
66
|
return { url, state, payload };
|
|
68
67
|
}
|
|
69
68
|
async getUser(query, saved) {
|
|
70
|
-
|
|
69
|
+
requireAuthConfig(this.auth);
|
|
71
70
|
const { code, state } = parseCallbackQuery(query);
|
|
72
|
-
|
|
71
|
+
resolveOAuthState(state, saved);
|
|
73
72
|
const tokens = await this.validateAuthorizationCode(code);
|
|
74
73
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
75
74
|
let user = {};
|
|
@@ -5,11 +5,11 @@ export interface TumblrOptions extends ProviderOptions {
|
|
|
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
13
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { 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://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,
|
|
@@ -37,13 +37,12 @@ export class Tumblr {
|
|
|
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 profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
49
48
|
let user = {};
|
|
@@ -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
15
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
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 { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
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,
|
|
@@ -65,13 +65,12 @@ export class Twitch {
|
|
|
65
65
|
const state = generateOAuthState();
|
|
66
66
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
67
67
|
const payload = {};
|
|
68
|
-
await saveOAuthState(auth.store, state, payload);
|
|
69
68
|
return { url, state, payload };
|
|
70
69
|
}
|
|
71
70
|
async getUser(query, saved) {
|
|
72
|
-
|
|
71
|
+
requireAuthConfig(this.auth);
|
|
73
72
|
const { code, state } = parseCallbackQuery(query);
|
|
74
|
-
|
|
73
|
+
resolveOAuthState(state, saved);
|
|
75
74
|
const tokens = await this.validateAuthorizationCode(code);
|
|
76
75
|
// Helix requires the Client-Id header alongside the user access token.
|
|
77
76
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken(), {
|