antarctic 0.4.0 → 0.6.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 (131) hide show
  1. package/dist/auth.d.ts +20 -0
  2. package/dist/auth.js +20 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/providers/42.d.ts +3 -3
  5. package/dist/providers/42.js +9 -6
  6. package/dist/providers/amazon-cognito.d.ts +3 -3
  7. package/dist/providers/amazon-cognito.js +9 -6
  8. package/dist/providers/anilist.d.ts +3 -3
  9. package/dist/providers/anilist.js +9 -6
  10. package/dist/providers/apple.d.ts +3 -3
  11. package/dist/providers/apple.js +9 -6
  12. package/dist/providers/atlassian.d.ts +3 -3
  13. package/dist/providers/atlassian.js +9 -6
  14. package/dist/providers/auth0.d.ts +3 -3
  15. package/dist/providers/auth0.js +9 -6
  16. package/dist/providers/authentik.d.ts +3 -3
  17. package/dist/providers/authentik.js +9 -6
  18. package/dist/providers/autodesk.d.ts +3 -3
  19. package/dist/providers/autodesk.js +9 -6
  20. package/dist/providers/battlenet.d.ts +3 -3
  21. package/dist/providers/battlenet.js +9 -6
  22. package/dist/providers/bitbucket.d.ts +3 -3
  23. package/dist/providers/bitbucket.js +9 -6
  24. package/dist/providers/box.d.ts +3 -3
  25. package/dist/providers/box.js +9 -6
  26. package/dist/providers/bungie.d.ts +3 -3
  27. package/dist/providers/bungie.js +9 -6
  28. package/dist/providers/coinbase.d.ts +3 -3
  29. package/dist/providers/coinbase.js +9 -6
  30. package/dist/providers/discord.d.ts +3 -3
  31. package/dist/providers/discord.js +9 -6
  32. package/dist/providers/donation-alerts.d.ts +3 -3
  33. package/dist/providers/donation-alerts.js +9 -6
  34. package/dist/providers/dribbble.d.ts +3 -3
  35. package/dist/providers/dribbble.js +9 -6
  36. package/dist/providers/dropbox.d.ts +3 -3
  37. package/dist/providers/dropbox.js +9 -6
  38. package/dist/providers/epicgames.d.ts +3 -3
  39. package/dist/providers/epicgames.js +9 -6
  40. package/dist/providers/etsy.d.ts +3 -3
  41. package/dist/providers/etsy.js +9 -6
  42. package/dist/providers/facebook.d.ts +3 -3
  43. package/dist/providers/facebook.js +9 -6
  44. package/dist/providers/figma.d.ts +3 -3
  45. package/dist/providers/figma.js +9 -6
  46. package/dist/providers/gitea.d.ts +3 -3
  47. package/dist/providers/gitea.js +9 -6
  48. package/dist/providers/github.d.ts +3 -3
  49. package/dist/providers/github.js +9 -6
  50. package/dist/providers/gitlab.d.ts +3 -3
  51. package/dist/providers/gitlab.js +9 -6
  52. package/dist/providers/google.d.ts +3 -3
  53. package/dist/providers/google.js +9 -6
  54. package/dist/providers/intuit.d.ts +3 -3
  55. package/dist/providers/intuit.js +9 -6
  56. package/dist/providers/kakao.d.ts +3 -3
  57. package/dist/providers/kakao.js +9 -6
  58. package/dist/providers/keycloak.d.ts +3 -3
  59. package/dist/providers/keycloak.js +9 -6
  60. package/dist/providers/kick.d.ts +3 -3
  61. package/dist/providers/kick.js +9 -6
  62. package/dist/providers/lichess.d.ts +3 -3
  63. package/dist/providers/lichess.js +9 -6
  64. package/dist/providers/line.d.ts +3 -3
  65. package/dist/providers/line.js +9 -6
  66. package/dist/providers/linear.d.ts +3 -3
  67. package/dist/providers/linear.js +9 -6
  68. package/dist/providers/linkedin.d.ts +3 -3
  69. package/dist/providers/linkedin.js +9 -6
  70. package/dist/providers/mastodon.d.ts +3 -3
  71. package/dist/providers/mastodon.js +9 -6
  72. package/dist/providers/mercadolibre.d.ts +3 -3
  73. package/dist/providers/mercadolibre.js +9 -6
  74. package/dist/providers/mercadopago.d.ts +3 -3
  75. package/dist/providers/mercadopago.js +9 -6
  76. package/dist/providers/microsoft-entra-id.d.ts +3 -3
  77. package/dist/providers/microsoft-entra-id.js +9 -6
  78. package/dist/providers/myanimelist.d.ts +3 -3
  79. package/dist/providers/myanimelist.js +9 -6
  80. package/dist/providers/naver.d.ts +3 -3
  81. package/dist/providers/naver.js +9 -6
  82. package/dist/providers/notion.d.ts +3 -3
  83. package/dist/providers/notion.js +9 -6
  84. package/dist/providers/okta.d.ts +3 -3
  85. package/dist/providers/okta.js +9 -6
  86. package/dist/providers/osu.d.ts +3 -3
  87. package/dist/providers/osu.js +9 -6
  88. package/dist/providers/patreon.d.ts +3 -3
  89. package/dist/providers/patreon.js +9 -6
  90. package/dist/providers/polar.d.ts +3 -3
  91. package/dist/providers/polar.js +9 -6
  92. package/dist/providers/reddit.d.ts +3 -3
  93. package/dist/providers/reddit.js +9 -6
  94. package/dist/providers/roblox.d.ts +3 -3
  95. package/dist/providers/roblox.js +9 -6
  96. package/dist/providers/salesforce.d.ts +3 -3
  97. package/dist/providers/salesforce.js +9 -6
  98. package/dist/providers/shikimori.d.ts +3 -3
  99. package/dist/providers/shikimori.js +9 -6
  100. package/dist/providers/slack.d.ts +3 -3
  101. package/dist/providers/slack.js +9 -6
  102. package/dist/providers/spotify.d.ts +3 -3
  103. package/dist/providers/spotify.js +9 -6
  104. package/dist/providers/startgg.d.ts +3 -3
  105. package/dist/providers/startgg.js +9 -6
  106. package/dist/providers/strava.d.ts +3 -3
  107. package/dist/providers/strava.js +9 -6
  108. package/dist/providers/tiktok.d.ts +3 -3
  109. package/dist/providers/tiktok.js +9 -6
  110. package/dist/providers/tiltify.d.ts +3 -3
  111. package/dist/providers/tiltify.js +9 -6
  112. package/dist/providers/tumblr.d.ts +3 -3
  113. package/dist/providers/tumblr.js +9 -6
  114. package/dist/providers/twitch.d.ts +3 -3
  115. package/dist/providers/twitch.js +9 -6
  116. package/dist/providers/twitter.d.ts +3 -3
  117. package/dist/providers/twitter.js +9 -6
  118. package/dist/providers/vk.d.ts +3 -3
  119. package/dist/providers/vk.js +9 -6
  120. package/dist/providers/withings.d.ts +3 -3
  121. package/dist/providers/withings.js +9 -6
  122. package/dist/providers/workos.d.ts +3 -3
  123. package/dist/providers/workos.js +9 -6
  124. package/dist/providers/yahoo.d.ts +3 -3
  125. package/dist/providers/yahoo.js +9 -6
  126. package/dist/providers/yandex.d.ts +3 -3
  127. package/dist/providers/yandex.js +9 -6
  128. package/dist/providers/zoom.d.ts +3 -3
  129. package/dist/providers/zoom.js +9 -6
  130. package/package.json +1 -1
  131. package/readme.md +12 -2
