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.
Files changed (132) hide show
  1. package/README.md +252 -0
  2. package/dist/auth.d.ts +19 -11
  3. package/dist/auth.js +16 -23
  4. package/dist/index.d.ts +1 -1
  5. package/dist/providers/42.d.ts +4 -4
  6. package/dist/providers/42.js +9 -8
  7. package/dist/providers/amazon-cognito.d.ts +4 -4
  8. package/dist/providers/amazon-cognito.js +9 -8
  9. package/dist/providers/anilist.d.ts +4 -4
  10. package/dist/providers/anilist.js +10 -9
  11. package/dist/providers/apple.d.ts +3 -3
  12. package/dist/providers/apple.js +8 -7
  13. package/dist/providers/atlassian.d.ts +4 -4
  14. package/dist/providers/atlassian.js +9 -8
  15. package/dist/providers/auth0.d.ts +4 -4
  16. package/dist/providers/auth0.js +9 -8
  17. package/dist/providers/authentik.d.ts +4 -4
  18. package/dist/providers/authentik.js +9 -8
  19. package/dist/providers/autodesk.d.ts +4 -4
  20. package/dist/providers/autodesk.js +9 -8
  21. package/dist/providers/battlenet.d.ts +4 -4
  22. package/dist/providers/battlenet.js +9 -8
  23. package/dist/providers/bitbucket.d.ts +4 -4
  24. package/dist/providers/bitbucket.js +10 -9
  25. package/dist/providers/box.d.ts +4 -4
  26. package/dist/providers/box.js +9 -8
  27. package/dist/providers/bungie.d.ts +4 -4
  28. package/dist/providers/bungie.js +9 -8
  29. package/dist/providers/coinbase.d.ts +4 -4
  30. package/dist/providers/coinbase.js +9 -8
  31. package/dist/providers/discord.d.ts +4 -4
  32. package/dist/providers/discord.js +9 -8
  33. package/dist/providers/donation-alerts.d.ts +4 -4
  34. package/dist/providers/donation-alerts.js +9 -8
  35. package/dist/providers/dribbble.d.ts +4 -4
  36. package/dist/providers/dribbble.js +9 -8
  37. package/dist/providers/dropbox.d.ts +4 -4
  38. package/dist/providers/dropbox.js +9 -8
  39. package/dist/providers/epicgames.d.ts +4 -4
  40. package/dist/providers/epicgames.js +9 -8
  41. package/dist/providers/etsy.d.ts +4 -4
  42. package/dist/providers/etsy.js +8 -7
  43. package/dist/providers/facebook.d.ts +4 -4
  44. package/dist/providers/facebook.js +9 -8
  45. package/dist/providers/figma.d.ts +4 -4
  46. package/dist/providers/figma.js +9 -8
  47. package/dist/providers/gitea.d.ts +4 -4
  48. package/dist/providers/gitea.js +9 -8
  49. package/dist/providers/github.d.ts +4 -4
  50. package/dist/providers/github.js +9 -8
  51. package/dist/providers/gitlab.d.ts +4 -4
  52. package/dist/providers/gitlab.js +9 -8
  53. package/dist/providers/google.d.ts +4 -4
  54. package/dist/providers/google.js +9 -8
  55. package/dist/providers/intuit.d.ts +4 -4
  56. package/dist/providers/intuit.js +9 -8
  57. package/dist/providers/kakao.d.ts +4 -4
  58. package/dist/providers/kakao.js +9 -8
  59. package/dist/providers/keycloak.d.ts +4 -4
  60. package/dist/providers/keycloak.js +9 -8
  61. package/dist/providers/kick.d.ts +4 -4
  62. package/dist/providers/kick.js +9 -8
  63. package/dist/providers/lichess.d.ts +4 -4
  64. package/dist/providers/lichess.js +9 -8
  65. package/dist/providers/line.d.ts +4 -4
  66. package/dist/providers/line.js +9 -8
  67. package/dist/providers/linear.d.ts +4 -4
  68. package/dist/providers/linear.js +9 -8
  69. package/dist/providers/linkedin.d.ts +4 -4
  70. package/dist/providers/linkedin.js +9 -8
  71. package/dist/providers/mastodon.d.ts +4 -4
  72. package/dist/providers/mastodon.js +9 -8
  73. package/dist/providers/mercadolibre.d.ts +4 -4
  74. package/dist/providers/mercadolibre.js +10 -9
  75. package/dist/providers/mercadopago.d.ts +4 -4
  76. package/dist/providers/mercadopago.js +10 -9
  77. package/dist/providers/microsoft-entra-id.d.ts +4 -4
  78. package/dist/providers/microsoft-entra-id.js +9 -8
  79. package/dist/providers/myanimelist.d.ts +4 -4
  80. package/dist/providers/myanimelist.js +10 -9
  81. package/dist/providers/naver.d.ts +4 -4
  82. package/dist/providers/naver.js +10 -9
  83. package/dist/providers/notion.d.ts +4 -4
  84. package/dist/providers/notion.js +10 -9
  85. package/dist/providers/okta.d.ts +4 -4
  86. package/dist/providers/okta.js +9 -8
  87. package/dist/providers/osu.d.ts +4 -4
  88. package/dist/providers/osu.js +9 -8
  89. package/dist/providers/patreon.d.ts +4 -4
  90. package/dist/providers/patreon.js +9 -8
  91. package/dist/providers/polar.d.ts +4 -4
  92. package/dist/providers/polar.js +9 -8
  93. package/dist/providers/reddit.d.ts +4 -4
  94. package/dist/providers/reddit.js +9 -8
  95. package/dist/providers/roblox.d.ts +4 -4
  96. package/dist/providers/roblox.js +9 -8
  97. package/dist/providers/salesforce.d.ts +4 -4
  98. package/dist/providers/salesforce.js +9 -8
  99. package/dist/providers/shikimori.d.ts +4 -4
  100. package/dist/providers/shikimori.js +10 -9
  101. package/dist/providers/slack.d.ts +4 -4
  102. package/dist/providers/slack.js +9 -8
  103. package/dist/providers/spotify.d.ts +4 -4
  104. package/dist/providers/spotify.js +9 -8
  105. package/dist/providers/startgg.d.ts +4 -4
  106. package/dist/providers/startgg.js +8 -7
  107. package/dist/providers/strava.d.ts +4 -4
  108. package/dist/providers/strava.js +9 -8
  109. package/dist/providers/tiktok.d.ts +4 -4
  110. package/dist/providers/tiktok.js +9 -8
  111. package/dist/providers/tiltify.d.ts +4 -4
  112. package/dist/providers/tiltify.js +9 -8
  113. package/dist/providers/tumblr.d.ts +4 -4
  114. package/dist/providers/tumblr.js +9 -8
  115. package/dist/providers/twitch.d.ts +4 -4
  116. package/dist/providers/twitch.js +9 -8
  117. package/dist/providers/twitter.d.ts +4 -4
  118. package/dist/providers/twitter.js +9 -8
  119. package/dist/providers/vk.d.ts +4 -4
  120. package/dist/providers/vk.js +9 -8
  121. package/dist/providers/withings.d.ts +4 -4
  122. package/dist/providers/withings.js +9 -8
  123. package/dist/providers/workos.d.ts +4 -4
  124. package/dist/providers/workos.js +10 -9
  125. package/dist/providers/yahoo.d.ts +4 -4
  126. package/dist/providers/yahoo.js +9 -8
  127. package/dist/providers/yandex.d.ts +4 -4
  128. package/dist/providers/yandex.js +9 -8
  129. package/dist/providers/zoom.d.ts +4 -4
  130. package/dist/providers/zoom.js +9 -8
  131. package/package.json +2 -1
  132. package/readme.md +0 -155
