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
|
@@ -10,12 +10,12 @@ export declare class Authentik {
|
|
|
10
10
|
private userinfoEndpoint;
|
|
11
11
|
private client;
|
|
12
12
|
private auth;
|
|
13
|
-
constructor(options
|
|
13
|
+
constructor(options?: AuthentikOptions);
|
|
14
14
|
constructor(baseURL: 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,7 +1,7 @@
|
|
|
1
1
|
import { CodeChallengeMethod, OAuth2Client } from "../client.js";
|
|
2
2
|
import { joinURIAndPath } from "../request.js";
|
|
3
3
|
import { decodeIdToken } from "../oidc.js";
|
|
4
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
4
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
5
5
|
const envPrefix = "AUTHENTIK";
|
|
6
6
|
const defaultScopes = ["openid", "profile", "email"];
|
|
7
7
|
export class Authentik {
|
|
@@ -11,7 +11,7 @@ export class Authentik {
|
|
|
11
11
|
userinfoEndpoint;
|
|
12
12
|
client;
|
|
13
13
|
auth = null;
|
|
14
|
-
constructor(baseURLOrOptions, clientId, clientSecret, redirectURI) {
|
|
14
|
+
constructor(baseURLOrOptions = {}, clientId, clientSecret, redirectURI) {
|
|
15
15
|
let baseURL;
|
|
16
16
|
if (typeof baseURLOrOptions === "object") {
|
|
17
17
|
this.auth = resolveAuthConfig(envPrefix, baseURLOrOptions, { redirectURI: true });
|
|
@@ -48,13 +48,12 @@ export class Authentik {
|
|
|
48
48
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
49
49
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
50
50
|
const payload = { codeVerifier };
|
|
51
|
-
await saveOAuthState(auth.store, state, payload);
|
|
52
51
|
return { url, state, payload };
|
|
53
52
|
}
|
|
54
53
|
async getUser(query, saved) {
|
|
55
|
-
|
|
54
|
+
requireAuthConfig(this.auth);
|
|
56
55
|
const { code, state } = parseCallbackQuery(query);
|
|
57
|
-
const stored =
|
|
56
|
+
const stored = resolveOAuthState(state, saved);
|
|
58
57
|
if (typeof stored.codeVerifier !== "string") {
|
|
59
58
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
60
59
|
}
|
|
@@ -5,12 +5,12 @@ export interface AutodeskOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Autodesk {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: AutodeskOptions);
|
|
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 { 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://developer.api.autodesk.com/authentication/v2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://developer.api.autodesk.com/authentication/v2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://developer.api.autodesk.com/authentication/v2/revoke";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["openid", "user-profile:read"];
|
|
|
9
9
|
export class Autodesk {
|
|
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 Autodesk {
|
|
|
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
|
}
|
|
@@ -7,10 +7,10 @@ export declare class BattleNet {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: BattleNetOptions);
|
|
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,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://oauth.battle.net/authorize";
|
|
4
4
|
const tokenEndpoint = "https://oauth.battle.net/token";
|
|
5
5
|
const userinfoEndpoint = "https://oauth.battle.net/userinfo";
|
|
@@ -10,7 +10,7 @@ export class BattleNet {
|
|
|
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,
|
|
@@ -51,13 +51,12 @@ export class BattleNet {
|
|
|
51
51
|
const state = generateOAuthState();
|
|
52
52
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
53
53
|
const payload = {};
|
|
54
|
-
await saveOAuthState(auth.store, state, payload);
|
|
55
54
|
return { url, state, payload };
|
|
56
55
|
}
|
|
57
56
|
async getUser(query, saved) {
|
|
58
|
-
|
|
57
|
+
requireAuthConfig(this.auth);
|
|
59
58
|
const { code, state } = parseCallbackQuery(query);
|
|
60
|
-
|
|
59
|
+
resolveOAuthState(state, saved);
|
|
61
60
|
const tokens = await this.validateAuthorizationCode(code);
|
|
62
61
|
const profile = await fetchUserProfile(userinfoEndpoint, tokens.accessToken());
|
|
63
62
|
return {
|
|
@@ -5,11 +5,11 @@ export interface BitbucketOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Bitbucket {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: BitbucketOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: string): URL;
|
|
11
11
|
validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
|
|
12
12
|
refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
|
|
13
13
|
getAuthorizationURL(): Promise<AuthorizationRequest>;
|
|
14
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.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://bitbucket.org/site/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://bitbucket.org/site/oauth2/access_token";
|
|
5
5
|
const userEndpoint = "https://api.bitbucket.org/2.0/user";
|
|
@@ -8,7 +8,7 @@ const envPrefix = "BITBUCKET";
|
|
|
8
8
|
export class Bitbucket {
|
|
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,
|
|
@@ -33,17 +33,16 @@ export class Bitbucket {
|
|
|
33
33
|
return tokens;
|
|
34
34
|
}
|
|
35
35
|
async getAuthorizationURL() {
|
|
36
|
-
|
|
36
|
+
requireAuthConfig(this.auth);
|
|
37
37
|
const state = generateOAuthState();
|
|
38
38
|
const url = this.createAuthorizationURL(state);
|
|
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
|
const profile = await fetchUserProfile(userEndpoint, accessToken);
|
package/dist/providers/box.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ export declare class Box {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: BoxOptions);
|
|
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
|
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/box.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } 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://account.box.com/api/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.box.com/oauth2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://api.box.com/oauth2/revoke";
|
|
@@ -11,7 +11,7 @@ export class Box {
|
|
|
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,
|
|
@@ -72,13 +72,12 @@ export class Box {
|
|
|
72
72
|
const state = generateOAuthState();
|
|
73
73
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
74
74
|
const payload = {};
|
|
75
|
-
await saveOAuthState(auth.store, state, payload);
|
|
76
75
|
return { url, state, payload };
|
|
77
76
|
}
|
|
78
77
|
async getUser(query, saved) {
|
|
79
|
-
|
|
78
|
+
requireAuthConfig(this.auth);
|
|
80
79
|
const { code, state } = parseCallbackQuery(query);
|
|
81
|
-
|
|
80
|
+
resolveOAuthState(state, saved);
|
|
82
81
|
const tokens = await this.validateAuthorizationCode(code);
|
|
83
82
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
84
83
|
return {
|
|
@@ -7,11 +7,11 @@ export declare class Bungie {
|
|
|
7
7
|
private client;
|
|
8
8
|
private apiKey;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: BungieOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string | null, 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/bungie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthConfigurationError, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveProviderOption, resolveScopes
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthConfigurationError, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveProviderOption, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://www.bungie.net/en/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.bungie.net/platform/app/oauth/token";
|
|
5
5
|
const userEndpoint = "https://www.bungie.net/platform/User/GetCurrentBungieNetUser/";
|
|
@@ -10,7 +10,7 @@ export class Bungie {
|
|
|
10
10
|
client;
|
|
11
11
|
apiKey = null;
|
|
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.apiKey = resolveProviderOption(clientIdOrOptions.apiKey, envPrefix, "API_KEY");
|
|
@@ -37,16 +37,15 @@ export class Bungie {
|
|
|
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
|
if (this.apiKey === null) {
|
|
46
45
|
throw new OAuthConfigurationError("Missing 'apiKey': pass it in the constructor options or set BUNGIE_API_KEY");
|
|
47
46
|
}
|
|
48
47
|
const { code, state } = parseCallbackQuery(query);
|
|
49
|
-
|
|
48
|
+
resolveOAuthState(state, saved);
|
|
50
49
|
const tokens = await this.validateAuthorizationCode(code);
|
|
51
50
|
const body = await fetchUserProfile(userEndpoint, tokens.accessToken(), {
|
|
52
51
|
"X-API-Key": this.apiKey
|
|
@@ -7,12 +7,12 @@ export declare class Coinbase {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: CoinbaseOptions);
|
|
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
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } 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://www.coinbase.com/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.coinbase.com/oauth/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://api.coinbase.com/oauth/revoke";
|
|
@@ -11,7 +11,7 @@ export class Coinbase {
|
|
|
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,
|
|
@@ -72,13 +72,12 @@ export class Coinbase {
|
|
|
72
72
|
const state = generateOAuthState();
|
|
73
73
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
74
74
|
const payload = {};
|
|
75
|
-
await saveOAuthState(auth.store, state, payload);
|
|
76
75
|
return { url, state, payload };
|
|
77
76
|
}
|
|
78
77
|
async getUser(query, saved) {
|
|
79
|
-
|
|
78
|
+
requireAuthConfig(this.auth);
|
|
80
79
|
const { code, state } = parseCallbackQuery(query);
|
|
81
|
-
|
|
80
|
+
resolveOAuthState(state, saved);
|
|
82
81
|
const tokens = await this.validateAuthorizationCode(code);
|
|
83
82
|
const body = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
84
83
|
const profile = body.data;
|
|
@@ -5,12 +5,12 @@ export interface DiscordOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Discord {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: DiscordOptions);
|
|
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
|
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 { 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://discord.com/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://discord.com/api/oauth2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://discord.com/api/oauth2/token/revoke";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["identify", "email"];
|
|
|
9
9
|
export class Discord {
|
|
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);
|
|
@@ -45,13 +45,12 @@ export class Discord {
|
|
|
45
45
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
46
46
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
47
47
|
const payload = { codeVerifier };
|
|
48
|
-
await saveOAuthState(auth.store, state, payload);
|
|
49
48
|
return { url, state, payload };
|
|
50
49
|
}
|
|
51
50
|
async getUser(query, saved) {
|
|
52
|
-
|
|
51
|
+
requireAuthConfig(this.auth);
|
|
53
52
|
const { code, state } = parseCallbackQuery(query);
|
|
54
|
-
const stored =
|
|
53
|
+
const stored = resolveOAuthState(state, saved);
|
|
55
54
|
if (typeof stored.codeVerifier !== "string") {
|
|
56
55
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
57
56
|
}
|
|
@@ -7,11 +7,11 @@ export declare class DonationAlerts {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: DonationAlertsOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(scopes: string[]): URL;
|
|
13
13
|
validateAuthorizationCode(code: 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, 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://www.donationalerts.com/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.donationalerts.com/oauth/token";
|
|
5
5
|
const userEndpoint = "https://www.donationalerts.com/api/v1/user/oauth";
|
|
@@ -10,7 +10,7 @@ export class DonationAlerts {
|
|
|
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 DonationAlerts {
|
|
|
63
63
|
// The legacy URL builder does not take a state parameter.
|
|
64
64
|
url.searchParams.set("state", state);
|
|
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 body = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
75
74
|
const profile = body.data;
|
|
@@ -7,10 +7,10 @@ export declare class Dribbble {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: DribbbleOptions);
|
|
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,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://dribbble.com/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://dribbble.com/oauth/token";
|
|
5
5
|
const userEndpoint = "https://api.dribbble.com/v2/user";
|
|
@@ -11,7 +11,7 @@ export class Dribbble {
|
|
|
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,
|
|
@@ -54,13 +54,12 @@ export class Dribbble {
|
|
|
54
54
|
const state = generateOAuthState();
|
|
55
55
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
56
56
|
const payload = {};
|
|
57
|
-
await saveOAuthState(auth.store, state, payload);
|
|
58
57
|
return { url, state, payload };
|
|
59
58
|
}
|
|
60
59
|
async getUser(query, saved) {
|
|
61
|
-
|
|
60
|
+
requireAuthConfig(this.auth);
|
|
62
61
|
const { code, state } = parseCallbackQuery(query);
|
|
63
|
-
|
|
62
|
+
resolveOAuthState(state, saved);
|
|
64
63
|
const tokens = await this.validateAuthorizationCode(code);
|
|
65
64
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
66
65
|
return {
|
|
@@ -5,12 +5,12 @@ export interface DropboxOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Dropbox {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: DropboxOptions);
|
|
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
|
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 } from "../client.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://www.dropbox.com/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.dropboxapi.com/oauth2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://api.dropboxapi.com/2/auth/token/revoke";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["account_info.read"];
|
|
|
9
9
|
export class Dropbox {
|
|
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,
|
|
@@ -41,13 +41,12 @@ export class Dropbox {
|
|
|
41
41
|
const state = generateOAuthState();
|
|
42
42
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
43
43
|
const payload = {};
|
|
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
|
-
|
|
49
|
+
resolveOAuthState(state, saved);
|
|
51
50
|
const tokens = await this.validateAuthorizationCode(code);
|
|
52
51
|
const profile = await fetchCurrentAccount(tokens.accessToken());
|
|
53
52
|
let name = null;
|
|
@@ -5,12 +5,12 @@ export interface EpicGamesOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class EpicGames {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: EpicGamesOptions);
|
|
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
|
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 } 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.epicgames.com/id/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.epicgames.dev/epic/oauth/v2/token";
|
|
5
5
|
const tokenRevocationEndpoint = "https://api.epicgames.dev/epic/oauth/v2/revoke";
|
|
@@ -9,7 +9,7 @@ const defaultScopes = ["basic_profile"];
|
|
|
9
9
|
export class EpicGames {
|
|
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,
|
|
@@ -41,13 +41,12 @@ export class EpicGames {
|
|
|
41
41
|
const state = generateOAuthState();
|
|
42
42
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
43
43
|
const payload = {};
|
|
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
|
-
|
|
49
|
+
resolveOAuthState(state, saved);
|
|
51
50
|
const tokens = await this.validateAuthorizationCode(code);
|
|
52
51
|
const claims = await fetchUserProfile(userinfoEndpoint, tokens.accessToken());
|
|
53
52
|
return {
|
package/dist/providers/etsy.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ export interface EtsyOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Etsy {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: EtsyOptions);
|
|
9
9
|
constructor(clientId: 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
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|