@@ -1,5 +1,5 @@
1
1
  import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } from "../request.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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://account.box.com/api/oauth2/authorize";
4
4
  const tokenEndpoint = "https://api.box.com/oauth2/token";
5
5
  const tokenRevocationEndpoint = "https://api.box.com/oauth2/revoke";
@@ -71,20 +71,23 @@ export class Box {
71
71
  const auth = requireAuthConfig(this.auth);
72
72
  const state = generateOAuthState();
73
73
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
74
- await saveOAuthState(auth.store, state, {});
75
- return url;
74
+ const payload = {};
75
+ await saveOAuthState(auth.store, state, payload);
76
+ return { url, state, payload };
76
77
  }
77
- async getUser(query) {
78
+ async getUser(query, saved) {
78
79
  const auth = requireAuthConfig(this.auth);
79
80
  const { code, state } = parseCallbackQuery(query);
80
- await consumeOAuthState(auth.store, state);
81
+ await resolveOAuthState(auth.store, state, saved);
81
82
  const tokens = await this.validateAuthorizationCode(code);
82
83
  const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
83
84
  return {
84
85
  id: profileId(profile.id),
85
86
  name: profileString(profile.name),
86
87
  email: profileString(profile.login),
87
- image: profileString(profile.avatar_url)
88
+ image: profileString(profile.avatar_url),
89
+ raw: profile,
90
+ ...extractOAuthTokens(tokens)
88
91
  };
89
92
  }
90
93
  }