@@ -1,6 +1,6 @@
1
1
  import { ArcticFetchError, createOAuth2Request, createOAuth2RequestError, UnexpectedErrorResponseBodyError, UnexpectedResponseError } from "../request.js";
2
2
  import { OAuth2Tokens } from "../oauth2.js";
3
- import { consumeOAuthState, generateOAuthState, parseCallbackQuery, profileId, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
3
+ import { extractOAuthTokens, generateOAuthState, parseCallbackQuery, profileId, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
4
4
  const authorizationEndpoint = "https://account.withings.com/oauth2_user/authorize2";
5
5
  const tokenEndpoint = "https://wbsapi.withings.net/v2/oauth2";
6
6
  const envPrefix = "WITHINGS";
@@ -10,7 +10,7 @@ export class Withings {
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,
@@ -55,13 +55,13 @@ export class Withings {
55
55
  const auth = requireAuthConfig(this.auth);
56
56
  const state = generateOAuthState();
57
57
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
58
- await saveOAuthState(auth.store, state, {});
59
- return url;
58
+ const payload = {};
59
+ return { url, state, payload };
60
60
  }
61
- async getUser(query) {
62
- const auth = requireAuthConfig(this.auth);
61
+ async getUser(query, saved) {
62
+ requireAuthConfig(this.auth);
63
63
  const { code, state } = parseCallbackQuery(query);
64
- await consumeOAuthState(auth.store, state);
64
+ resolveOAuthState(state, saved);
65
65
  const tokens = await this.validateAuthorizationCode(code);
66
66
  // Withings has no profile API; the token response only carries the user id.
67
67
  const data = tokens.data;
@@ -70,7 +70,8 @@ export class Withings {
70
70
  name: null,
71
71
  email: null,
72
72
  image: null,
73
- raw: data
73
+ raw: data,
74
+ ...extractOAuthTokens(tokens)
74
75
  };
75
76
  }
76
77
  }
@@ -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 WorkOSOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class WorkOS {
@@ -7,10 +7,10 @@ export declare class WorkOS {
7
7
  private clientSecret;
8
8
  private redirectURI;
9
9
  private auth;
10
- constructor(options: WorkOSOptions);
10
+ constructor(options?: WorkOSOptions);
11
11
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
12
12
  createAuthorizationURL(state: string, codeVerifier: string | null): Promise<URL>;
13
13
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
14
- getAuthorizationURL(): Promise<URL>;
15
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
14
+ getAuthorizationURL(): Promise<AuthorizationRequest>;
15
+ getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import { createOAuth2Request, sendTokenRequest } from "../request.js";
2
- import { consumeOAuthState, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState } from "../auth.js";
3
3
  import { createS256CodeChallenge } from "../oauth2.js";
4
4
  const authorizationEndpoint = "https://api.workos.com/sso/authorize";
5
5
  const tokenEndpoint = "https://api.workos.com/sso/token";
@@ -10,7 +10,7 @@ export class WorkOS {
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, { redirectURI: true });
16
16
  this.clientId = this.auth.clientId;
@@ -53,17 +53,17 @@ export class WorkOS {
53
53
  return tokens;
54
54
  }
55
55
  async getAuthorizationURL() {
56
- const auth = requireAuthConfig(this.auth);
56
+ requireAuthConfig(this.auth);
57
57
  const state = generateOAuthState();
58
58
  const codeVerifier = generateOAuthCodeVerifier();
59
59
  const url = await this.createAuthorizationURL(state, codeVerifier);
60
- await saveOAuthState(auth.store, state, { codeVerifier });
61
- return url;
60
+ const payload = { codeVerifier };
61
+ return { url, state, payload };
62
62
  }
63
- async getUser(query) {
64
- const auth = requireAuthConfig(this.auth);
63
+ async getUser(query, saved) {
64
+ requireAuthConfig(this.auth);
65
65
  const { code, state } = parseCallbackQuery(query);
66
- const stored = await consumeOAuthState(auth.store, state);
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
  }
@@ -77,7 +77,8 @@ export class WorkOS {
77
77
  name: profileString(profile.name) ?? (fullName !== "" ? fullName : null),
78
78
  email: profileString(profile.email),
79
79
  image: profileString(profile.profile_picture_url),
80
- raw: profile
80
+ raw: profile,
81
+ ...extractOAuthTokens(tokens)
81
82
  };
82
83
  }
83
84
  }
@@ -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 YahooOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Yahoo {
6
6
  private client;
7
7
  private auth;
8
- constructor(options: YahooOptions);
8
+ constructor(options?: YahooOptions);
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<URL>;
14
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
13
+ getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
14
+ getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  import { OAuth2Client } from "../client.js";
2
2
  import { decodeIdToken } from "../oidc.js";
3
- import { consumeOAuthState, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
3
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
4
4
  const authorizationEndpoint = "https://api.login.yahoo.com/oauth2/request_auth";
5
5
  const tokenEndpoint = "https://api.login.yahoo.com/oauth2/get_token";
6
6
  const userinfoEndpoint = "https://api.login.yahoo.com/openid/v1/userinfo";
@@ -9,7 +9,7 @@ const defaultScopes = ["openid", "profile", "email"];
9
9
  export class Yahoo {
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,
@@ -37,13 +37,13 @@ export class Yahoo {
37
37
  const auth = requireAuthConfig(this.auth);
38
38
  const state = generateOAuthState();
39
39
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
40
- await saveOAuthState(auth.store, state, {});
41
- return url;
40
+ const payload = {};
41
+ return { url, state, payload };
42
42
  }
43
- async getUser(query) {
44
- const auth = requireAuthConfig(this.auth);
43
+ async getUser(query, saved) {
44
+ requireAuthConfig(this.auth);
45
45
  const { code, state } = parseCallbackQuery(query);
46
- await consumeOAuthState(auth.store, state);
46
+ resolveOAuthState(state, saved);
47
47
  const tokens = await this.validateAuthorizationCode(code);
48
48
  let claims;
49
49
  if ("id_token" in tokens.data) {
@@ -60,7 +60,8 @@ export class Yahoo {
60
60
  name: profileString(claims.name) ?? (fullName !== "" ? fullName : null),
61
61
  email: profileString(claims.email),
62
62
  image: profileString(claims.picture),
63
- raw: claims
63
+ raw: claims,
64
+ ...extractOAuthTokens(tokens)
64
65
  };
65
66
  }
66
67
  }
@@ -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 YandexOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Yandex {
6
6
  private client;
7
7
  private auth;
8
- constructor(options: YandexOptions);
8
+ constructor(options?: YandexOptions);
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<URL>;
14
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
13
+ getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
14
+ getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import { OAuth2Client } from "../client.js";
2
- import { consumeOAuthState, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
3
3
  const authorizationEndpoint = "https://oauth.yandex.com/authorize";
4
4
  const tokenEndpoint = "https://oauth.yandex.com/token";
5
5
  const userEndpoint = "https://login.yandex.ru/info?format=json";
@@ -8,7 +8,7 @@ const defaultScopes = ["login:info", "login:email", "login:avatar"];
8
8
  export class Yandex {
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 Yandex {
36
36
  const auth = requireAuthConfig(this.auth);
37
37
  const state = generateOAuthState();
38
38
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
39
- await saveOAuthState(auth.store, state, {});
40
- return url;
39
+ const payload = {};
40
+ return { url, state, payload };
41
41
  }
42
- async getUser(query) {
43
- const auth = requireAuthConfig(this.auth);
42
+ async getUser(query, saved) {
43
+ requireAuthConfig(this.auth);
44
44
  const { code, state } = parseCallbackQuery(query);
45
- await consumeOAuthState(auth.store, state);
45
+ resolveOAuthState(state, saved);
46
46
  const tokens = await this.validateAuthorizationCode(code);
47
47
  const accessToken = tokens.accessToken();
48
48
  // Yandex expects the "OAuth" scheme instead of "Bearer".
@@ -61,7 +61,8 @@ export class Yandex {
61
61
  profileString(profile.login),
62
62
  email: profileString(profile.default_email),
63
63
  image,
64
- raw: profile
64
+ raw: profile,
65
+ ...extractOAuthTokens(tokens)
65
66
  };
66
67
  }
67
68
  }
@@ -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 ZoomOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Zoom {
6
6
  private client;
7
7
  private auth;
8
- constructor(options: ZoomOptions);
8
+ constructor(options?: ZoomOptions);
9
9
  constructor(clientId: string, clientSecret: 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
  revokeToken(token: string): Promise<void>;
14
- getAuthorizationURL(scopes?: string[]): Promise<URL>;
15
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
14
+ getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
15
+ getUser(query: OAuthCallbackQuery, saved: SavedOAuthState): Promise<OAuthUser>;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import { OAuth2Client, CodeChallengeMethod } from "../client.js";
2
- import { consumeOAuthState, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthCodeVerifier, generateOAuthState, InvalidOAuthCallbackError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes } from "../auth.js";
3
3
  const authorizationEndpoint = "https://zoom.us/oauth/authorize";
4
4
  const tokenEndpoint = "https://zoom.us/oauth/token";
5
5
  const tokenRevocationEndpoint = "https://zoom.us/oauth/revoke";
@@ -9,7 +9,7 @@ const defaultScopes = ["user:read:user"];
9
9
  export class Zoom {
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,13 @@ export class Zoom {
41
41
  const state = generateOAuthState();
42
42
  const codeVerifier = generateOAuthCodeVerifier();
43
43
  const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
44
- await saveOAuthState(auth.store, state, { codeVerifier });
45
- return url;
44
+ const payload = { codeVerifier };
45
+ return { url, state, payload };
46
46
  }
47
- async getUser(query) {
48
- const auth = requireAuthConfig(this.auth);
47
+ async getUser(query, saved) {
48
+ requireAuthConfig(this.auth);
49
49
  const { code, state } = parseCallbackQuery(query);
50
- const stored = await consumeOAuthState(auth.store, state);
50
+ const stored = resolveOAuthState(state, saved);
51
51
  if (typeof stored.codeVerifier !== "string") {
52
52
  throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
53
53
  }
@@ -61,7 +61,8 @@ export class Zoom {
61
61
  name: profileString(profile.display_name) ?? (fullName !== "" ? fullName : null),
62
62
  email: profileString(profile.email),
63
63
  image: profileString(profile.pic_url),
64
- raw: profile
64
+ raw: profile,
65
+ ...extractOAuthTokens(tokens)
65
66
  };
66
67
  }
67
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antarctic",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "High-level OAuth 2.0 clients for popular providers, forked from Arctic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,7 @@
20
20
  "pilcrowOnPaper (author of Arctic, which Antarctic is a fork of)"
21
21
  ],
22
22
  "license": "MIT",
23
+ "homepage": "https://antarcticjs.dev",
23
24
  "repository": {
24
25
  "type": "git",
25
26
  "url": "git+https://github.com/franciscop/antarctic.git"
package/readme.md DELETED
@@ -1,155 +0,0 @@
1
- # Antarctic
2
-
3
- Antarctic is a fork of [Arctic](https://arcticjs.dev) by [pilcrowOnPaper](https://github.com/pilcrowOnPaper), adding a high level auth layer on top of its OAuth 2.0 clients. Only the authorization code flow is supported. Built on top of the Fetch API, it's light weight, fully-typed, and runtime-agnostic.
4
-
5
- All of the OAuth 2.0 clients and provider coverage are Arctic's work. If you only need those, use [Arctic](https://arcticjs.dev) directly. See [credits](#credits).
6
-
7
- ```
8
- npm install antarctic
9
- ```
10
-
11
- ## High-level API
12
-
13
- Construct a provider with an options object and get two methods that handle the whole flow: `getAuthorizationURL()` and `getUser()`. State and PKCE values are generated for you and kept in a [polystore](https://polystore.dev) compatible key-value store.
14
-
15
- ```ts
16
- import * as auth from "antarctic";
17
- import kv from "polystore";
18
-
19
- const store = kv(new Map());
20
- const scopes = ["read:user", "user:email"];
21
-
22
- const github = new auth.GitHub({ store, scopes });
23
-
24
- // Redirect the user here to sign in.
25
- const url = await github.getAuthorizationURL();
26
-
27
- // In the OAuth callback route:
28
- const user = await github.getUser(request.url);
29
- // { id: "1", name: "The Octocat", email: "octocat@github.com", image: "https://..." }
30
- ```
31
-
32
- `getUser()` accepts the callback query as a full URL, a query string, a `URLSearchParams`, or a plain object. It validates the `state`, exchanges the code (with PKCE where the provider supports it), fetches the profile, deletes the consumed state, and returns a normalized user: `{ id, name, email, image }`.
33
-
34
- Options resolve as `explicit > environment > provider default`. Every option except `store` can come from the environment, named after the provider:
35
-
36
- ```
37
- GITHUB_CLIENT_ID
38
- GITHUB_CLIENT_SECRET
39
- GITHUB_REDIRECT_URI
40
- GITHUB_SCOPES
41
-
42
- GOOGLE_CLIENT_ID
43
- ...
44
- ```
45
-
46
- `GITHUB_SCOPES` takes a list separated by commas, whitespace, or both. Scopes resolve as `argument > constructor > environment > provider default`, where the provider default is the minimal set that yields a full profile:
47
-
48
- ```ts
49
- await github.getAuthorizationURL(["repo"]); // overrides the constructor and the environment
50
- ```
51
-
52
- The environment is read when the provider is constructed, so load your `.env` file first. See the [documentation](https://documentation.page/github/franciscop/antarctic/) for the details.
53
-
54
- Errors thrown by the high-level layer: `InvalidOAuthStateError`, `InvalidOAuthCallbackError`, `OAuthConfigurationError`, and `OAuthProviderError`.
55
-
56
- Sessions, cookies, and your user database remain your responsibility: take the returned user and plug it into your framework of choice.
57
-
58
- ## Low-level API
59
-
60
- Arctic's low level API remains available on the same objects, including the positional constructors. It is unchanged except that PKCE providers build the URL asynchronously, so `createAuthorizationURL()` returns a promise for them:
61
-
62
- ```ts
63
- import * as arctic from "antarctic";
64
-
65
- const github = new arctic.GitHub(clientId, clientSecret, redirectURI);
66
-
67
- const state = arctic.generateState();
68
- const scopes = ["user:email"];
69
- const authorizationURL = github.createAuthorizationURL(state, scopes);
70
-
71
- // ...
72
-
73
- const tokens = await github.validateAuthorizationCode(code);
74
- const accessToken = tokens.accessToken();
75
- ```
76
-
77
- > Antarctic only supports providers that follow the OAuth 2.0 spec (including PKCE and token revocation).
78
-
79
- ## Credits
80
-
81
- Antarctic is a fork of [Arctic](https://github.com/pilcrowonpaper/arctic), created and maintained by [pilcrowOnPaper](https://github.com/pilcrowOnPaper). The OAuth 2.0 clients, the provider implementations, the docs those pages grew from, and the design that makes all of it consistent are their work. Antarctic adds one layer on top: `getAuthorizationURL()`, `getUser()`, and the option resolution around them.
82
-
83
- Arctic is MIT licensed. Antarctic keeps that license and the original copyright notice, and adds its own for the new work. See [LICENSE](./LICENSE).
84
-
85
- If you only need the OAuth 2.0 clients without the high level layer, use [Arctic](https://arcticjs.dev) directly. Please report provider issues that are not specific to Antarctic's additions upstream, where they benefit everyone.
86
-
87
- ## Semver
88
-
89
- Antarctic does not strictly follow semantic versioning. While we aim to only introduce breaking changes in major versions, we may introduce them in a minor update if a provider updates their API in a non-backward compatible way. However, they will never be introduced in a patch update.
90
-
91
- ## Supported providers
92
-
93
- - 42 School
94
- - Amazon Cognito
95
- - AniList
96
- - Apple
97
- - Atlassian
98
- - Auth0
99
- - Authentik
100
- - Autodesk Platform Services
101
- - Battle.net
102
- - Bitbucket
103
- - Box
104
- - Bungie
105
- - Coinbase
106
- - Discord
107
- - DonationAlerts
108
- - Dribbble
109
- - Dropbox
110
- - Etsy
111
- - Epic Games
112
- - Facebook
113
- - Figma
114
- - Gitea
115
- - GitHub
116
- - GitLab
117
- - Google
118
- - Intuit
119
- - Kakao
120
- - KeyCloak
121
- - Kick
122
- - Lichess
123
- - Line
124
- - Linear
125
- - LinkedIn
126
- - Mastodon
127
- - MercadoLibre
128
- - MercadoPago
129
- - Microsoft Entra ID
130
- - MyAnimeList
131
- - Naver
132
- - Notion
133
- - Okta
134
- - osu!
135
- - Patreon
136
- - Polar
137
- - Reddit
138
- - Roblox
139
- - Salesforce
140
- - Shikimori
141
- - Slack
142
- - Spotify
143
- - Start.gg
144
- - Strava
145
- - Synology
146
- - TikTok
147
- - Tiltify
148
- - Tumblr
149
- - Twitch
150
- - Twitter
151
- - VK
152
- - WorkOS
153
- - Yahoo
154
- - Yandex
155
- - Zoom