antarctic 0.2.0 → 0.4.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 (67) hide show
  1. package/dist/client.d.ts +1 -1
  2. package/dist/client.js +2 -2
  3. package/dist/encoding.d.ts +3 -0
  4. package/dist/encoding.js +39 -0
  5. package/dist/jwt.d.ts +3 -0
  6. package/dist/jwt.js +38 -0
  7. package/dist/oauth2.d.ts +1 -1
  8. package/dist/oauth2.js +7 -7
  9. package/dist/oidc.js +2 -2
  10. package/dist/providers/amazon-cognito.d.ts +1 -1
  11. package/dist/providers/amazon-cognito.js +3 -3
  12. package/dist/providers/apple.js +3 -3
  13. package/dist/providers/auth0.d.ts +1 -1
  14. package/dist/providers/auth0.js +3 -3
  15. package/dist/providers/authentik.d.ts +1 -1
  16. package/dist/providers/authentik.js +3 -3
  17. package/dist/providers/autodesk.d.ts +1 -1
  18. package/dist/providers/autodesk.js +3 -3
  19. package/dist/providers/discord.d.ts +1 -1
  20. package/dist/providers/discord.js +3 -3
  21. package/dist/providers/etsy.d.ts +1 -1
  22. package/dist/providers/etsy.js +3 -3
  23. package/dist/providers/gitea.d.ts +1 -1
  24. package/dist/providers/gitea.js +3 -3
  25. package/dist/providers/google.d.ts +1 -1
  26. package/dist/providers/google.js +3 -3
  27. package/dist/providers/keycloak.d.ts +1 -1
  28. package/dist/providers/keycloak.js +3 -3
  29. package/dist/providers/kick.d.ts +1 -1
  30. package/dist/providers/kick.js +3 -3
  31. package/dist/providers/lichess.d.ts +1 -1
  32. package/dist/providers/lichess.js +3 -3
  33. package/dist/providers/line.d.ts +1 -1
  34. package/dist/providers/line.js +3 -3
  35. package/dist/providers/mastodon.d.ts +1 -1
  36. package/dist/providers/mastodon.js +3 -3
  37. package/dist/providers/mercadolibre.d.ts +1 -1
  38. package/dist/providers/mercadolibre.js +3 -3
  39. package/dist/providers/mercadopago.d.ts +1 -1
  40. package/dist/providers/mercadopago.js +3 -3
  41. package/dist/providers/microsoft-entra-id.d.ts +1 -1
  42. package/dist/providers/microsoft-entra-id.js +3 -3
  43. package/dist/providers/myanimelist.d.ts +1 -1
  44. package/dist/providers/myanimelist.js +3 -3
  45. package/dist/providers/okta.d.ts +1 -1
  46. package/dist/providers/okta.js +3 -3
  47. package/dist/providers/polar.d.ts +1 -1
  48. package/dist/providers/polar.js +3 -3
  49. package/dist/providers/roblox.d.ts +1 -1
  50. package/dist/providers/roblox.js +3 -3
  51. package/dist/providers/salesforce.d.ts +1 -1
  52. package/dist/providers/salesforce.js +3 -3
  53. package/dist/providers/spotify.d.ts +1 -1
  54. package/dist/providers/spotify.js +3 -3
  55. package/dist/providers/synology.d.ts +1 -1
  56. package/dist/providers/synology.js +2 -2
  57. package/dist/providers/tiktok.d.ts +1 -1
  58. package/dist/providers/tiktok.js +3 -3
  59. package/dist/providers/twitter.d.ts +1 -1
  60. package/dist/providers/twitter.js +3 -3
  61. package/dist/providers/workos.d.ts +1 -1
  62. package/dist/providers/workos.js +3 -3
  63. package/dist/providers/zoom.d.ts +1 -1
  64. package/dist/providers/zoom.js +3 -3
  65. package/dist/request.js +2 -2
  66. package/package.json +1 -6
  67. package/{README.md → readme.md} +1 -1