@@ -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 BungieOptions extends ProviderOptions {
4
4
  apiKey?: string;
5
5
  }
@@ -12,6 +12,6 @@ export declare class Bungie {
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<URL>;
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 { OAuth2Client } from "../client.js";
2
- import { consumeOAuthState, fetchUserProfile, generateOAuthState, OAuthConfigurationError, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveProviderOption, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthConfigurationError, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveProviderOption, resolveScopes, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.bungie.net/en/oauth/authorize";
4
4
  const tokenEndpoint = "https://www.bungie.net/platform/app/oauth/token";
5
5
  const userEndpoint = "https://www.bungie.net/platform/User/GetCurrentBungieNetUser/";
@@ -36,16 +36,17 @@ export class Bungie {
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
+ await saveOAuthState(auth.store, state, payload);
41
+ return { url, state, payload };
41
42
  }
42
- async getUser(query) {
43
+ async getUser(query, saved) {
43
44
  const auth = requireAuthConfig(this.auth);
44
45
  if (this.apiKey === null) {
45
46
  throw new OAuthConfigurationError("Missing 'apiKey': pass it in the constructor options or set BUNGIE_API_KEY");
46
47
  }
47
48
  const { code, state } = parseCallbackQuery(query);
48
- await consumeOAuthState(auth.store, state);
49
+ await resolveOAuthState(auth.store, state, saved);
49
50
  const tokens = await this.validateAuthorizationCode(code);
50
51
  const body = await fetchUserProfile(userEndpoint, tokens.accessToken(), {
51
52
  "X-API-Key": this.apiKey
@@ -66,7 +67,9 @@ export class Bungie {
66
67
  id: profileId(user.membershipId),
67
68
  name: profileString(user.cachedBungieGlobalDisplayName) ?? profileString(user.displayName),
68
69
  email: null,
69
- image
70
+ image,
71
+ raw: user,
72
+ ...extractOAuthTokens(tokens)
70
73
  };
71
74
  }
72
75
  }
@@ -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 CoinbaseOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Coinbase {
@@ -13,6 +13,6 @@ export declare class Coinbase {
13
13
  validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
14
14
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
15
15
  revokeToken(token: string): Promise<void>;
16
- getAuthorizationURL(scopes?: string[]): Promise<URL>;
17
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
16
+ getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
17
+ getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
18
18
  }
@@ -1,5 +1,5 @@
1
1
  import { createOAuth2Request, sendTokenRequest, sendTokenRevocationRequest } from "../request.js";
2
- import { consumeOAuthState, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.coinbase.com/oauth/authorize";
4
4
  const tokenEndpoint = "https://www.coinbase.com/oauth/token";
5
5
  const tokenRevocationEndpoint = "https://api.coinbase.com/oauth/revoke";
@@ -71,13 +71,14 @@ export class Coinbase {
71
71
  const auth = requireAuthConfig(this.auth);
72
72
  const state = generateOAuthState();
73
73
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
74
- await saveOAuthState(auth.store, state, {});
75
- return url;
74
+ const payload = {};
75
+ await saveOAuthState(auth.store, state, payload);
76
+ return { url, state, payload };
76
77
  }
77
- async getUser(query) {
78
+ async getUser(query, saved) {
78
79
  const auth = requireAuthConfig(this.auth);
79
80
  const { code, state } = parseCallbackQuery(query);
80
- await consumeOAuthState(auth.store, state);
81
+ await resolveOAuthState(auth.store, state, saved);
81
82
  const tokens = await this.validateAuthorizationCode(code);
82
83
  const body = await fetchUserProfile(userEndpoint, tokens.accessToken());
83
84
  const profile = body.data;
@@ -89,7 +90,9 @@ export class Coinbase {
89
90
  id: profileId(user.id),
90
91
  name: profileString(user.name) ?? profileString(user.username),
91
92
  email: profileString(user.email),
92
- image: profileString(user.avatar_url)
93
+ image: profileString(user.avatar_url),
94
+ raw: user,
95
+ ...extractOAuthTokens(tokens)
93
96
  };
94
97
  }
95
98
  }
@@ -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 DiscordOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Discord {
@@ -11,6 +11,6 @@ export declare class Discord {
11
11
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
12
12
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
13
13
  revokeToken(token: string): Promise<void>;
14
- 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 { CodeChallengeMethod, OAuth2Client } 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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://discord.com/oauth2/authorize";
4
4
  const tokenEndpoint = "https://discord.com/api/oauth2/token";
5
5
  const tokenRevocationEndpoint = "https://discord.com/api/oauth2/token/revoke";
@@ -44,13 +44,14 @@ export class Discord {
44
44
  const state = generateOAuthState();
45
45
  const codeVerifier = generateOAuthCodeVerifier();
46
46
  const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
47
- await saveOAuthState(auth.store, state, { codeVerifier });
48
- return url;
47
+ const payload = { codeVerifier };
48
+ await saveOAuthState(auth.store, state, payload);
49
+ return { url, state, payload };
49
50
  }
50
- async getUser(query) {
51
+ async getUser(query, saved) {
51
52
  const auth = requireAuthConfig(this.auth);
52
53
  const { code, state } = parseCallbackQuery(query);
53
- const stored = await consumeOAuthState(auth.store, state);
54
+ const stored = await resolveOAuthState(auth.store, state, saved);
54
55
  if (typeof stored.codeVerifier !== "string") {
55
56
  throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
56
57
  }
@@ -62,7 +63,9 @@ export class Discord {
62
63
  id,
63
64
  name: profileString(profile.global_name) ?? profileString(profile.username),
64
65
  email: profileString(profile.email),
65
- image: avatar === null ? null : `https://cdn.discordapp.com/avatars/${id}/${avatar}.png`
66
+ image: avatar === null ? null : `https://cdn.discordapp.com/avatars/${id}/${avatar}.png`,
67
+ raw: profile,
68
+ ...extractOAuthTokens(tokens)
66
69
  };
67
70
  }
68
71
  }
@@ -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 DonationAlertsOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class DonationAlerts {
@@ -12,6 +12,6 @@ export declare class DonationAlerts {
12
12
  createAuthorizationURL(scopes: string[]): URL;
13
13
  validateAuthorizationCode(code: string): Promise<OAuth2Tokens>;
14
14
  refreshAccessToken(refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
15
- getAuthorizationURL(scopes?: string[]): Promise<URL>;
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 { consumeOAuthState, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, fetchUserProfile, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.donationalerts.com/oauth/authorize";
4
4
  const tokenEndpoint = "https://www.donationalerts.com/oauth/token";
5
5
  const userEndpoint = "https://www.donationalerts.com/api/v1/user/oauth";
@@ -62,13 +62,14 @@ export class DonationAlerts {
62
62
  const url = this.createAuthorizationURL(resolveScopes(scopes, auth, defaultScopes));
63
63
  // The legacy URL builder does not take a state parameter.
64
64
  url.searchParams.set("state", state);
65
- await saveOAuthState(auth.store, state, {});
66
- return url;
65
+ const payload = {};
66
+ await saveOAuthState(auth.store, state, payload);
67
+ return { url, state, payload };
67
68
  }
68
- async getUser(query) {
69
+ async getUser(query, saved) {
69
70
  const auth = requireAuthConfig(this.auth);
70
71
  const { code, state } = parseCallbackQuery(query);
71
- await consumeOAuthState(auth.store, state);
72
+ await resolveOAuthState(auth.store, state, saved);
72
73
  const tokens = await this.validateAuthorizationCode(code);
73
74
  const body = await fetchUserProfile(userEndpoint, tokens.accessToken());
74
75
  const profile = body.data;
@@ -80,7 +81,9 @@ export class DonationAlerts {
80
81
  id: profileId(user.id),
81
82
  name: profileString(user.name) ?? profileString(user.code),
82
83
  email: profileString(user.email),
83
- image: profileString(user.avatar)
84
+ image: profileString(user.avatar),
85
+ raw: user,
86
+ ...extractOAuthTokens(tokens)
84
87
  };
85
88
  }
86
89
  }
@@ -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 DribbbleOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Dribbble {
@@ -11,6 +11,6 @@ export declare class Dribbble {
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
- 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 { createOAuth2Request, sendTokenRequest } from "../request.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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://dribbble.com/oauth/authorize";
4
4
  const tokenEndpoint = "https://dribbble.com/oauth/token";
5
5
  const userEndpoint = "https://api.dribbble.com/v2/user";
@@ -53,13 +53,14 @@ export class Dribbble {
53
53
  const auth = requireAuthConfig(this.auth);
54
54
  const state = generateOAuthState();
55
55
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
56
- await saveOAuthState(auth.store, state, {});
57
- return url;
56
+ const payload = {};
57
+ await saveOAuthState(auth.store, state, payload);
58
+ return { url, state, payload };
58
59
  }
59
- async getUser(query) {
60
+ async getUser(query, saved) {
60
61
  const auth = requireAuthConfig(this.auth);
61
62
  const { code, state } = parseCallbackQuery(query);
62
- await consumeOAuthState(auth.store, state);
63
+ await resolveOAuthState(auth.store, state, saved);
63
64
  const tokens = await this.validateAuthorizationCode(code);
64
65
  const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
65
66
  return {
@@ -67,7 +68,9 @@ export class Dribbble {
67
68
  name: profileString(profile.name) ?? profileString(profile.login),
68
69
  // The v2 user endpoint does not expose an email address.
69
70
  email: null,
70
- image: profileString(profile.avatar_url)
71
+ image: profileString(profile.avatar_url),
72
+ raw: profile,
73
+ ...extractOAuthTokens(tokens)
71
74
  };
72
75
  }
73
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 DropboxOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Dropbox {
@@ -11,6 +11,6 @@ export declare class Dropbox {
11
11
  validateAuthorizationCode(code: 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 } from "../client.js";
2
- import { consumeOAuthState, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
2
+ import { extractOAuthTokens, generateOAuthState, OAuthProviderError, parseCallbackQuery, profileId, profileString, requireAuthConfig, resolveAuthConfig, resolveOAuthState, resolveScopes, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.dropbox.com/oauth2/authorize";
4
4
  const tokenEndpoint = "https://api.dropboxapi.com/oauth2/token";
5
5
  const tokenRevocationEndpoint = "https://api.dropboxapi.com/2/auth/token/revoke";
@@ -40,13 +40,14 @@ export class Dropbox {
40
40
  const auth = requireAuthConfig(this.auth);
41
41
  const state = generateOAuthState();
42
42
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
43
- await saveOAuthState(auth.store, state, {});
44
- return url;
43
+ const payload = {};
44
+ await saveOAuthState(auth.store, state, payload);
45
+ return { url, state, payload };
45
46
  }
46
- async getUser(query) {
47
+ async getUser(query, saved) {
47
48
  const auth = requireAuthConfig(this.auth);
48
49
  const { code, state } = parseCallbackQuery(query);
49
- await consumeOAuthState(auth.store, state);
50
+ await resolveOAuthState(auth.store, state, saved);
50
51
  const tokens = await this.validateAuthorizationCode(code);
51
52
  const profile = await fetchCurrentAccount(tokens.accessToken());
52
53
  let name = null;
@@ -57,7 +58,9 @@ export class Dropbox {
57
58
  id: profileId(profile.account_id),
58
59
  name,
59
60
  email: profileString(profile.email),
60
- image: profileString(profile.profile_photo_url)
61
+ image: profileString(profile.profile_photo_url),
62
+ raw: profile,
63
+ ...extractOAuthTokens(tokens)
61
64
  };
62
65
  }
63
66
  }
@@ -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 EpicGamesOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class EpicGames {
@@ -11,6 +11,6 @@ export declare class EpicGames {
11
11
  validateAuthorizationCode(code: 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 } 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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.epicgames.com/id/authorize";
4
4
  const tokenEndpoint = "https://api.epicgames.dev/epic/oauth/v2/token";
5
5
  const tokenRevocationEndpoint = "https://api.epicgames.dev/epic/oauth/v2/revoke";
@@ -40,13 +40,14 @@ export class EpicGames {
40
40
  const auth = requireAuthConfig(this.auth);
41
41
  const state = generateOAuthState();
42
42
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
43
- await saveOAuthState(auth.store, state, {});
44
- return url;
43
+ const payload = {};
44
+ await saveOAuthState(auth.store, state, payload);
45
+ return { url, state, payload };
45
46
  }
46
- async getUser(query) {
47
+ async getUser(query, saved) {
47
48
  const auth = requireAuthConfig(this.auth);
48
49
  const { code, state } = parseCallbackQuery(query);
49
- await consumeOAuthState(auth.store, state);
50
+ await resolveOAuthState(auth.store, state, saved);
50
51
  const tokens = await this.validateAuthorizationCode(code);
51
52
  const claims = await fetchUserProfile(userinfoEndpoint, tokens.accessToken());
52
53
  return {
@@ -54,7 +55,9 @@ export class EpicGames {
54
55
  name: profileString(claims.preferred_username),
55
56
  // Epic Games does not expose user emails or avatars.
56
57
  email: null,
57
- image: null
58
+ image: null,
59
+ raw: claims,
60
+ ...extractOAuthTokens(tokens)
58
61
  };
59
62
  }
60
63
  }
@@ -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 EtsyOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Etsy {
@@ -10,6 +10,6 @@ export declare class Etsy {
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
- 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 { CodeChallengeMethod, OAuth2Client } 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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.etsy.com/oauth/connect";
4
4
  const tokenEndpoint = "https://api.etsy.com/v3/public/oauth/token";
5
5
  const meEndpoint = "https://openapi.etsy.com/v3/application/users/me";
@@ -35,13 +35,14 @@ export class Etsy {
35
35
  const state = generateOAuthState();
36
36
  const codeVerifier = generateOAuthCodeVerifier();
37
37
  const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
38
- await saveOAuthState(auth.store, state, { codeVerifier });
39
- return url;
38
+ const payload = { codeVerifier };
39
+ await saveOAuthState(auth.store, state, payload);
40
+ return { url, state, payload };
40
41
  }
41
- async getUser(query) {
42
+ async getUser(query, saved) {
42
43
  const auth = requireAuthConfig(this.auth);
43
44
  const { code, state } = parseCallbackQuery(query);
44
- const stored = await consumeOAuthState(auth.store, state);
45
+ const stored = await resolveOAuthState(auth.store, state, saved);
45
46
  if (typeof stored.codeVerifier !== "string") {
46
47
  throw new InvalidOAuthCallbackError("Missing PKCE code verifier for OAuth state");
47
48
  }
@@ -62,7 +63,9 @@ export class Etsy {
62
63
  id: userId,
63
64
  name,
64
65
  email: profileString(profile.primary_email),
65
- image: profileString(profile.image_url_75x75)
66
+ image: profileString(profile.image_url_75x75),
67
+ raw: profile,
68
+ ...extractOAuthTokens(tokens)
66
69
  };
67
70
  }
68
71
  }
@@ -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 FacebookOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Facebook {
@@ -11,6 +11,6 @@ export declare class Facebook {
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
- 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 { createOAuth2Request, sendTokenRequest } from "../request.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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.facebook.com/v16.0/dialog/oauth";
4
4
  const tokenEndpoint = "https://graph.facebook.com/v16.0/oauth/access_token";
5
5
  const userEndpoint = "https://graph.facebook.com/v16.0/me";
@@ -52,13 +52,14 @@ export class Facebook {
52
52
  const auth = requireAuthConfig(this.auth);
53
53
  const state = generateOAuthState();
54
54
  const url = this.createAuthorizationURL(state, resolveScopes(scopes, auth, defaultScopes));
55
- await saveOAuthState(auth.store, state, {});
56
- return url;
55
+ const payload = {};
56
+ await saveOAuthState(auth.store, state, payload);
57
+ return { url, state, payload };
57
58
  }
58
- async getUser(query) {
59
+ async getUser(query, saved) {
59
60
  const auth = requireAuthConfig(this.auth);
60
61
  const { code, state } = parseCallbackQuery(query);
61
- await consumeOAuthState(auth.store, state);
62
+ await resolveOAuthState(auth.store, state, saved);
62
63
  const tokens = await this.validateAuthorizationCode(code);
63
64
  const url = new URL(userEndpoint);
64
65
  url.searchParams.set("fields", "id,name,email,picture.width(256)");
@@ -74,7 +75,9 @@ export class Facebook {
74
75
  id: profileId(profile.id),
75
76
  name: profileString(profile.name),
76
77
  email: profileString(profile.email),
77
- image
78
+ image,
79
+ raw: profile,
80
+ ...extractOAuthTokens(tokens)
78
81
  };
79
82
  }
80
83
  }
@@ -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 FigmaOptions extends ProviderOptions {
4
4
  }
5
5
  export declare class Figma {
@@ -10,6 +10,6 @@ export declare class Figma {
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, saveOAuthState } from "../auth.js";
3
3
  const authorizationEndpoint = "https://www.figma.com/oauth";
4
4
  const tokenEndpoint = "https://api.figma.com/v1/oauth/token";
5
5
  const refreshEndpoint = "https://api.figma.com/v1/oauth/refresh";
@@ -37,20 +37,23 @@ export class Figma {
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
+ await saveOAuthState(auth.store, state, payload);
42
+ return { url, state, payload };
42
43
  }
43
- async getUser(query) {
44
+ async getUser(query, saved) {
44
45
  const auth = requireAuthConfig(this.auth);
45
46
  const { code, state } = parseCallbackQuery(query);
46
- await consumeOAuthState(auth.store, state);
47
+ await resolveOAuthState(auth.store, state, saved);
47
48
  const tokens = await this.validateAuthorizationCode(code);
48
49
  const profile = await fetchUserProfile(userEndpoint, tokens.accessToken());
49
50
  return {
50
51
  id: profileId(profile.id),
51
52
  name: profileString(profile.handle),
52
53
  email: profileString(profile.email),
53
- image: profileString(profile.img_url)
54
+ image: profileString(profile.img_url),
55
+ raw: profile,
56
+ ...extractOAuthTokens(tokens)
54
57
  };
55
58
  }
56
59
  }
@@ -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 GiteaOptions extends ProviderOptions {
4
4
  baseURL?: string;
5
5
  }
@@ -14,6 +14,6 @@ export declare class Gitea {
14
14
  createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
15
15
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
16
16
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
17
- getAuthorizationURL(scopes?: string[]): Promise<URL>;
18
- getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
17
+ getAuthorizationURL(scopes?: string[]): Promise<AuthorizationRequest>;
18
+ getUser(query: OAuthCallbackQuery, saved?: SavedOAuthState): Promise<OAuthUser>;
19
19
  }