antarctic 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -0
- package/dist/auth.d.ts +19 -11
- package/dist/auth.js +16 -23
- package/dist/index.d.ts +1 -1
- package/dist/providers/42.d.ts +4 -4
- package/dist/providers/42.js +9 -8
- package/dist/providers/amazon-cognito.d.ts +4 -4
- package/dist/providers/amazon-cognito.js +9 -8
- package/dist/providers/anilist.d.ts +4 -4
- package/dist/providers/anilist.js +10 -9
- package/dist/providers/apple.d.ts +3 -3
- package/dist/providers/apple.js +8 -7
- package/dist/providers/atlassian.d.ts +4 -4
- package/dist/providers/atlassian.js +9 -8
- package/dist/providers/auth0.d.ts +4 -4
- package/dist/providers/auth0.js +9 -8
- package/dist/providers/authentik.d.ts +4 -4
- package/dist/providers/authentik.js +9 -8
- package/dist/providers/autodesk.d.ts +4 -4
- package/dist/providers/autodesk.js +9 -8
- package/dist/providers/battlenet.d.ts +4 -4
- package/dist/providers/battlenet.js +9 -8
- package/dist/providers/bitbucket.d.ts +4 -4
- package/dist/providers/bitbucket.js +10 -9
- package/dist/providers/box.d.ts +4 -4
- package/dist/providers/box.js +9 -8
- package/dist/providers/bungie.d.ts +4 -4
- package/dist/providers/bungie.js +9 -8
- package/dist/providers/coinbase.d.ts +4 -4
- package/dist/providers/coinbase.js +9 -8
- package/dist/providers/discord.d.ts +4 -4
- package/dist/providers/discord.js +9 -8
- package/dist/providers/donation-alerts.d.ts +4 -4
- package/dist/providers/donation-alerts.js +9 -8
- package/dist/providers/dribbble.d.ts +4 -4
- package/dist/providers/dribbble.js +9 -8
- package/dist/providers/dropbox.d.ts +4 -4
- package/dist/providers/dropbox.js +9 -8
- package/dist/providers/epicgames.d.ts +4 -4
- package/dist/providers/epicgames.js +9 -8
- package/dist/providers/etsy.d.ts +4 -4
- package/dist/providers/etsy.js +8 -7
- package/dist/providers/facebook.d.ts +4 -4
- package/dist/providers/facebook.js +9 -8
- package/dist/providers/figma.d.ts +4 -4
- package/dist/providers/figma.js +9 -8
- package/dist/providers/gitea.d.ts +4 -4
- package/dist/providers/gitea.js +9 -8
- package/dist/providers/github.d.ts +4 -4
- package/dist/providers/github.js +9 -8
- package/dist/providers/gitlab.d.ts +4 -4
- package/dist/providers/gitlab.js +9 -8
- package/dist/providers/google.d.ts +4 -4
- package/dist/providers/google.js +9 -8
- package/dist/providers/intuit.d.ts +4 -4
- package/dist/providers/intuit.js +9 -8
- package/dist/providers/kakao.d.ts +4 -4
- package/dist/providers/kakao.js +9 -8
- package/dist/providers/keycloak.d.ts +4 -4
- package/dist/providers/keycloak.js +9 -8
- package/dist/providers/kick.d.ts +4 -4
- package/dist/providers/kick.js +9 -8
- package/dist/providers/lichess.d.ts +4 -4
- package/dist/providers/lichess.js +9 -8
- package/dist/providers/line.d.ts +4 -4
- package/dist/providers/line.js +9 -8
- package/dist/providers/linear.d.ts +4 -4
- package/dist/providers/linear.js +9 -8
- package/dist/providers/linkedin.d.ts +4 -4
- package/dist/providers/linkedin.js +9 -8
- package/dist/providers/mastodon.d.ts +4 -4
- package/dist/providers/mastodon.js +9 -8
- package/dist/providers/mercadolibre.d.ts +4 -4
- package/dist/providers/mercadolibre.js +10 -9
- package/dist/providers/mercadopago.d.ts +4 -4
- package/dist/providers/mercadopago.js +10 -9
- package/dist/providers/microsoft-entra-id.d.ts +4 -4
- package/dist/providers/microsoft-entra-id.js +9 -8
- package/dist/providers/myanimelist.d.ts +4 -4
- package/dist/providers/myanimelist.js +10 -9
- package/dist/providers/naver.d.ts +4 -4
- package/dist/providers/naver.js +10 -9
- package/dist/providers/notion.d.ts +4 -4
- package/dist/providers/notion.js +10 -9
- package/dist/providers/okta.d.ts +4 -4
- package/dist/providers/okta.js +9 -8
- package/dist/providers/osu.d.ts +4 -4
- package/dist/providers/osu.js +9 -8
- package/dist/providers/patreon.d.ts +4 -4
- package/dist/providers/patreon.js +9 -8
- package/dist/providers/polar.d.ts +4 -4
- package/dist/providers/polar.js +9 -8
- package/dist/providers/reddit.d.ts +4 -4
- package/dist/providers/reddit.js +9 -8
- package/dist/providers/roblox.d.ts +4 -4
- package/dist/providers/roblox.js +9 -8
- package/dist/providers/salesforce.d.ts +4 -4
- package/dist/providers/salesforce.js +9 -8
- package/dist/providers/shikimori.d.ts +4 -4
- package/dist/providers/shikimori.js +10 -9
- package/dist/providers/slack.d.ts +4 -4
- package/dist/providers/slack.js +9 -8
- package/dist/providers/spotify.d.ts +4 -4
- package/dist/providers/spotify.js +9 -8
- package/dist/providers/startgg.d.ts +4 -4
- package/dist/providers/startgg.js +8 -7
- package/dist/providers/strava.d.ts +4 -4
- package/dist/providers/strava.js +9 -8
- package/dist/providers/tiktok.d.ts +4 -4
- package/dist/providers/tiktok.js +9 -8
- package/dist/providers/tiltify.d.ts +4 -4
- package/dist/providers/tiltify.js +9 -8
- package/dist/providers/tumblr.d.ts +4 -4
- package/dist/providers/tumblr.js +9 -8
- package/dist/providers/twitch.d.ts +4 -4
- package/dist/providers/twitch.js +9 -8
- package/dist/providers/twitter.d.ts +4 -4
- package/dist/providers/twitter.js +9 -8
- package/dist/providers/vk.d.ts +4 -4
- package/dist/providers/vk.js +9 -8
- package/dist/providers/withings.d.ts +4 -4
- package/dist/providers/withings.js +9 -8
- package/dist/providers/workos.d.ts +4 -4
- package/dist/providers/workos.js +10 -9
- package/dist/providers/yahoo.d.ts +4 -4
- package/dist/providers/yahoo.js +9 -8
- package/dist/providers/yandex.d.ts +4 -4
- package/dist/providers/yandex.js +9 -8
- package/dist/providers/zoom.d.ts +4 -4
- package/dist/providers/zoom.js +9 -8
- package/package.json +2 -1
- package/readme.md +0 -155
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 {
|
|
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") {
|
|
@@ -57,13 +57,13 @@ export class Okta {
|
|
|
57
57
|
const state = generateOAuthState();
|
|
58
58
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
59
59
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
60
|
-
|
|
61
|
-
return url;
|
|
60
|
+
const payload = { codeVerifier };
|
|
61
|
+
return { url, state, payload };
|
|
62
62
|
}
|
|
63
|
-
async getUser(query) {
|
|
64
|
-
|
|
63
|
+
async getUser(query, saved) {
|
|
64
|
+
requireAuthConfig(this.auth);
|
|
65
65
|
const { code, state } = parseCallbackQuery(query);
|
|
66
|
-
const stored =
|
|
66
|
+
const stored = resolveOAuthState(state, saved);
|
|
67
67
|
if (typeof stored.codeVerifier !== "string") {
|
|
68
68
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
69
69
|
}
|
|
@@ -80,7 +80,8 @@ export class Okta {
|
|
|
80
80
|
name: profileString(claims.name),
|
|
81
81
|
email: profileString(claims.email),
|
|
82
82
|
image: profileString(claims.picture),
|
|
83
|
-
raw: claims
|
|
83
|
+
raw: claims,
|
|
84
|
+
...extractOAuthTokens(tokens)
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
}
|
package/dist/providers/osu.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface OsuOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Osu {
|
|
@@ -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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
16
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
15
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
package/dist/providers/osu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://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;
|
|
@@ -63,13 +63,13 @@ export class Osu {
|
|
|
63
63
|
const auth = requireAuthConfig(this.auth);
|
|
64
64
|
const state = generateOAuthState();
|
|
65
65
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
66
|
-
|
|
67
|
-
return url;
|
|
66
|
+
const payload = {};
|
|
67
|
+
return { url, state, payload };
|
|
68
68
|
}
|
|
69
|
-
async getUser(query) {
|
|
70
|
-
|
|
69
|
+
async getUser(query, saved) {
|
|
70
|
+
requireAuthConfig(this.auth);
|
|
71
71
|
const { code, state } = parseCallbackQuery(query);
|
|
72
|
-
|
|
72
|
+
resolveOAuthState(state, saved);
|
|
73
73
|
const tokens = await this.validateAuthorizationCode(code);
|
|
74
74
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
75
75
|
return {
|
|
@@ -77,7 +77,8 @@ export class Osu {
|
|
|
77
77
|
name: profileString(profile.username),
|
|
78
78
|
email: null,
|
|
79
79
|
image: profileString(profile.avatar_url),
|
|
80
|
-
raw: profile
|
|
80
|
+
raw: profile,
|
|
81
|
+
...extractOAuthTokens(tokens)
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface PatreonOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Patreon {
|
|
@@ -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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
16
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
15
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, 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,
|
|
@@ -62,13 +62,13 @@ export class Patreon {
|
|
|
62
62
|
const auth = requireAuthConfig(this.auth);
|
|
63
63
|
const state = generateOAuthState();
|
|
64
64
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
65
|
-
|
|
66
|
-
return url;
|
|
65
|
+
const payload = {};
|
|
66
|
+
return { url, state, payload };
|
|
67
67
|
}
|
|
68
|
-
async getUser(query) {
|
|
69
|
-
|
|
68
|
+
async getUser(query, saved) {
|
|
69
|
+
requireAuthConfig(this.auth);
|
|
70
70
|
const { code, state } = parseCallbackQuery(query);
|
|
71
|
-
|
|
71
|
+
resolveOAuthState(state, saved);
|
|
72
72
|
const tokens = await this.validateAuthorizationCode(code);
|
|
73
73
|
const url = new URL(identityEndpoint);
|
|
74
74
|
url.searchParams.set("fields[user]", "email,full_name,image_url");
|
|
@@ -84,7 +84,8 @@ export class Patreon {
|
|
|
84
84
|
name: profileString(attributes.full_name),
|
|
85
85
|
email: profileString(attributes.email),
|
|
86
86
|
image: profileString(attributes.image_url),
|
|
87
|
-
raw: user
|
|
87
|
+
raw: user,
|
|
88
|
+
...extractOAuthTokens(tokens)
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface PolarOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Polar {
|
|
@@ -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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
17
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
16
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
17
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
18
18
|
}
|
package/dist/providers/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 {
|
|
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;
|
|
@@ -77,13 +77,13 @@ export class Polar {
|
|
|
77
77
|
const state = generateOAuthState();
|
|
78
78
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
79
79
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
80
|
-
|
|
81
|
-
return url;
|
|
80
|
+
const payload = { codeVerifier };
|
|
81
|
+
return { url, state, payload };
|
|
82
82
|
}
|
|
83
|
-
async getUser(query) {
|
|
84
|
-
|
|
83
|
+
async getUser(query, saved) {
|
|
84
|
+
requireAuthConfig(this.auth);
|
|
85
85
|
const { code, state } = parseCallbackQuery(query);
|
|
86
|
-
const stored =
|
|
86
|
+
const stored = resolveOAuthState(state, saved);
|
|
87
87
|
if (typeof stored.codeVerifier !== "string") {
|
|
88
88
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
89
89
|
}
|
|
@@ -95,7 +95,8 @@ export class Polar {
|
|
|
95
95
|
email: profileString(claims.email),
|
|
96
96
|
// Polar's userinfo response has no avatar field.
|
|
97
97
|
image: null,
|
|
98
|
-
raw: claims
|
|
98
|
+
raw: claims,
|
|
99
|
+
...extractOAuthTokens(tokens)
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface RedditOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
14
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
13
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|
package/dist/providers/reddit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Client } from "../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
3
3
|
const authorizationEndpoint = "https://www.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,
|
|
@@ -36,13 +36,13 @@ export class Reddit {
|
|
|
36
36
|
const auth = requireAuthConfig(this.auth);
|
|
37
37
|
const state = generateOAuthState();
|
|
38
38
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
39
|
-
|
|
40
|
-
return url;
|
|
39
|
+
const payload = {};
|
|
40
|
+
return { url, state, payload };
|
|
41
41
|
}
|
|
42
|
-
async getUser(query) {
|
|
43
|
-
|
|
42
|
+
async getUser(query, saved) {
|
|
43
|
+
requireAuthConfig(this.auth);
|
|
44
44
|
const { code, state } = parseCallbackQuery(query);
|
|
45
|
-
|
|
45
|
+
resolveOAuthState(state, saved);
|
|
46
46
|
const tokens = await this.validateAuthorizationCode(code);
|
|
47
47
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
48
48
|
return {
|
|
@@ -50,7 +50,8 @@ export class Reddit {
|
|
|
50
50
|
name: profileString(profile.name),
|
|
51
51
|
email: null,
|
|
52
52
|
image: profileString(profile.icon_img),
|
|
53
|
-
raw: profile
|
|
53
|
+
raw: profile,
|
|
54
|
+
...extractOAuthTokens(tokens)
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface RobloxOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
15
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
14
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
15
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
16
16
|
}
|
package/dist/providers/roblox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
|
|
2
2
|
import { decodeIdToken } from "../oidc.js";
|
|
3
|
-
import {
|
|
3
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
|
|
4
4
|
const authorizationEndpoint = "https://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);
|
|
@@ -39,13 +39,13 @@ export class Roblox {
|
|
|
39
39
|
const state = generateOAuthState();
|
|
40
40
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
41
41
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
42
|
-
|
|
43
|
-
return url;
|
|
42
|
+
const payload = { codeVerifier };
|
|
43
|
+
return { url, state, payload };
|
|
44
44
|
}
|
|
45
|
-
async getUser(query) {
|
|
46
|
-
|
|
45
|
+
async getUser(query, saved) {
|
|
46
|
+
requireAuthConfig(this.auth);
|
|
47
47
|
const { code, state } = parseCallbackQuery(query);
|
|
48
|
-
const stored =
|
|
48
|
+
const stored = resolveOAuthState(state, saved);
|
|
49
49
|
if (typeof stored.codeVerifier !== "string") {
|
|
50
50
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
51
51
|
}
|
|
@@ -62,7 +62,8 @@ export class Roblox {
|
|
|
62
62
|
name: profileString(claims.name) ?? profileString(claims.preferred_username),
|
|
63
63
|
email: null,
|
|
64
64
|
image: profileString(claims.picture),
|
|
65
|
-
raw: claims
|
|
65
|
+
raw: claims,
|
|
66
|
+
...extractOAuthTokens(tokens)
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface SalesforceOptions extends ProviderOptions {
|
|
4
4
|
domain?: string;
|
|
5
5
|
}
|
|
@@ -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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
20
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
19
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
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 {
|
|
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 });
|
|
@@ -46,13 +46,13 @@ export class Salesforce {
|
|
|
46
46
|
const state = generateOAuthState();
|
|
47
47
|
const codeVerifier = generateOAuthCodeVerifier();
|
|
48
48
|
const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
|
|
49
|
-
|
|
50
|
-
return url;
|
|
49
|
+
const payload = { codeVerifier };
|
|
50
|
+
return { url, state, payload };
|
|
51
51
|
}
|
|
52
|
-
async getUser(query) {
|
|
53
|
-
|
|
52
|
+
async getUser(query, saved) {
|
|
53
|
+
requireAuthConfig(this.auth);
|
|
54
54
|
const { code, state } = parseCallbackQuery(query);
|
|
55
|
-
const stored =
|
|
55
|
+
const stored = resolveOAuthState(state, saved);
|
|
56
56
|
if (typeof stored.codeVerifier !== "string") {
|
|
57
57
|
throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
|
|
58
58
|
}
|
|
@@ -69,7 +69,8 @@ export class Salesforce {
|
|
|
69
69
|
name: profileString(claims.name) ?? profileString(claims.preferred_username),
|
|
70
70
|
email: profileString(claims.email),
|
|
71
71
|
image: profileString(claims.picture),
|
|
72
|
-
raw: claims
|
|
72
|
+
raw: claims,
|
|
73
|
+
...extractOAuthTokens(tokens)
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface ShikimoriOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare class Shikimori {
|
|
@@ -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
|
-
getAuthorizationURL(): Promise<
|
|
16
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
15
|
+
getAuthorizationURL(): Promise<AuthorizationRequest>;
|
|
16
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOAuth2Request, sendTokenRequest } from "../request.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } 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,16 +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
|
-
|
|
62
|
-
return url;
|
|
61
|
+
const payload = {};
|
|
62
|
+
return { url, state, payload };
|
|
63
63
|
}
|
|
64
|
-
async getUser(query) {
|
|
65
|
-
|
|
64
|
+
async getUser(query, saved) {
|
|
65
|
+
requireAuthConfig(this.auth);
|
|
66
66
|
const { code, state } = parseCallbackQuery(query);
|
|
67
|
-
|
|
67
|
+
resolveOAuthState(state, saved);
|
|
68
68
|
const tokens = await this.validateAuthorizationCode(code);
|
|
69
69
|
const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
|
|
70
70
|
let image = null;
|
|
@@ -76,7 +76,8 @@ export class Shikimori {
|
|
|
76
76
|
name: profileString(profile.nickname),
|
|
77
77
|
email: null,
|
|
78
78
|
image: image ?? profileString(profile.avatar),
|
|
79
|
-
raw: profile
|
|
79
|
+
raw: profile,
|
|
80
|
+
...extractOAuthTokens(tokens)
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface SlackOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
13
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
12
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
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 {
|
|
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);
|
|
@@ -30,13 +30,13 @@ export class Slack {
|
|
|
30
30
|
const auth = requireAuthConfig(this.auth);
|
|
31
31
|
const state = generateOAuthState();
|
|
32
32
|
const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
|
|
33
|
-
|
|
34
|
-
return url;
|
|
33
|
+
const payload = {};
|
|
34
|
+
return { url, state, payload };
|
|
35
35
|
}
|
|
36
|
-
async getUser(query) {
|
|
37
|
-
|
|
36
|
+
async getUser(query, saved) {
|
|
37
|
+
requireAuthConfig(this.auth);
|
|
38
38
|
const { code, state } = parseCallbackQuery(query);
|
|
39
|
-
|
|
39
|
+
resolveOAuthState(state, saved);
|
|
40
40
|
const tokens = await this.validateAuthorizationCode(code);
|
|
41
41
|
let claims;
|
|
42
42
|
if ("id_token" in tokens.data) {
|
|
@@ -54,7 +54,8 @@ export class Slack {
|
|
|
54
54
|
name: profileString(claims.name),
|
|
55
55
|
email: profileString(claims.email),
|
|
56
56
|
image: profileString(claims.picture),
|
|
57
|
-
raw: claims
|
|
57
|
+
raw: claims,
|
|
58
|
+
...extractOAuthTokens(tokens)
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from "../oauth2.js";
|
|
2
|
-
import type { OAuthCallbackQuery, OAuthUser, ProviderOptions } from "../auth.js";
|
|
2
|
+
import type { AuthorizationRequest, OAuthCallbackQuery, OAuthUser, ProviderOptions, SavedOAuthState } from "../auth.js";
|
|
3
3
|
export interface SpotifyOptions extends ProviderOptions {
|
|
4
4
|
}
|
|
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
|
-
getAuthorizationURL(scopes?: string[]): Promise<
|
|
14
|
-
getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
|
|
13
|
+
getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
|
|
14
|
+
getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
|
|
15
15
|
}
|