package/dist/client.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare class OAuth2Client {
5
5
  private redirectURI;
6
6
  constructor(clientId: string, clientPassword: string | null, redirectURI: string | null);
7
7
  createAuthorizationURL(authorizationEndpoint: string, state: string, scopes: string[]): URL;
8
- createAuthorizationURLWithPKCE(authorizationEndpoint: string, state: string, codeChallengeMethod: CodeChallengeMethod, codeVerifier: string, scopes: string[]): URL;
8
+ createAuthorizationURLWithPKCE(authorizationEndpoint: string, state: string, codeChallengeMethod: CodeChallengeMethod, codeVerifier: string, scopes: string[]): Promise<URL>;
9
9
  validateAuthorizationCode(tokenEndpoint: string, code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
10
10
  refreshAccessToken(tokenEndpoint: string, refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
11
11
  revokeToken(tokenRevocationEndpoint: string, token: string): Promise<void>;
package/dist/client.js CHANGED
@@ -23,7 +23,7 @@ export class OAuth2Client {
23
23
  }
24
24
  return url;
25
25
  }
26
- createAuthorizationURLWithPKCE(authorizationEndpoint, state, codeChallengeMethod, codeVerifier, scopes) {
26
+ async createAuthorizationURLWithPKCE(authorizationEndpoint, state, codeChallengeMethod, codeVerifier, scopes) {
27
27
  const url = new URL(authorizationEndpoint);
28
28
  url.searchParams.set("response_type", "code");
29
29
  url.searchParams.set("client_id", this.clientId);
@@ -32,7 +32,7 @@ export class OAuth2Client {
32
32
  }
33
33
  url.searchParams.set("state", state);
34
34
  if (codeChallengeMethod === CodeChallengeMethod.S256) {
35
- const codeChallenge = createS256CodeChallenge(codeVerifier);
35
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
36
36
  url.searchParams.set("code_challenge_method", "S256");
37
37
  url.searchParams.set("code_challenge", codeChallenge);
38
38
  }
@@ -0,0 +1,3 @@
1
+ export declare function encodeBase64(bytes: Uint8Array): string;
2
+ export declare function encodeBase64urlNoPadding(bytes: Uint8Array): string;
3
+ export declare function decodeBase64urlIgnorePadding(encoded: string): Uint8Array;
@@ -0,0 +1,39 @@
1
+ const base64urlAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2
+ function encodeBinaryString(bytes) {
3
+ let binary = "";
4
+ // Chunked to stay well under the argument limit for large inputs.
5
+ for (let i = 0; i < bytes.length; i += 0x8000) {
6
+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
7
+ }
8
+ return binary;
9
+ }
10
+ export function encodeBase64(bytes) {
11
+ return btoa(encodeBinaryString(bytes));
12
+ }
13
+ export function encodeBase64urlNoPadding(bytes) {
14
+ let result = "";
15
+ for (let i = 0; i < bytes.length; i += 3) {
16
+ let buffer = 0;
17
+ let bits = 0;
18
+ for (let j = 0; j < 3 && i + j < bytes.length; j++) {
19
+ buffer = (buffer << 8) | bytes[i + j];
20
+ bits += 8;
21
+ }
22
+ for (let j = 0; j < 4 && bits > 0; j++) {
23
+ bits -= 6;
24
+ const index = bits >= 0 ? (buffer >> bits) & 0x3f : (buffer << -bits) & 0x3f;
25
+ result += base64urlAlphabet[index];
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ export function decodeBase64urlIgnorePadding(encoded) {
31
+ const normalized = encoded.replaceAll("-", "+").replaceAll("_", "/").replaceAll("=", "");
32
+ const padded = normalized + "=".repeat((4 - (normalized.length % 4)) % 4);
33
+ const binary = atob(padded);
34
+ const bytes = new Uint8Array(binary.length);
35
+ for (let i = 0; i < binary.length; i++) {
36
+ bytes[i] = binary.charCodeAt(i);
37
+ }
38
+ return bytes;
39
+ }
package/dist/jwt.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare function decodeJWT(jwt: string): object;
2
+ export declare function createJWTSignatureMessage(headerJSON: string, payloadJSON: string): Uint8Array;
3
+ export declare function encodeJWT(headerJSON: string, payloadJSON: string, signature: Uint8Array): string;
package/dist/jwt.js ADDED
@@ -0,0 +1,38 @@
1
+ import { decodeBase64urlIgnorePadding, encodeBase64urlNoPadding } from "./encoding.js";
2
+ export function decodeJWT(jwt) {
3
+ const parts = jwt.split(".");
4
+ if (parts.length !== 3) {
5
+ throw new Error("Invalid JWT");
6
+ }
7
+ let jsonPayload;
8
+ try {
9
+ jsonPayload = new TextDecoder().decode(decodeBase64urlIgnorePadding(parts[1]));
10
+ }
11
+ catch {
12
+ throw new Error("Invalid JWT: Invalid base64url encoding");
13
+ }
14
+ let payload;
15
+ try {
16
+ payload = JSON.parse(jsonPayload);
17
+ }
18
+ catch {
19
+ throw new Error("Invalid JWT: Invalid JSON encoding");
20
+ }
21
+ if (typeof payload !== "object" || payload === null) {
22
+ throw new Error("Invalid JWT: Invalid payload");
23
+ }
24
+ return payload;
25
+ }
26
+ export function createJWTSignatureMessage(headerJSON, payloadJSON) {
27
+ const encoder = new TextEncoder();
28
+ const encodedHeader = encodeBase64urlNoPadding(encoder.encode(headerJSON));
29
+ const encodedPayload = encodeBase64urlNoPadding(encoder.encode(payloadJSON));
30
+ return encoder.encode(encodedHeader + "." + encodedPayload);
31
+ }
32
+ export function encodeJWT(headerJSON, payloadJSON, signature) {
33
+ const encoder = new TextEncoder();
34
+ const encodedHeader = encodeBase64urlNoPadding(encoder.encode(headerJSON));
35
+ const encodedPayload = encodeBase64urlNoPadding(encoder.encode(payloadJSON));
36
+ const encodedSignature = encodeBase64urlNoPadding(signature);
37
+ return encodedHeader + "." + encodedPayload + "." + encodedSignature;
38
+ }
package/dist/oauth2.d.ts CHANGED
@@ -11,6 +11,6 @@ export declare class OAuth2Tokens {
11
11
  scopes(): string[];
12
12
  idToken(): string;
13
13
  }
14
- export declare function createS256CodeChallenge(codeVerifier: string): string;
14
+ export declare function createS256CodeChallenge(codeVerifier: string): Promise<string>;
15
15
  export declare function generateCodeVerifier(): string;
16
16
  export declare function generateState(): string;
package/dist/oauth2.js CHANGED
@@ -1,5 +1,4 @@
1
- import * as encoding from "@oslojs/encoding";
2
- import * as sha2 from "@oslojs/crypto/sha2";
1
+ import { encodeBase64urlNoPadding } from "./encoding.js";
3
2
  export class OAuth2Tokens {
4
3
  data;
5
4
  constructor(data) {
@@ -51,17 +50,18 @@ export class OAuth2Tokens {
51
50
  throw new Error("Missing or invalid field 'id_token'");
52
51
  }
53
52
  }
54
- export function createS256CodeChallenge(codeVerifier) {
55
- const codeChallengeBytes = sha2.sha256(new TextEncoder().encode(codeVerifier));
56
- return encoding.encodeBase64urlNoPadding(codeChallengeBytes);
53
+ export async function createS256CodeChallenge(codeVerifier) {
54
+ const data = new TextEncoder().encode(codeVerifier);
55
+ const digest = await crypto.subtle.digest("SHA-256", data);
56
+ return encodeBase64urlNoPadding(new Uint8Array(digest));
57
57
  }
58
58
  export function generateCodeVerifier() {
59
59
  const randomValues = new Uint8Array(32);
60
60
  crypto.getRandomValues(randomValues);
61
- return encoding.encodeBase64urlNoPadding(randomValues);
61
+ return encodeBase64urlNoPadding(randomValues);
62
62
  }
63
63
  export function generateState() {
64
64
  const randomValues = new Uint8Array(32);
65
65
  crypto.getRandomValues(randomValues);
66
- return encoding.encodeBase64urlNoPadding(randomValues);
66
+ return encodeBase64urlNoPadding(randomValues);
67
67
  }
package/dist/oidc.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as jwt from "@oslojs/jwt";
1
+ import { decodeJWT } from "./jwt.js";
2
2
  export function decodeIdToken(idToken) {
3
3
  try {
4
- return jwt.decodeJWT(idToken);
4
+ return decodeJWT(idToken);
5
5
  }
6
6
  catch (e) {
7
7
  throw new Error("Invalid ID token", {
@@ -12,7 +12,7 @@ export declare class AmazonCognito {
12
12
  private auth;
13
13
  constructor(options: AmazonCognitoOptions);
14
14
  constructor(domain: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
15
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
16
16
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
17
17
  refreshAccessToken(refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
18
18
  revokeToken(token: string): Promise<void>;
@@ -26,8 +26,8 @@ export class AmazonCognito {
26
26
  this.tokenRevocationEndpoint = `https://${domain}/oauth2/revoke`;
27
27
  this.userinfoEndpoint = `https://${domain}/oauth2/userInfo`;
28
28
  }
29
- createAuthorizationURL(state, codeVerifier, scopes) {
30
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
29
+ async createAuthorizationURL(state, codeVerifier, scopes) {
30
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
31
31
  return url;
32
32
  }
33
33
  async validateAuthorizationCode(code, codeVerifier) {
@@ -45,7 +45,7 @@ export class AmazonCognito {
45
45
  const auth = requireAuthConfig(this.auth);
46
46
  const state = generateOAuthState();
47
47
  const codeVerifier = generateOAuthCodeVerifier();
48
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
48
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
49
49
  await saveOAuthState(auth.store, state, { codeVerifier });
50
50
  return url;
51
51
  }
@@ -1,4 +1,4 @@
1
- import * as jwt from "@oslojs/jwt";
1
+ import { createJWTSignatureMessage, encodeJWT } from "../jwt.js";
2
2
  import { createOAuth2Request, sendTokenRequest } from "../request.js";
3
3
  import { decodeIdToken } from "../oidc.js";
4
4
  import { consumeOAuthState, generateOAuthState, parseCallbackQuery, profileId, profileString, requireAuthConfig, requireProviderOption, resolveAuthConfig, resolveScopes, saveOAuthState } from "../auth.js";
@@ -99,8 +99,8 @@ export class Apple {
99
99
  const signature = new Uint8Array(await crypto.subtle.sign({
100
100
  name: "ECDSA",
101
101
  hash: "SHA-256"
102
- }, privateKey, jwt.createJWTSignatureMessage(headerJSON, payloadJSON)));
103
- const token = jwt.encodeJWT(headerJSON, payloadJSON, signature);
102
+ }, privateKey, createJWTSignatureMessage(headerJSON, payloadJSON)));
103
+ const token = encodeJWT(headerJSON, payloadJSON, signature);
104
104
  return token;
105
105
  }
106
106
  }
@@ -12,7 +12,7 @@ export declare class Auth0 {
12
12
  private auth;
13
13
  constructor(options: Auth0Options);
14
14
  constructor(domain: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): URL;
15
+ createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): Promise<URL>;
16
16
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
17
17
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
18
18
  revokeToken(token: string): Promise<void>;
@@ -26,10 +26,10 @@ export class Auth0 {
26
26
  this.tokenRevocationEndpoint = `https://${domain}/oauth/revoke`;
27
27
  this.userinfoEndpoint = `https://${domain}/userinfo`;
28
28
  }
29
- createAuthorizationURL(state, codeVerifier, scopes) {
29
+ async createAuthorizationURL(state, codeVerifier, scopes) {
30
30
  let url;
31
31
  if (codeVerifier !== null) {
32
- url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
32
+ url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
33
33
  }
34
34
  else {
35
35
  url = this.client.createAuthorizationURL(this.authorizationEndpoint, state, scopes);
@@ -51,7 +51,7 @@ export class Auth0 {
51
51
  const auth = requireAuthConfig(this.auth);
52
52
  const state = generateOAuthState();
53
53
  const codeVerifier = generateOAuthCodeVerifier();
54
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
54
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
55
55
  await saveOAuthState(auth.store, state, { codeVerifier });
56
56
  return url;
57
57
  }
@@ -12,7 +12,7 @@ export declare class Authentik {
12
12
  private auth;
13
13
  constructor(options: AuthentikOptions);
14
14
  constructor(baseURL: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -27,8 +27,8 @@ export class Authentik {
27
27
  this.tokenRevocationEndpoint = joinURIAndPath(baseURL, "/application/o/revoke/");
28
28
  this.userinfoEndpoint = joinURIAndPath(baseURL, "/application/o/userinfo/");
29
29
  }
30
- createAuthorizationURL(state, codeVerifier, scopes) {
31
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
30
+ async createAuthorizationURL(state, codeVerifier, scopes) {
31
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
32
32
  return url;
33
33
  }
34
34
  async validateAuthorizationCode(code, codeVerifier) {
@@ -46,7 +46,7 @@ export class Authentik {
46
46
  const auth = requireAuthConfig(this.auth);
47
47
  const state = generateOAuthState();
48
48
  const codeVerifier = generateOAuthCodeVerifier();
49
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
49
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
50
50
  await saveOAuthState(auth.store, state, { codeVerifier });
51
51
  return url;
52
52
  }
@@ -7,7 +7,7 @@ export declare class Autodesk {
7
7
  private auth;
8
8
  constructor(options: AutodeskOptions);
9
9
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -18,8 +18,8 @@ export class Autodesk {
18
18
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
19
19
  }
20
20
  }
21
- createAuthorizationURL(state, codeVerifier, scopes) {
22
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
21
+ async createAuthorizationURL(state, codeVerifier, scopes) {
22
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
23
23
  return url;
24
24
  }
25
25
  async validateAuthorizationCode(code, codeVerifier) {
@@ -37,7 +37,7 @@ export class Autodesk {
37
37
  const auth = requireAuthConfig(this.auth);
38
38
  const state = generateOAuthState();
39
39
  const codeVerifier = generateOAuthCodeVerifier();
40
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
40
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
41
41
  await saveOAuthState(auth.store, state, { codeVerifier });
42
42
  return url;
43
43
  }
@@ -7,7 +7,7 @@ export declare class Discord {
7
7
  private auth;
8
8
  constructor(options: DiscordOptions);
9
9
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): URL;
10
+ createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): Promise<URL>;
11
11
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
12
12
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
13
13
  revokeToken(token: string): Promise<void>;
@@ -18,10 +18,10 @@ export class Discord {
18
18
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
19
19
  }
20
20
  }
21
- createAuthorizationURL(state, codeVerifier, scopes) {
21
+ async createAuthorizationURL(state, codeVerifier, scopes) {
22
22
  let url;
23
23
  if (codeVerifier !== null) {
24
- url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
24
+ url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
25
25
  }
26
26
  else {
27
27
  url = this.client.createAuthorizationURL(authorizationEndpoint, state, scopes);
@@ -43,7 +43,7 @@ export class Discord {
43
43
  const auth = requireAuthConfig(this.auth);
44
44
  const state = generateOAuthState();
45
45
  const codeVerifier = generateOAuthCodeVerifier();
46
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
46
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
47
47
  await saveOAuthState(auth.store, state, { codeVerifier });
48
48
  return url;
49
49
  }
@@ -7,7 +7,7 @@ export declare class Etsy {
7
7
  private auth;
8
8
  constructor(options: EtsyOptions);
9
9
  constructor(clientId: string, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
10
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
11
11
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
12
12
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
13
13
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -18,8 +18,8 @@ export class Etsy {
18
18
  this.client = new OAuth2Client(clientIdOrOptions, null, redirectURI ?? null);
19
19
  }
20
20
  }
21
- createAuthorizationURL(state, codeVerifier, scopes) {
22
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
21
+ async createAuthorizationURL(state, codeVerifier, scopes) {
22
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
23
23
  return url;
24
24
  }
25
25
  async validateAuthorizationCode(code, codeVerifier) {
@@ -34,7 +34,7 @@ export class Etsy {
34
34
  const auth = requireAuthConfig(this.auth);
35
35
  const state = generateOAuthState();
36
36
  const codeVerifier = generateOAuthCodeVerifier();
37
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
37
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
38
38
  await saveOAuthState(auth.store, state, { codeVerifier });
39
39
  return url;
40
40
  }
@@ -11,7 +11,7 @@ export declare class Gitea {
11
11
  private auth;
12
12
  constructor(options: GiteaOptions);
13
13
  constructor(baseURL: string, clientId: string, clientSecret: string | null, redirectURI: string);
14
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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
17
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -22,8 +22,8 @@ export class Gitea {
22
22
  this.authorizationEndpoint = joinURIAndPath(this.baseURL, "/login/oauth/authorize");
23
23
  this.tokenEndpoint = joinURIAndPath(this.baseURL, "/login/oauth/access_token");
24
24
  }
25
- createAuthorizationURL(state, codeVerifier, scopes) {
26
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
25
+ async createAuthorizationURL(state, codeVerifier, scopes) {
26
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
27
27
  return url;
28
28
  }
29
29
  async validateAuthorizationCode(code, codeVerifier) {
@@ -38,7 +38,7 @@ export class Gitea {
38
38
  const auth = requireAuthConfig(this.auth);
39
39
  const state = generateOAuthState();
40
40
  const codeVerifier = generateOAuthCodeVerifier();
41
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
41
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
42
42
  await saveOAuthState(auth.store, state, { codeVerifier });
43
43
  return url;
44
44
  }
@@ -7,7 +7,7 @@ export declare class Google {
7
7
  private auth;
8
8
  constructor(options: GoogleOptions);
9
9
  constructor(clientId: string, clientSecret: string, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -22,8 +22,8 @@ export class Google {
22
22
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
23
23
  }
24
24
  }
25
- createAuthorizationURL(state, codeVerifier, scopes) {
26
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
25
+ async createAuthorizationURL(state, codeVerifier, scopes) {
26
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
27
27
  return url;
28
28
  }
29
29
  async validateAuthorizationCode(code, codeVerifier) {
@@ -41,7 +41,7 @@ export class Google {
41
41
  const auth = requireAuthConfig(this.auth);
42
42
  const state = generateOAuthState();
43
43
  const codeVerifier = generateOAuthCodeVerifier();
44
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
44
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
45
45
  await saveOAuthState(auth.store, state, { codeVerifier });
46
46
  return url;
47
47
  }
@@ -12,7 +12,7 @@ export declare class KeyCloak {
12
12
  private auth;
13
13
  constructor(options: KeyCloakOptions);
14
14
  constructor(realmURL: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -26,8 +26,8 @@ export class KeyCloak {
26
26
  this.tokenRevocationEndpoint = realmURL + "/protocol/openid-connect/revoke";
27
27
  this.userinfoEndpoint = realmURL + "/protocol/openid-connect/userinfo";
28
28
  }
29
- createAuthorizationURL(state, codeVerifier, scopes) {
30
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
29
+ async createAuthorizationURL(state, codeVerifier, scopes) {
30
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
31
31
  return url;
32
32
  }
33
33
  async validateAuthorizationCode(code, codeVerifier) {
@@ -45,7 +45,7 @@ export class KeyCloak {
45
45
  const auth = requireAuthConfig(this.auth);
46
46
  const state = generateOAuthState();
47
47
  const codeVerifier = generateOAuthCodeVerifier();
48
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
48
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
49
49
  await saveOAuthState(auth.store, state, { codeVerifier });
50
50
  return url;
51
51
  }
@@ -9,7 +9,7 @@ export declare class Kick {
9
9
  private auth;
10
10
  constructor(options: KickOptions);
11
11
  constructor(clientId: string, clientSecret: string, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -28,7 +28,7 @@ export class Kick {
28
28
  this.redirectURI = redirectURI ?? "";
29
29
  }
30
30
  }
31
- createAuthorizationURL(state, codeVerifier, scopes) {
31
+ async createAuthorizationURL(state, codeVerifier, scopes) {
32
32
  const url = new URL(authorizationEndpoint);
33
33
  url.searchParams.set("client_id", this.clientId);
34
34
  url.searchParams.set("response_type", "code");
@@ -37,7 +37,7 @@ export class Kick {
37
37
  if (scopes.length > 0) {
38
38
  url.searchParams.set("scope", scopes.join(" "));
39
39
  }
40
- const codeChallenge = createS256CodeChallenge(codeVerifier);
40
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
41
41
  url.searchParams.set("code_challenge", codeChallenge);
42
42
  url.searchParams.set("code_challenge_method", "S256");
43
43
  return url;
@@ -74,7 +74,7 @@ export class Kick {
74
74
  const auth = requireAuthConfig(this.auth);
75
75
  const state = generateOAuthState();
76
76
  const codeVerifier = generateOAuthCodeVerifier();
77
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
77
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
78
78
  await saveOAuthState(auth.store, state, { codeVerifier });
79
79
  return url;
80
80
  }
@@ -7,7 +7,7 @@ export declare class Lichess {
7
7
  private auth;
8
8
  constructor(options: LichessOptions);
9
9
  constructor(clientId: string, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
10
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
11
11
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
12
12
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
13
13
  getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
@@ -18,8 +18,8 @@ export class Lichess {
18
18
  this.client = new OAuth2Client(clientIdOrOptions, null, redirectURI ?? null);
19
19
  }
20
20
  }
21
- createAuthorizationURL(state, codeVerifier, scopes) {
22
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
21
+ async createAuthorizationURL(state, codeVerifier, scopes) {
22
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
23
23
  return url;
24
24
  }
25
25
  async validateAuthorizationCode(code, codeVerifier) {
@@ -30,7 +30,7 @@ export class Lichess {
30
30
  const auth = requireAuthConfig(this.auth);
31
31
  const state = generateOAuthState();
32
32
  const codeVerifier = generateOAuthCodeVerifier();
33
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
33
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
34
34
  await saveOAuthState(auth.store, state, { codeVerifier });
35
35
  return url;
36
36
  }
@@ -9,7 +9,7 @@ export declare class Line {
9
9
  private auth;
10
10
  constructor(options: LineOptions);
11
11
  constructor(clientId: string, clientSecret: string, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -28,7 +28,7 @@ export class Line {
28
28
  this.redirectURI = redirectURI ?? "";
29
29
  }
30
30
  }
31
- createAuthorizationURL(state, codeVerifier, scopes) {
31
+ async createAuthorizationURL(state, codeVerifier, scopes) {
32
32
  const url = new URL(authorizationEndpoint);
33
33
  url.searchParams.set("response_type", "code");
34
34
  url.searchParams.set("client_id", this.clientId);
@@ -37,7 +37,7 @@ export class Line {
37
37
  url.searchParams.set("scope", scopes.join(" "));
38
38
  }
39
39
  url.searchParams.set("redirect_uri", this.redirectURI);
40
- const codeChallenge = createS256CodeChallenge(codeVerifier);
40
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
41
41
  url.searchParams.set("code_challenge_method", "S256");
42
42
  url.searchParams.set("code_challenge", codeChallenge);
43
43
  return url;
@@ -68,7 +68,7 @@ export class Line {
68
68
  const auth = requireAuthConfig(this.auth);
69
69
  const state = generateOAuthState();
70
70
  const codeVerifier = generateOAuthCodeVerifier();
71
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
71
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
72
72
  await saveOAuthState(auth.store, state, { codeVerifier });
73
73
  return url;
74
74
  }
@@ -12,7 +12,7 @@ export declare class Mastodon {
12
12
  private auth;
13
13
  constructor(options: MastodonOptions);
14
14
  constructor(baseURL: string, clientId: string, clientSecret: string, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
15
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
16
16
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
17
17
  revokeToken(token: string): Promise<void>;
18
18
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -29,8 +29,8 @@ export class Mastodon {
29
29
  this.tokenRevocationEndpoint = joinURIAndPath(baseURL, "/api/v1/oauth/revoke");
30
30
  this.userEndpoint = joinURIAndPath(baseURL, "/api/v1/accounts/verify_credentials");
31
31
  }
32
- createAuthorizationURL(state, codeVerifier, scopes) {
33
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
32
+ async createAuthorizationURL(state, codeVerifier, scopes) {
33
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
34
34
  return url;
35
35
  }
36
36
  async validateAuthorizationCode(code, codeVerifier) {
@@ -44,7 +44,7 @@ export class Mastodon {
44
44
  const auth = requireAuthConfig(this.auth);
45
45
  const state = generateOAuthState();
46
46
  const codeVerifier = generateOAuthCodeVerifier();
47
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
47
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
48
48
  await saveOAuthState(auth.store, state, { codeVerifier });
49
49
  return url;
50
50
  }
@@ -9,7 +9,7 @@ export declare class MercadoLibre {
9
9
  private auth;
10
10
  constructor(options: MercadoLibreOptions);
11
11
  constructor(clientId: string, clientSecret: string, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string): URL;
12
+ createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
13
13
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
14
14
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
15
15
  getAuthorizationURL(_scopes?: string[]): Promise<URL>;
@@ -27,13 +27,13 @@ export class MercadoLibre {
27
27
  }
28
28
  }
29
29
  // `scopes` not required since they are defined in the application settings
30
- createAuthorizationURL(state, codeVerifier) {
30
+ async createAuthorizationURL(state, codeVerifier) {
31
31
  const url = new URL(authorizationEndpoint);
32
32
  url.searchParams.set("response_type", "code");
33
33
  url.searchParams.set("client_id", this.clientId);
34
34
  url.searchParams.set("redirect_uri", this.redirectURI);
35
35
  url.searchParams.set("state", state);
36
- const codeChallenge = createS256CodeChallenge(codeVerifier);
36
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
37
37
  url.searchParams.set("code_challenge_method", "S256");
38
38
  url.searchParams.set("code_challenge", codeChallenge);
39
39
  return url;
@@ -65,7 +65,7 @@ export class MercadoLibre {
65
65
  const auth = requireAuthConfig(this.auth);
66
66
  const state = generateOAuthState();
67
67
  const codeVerifier = generateOAuthCodeVerifier();
68
- const url = this.createAuthorizationURL(state, codeVerifier);
68
+ const url = await this.createAuthorizationURL(state, codeVerifier);
69
69
  await saveOAuthState(auth.store, state, { codeVerifier });
70
70
  return url;
71
71
  }
@@ -9,7 +9,7 @@ export declare class MercadoPago {
9
9
  private auth;
10
10
  constructor(options: MercadoPagoOptions);
11
11
  constructor(clientId: string, clientSecret: string, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string): URL;
12
+ createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
13
13
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
14
14
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
15
15
  getAuthorizationURL(_scopes?: string[]): Promise<URL>;
@@ -27,13 +27,13 @@ export class MercadoPago {
27
27
  }
28
28
  }
29
29
  // `scopes` not required since they are defined in the application settings
30
- createAuthorizationURL(state, codeVerifier) {
30
+ async createAuthorizationURL(state, codeVerifier) {
31
31
  const url = new URL(authorizationEndpoint);
32
32
  url.searchParams.set("response_type", "code");
33
33
  url.searchParams.set("client_id", this.clientId);
34
34
  url.searchParams.set("redirect_uri", this.redirectURI);
35
35
  url.searchParams.set("state", state);
36
- const codeChallenge = createS256CodeChallenge(codeVerifier);
36
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
37
37
  url.searchParams.set("code_challenge_method", "S256");
38
38
  url.searchParams.set("code_challenge", codeChallenge);
39
39
  return url;
@@ -65,7 +65,7 @@ export class MercadoPago {
65
65
  const auth = requireAuthConfig(this.auth);
66
66
  const state = generateOAuthState();
67
67
  const codeVerifier = generateOAuthCodeVerifier();
68
- const url = this.createAuthorizationURL(state, codeVerifier);
68
+ const url = await this.createAuthorizationURL(state, codeVerifier);
69
69
  await saveOAuthState(auth.store, state, { codeVerifier });
70
70
  return url;
71
71
  }
@@ -12,7 +12,7 @@ export declare class MicrosoftEntraId {
12
12
  private auth;
13
13
  constructor(options: MicrosoftEntraIdOptions);
14
14
  constructor(tenant: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
15
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
16
16
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
17
17
  refreshAccessToken(refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
18
18
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -30,13 +30,13 @@ export class MicrosoftEntraId {
30
30
  this.authorizationEndpoint = joinURIAndPath("https://login.microsoftonline.com", tenant, "/oauth2/v2.0/authorize");
31
31
  this.tokenEndpoint = joinURIAndPath("https://login.microsoftonline.com", tenant, "/oauth2/v2.0/token");
32
32
  }
33
- createAuthorizationURL(state, codeVerifier, scopes) {
33
+ async createAuthorizationURL(state, codeVerifier, scopes) {
34
34
  const url = new URL(this.authorizationEndpoint);
35
35
  url.searchParams.set("response_type", "code");
36
36
  url.searchParams.set("client_id", this.clientId);
37
37
  url.searchParams.set("redirect_uri", this.redirectURI);
38
38
  url.searchParams.set("state", state);
39
- const codeChallenge = createS256CodeChallenge(codeVerifier);
39
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
40
40
  url.searchParams.set("code_challenge_method", "S256");
41
41
  url.searchParams.set("code_challenge", codeChallenge);
42
42
  if (scopes.length > 0) {
@@ -91,7 +91,7 @@ export class MicrosoftEntraId {
91
91
  const auth = requireAuthConfig(this.auth);
92
92
  const state = generateOAuthState();
93
93
  const codeVerifier = generateOAuthCodeVerifier();
94
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
94
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
95
95
  await saveOAuthState(auth.store, state, { codeVerifier });
96
96
  return url;
97
97
  }
@@ -7,7 +7,7 @@ export declare class MyAnimeList {
7
7
  private auth;
8
8
  constructor(options: MyAnimeListOptions);
9
9
  constructor(clientId: string, clientSecret: string, redirectURI: string | null);
10
- createAuthorizationURL(state: string, codeVerifier: string): URL;
10
+ createAuthorizationURL(state: string, codeVerifier: string): Promise<URL>;
11
11
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
12
12
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
13
13
  getAuthorizationURL(_scopes?: string[]): Promise<URL>;
@@ -16,8 +16,8 @@ export class MyAnimeList {
16
16
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
17
17
  }
18
18
  }
19
- createAuthorizationURL(state, codeVerifier) {
20
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.Plain, codeVerifier, []);
19
+ async createAuthorizationURL(state, codeVerifier) {
20
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.Plain, codeVerifier, []);
21
21
  return url;
22
22
  }
23
23
  async validateAuthorizationCode(code, codeVerifier) {
@@ -33,7 +33,7 @@ export class MyAnimeList {
33
33
  const auth = requireAuthConfig(this.auth);
34
34
  const state = generateOAuthState();
35
35
  const codeVerifier = generateOAuthCodeVerifier();
36
- const url = this.createAuthorizationURL(state, codeVerifier);
36
+ const url = await this.createAuthorizationURL(state, codeVerifier);
37
37
  await saveOAuthState(auth.store, state, { codeVerifier });
38
38
  return url;
39
39
  }
@@ -13,7 +13,7 @@ export declare class Okta {
13
13
  private auth;
14
14
  constructor(options: OktaOptions);
15
15
  constructor(domain: string, authorizationServerId: string | null, clientId: string, clientSecret: string, redirectURI: string);
16
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
16
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
17
17
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
18
18
  refreshAccessToken(refreshToken: string, scopes: string[]): Promise<OAuth2Tokens>;
19
19
  revokeToken(token: string): Promise<void>;
@@ -37,8 +37,8 @@ export class Okta {
37
37
  this.tokenRevocationEndpoint = joinURIAndPath(baseURL, "/v1/revoke");
38
38
  this.userinfoEndpoint = joinURIAndPath(baseURL, "/v1/userinfo");
39
39
  }
40
- createAuthorizationURL(state, codeVerifier, scopes) {
41
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
40
+ async createAuthorizationURL(state, codeVerifier, scopes) {
41
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
42
42
  return url;
43
43
  }
44
44
  async validateAuthorizationCode(code, codeVerifier) {
@@ -56,7 +56,7 @@ export class Okta {
56
56
  const auth = requireAuthConfig(this.auth);
57
57
  const state = generateOAuthState();
58
58
  const codeVerifier = generateOAuthCodeVerifier();
59
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
59
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
60
60
  await saveOAuthState(auth.store, state, { codeVerifier });
61
61
  return url;
62
62
  }
@@ -9,7 +9,7 @@ export declare class Polar {
9
9
  private auth;
10
10
  constructor(options: PolarOptions);
11
11
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -26,7 +26,7 @@ export class Polar {
26
26
  this.redirectURI = redirectURI ?? "";
27
27
  }
28
28
  }
29
- createAuthorizationURL(state, codeVerifier, scopes) {
29
+ async createAuthorizationURL(state, codeVerifier, scopes) {
30
30
  const url = new URL(authorizationEndpoint);
31
31
  url.searchParams.set("client_id", this.clientId);
32
32
  url.searchParams.set("response_type", "code");
@@ -35,7 +35,7 @@ export class Polar {
35
35
  if (scopes.length > 0) {
36
36
  url.searchParams.set("scope", scopes.join(" "));
37
37
  }
38
- const codeChallenge = createS256CodeChallenge(codeVerifier);
38
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
39
39
  url.searchParams.set("code_challenge", codeChallenge);
40
40
  url.searchParams.set("code_challenge_method", "S256");
41
41
  return url;
@@ -76,7 +76,7 @@ export class Polar {
76
76
  const auth = requireAuthConfig(this.auth);
77
77
  const state = generateOAuthState();
78
78
  const codeVerifier = generateOAuthCodeVerifier();
79
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
79
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
80
80
  await saveOAuthState(auth.store, state, { codeVerifier });
81
81
  return url;
82
82
  }
@@ -7,7 +7,7 @@ export declare class Roblox {
7
7
  private auth;
8
8
  constructor(options: RobloxOptions);
9
9
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -19,8 +19,8 @@ export class Roblox {
19
19
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
20
20
  }
21
21
  }
22
- createAuthorizationURL(state, codeVerifier, scopes) {
23
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
22
+ async createAuthorizationURL(state, codeVerifier, scopes) {
23
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
24
24
  return url;
25
25
  }
26
26
  async validateAuthorizationCode(code, codeVerifier) {
@@ -38,7 +38,7 @@ export class Roblox {
38
38
  const auth = requireAuthConfig(this.auth);
39
39
  const state = generateOAuthState();
40
40
  const codeVerifier = generateOAuthCodeVerifier();
41
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
41
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
42
42
  await saveOAuthState(auth.store, state, { codeVerifier });
43
43
  return url;
44
44
  }
@@ -12,7 +12,7 @@ export declare class Salesforce {
12
12
  private auth;
13
13
  constructor(options: SalesforceOptions);
14
14
  constructor(domain: string, clientId: string, clientSecret: string | null, redirectURI: string);
15
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -26,8 +26,8 @@ export class Salesforce {
26
26
  this.tokenRevocationEndpoint = `https://${domain}/services/oauth2/revoke`;
27
27
  this.userinfoEndpoint = `https://${domain}/services/oauth2/userinfo`;
28
28
  }
29
- createAuthorizationURL(state, codeVerifier, scopes) {
30
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
29
+ async createAuthorizationURL(state, codeVerifier, scopes) {
30
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
31
31
  return url;
32
32
  }
33
33
  async validateAuthorizationCode(code, codeVerifier) {
@@ -45,7 +45,7 @@ export class Salesforce {
45
45
  const auth = requireAuthConfig(this.auth);
46
46
  const state = generateOAuthState();
47
47
  const codeVerifier = generateOAuthCodeVerifier();
48
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
48
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
49
49
  await saveOAuthState(auth.store, state, { codeVerifier });
50
50
  return url;
51
51
  }
@@ -7,7 +7,7 @@ export declare class Spotify {
7
7
  private auth;
8
8
  constructor(options: SpotifyOptions);
9
9
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): URL;
10
+ createAuthorizationURL(state: string, codeVerifier: string | null, scopes: string[]): Promise<URL>;
11
11
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
12
12
  refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens>;
13
13
  getAuthorizationURL(scopes?: string[]): Promise<URL>;
@@ -17,10 +17,10 @@ export class Spotify {
17
17
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? "");
18
18
  }
19
19
  }
20
- createAuthorizationURL(state, codeVerifier, scopes) {
20
+ async createAuthorizationURL(state, codeVerifier, scopes) {
21
21
  let url;
22
22
  if (codeVerifier !== null) {
23
- url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
23
+ url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
24
24
  }
25
25
  else {
26
26
  url = this.client.createAuthorizationURL(authorizationEndpoint, state, scopes);
@@ -39,7 +39,7 @@ export class Spotify {
39
39
  const auth = requireAuthConfig(this.auth);
40
40
  const state = generateOAuthState();
41
41
  const codeVerifier = generateOAuthCodeVerifier();
42
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
42
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
43
43
  await saveOAuthState(auth.store, state, { codeVerifier });
44
44
  return url;
45
45
  }
@@ -4,6 +4,6 @@ export declare class Synology {
4
4
  private tokenEndpoint;
5
5
  private client;
6
6
  constructor(baseURL: string, applicationId: string, applicationSecret: string, redirectURI: string);
7
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
7
+ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): Promise<URL>;
8
8
  validateAuthorizationCode(code: string, codeVerifier: string): Promise<OAuth2Tokens>;
9
9
  }
@@ -9,8 +9,8 @@ export class Synology {
9
9
  this.tokenEndpoint = joinURIAndPath(baseURL, "/webman/sso/SSOAccessToken.cgi");
10
10
  this.client = new OAuth2Client(applicationId, applicationSecret, redirectURI);
11
11
  }
12
- createAuthorizationURL(state, codeVerifier, scopes) {
13
- const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
12
+ async createAuthorizationURL(state, codeVerifier, scopes) {
13
+ const url = await this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
14
14
  return url;
15
15
  }
16
16
  async validateAuthorizationCode(code, codeVerifier) {
@@ -9,7 +9,7 @@ export declare class TikTok {
9
9
  private auth;
10
10
  constructor(options: TikTokOptions);
11
11
  constructor(clientKey: string, clientSecret: string, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -28,12 +28,12 @@ export class TikTok {
28
28
  this.redirectURI = redirectURI ?? "";
29
29
  }
30
30
  }
31
- createAuthorizationURL(state, codeVerifier, scopes) {
31
+ async createAuthorizationURL(state, codeVerifier, scopes) {
32
32
  const url = new URL(authorizationEndpoint);
33
33
  url.searchParams.set("response_type", "code");
34
34
  url.searchParams.set("client_key", this.clientKey);
35
35
  url.searchParams.set("state", state);
36
- const codeChallenge = createS256CodeChallenge(codeVerifier);
36
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
37
37
  url.searchParams.set("code_challenge_method", "S256");
38
38
  url.searchParams.set("code_challenge", codeChallenge);
39
39
  if (scopes.length > 0) {
@@ -76,7 +76,7 @@ export class TikTok {
76
76
  const auth = requireAuthConfig(this.auth);
77
77
  const state = generateOAuthState();
78
78
  const codeVerifier = generateOAuthCodeVerifier();
79
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
79
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
80
80
  await saveOAuthState(auth.store, state, { codeVerifier });
81
81
  return url;
82
82
  }
@@ -7,7 +7,7 @@ export declare class Twitter {
7
7
  private auth;
8
8
  constructor(options: TwitterOptions);
9
9
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -18,8 +18,8 @@ export class Twitter {
18
18
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? null, redirectURI ?? null);
19
19
  }
20
20
  }
21
- createAuthorizationURL(state, codeVerifier, scopes) {
22
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
21
+ async createAuthorizationURL(state, codeVerifier, scopes) {
22
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
23
23
  return url;
24
24
  }
25
25
  async validateAuthorizationCode(code, codeVerifier) {
@@ -37,7 +37,7 @@ export class Twitter {
37
37
  const auth = requireAuthConfig(this.auth);
38
38
  const state = generateOAuthState();
39
39
  const codeVerifier = generateOAuthCodeVerifier();
40
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
40
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
41
41
  await saveOAuthState(auth.store, state, { codeVerifier });
42
42
  return url;
43
43
  }
@@ -9,7 +9,7 @@ export declare class WorkOS {
9
9
  private auth;
10
10
  constructor(options: WorkOSOptions);
11
11
  constructor(clientId: string, clientSecret: string | null, redirectURI: string);
12
- createAuthorizationURL(state: string, codeVerifier: string | null): URL;
12
+ createAuthorizationURL(state: string, codeVerifier: string | null): Promise<URL>;
13
13
  validateAuthorizationCode(code: string, codeVerifier: string | null): Promise<OAuth2Tokens>;
14
14
  getAuthorizationURL(): Promise<URL>;
15
15
  getUser(query: OAuthCallbackQuery): Promise<OAuthUser>;
@@ -23,14 +23,14 @@ export class WorkOS {
23
23
  this.redirectURI = redirectURI ?? "";
24
24
  }
25
25
  }
26
- createAuthorizationURL(state, codeVerifier) {
26
+ async createAuthorizationURL(state, codeVerifier) {
27
27
  const url = new URL(authorizationEndpoint);
28
28
  url.searchParams.set("response_type", "code");
29
29
  url.searchParams.set("client_id", this.clientId);
30
30
  url.searchParams.set("state", state);
31
31
  url.searchParams.set("redirect_uri", this.redirectURI);
32
32
  if (codeVerifier !== null) {
33
- const codeChallenge = createS256CodeChallenge(codeVerifier);
33
+ const codeChallenge = await createS256CodeChallenge(codeVerifier);
34
34
  url.searchParams.set("code_challenge_method", "S256");
35
35
  url.searchParams.set("code_challenge", codeChallenge);
36
36
  }
@@ -56,7 +56,7 @@ export class WorkOS {
56
56
  const auth = requireAuthConfig(this.auth);
57
57
  const state = generateOAuthState();
58
58
  const codeVerifier = generateOAuthCodeVerifier();
59
- const url = this.createAuthorizationURL(state, codeVerifier);
59
+ const url = await this.createAuthorizationURL(state, codeVerifier);
60
60
  await saveOAuthState(auth.store, state, { codeVerifier });
61
61
  return url;
62
62
  }
@@ -7,7 +7,7 @@ export declare class Zoom {
7
7
  private auth;
8
8
  constructor(options: ZoomOptions);
9
9
  constructor(clientId: string, clientSecret: string, redirectURI: string);
10
- createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;
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>;
@@ -21,8 +21,8 @@ export class Zoom {
21
21
  this.client = new OAuth2Client(clientIdOrOptions, clientSecret ?? "", redirectURI ?? "");
22
22
  }
23
23
  }
24
- createAuthorizationURL(state, codeVerifier, scopes) {
25
- const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
24
+ async createAuthorizationURL(state, codeVerifier, scopes) {
25
+ const url = await this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
26
26
  return url;
27
27
  }
28
28
  async validateAuthorizationCode(code, codeVerifier) {
@@ -40,7 +40,7 @@ export class Zoom {
40
40
  const auth = requireAuthConfig(this.auth);
41
41
  const state = generateOAuthState();
42
42
  const codeVerifier = generateOAuthCodeVerifier();
43
- const url = this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
43
+ const url = await this.createAuthorizationURL(state, codeVerifier, resolveScopes(scopes, auth, defaultScopes));
44
44
  await saveOAuthState(auth.store, state, { codeVerifier });
45
45
  return url;
46
46
  }
package/dist/request.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as encoding from "@oslojs/encoding";
1
+ import { encodeBase64 } from "./encoding.js";
2
2
  import { OAuth2Tokens } from "./oauth2.js";
3
3
  import { trimLeft, trimRight } from "./utils.js";
4
4
  export function joinURIAndPath(base, ...path) {
@@ -24,7 +24,7 @@ export function createOAuth2Request(endpoint, body) {
24
24
  }
25
25
  export function encodeBasicCredentials(username, password) {
26
26
  const bytes = new TextEncoder().encode(`${username}:${password}`);
27
- return encoding.encodeBase64(bytes);
27
+ return encodeBase64(bytes);
28
28
  }
29
29
  export async function sendTokenRequest(request) {
30
30
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antarctic",
3
- "version": "0.2.0",
3
+ "version": "0.4.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",
@@ -33,10 +33,5 @@
33
33
  "prettier": "^3.0.3",
34
34
  "typescript": "^5.2.2",
35
35
  "vitest": "1.6.0"
36
- },
37
- "dependencies": {
38
- "@oslojs/crypto": "1.0.1",
39
- "@oslojs/encoding": "1.1.0",
40
- "@oslojs/jwt": "0.2.0"
41
36
  }
42
37
  }
@@ -57,7 +57,7 @@ Sessions, cookies, and your user database remain your responsibility: take the r
57
57
 
58
58
  ## Low-level API
59
59
 
60
- The original Arctic API is unchanged and remains available on the same objects, including the positional constructors:
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
61
 
62
62
  ```ts
63
63
  import * as arctic from "antarctic";