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/linear.js
CHANGED
|
@@ -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://linear.app/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.linear.app/oauth/token";
|
|
5
5
|
const graphqlEndpoint = "https://api.linear.app/graphql";
|
|
@@ -10,7 +10,7 @@ export class Linear {
|
|
|
10
10
|
clientSecret;
|
|
11
11
|
redirectURI;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
13
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
14
14
|
if (typeof clientIdOrOptions === "object") {
|
|
15
15
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
16
16
|
clientSecret: true,
|
|
@@ -53,13 +53,12 @@ export class Linear {
|
|
|
53
53
|
const state = generateOAuthState();
|
|
54
54
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
55
55
|
const payload = {};
|
|
56
|
-
await saveOAuthState(auth.store, state, payload);
|
|
57
56
|
return { url, state, payload };
|
|
58
57
|
}
|
|
59
58
|
async getUser(query, saved) {
|
|
60
|
-
|
|
59
|
+
requireAuthConfig(this.auth);
|
|
61
60
|
const { code, state } = parseCallbackQuery(query);
|
|
62
|
-
|
|
61
|
+
resolveOAuthState(state, saved);
|
|
63
62
|
const tokens = await this.validateAuthorizationCode(code);
|
|
64
63
|
const viewer = await fetchViewer(tokens.accessToken());
|
|
65
64
|
return {
|
|
@@ -7,11 +7,11 @@ export declare class LinkedIn {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: LinkedInOptions);
|
|
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,7 +1,7 @@
|
|
|
1
1
|
// LinkedIn doesn't seem to support HTTP Basic Auth
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
3
3
|
import { decodeIdToken } from "../oidc.js";
|
|
4
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes
|
|
4
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
5
5
|
const authorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization";
|
|
6
6
|
const tokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken";
|
|
7
7
|
const userinfoEndpoint = "https://api.linkedin.com/v2/userinfo";
|
|
@@ -12,7 +12,7 @@ export class LinkedIn {
|
|
|
12
12
|
clientSecret;
|
|
13
13
|
redirectURI;
|
|
14
14
|
auth = null;
|
|
15
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
15
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
16
16
|
if (typeof clientIdOrOptions === "object") {
|
|
17
17
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
18
18
|
clientSecret: true,
|
|
@@ -65,13 +65,12 @@ export class LinkedIn {
|
|
|
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
|
let claims;
|
|
77
76
|
if ("id_token" in tokens.data) {
|
|
@@ -10,11 +10,11 @@ export declare class Mastodon {
|
|
|
10
10
|
private userEndpoint;
|
|
11
11
|
private client;
|
|
12
12
|
private auth;
|
|
13
|
-
constructor(options
|
|
13
|
+
constructor(options?: MastodonOptions);
|
|
14
14
|
constructor(baseURL: string, clientId: string, clientSecret: string, redirectURI: string);
|
|
15
15
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
16
16
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
17
17
|
revokeToken(token: string): Promise<void>;
|
|
18
18
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
19
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
19
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
20
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
2
|
import { joinURIAndPath } from "../request.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 = "MASTODON";
|
|
5
5
|
const defaultScopes = ["read:accounts"];
|
|
6
6
|
export class Mastodon {
|
|
@@ -10,7 +10,7 @@ export class Mastodon {
|
|
|
10
10
|
userEndpoint;
|
|
11
11
|
client;
|
|
12
12
|
auth = null;
|
|
13
|
-
constructor(baseURLOrOptions, clientId, clientSecret, redirectURI) {
|
|
13
|
+
constructor(baseURLOrOptions = {}, clientId, clientSecret, redirectURI) {
|
|
14
14
|
let baseURL;
|
|
15
15
|
if (typeof baseURLOrOptions === "object") {
|
|
16
16
|
this.auth = resolveAuthConfig(envPrefix, baseURLOrOptions, {
|
|
@@ -46,13 +46,12 @@ export class Mastodon {
|
|
|
46
46
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
47
47
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
48
48
|
const payload = { codeVerifier };
|
|
49
|
-
await saveOAuthState(auth.store, state, payload);
|
|
50
49
|
return { url, state, payload };
|
|
51
50
|
}
|
|
52
51
|
async getUser(query, saved) {
|
|
53
|
-
|
|
52
|
+
requireAuthConfig(this.auth);
|
|
54
53
|
const { code, state } = parseCallbackQuery(query);
|
|
55
|
-
const stored =
|
|
54
|
+
const stored = resolveOAuthState(state, saved);
|
|
56
55
|
if (typeof stored.codeVerifier !== "string") {
|
|
57
56
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
58
57
|
}
|
|
@@ -7,11 +7,11 @@ export declare class MercadoLibre {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: MercadoLibreOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
|
|
13
13
|
validateAuthorizationCode(code: string, codeVerifier: 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,6 +1,6 @@
|
|
|
1
1
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://auth.mercadolibre.com/authorization";
|
|
5
5
|
const tokenEndpoint = "https://api.mercadolibre.com/oauth/token";
|
|
6
6
|
const userEndpoint = "https://api.mercadolibre.com/users/me";
|
|
@@ -10,7 +10,7 @@ export class MercadoLibre {
|
|
|
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,18 +62,17 @@ export class MercadoLibre {
|
|
|
62
62
|
}
|
|
63
63
|
// Scopes are defined in the application settings, so the argument is ignored.
|
|
64
64
|
async getAuthorizationURL(_scopes) {
|
|
65
|
-
|
|
65
|
+
requireAuthConfig(this.auth);
|
|
66
66
|
const state = generateOAuthState();
|
|
67
67
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
68
68
|
const url = await this.createAuthorizationURL(state, codeVerifier);
|
|
69
69
|
const payload = { codeVerifier };
|
|
70
|
-
await saveOAuthState(auth.store, state, payload);
|
|
71
70
|
return { url, state, payload };
|
|
72
71
|
}
|
|
73
72
|
async getUser(query, saved) {
|
|
74
|
-
|
|
73
|
+
requireAuthConfig(this.auth);
|
|
75
74
|
const { code, state } = parseCallbackQuery(query);
|
|
76
|
-
const stored =
|
|
75
|
+
const stored = resolveOAuthState(state, saved);
|
|
77
76
|
if (typeof stored.codeVerifier !== "string") {
|
|
78
77
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
79
78
|
}
|
|
@@ -7,11 +7,11 @@ export declare class MercadoPago {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: MercadoPagoOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
|
|
13
13
|
validateAuthorizationCode(code: string, codeVerifier: 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,6 +1,6 @@
|
|
|
1
1
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
2
2
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://auth.mercadopago.com/authorization";
|
|
5
5
|
const tokenEndpoint = "https://api.mercadopago.com/oauth/token";
|
|
6
6
|
const userEndpoint = "https://api.mercadopago.com/users/me";
|
|
@@ -10,7 +10,7 @@ export class MercadoPago {
|
|
|
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,18 +62,17 @@ export class MercadoPago {
|
|
|
62
62
|
}
|
|
63
63
|
// Scopes are defined in the application settings, so the argument is ignored.
|
|
64
64
|
async getAuthorizationURL(_scopes) {
|
|
65
|
-
|
|
65
|
+
requireAuthConfig(this.auth);
|
|
66
66
|
const state = generateOAuthState();
|
|
67
67
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
68
68
|
const url = await this.createAuthorizationURL(state, codeVerifier);
|
|
69
69
|
const payload = { codeVerifier };
|
|
70
|
-
await saveOAuthState(auth.store, state, payload);
|
|
71
70
|
return { url, state, payload };
|
|
72
71
|
}
|
|
73
72
|
async getUser(query, saved) {
|
|
74
|
-
|
|
73
|
+
requireAuthConfig(this.auth);
|
|
75
74
|
const { code, state } = parseCallbackQuery(query);
|
|
76
|
-
const stored =
|
|
75
|
+
const stored = resolveOAuthState(state, saved);
|
|
77
76
|
if (typeof stored.codeVerifier !== "string") {
|
|
78
77
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
79
78
|
}
|
|
@@ -10,11 +10,11 @@ export declare class MicrosoftEntraId {
|
|
|
10
10
|
private clientSecret;
|
|
11
11
|
private redirectURI;
|
|
12
12
|
private auth;
|
|
13
|
-
constructor(options
|
|
13
|
+
constructor(options?: MicrosoftEntraIdOptions);
|
|
14
14
|
constructor(tenant: 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, scopes: string[]): Promise<OAuth2Tokens>;
|
|
18
18
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
19
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
19
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createS256CodeChallenge } from "../oauth2.js";
|
|
2
2
|
import { createOAuth2Request, encodeBasicCredentials, joinURIAndPath, sendTokenRequest } 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 userinfoEndpoint = "https://graph.microsoft.com/oidc/userinfo";
|
|
6
6
|
const envPrefix = "MICROSOFT_ENTRA_ID";
|
|
7
7
|
const defaultScopes = ["openid", "profile", "email"];
|
|
@@ -12,7 +12,7 @@ export class MicrosoftEntraId {
|
|
|
12
12
|
clientSecret;
|
|
13
13
|
redirectURI;
|
|
14
14
|
auth = null;
|
|
15
|
-
constructor(tenantOrOptions, clientId, clientSecret, redirectURI) {
|
|
15
|
+
constructor(tenantOrOptions = {}, clientId, clientSecret, redirectURI) {
|
|
16
16
|
let tenant;
|
|
17
17
|
if (typeof tenantOrOptions === "object") {
|
|
18
18
|
this.auth = resolveAuthConfig(envPrefix, tenantOrOptions, { redirectURI: true });
|
|
@@ -93,13 +93,12 @@ export class MicrosoftEntraId {
|
|
|
93
93
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
94
94
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
95
95
|
const payload = { codeVerifier };
|
|
96
|
-
await saveOAuthState(auth.store, state, payload);
|
|
97
96
|
return { url, state, payload };
|
|
98
97
|
}
|
|
99
98
|
async getUser(query, saved) {
|
|
100
|
-
|
|
99
|
+
requireAuthConfig(this.auth);
|
|
101
100
|
const { code, state } = parseCallbackQuery(query);
|
|
102
|
-
const stored =
|
|
101
|
+
const stored = resolveOAuthState(state, saved);
|
|
103
102
|
if (typeof stored.codeVerifier !== "string") {
|
|
104
103
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
105
104
|
}
|
|
@@ -5,11 +5,11 @@ export interface MyAnimeListOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class MyAnimeList {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: MyAnimeListOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string | null);
|
|
10
10
|
createAuthorizationURL(state: string, codeVerifier: 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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://myanimelist.net/v1/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://myanimelist.net/v1/oauth2/token";
|
|
5
5
|
const userEndpoint = "https://api.myanimelist.net/v2/users/@me";
|
|
@@ -7,7 +7,7 @@ const envPrefix = "MY_ANIME_LIST";
|
|
|
7
7
|
export class MyAnimeList {
|
|
8
8
|
client;
|
|
9
9
|
auth = null;
|
|
10
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
10
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
11
11
|
if (typeof clientIdOrOptions === "object") {
|
|
12
12
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, { clientSecret: true });
|
|
13
13
|
this.client = new OAuth2Client(this.auth.clientId, this.auth.clientSecret, this.auth.redirectURI);
|
|
@@ -30,18 +30,17 @@ export class MyAnimeList {
|
|
|
30
30
|
}
|
|
31
31
|
// MyAnimeList does not use scopes, so the argument is ignored.
|
|
32
32
|
async getAuthorizationURL(_scopes) {
|
|
33
|
-
|
|
33
|
+
requireAuthConfig(this.auth);
|
|
34
34
|
const state = generateOAuthState();
|
|
35
35
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
36
36
|
const url = await this.createAuthorizationURL(state, codeVerifier);
|
|
37
37
|
const payload = { codeVerifier };
|
|
38
|
-
await saveOAuthState(auth.store, state, payload);
|
|
39
38
|
return { url, state, payload };
|
|
40
39
|
}
|
|
41
40
|
async getUser(query, saved) {
|
|
42
|
-
|
|
41
|
+
requireAuthConfig(this.auth);
|
|
43
42
|
const { code, state } = parseCallbackQuery(query);
|
|
44
|
-
const stored =
|
|
43
|
+
const stored = resolveOAuthState(state, saved);
|
|
45
44
|
if (typeof stored.codeVerifier !== "string") {
|
|
46
45
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
47
46
|
}
|
|
@@ -7,11 +7,11 @@ export declare class Naver {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: NaverOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
12
12
|
createAuthorizationURL(): 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/naver.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://nid.naver.com/oauth2.0/authorize";
|
|
4
4
|
const tokenEndpoint = "https://nid.naver.com/oauth2.0/token";
|
|
5
5
|
const userEndpoint = "https://openapi.naver.com/v1/nid/me";
|
|
@@ -9,7 +9,7 @@ export class Naver {
|
|
|
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,18 +55,17 @@ export class Naver {
|
|
|
55
55
|
}
|
|
56
56
|
// Naver scopes are configured in the application settings, so the argument is ignored.
|
|
57
57
|
async getAuthorizationURL(_scopes) {
|
|
58
|
-
|
|
58
|
+
requireAuthConfig(this.auth);
|
|
59
59
|
const state = generateOAuthState();
|
|
60
60
|
const url = this.createAuthorizationURL();
|
|
61
61
|
url.searchParams.set("state", state);
|
|
62
62
|
const payload = {};
|
|
63
|
-
await saveOAuthState(auth.store, state, payload);
|
|
64
63
|
return { url, state, payload };
|
|
65
64
|
}
|
|
66
65
|
async getUser(query, saved) {
|
|
67
|
-
|
|
66
|
+
requireAuthConfig(this.auth);
|
|
68
67
|
const { code, state } = parseCallbackQuery(query);
|
|
69
|
-
|
|
68
|
+
resolveOAuthState(state, saved);
|
|
70
69
|
const tokens = await this.validateAuthorizationCode(code);
|
|
71
70
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
72
71
|
const response = profile.response;
|
|
@@ -5,10 +5,10 @@ export interface NotionOptions extends ProviderOptions {
|
|
|
5
5
|
export declare class Notion {
|
|
6
6
|
private client;
|
|
7
7
|
private auth;
|
|
8
|
-
constructor(options
|
|
8
|
+
constructor(options?: NotionOptions);
|
|
9
9
|
constructor(clientId: string, clientSecret: string, redirectURI: string);
|
|
10
10
|
createAuthorizationURL(state: 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/notion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
|
-
import { extractOAuthTokens, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState
|
|
2
|
+
import { extractOAuthTokens, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://api.notion.com/v1/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://api.notion.com/v1/oauth/token";
|
|
5
5
|
const envPrefix = "NOTION";
|
|
6
6
|
export class Notion {
|
|
7
7
|
client;
|
|
8
8
|
auth = null;
|
|
9
|
-
constructor(clientIdOrOptions, clientSecret, redirectURI) {
|
|
9
|
+
constructor(clientIdOrOptions = {}, clientSecret, redirectURI) {
|
|
10
10
|
if (typeof clientIdOrOptions === "object") {
|
|
11
11
|
this.auth = resolveAuthConfig(envPrefix, clientIdOrOptions, {
|
|
12
12
|
clientSecret: true,
|
|
@@ -29,17 +29,16 @@ export class Notion {
|
|
|
29
29
|
}
|
|
30
30
|
// Notion does not use scopes, so the argument is ignored.
|
|
31
31
|
async getAuthorizationURL(_scopes) {
|
|
32
|
-
|
|
32
|
+
requireAuthConfig(this.auth);
|
|
33
33
|
const state = generateOAuthState();
|
|
34
34
|
const url = this.createAuthorizationURL(state);
|
|
35
35
|
const payload = {};
|
|
36
|
-
await saveOAuthState(auth.store, state, payload);
|
|
37
36
|
return { url, state, payload };
|
|
38
37
|
}
|
|
39
38
|
async getUser(query, saved) {
|
|
40
|
-
|
|
39
|
+
requireAuthConfig(this.auth);
|
|
41
40
|
const { code, state } = parseCallbackQuery(query);
|
|
42
|
-
|
|
41
|
+
resolveOAuthState(state, saved);
|
|
43
42
|
const tokens = await this.validateAuthorizationCode(code);
|
|
44
43
|
// Notion returns the authorizing user inside the token response.
|
|
45
44
|
const data = tokens.data;
|
package/dist/providers/okta.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ export declare class Okta {
|
|
|
11
11
|
private userinfoEndpoint;
|
|
12
12
|
private client;
|
|
13
13
|
private auth;
|
|
14
|
-
constructor(options
|
|
14
|
+
constructor(options?: OktaOptions);
|
|
15
15
|
constructor(domain: string, authorizationServerId: string | null, clientId: string, clientSecret: string, redirectURI: string);
|
|
16
16
|
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
|
|
17
17
|
validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
|
|
18
18
|
refreshAccessToken(refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
|
|
19
19
|
revokeToken(token: string): Promise<void>;
|
|
20
20
|
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
21
|
-
getUser(query: OAuthCallbackQuery, saved
|
|
21
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
22
22
|
}
|
package/dist/providers/okta.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeChallengeMethod, OAuth2Client } from "../client.js";
|
|
2
2
|
import { decodeIdToken } from "../oidc.js";
|
|
3
|
-
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveProviderOption, resolveScopes
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveOAuthState, resolveProviderOption, resolveScopes } from "../auth.js";
|
|
4
4
|
import { joinURIAndPath } from "../request.js";
|
|
5
5
|
const envPrefix = "OKTA";
|
|
6
6
|
const defaultScopes = ["openid", "profile", "email"];
|
|
@@ -11,7 +11,7 @@ export class Okta {
|
|
|
11
11
|
userinfoEndpoint;
|
|
12
12
|
client;
|
|
13
13
|
auth = null;
|
|
14
|
-
constructor(domainOrOptions, authorizationServerId, clientId, clientSecret, redirectURI) {
|
|
14
|
+
constructor(domainOrOptions = {}, authorizationServerId, clientId, clientSecret, redirectURI) {
|
|
15
15
|
let domain;
|
|
16
16
|
let serverId;
|
|
17
17
|
if (typeof domainOrOptions === "object") {
|
|
@@ -58,13 +58,12 @@ export class Okta {
|
|
|
58
58
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
59
59
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
60
60
|
const payload = { codeVerifier };
|
|
61
|
-
await saveOAuthState(auth.store, state, payload);
|
|
62
61
|
return { url, state, payload };
|
|
63
62
|
}
|
|
64
63
|
async getUser(query, saved) {
|
|
65
|
-
|
|
64
|
+
requireAuthConfig(this.auth);
|
|
66
65
|
const { code, state } = parseCallbackQuery(query);
|
|
67
|
-
const stored =
|
|
66
|
+
const stored = resolveOAuthState(state, saved);
|
|
68
67
|
if (typeof stored.codeVerifier !== "string") {
|
|
69
68
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
70
69
|
}
|
package/dist/providers/osu.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ export declare class Osu {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: OsuOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string, redirectURI: string | null);
|
|
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/osu.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://osu.ppy.sh/oauth/authorize";
|
|
4
4
|
const tokenEndpoint = "https://osu.ppy.sh/oauth/token";
|
|
5
5
|
const userEndpoint = "https://osu.ppy.sh/api/v2/me";
|
|
@@ -10,7 +10,7 @@ export class Osu {
|
|
|
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, { clientSecret: true });
|
|
16
16
|
this.clientId = this.auth.clientId;
|
|
@@ -64,13 +64,12 @@ export class Osu {
|
|
|
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
|
return {
|
|
@@ -7,11 +7,11 @@ export declare class Patreon {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: PatreonOptions);
|
|
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, 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.patreon.com/oauth2/authorize";
|
|
4
4
|
const tokenEndpoint = "https://www.patreon.com/api/oauth2/token";
|
|
5
5
|
const identityEndpoint = "https://www.patreon.com/api/oauth2/v2/identity";
|
|
@@ -10,7 +10,7 @@ export class Patreon {
|
|
|
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 Patreon {
|
|
|
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 url = new URL(identityEndpoint);
|
|
75
74
|
url.searchParams.set("fields[user]", "email,full_name,image_url");
|
|
@@ -7,12 +7,12 @@ export declare class Polar {
|
|
|
7
7
|
private clientSecret;
|
|
8
8
|
private redirectURI;
|
|
9
9
|
private auth;
|
|
10
|
-
constructor(options
|
|
10
|
+
constructor(options?: PolarOptions);
|
|
11
11
|
constructor(clientId: string, clientSecret: string | null, 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
|
}
|