@aura-stack/auth 0.2.0 → 0.3.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 (76) hide show
  1. package/dist/@types/index.d.ts +3 -2
  2. package/dist/@types/router.d.d.ts +3 -2
  3. package/dist/actions/callback/access-token.cjs +52 -41
  4. package/dist/actions/callback/access-token.d.ts +5 -4
  5. package/dist/actions/callback/access-token.js +3 -2
  6. package/dist/actions/callback/callback.cjs +69 -52
  7. package/dist/actions/callback/callback.d.ts +4 -3
  8. package/dist/actions/callback/callback.js +6 -5
  9. package/dist/actions/callback/userinfo.cjs +54 -43
  10. package/dist/actions/callback/userinfo.d.ts +3 -2
  11. package/dist/actions/callback/userinfo.js +3 -2
  12. package/dist/actions/csrfToken/csrfToken.cjs +2 -2
  13. package/dist/actions/csrfToken/csrfToken.js +2 -2
  14. package/dist/actions/index.cjs +93 -71
  15. package/dist/actions/index.d.ts +3 -2
  16. package/dist/actions/index.js +15 -14
  17. package/dist/actions/session/session.js +2 -2
  18. package/dist/actions/signIn/authorization.cjs +40 -40
  19. package/dist/actions/signIn/authorization.d.ts +3 -2
  20. package/dist/actions/signIn/authorization.js +2 -2
  21. package/dist/actions/signIn/signIn.cjs +63 -50
  22. package/dist/actions/signIn/signIn.d.ts +4 -3
  23. package/dist/actions/signIn/signIn.js +4 -3
  24. package/dist/actions/signOut/signOut.cjs +66 -66
  25. package/dist/actions/signOut/signOut.js +4 -4
  26. package/dist/assert.d.ts +3 -2
  27. package/dist/{chunk-2RXNXMCZ.js → chunk-3EUWD5BB.js} +15 -7
  28. package/dist/{chunk-NEVKX6K2.js → chunk-A3N4PVAT.js} +3 -3
  29. package/dist/chunk-B737EUJV.js +22 -0
  30. package/dist/{chunk-7H3OR6UU.js → chunk-EMKJA2GJ.js} +18 -10
  31. package/dist/{chunk-4V4JNXVF.js → chunk-GA2SMTJO.js} +9 -6
  32. package/dist/chunk-HP34YGGJ.js +22 -0
  33. package/dist/{chunk-QDO2KSRJ.js → chunk-HT4YLL7N.js} +1 -1
  34. package/dist/{chunk-ZLR3LI6X.js → chunk-IVET23KF.js} +7 -4
  35. package/dist/{chunk-PTJUYB33.js → chunk-JVFTCTTE.js} +1 -1
  36. package/dist/{chunk-UEH3LVON.js → chunk-KSWLO5ZU.js} +21 -16
  37. package/dist/{chunk-QEZL7EYN.js → chunk-N4SX7TZT.js} +3 -3
  38. package/dist/{chunk-IMICRJ5U.js → chunk-W6LG7BFW.js} +14 -14
  39. package/dist/{chunk-WD7AUHQ5.js → chunk-YRCB5FLE.js} +8 -8
  40. package/dist/chunk-ZNCZVF6U.js +14 -0
  41. package/dist/cookie.cjs +14 -14
  42. package/dist/cookie.d.ts +3 -2
  43. package/dist/cookie.js +1 -1
  44. package/dist/errors.d.ts +3 -2
  45. package/dist/{index-EqsoyjrF.d.ts → index-DkaLJFn8.d.ts} +57 -8
  46. package/dist/index.cjs +155 -93
  47. package/dist/index.d.ts +4 -3
  48. package/dist/index.js +20 -17
  49. package/dist/jose.cjs +2 -2
  50. package/dist/oauth/bitbucket.d.ts +3 -2
  51. package/dist/oauth/discord.d.ts +3 -2
  52. package/dist/oauth/figma.d.ts +3 -2
  53. package/dist/oauth/github.d.ts +3 -2
  54. package/dist/oauth/gitlab.d.ts +3 -2
  55. package/dist/oauth/index.cjs +85 -41
  56. package/dist/oauth/index.d.ts +3 -2
  57. package/dist/oauth/index.js +16 -8
  58. package/dist/oauth/mailchimp.cjs +46 -0
  59. package/dist/oauth/mailchimp.d.ts +7 -0
  60. package/dist/oauth/mailchimp.js +6 -0
  61. package/dist/oauth/pinterest.cjs +46 -0
  62. package/dist/oauth/pinterest.d.ts +7 -0
  63. package/dist/oauth/pinterest.js +6 -0
  64. package/dist/oauth/spotify.d.ts +3 -2
  65. package/dist/oauth/strava.d.ts +3 -2
  66. package/dist/oauth/x.d.ts +3 -2
  67. package/dist/request.cjs +38 -0
  68. package/dist/request.d.ts +13 -0
  69. package/dist/request.js +6 -0
  70. package/dist/schemas.cjs +40 -40
  71. package/dist/schemas.d.ts +15 -15
  72. package/dist/schemas.js +1 -1
  73. package/dist/secure.cjs +5 -5
  74. package/dist/secure.d.ts +3 -2
  75. package/dist/utils.d.ts +3 -3
  76. package/package.json +6 -4
package/dist/index.cjs CHANGED
@@ -36,6 +36,13 @@ module.exports = __toCommonJS(index_exports);
36
36
  var import_config2 = require("dotenv/config");
37
37
  var import_router7 = require("@aura-stack/router");
38
38
 
39
+ // src/jose.ts
40
+ var import_config = require("dotenv/config");
41
+ var import_jose = require("@aura-stack/jose");
42
+
43
+ // src/secure.ts
44
+ var import_crypto = __toESM(require("crypto"), 1);
45
+
39
46
  // src/utils.ts
40
47
  var import_router = require("@aura-stack/router");
41
48
 
@@ -208,13 +215,6 @@ var formatZodError = (error) => {
208
215
  }, {});
209
216
  };
210
217
 
211
- // src/jose.ts
212
- var import_config = require("dotenv/config");
213
- var import_jose = require("@aura-stack/jose");
214
-
215
- // src/secure.ts
216
- var import_node_crypto = __toESM(require("crypto"), 1);
217
-
218
218
  // src/assert.ts
219
219
  var isValidURL = (value) => {
220
220
  if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
@@ -227,10 +227,10 @@ var isJWTPayloadWithToken = (payload) => {
227
227
 
228
228
  // src/secure.ts
229
229
  var generateSecure = (length = 32) => {
230
- return import_node_crypto.default.randomBytes(length).toString("base64url");
230
+ return import_crypto.default.randomBytes(length).toString("base64url");
231
231
  };
232
232
  var createHash = (data, base = "hex") => {
233
- return import_node_crypto.default.createHash("sha256").update(data).digest().toString(base);
233
+ return import_crypto.default.createHash("sha256").update(data).digest().toString(base);
234
234
  };
235
235
  var createPKCE = async (verifier) => {
236
236
  const codeVerifier = verifier ?? generateSecure(86);
@@ -265,7 +265,7 @@ var verifyCSRF = async (jose, cookie, header) => {
265
265
  if (!equals(headerBuffer.length, cookieBuffer.length)) {
266
266
  throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
267
267
  }
268
- if (!import_node_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
268
+ if (!import_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
269
269
  throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
270
270
  }
271
271
  return true;
@@ -274,7 +274,7 @@ var verifyCSRF = async (jose, cookie, header) => {
274
274
  }
275
275
  };
276
276
  var createDerivedSalt = (secret) => {
277
- return import_node_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
277
+ return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
278
278
  };
279
279
 
280
280
  // src/jose.ts
@@ -404,7 +404,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
404
404
  const hostPrefix = useSecure ? "__Host-" : "";
405
405
  return {
406
406
  sessionToken: {
407
- name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "sessionToken"}`,
407
+ name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "session_token"}`,
408
408
  attributes: defineSecureCookieOptions(
409
409
  useSecure,
410
410
  {
@@ -426,7 +426,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
426
426
  )
427
427
  },
428
428
  csrfToken: {
429
- name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrfToken"}`,
429
+ name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrf_token"}`,
430
430
  attributes: defineSecureCookieOptions(
431
431
  useSecure,
432
432
  {
@@ -436,37 +436,37 @@ var createCookieStore = (useSecure, prefix, overrides) => {
436
436
  overrides?.csrfToken?.attributes?.strategy ?? "host"
437
437
  )
438
438
  },
439
- redirect_to: {
440
- name: `${securePrefix}${prefix}.${overrides?.redirect_to?.name ?? "redirect_to"}`,
439
+ redirectTo: {
440
+ name: `${securePrefix}${prefix}.${overrides?.redirectTo?.name ?? "redirect_to"}`,
441
441
  attributes: defineSecureCookieOptions(
442
442
  useSecure,
443
443
  {
444
444
  ...oauthCookieOptions,
445
- ...overrides?.redirect_to?.attributes
445
+ ...overrides?.redirectTo?.attributes
446
446
  },
447
- overrides?.redirect_to?.attributes?.strategy ?? "secure"
447
+ overrides?.redirectTo?.attributes?.strategy ?? "secure"
448
448
  )
449
449
  },
450
- redirect_uri: {
451
- name: `${securePrefix}${prefix}.${overrides?.redirect_uri?.name ?? "redirect_uri"}`,
450
+ redirectURI: {
451
+ name: `${securePrefix}${prefix}.${overrides?.redirectURI?.name ?? "redirect_uri"}`,
452
452
  attributes: defineSecureCookieOptions(
453
453
  useSecure,
454
454
  {
455
455
  ...oauthCookieOptions,
456
- ...overrides?.redirect_uri?.attributes
456
+ ...overrides?.redirectURI?.attributes
457
457
  },
458
- overrides?.redirect_uri?.attributes?.strategy ?? "secure"
458
+ overrides?.redirectURI?.attributes?.strategy ?? "secure"
459
459
  )
460
460
  },
461
- code_verifier: {
462
- name: `${securePrefix}${prefix}.${overrides?.code_verifier?.name ?? "code_verifier"}`,
461
+ codeVerifier: {
462
+ name: `${securePrefix}${prefix}.${overrides?.codeVerifier?.name ?? "code_verifier"}`,
463
463
  attributes: defineSecureCookieOptions(
464
464
  useSecure,
465
465
  {
466
466
  ...oauthCookieOptions,
467
- ...overrides?.code_verifier?.attributes
467
+ ...overrides?.codeVerifier?.attributes
468
468
  },
469
- overrides?.code_verifier?.attributes?.strategy ?? "secure"
469
+ overrides?.codeVerifier?.attributes?.strategy ?? "secure"
470
470
  )
471
471
  }
472
472
  };
@@ -623,29 +623,67 @@ var strava = {
623
623
  }
624
624
  };
625
625
 
626
+ // src/oauth/mailchimp.ts
627
+ var mailchimp = {
628
+ id: "mailchimp",
629
+ name: "Mailchimp",
630
+ authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
631
+ accessToken: "https://login.mailchimp.com/oauth2/token",
632
+ userInfo: "https://login.mailchimp.com/oauth2/metadata",
633
+ scope: "",
634
+ responseType: "code",
635
+ profile(profile) {
636
+ return {
637
+ sub: profile.user_id,
638
+ name: profile.accountname,
639
+ email: profile.login.login_email,
640
+ image: null
641
+ };
642
+ }
643
+ };
644
+
645
+ // src/oauth/pinterest.ts
646
+ var pinterest = {
647
+ id: "pinterest",
648
+ name: "Pinterest",
649
+ authorizeURL: "https://api.pinterest.com/oauth/",
650
+ accessToken: "https://api.pinterest.com/v5/oauth/token",
651
+ userInfo: "https://api.pinterest.com/v5/user_account",
652
+ scope: "user_accounts:read",
653
+ responseType: "code",
654
+ profile(profile) {
655
+ return {
656
+ sub: profile.id,
657
+ name: profile.username,
658
+ email: null,
659
+ image: profile.profile_image
660
+ };
661
+ }
662
+ };
663
+
626
664
  // src/schemas.ts
627
- var import_v4 = require("zod/v4");
628
- var OAuthProviderConfigSchema = (0, import_v4.object)({
629
- authorizeURL: (0, import_v4.httpUrl)(),
630
- accessToken: (0, import_v4.httpUrl)(),
631
- scope: (0, import_v4.string)().optional(),
632
- userInfo: (0, import_v4.httpUrl)(),
633
- responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
634
- clientId: (0, import_v4.string)(),
635
- clientSecret: (0, import_v4.string)()
665
+ var import_zod = require("zod");
666
+ var OAuthProviderConfigSchema = (0, import_zod.object)({
667
+ authorizeURL: (0, import_zod.string)().url(),
668
+ accessToken: (0, import_zod.string)().url(),
669
+ scope: (0, import_zod.string)().optional(),
670
+ userInfo: (0, import_zod.string)().url(),
671
+ responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
672
+ clientId: (0, import_zod.string)(),
673
+ clientSecret: (0, import_zod.string)()
636
674
  });
637
675
  var OAuthAuthorization = OAuthProviderConfigSchema.extend({
638
- redirectURI: (0, import_v4.string)(),
639
- state: (0, import_v4.string)(),
640
- codeChallenge: (0, import_v4.string)(),
641
- codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
676
+ redirectURI: (0, import_zod.string)(),
677
+ state: (0, import_zod.string)(),
678
+ codeChallenge: (0, import_zod.string)(),
679
+ codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
642
680
  });
643
- var OAuthAuthorizationResponse = (0, import_v4.object)({
644
- state: (0, import_v4.string)("Missing state parameter in the OAuth authorization response."),
645
- code: (0, import_v4.string)("Missing code parameter in the OAuth authorization response.")
681
+ var OAuthAuthorizationResponse = (0, import_zod.object)({
682
+ state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
683
+ code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
646
684
  });
647
- var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
648
- error: (0, import_v4.enum)([
685
+ var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
686
+ error: (0, import_zod.enum)([
649
687
  "invalid_request",
650
688
  "unauthorized_client",
651
689
  "access_denied",
@@ -654,24 +692,24 @@ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
654
692
  "server_error",
655
693
  "temporarily_unavailable"
656
694
  ]),
657
- error_description: (0, import_v4.string)().optional(),
658
- error_uri: (0, import_v4.string)().optional(),
659
- state: (0, import_v4.string)()
695
+ error_description: (0, import_zod.string)().optional(),
696
+ error_uri: (0, import_zod.string)().optional(),
697
+ state: (0, import_zod.string)()
660
698
  });
661
699
  var OAuthAccessToken = OAuthProviderConfigSchema.extend({
662
- redirectURI: (0, import_v4.string)(),
663
- code: (0, import_v4.string)(),
664
- codeVerifier: (0, import_v4.string)().min(43).max(128)
700
+ redirectURI: (0, import_zod.string)(),
701
+ code: (0, import_zod.string)(),
702
+ codeVerifier: (0, import_zod.string)().min(43).max(128)
665
703
  });
666
- var OAuthAccessTokenResponse = (0, import_v4.object)({
667
- access_token: (0, import_v4.string)(),
668
- token_type: (0, import_v4.string)(),
669
- expires_in: (0, import_v4.number)().optional(),
670
- refresh_token: (0, import_v4.string)().optional(),
671
- scope: (0, import_v4.string)().optional()
704
+ var OAuthAccessTokenResponse = (0, import_zod.object)({
705
+ access_token: (0, import_zod.string)(),
706
+ token_type: (0, import_zod.string)().optional(),
707
+ expires_in: (0, import_zod.number)().optional(),
708
+ refresh_token: (0, import_zod.string)().optional(),
709
+ scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
672
710
  });
673
- var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
674
- error: (0, import_v4.enum)([
711
+ var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
712
+ error: (0, import_zod.enum)([
675
713
  "invalid_request",
676
714
  "invalid_client",
677
715
  "invalid_grant",
@@ -679,16 +717,16 @@ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
679
717
  "unsupported_grant_type",
680
718
  "invalid_scope"
681
719
  ]),
682
- error_description: (0, import_v4.string)().optional(),
683
- error_uri: (0, import_v4.string)().optional()
720
+ error_description: (0, import_zod.string)().optional(),
721
+ error_uri: (0, import_zod.string)().optional()
684
722
  });
685
- var OAuthErrorResponse = (0, import_v4.object)({
686
- error: (0, import_v4.string)(),
687
- error_description: (0, import_v4.string)().optional()
723
+ var OAuthErrorResponse = (0, import_zod.object)({
724
+ error: (0, import_zod.string)(),
725
+ error_description: (0, import_zod.string)().optional()
688
726
  });
689
- var OAuthEnvSchema = (0, import_v4.object)({
690
- clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
691
- clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
727
+ var OAuthEnvSchema = (0, import_zod.object)({
728
+ clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
729
+ clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
692
730
  });
693
731
 
694
732
  // src/oauth/index.ts
@@ -700,7 +738,9 @@ var builtInOAuthProviders = {
700
738
  gitlab,
701
739
  spotify,
702
740
  x,
703
- strava
741
+ strava,
742
+ mailchimp,
743
+ pinterest
704
744
  };
705
745
  var defineOAuthEnvironment = (oauth) => {
706
746
  const env = process.env;
@@ -735,9 +775,17 @@ var createBuiltInOAuthProviders = (oauth = []) => {
735
775
  };
736
776
 
737
777
  // src/actions/signIn/signIn.ts
738
- var import_zod = __toESM(require("zod"), 1);
778
+ var import_zod2 = require("zod");
739
779
  var import_router2 = require("@aura-stack/router");
740
780
 
781
+ // src/headers.ts
782
+ var cacheControl = {
783
+ "Cache-Control": "no-store",
784
+ Pragma: "no-cache",
785
+ Expires: "0",
786
+ Vary: "Cookie"
787
+ };
788
+
741
789
  // src/actions/signIn/authorization.ts
742
790
  var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod) => {
743
791
  const parsed = OAuthAuthorization.safeParse({ ...oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod });
@@ -813,9 +861,14 @@ var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
813
861
  var signInConfig = (oauth) => {
814
862
  return (0, import_router2.createEndpointConfig)("/signIn/:oauth", {
815
863
  schemas: {
816
- params: import_zod.default.object({
817
- oauth: import_zod.default.enum(Object.keys(oauth), "The OAuth provider is not supported or invalid."),
818
- redirectTo: import_zod.default.string().optional()
864
+ params: import_zod2.z.object({
865
+ oauth: import_zod2.z.enum(
866
+ Object.keys(oauth),
867
+ "The OAuth provider is not supported or invalid."
868
+ )
869
+ }),
870
+ searchParams: import_zod2.z.object({
871
+ redirectTo: import_zod2.z.string().optional()
819
872
  })
820
873
  }
821
874
  });
@@ -827,8 +880,8 @@ var signInAction = (oauth) => {
827
880
  async (ctx) => {
828
881
  const {
829
882
  request,
830
- headers: headersBuilder,
831
- params: { oauth: oauth2, redirectTo },
883
+ params: { oauth: oauth2 },
884
+ searchParams: { redirectTo },
832
885
  context: { oauth: providers, cookies, trustedProxyHeaders, basePath }
833
886
  } = ctx;
834
887
  const state = generateSecure();
@@ -836,7 +889,7 @@ var signInAction = (oauth) => {
836
889
  const redirectToValue = createRedirectTo(request, redirectTo, trustedProxyHeaders);
837
890
  const { codeVerifier, codeChallenge, method } = await createPKCE();
838
891
  const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method);
839
- const headers = headersBuilder.setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirect_uri.name, redirectURI, cookies.redirect_uri.attributes).setCookie(cookies.redirect_to.name, redirectToValue, cookies.redirect_to.attributes).setCookie(cookies.code_verifier.name, codeVerifier, cookies.code_verifier.attributes).toHeaders();
892
+ const headers = new import_router2.HeadersBuilder(cacheControl).setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirectURI.name, redirectURI, cookies.redirectURI.attributes).setCookie(cookies.redirectTo.name, redirectToValue, cookies.redirectTo.attributes).setCookie(cookies.codeVerifier.name, codeVerifier, cookies.codeVerifier.attributes).toHeaders();
840
893
  return Response.json(
841
894
  { oauth: oauth2 },
842
895
  {
@@ -850,15 +903,18 @@ var signInAction = (oauth) => {
850
903
  };
851
904
 
852
905
  // src/actions/callback/callback.ts
853
- var import_zod2 = __toESM(require("zod"), 1);
906
+ var import_zod3 = require("zod");
854
907
  var import_router3 = require("@aura-stack/router");
855
908
 
856
- // src/headers.ts
857
- var cacheControl = {
858
- "Cache-Control": "no-store",
859
- Pragma: "no-cache",
860
- Expires: "0",
861
- Vary: "Cookie"
909
+ // src/request.ts
910
+ var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
911
+ const controller = new AbortController();
912
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
913
+ const response = await fetch(url, {
914
+ ...options2,
915
+ signal: controller.signal
916
+ }).finally(() => clearTimeout(timeoutId));
917
+ return response;
862
918
  };
863
919
 
864
920
  // src/actions/callback/userinfo.ts
@@ -874,7 +930,7 @@ var getDefaultUserInfo = (profile) => {
874
930
  var getUserInfo = async (oauthConfig, accessToken) => {
875
931
  const userinfoEndpoint = oauthConfig.userInfo;
876
932
  try {
877
- const response = await fetch(userinfoEndpoint, {
933
+ const response = await fetchAsync(userinfoEndpoint, {
878
934
  method: "GET",
879
935
  headers: {
880
936
  Accept: "application/json",
@@ -910,7 +966,7 @@ var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) =>
910
966
  }
911
967
  const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
912
968
  try {
913
- const response = await fetch(accessToken, {
969
+ const response = await fetchAsync(accessToken, {
914
970
  method: "POST",
915
971
  headers: {
916
972
  Accept: "application/json",
@@ -944,9 +1000,15 @@ var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) =>
944
1000
  var callbackConfig = (oauth) => {
945
1001
  return (0, import_router3.createEndpointConfig)("/callback/:oauth", {
946
1002
  schemas: {
947
- searchParams: OAuthAuthorizationResponse,
948
- params: import_zod2.default.object({
949
- oauth: import_zod2.default.enum(Object.keys(oauth), "The OAuth provider is not supported or invalid.")
1003
+ params: import_zod3.z.object({
1004
+ oauth: import_zod3.z.enum(
1005
+ Object.keys(oauth),
1006
+ "The OAuth provider is not supported or invalid."
1007
+ )
1008
+ }),
1009
+ searchParams: import_zod3.z.object({
1010
+ code: import_zod3.z.string("Missing code parameter in the OAuth authorization response."),
1011
+ state: import_zod3.z.string("Missing state parameter in the OAuth authorization response.")
950
1012
  })
951
1013
  },
952
1014
  middlewares: [
@@ -974,9 +1036,9 @@ var callbackAction = (oauth) => {
974
1036
  } = ctx;
975
1037
  const oauthConfig = providers[oauth2];
976
1038
  const cookieState = getCookie(request, cookies.state.name);
977
- const cookieRedirectTo = getCookie(request, cookies.redirect_to.name);
978
- const cookieRedirectURI = getCookie(request, cookies.redirect_uri.name);
979
- const codeVerifier = getCookie(request, cookies.code_verifier.name);
1039
+ const cookieRedirectTo = getCookie(request, cookies.redirectTo.name);
1040
+ const cookieRedirectURI = getCookie(request, cookies.redirectURI.name);
1041
+ const codeVerifier = getCookie(request, cookies.codeVerifier.name);
980
1042
  if (!equals(cookieState, state)) {
981
1043
  throw new AuthSecurityError(
982
1044
  "MISMATCHING_STATE",
@@ -994,7 +1056,7 @@ var callbackAction = (oauth) => {
994
1056
  const userInfo = await getUserInfo(oauthConfig, accessToken.access_token);
995
1057
  const sessionCookie = await createSessionCookie(jose, userInfo);
996
1058
  const csrfToken = await createCSRF(jose);
997
- const headers = new import_router3.HeadersBuilder(cacheControl).setHeader("Location", sanitized).setCookie(cookies.sessionToken.name, sessionCookie, cookies.sessionToken.attributes).setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes).setCookie(cookies.state.name, "", expiredCookieAttributes).setCookie(cookies.redirect_uri.name, "", expiredCookieAttributes).setCookie(cookies.redirect_to.name, "", expiredCookieAttributes).setCookie(cookies.code_verifier.name, "", expiredCookieAttributes).toHeaders();
1059
+ const headers = new import_router3.HeadersBuilder(cacheControl).setHeader("Location", sanitized).setCookie(cookies.sessionToken.name, sessionCookie, cookies.sessionToken.attributes).setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes).setCookie(cookies.state.name, "", expiredCookieAttributes).setCookie(cookies.redirectURI.name, "", expiredCookieAttributes).setCookie(cookies.redirectTo.name, "", expiredCookieAttributes).setCookie(cookies.codeVerifier.name, "", expiredCookieAttributes).toHeaders();
998
1060
  return Response.json({ oauth: oauth2 }, { status: 302, headers });
999
1061
  },
1000
1062
  callbackConfig(oauth)
@@ -1021,13 +1083,13 @@ var sessionAction = (0, import_router4.createEndpoint)("GET", "/session", async
1021
1083
  });
1022
1084
 
1023
1085
  // src/actions/signOut/signOut.ts
1024
- var import_zod3 = __toESM(require("zod"), 1);
1086
+ var import_zod4 = require("zod");
1025
1087
  var import_router5 = require("@aura-stack/router");
1026
1088
  var config = (0, import_router5.createEndpointConfig)({
1027
1089
  schemas: {
1028
- searchParams: import_zod3.default.object({
1029
- token_type_hint: import_zod3.default.literal("session_token"),
1030
- redirectTo: import_zod3.default.string().optional()
1090
+ searchParams: import_zod4.z.object({
1091
+ token_type_hint: import_zod4.z.literal("session_token"),
1092
+ redirectTo: import_zod4.z.string().optional()
1031
1093
  })
1032
1094
  }
1033
1095
  });
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { d as AuthConfig, e as AuthInstance } from './index-EqsoyjrF.js';
2
- export { C as CookieConfig, E as ErrorType, f as JoseInstance, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-EqsoyjrF.js';
3
- import 'zod/v4';
1
+ import { d as AuthConfig, e as AuthInstance } from './index-DkaLJFn8.js';
2
+ export { C as CookieConfig, E as ErrorType, f as JoseInstance, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-DkaLJFn8.js';
3
+ import 'zod';
4
4
  import './schemas.js';
5
5
  import '@aura-stack/router/cookie';
6
+ import '@aura-stack/jose';
6
7
  import '@aura-stack/jose/jose';
7
8
  import './@types/utility.js';
8
9
 
package/dist/index.js CHANGED
@@ -1,41 +1,42 @@
1
1
  import {
2
2
  createBuiltInOAuthProviders
3
- } from "./chunk-7H3OR6UU.js";
3
+ } from "./chunk-EMKJA2GJ.js";
4
+ import "./chunk-42XB3YCW.js";
5
+ import "./chunk-FKRDCWBF.js";
4
6
  import "./chunk-IKHPGFCW.js";
5
7
  import "./chunk-KRNOMBXQ.js";
8
+ import "./chunk-B737EUJV.js";
9
+ import "./chunk-HP34YGGJ.js";
6
10
  import "./chunk-E3OXBRYF.js";
7
11
  import "./chunk-6R2YZ4AC.js";
8
- import "./chunk-42XB3YCW.js";
9
12
  import "./chunk-ITQ7352M.js";
13
+ import {
14
+ signOutAction
15
+ } from "./chunk-A3N4PVAT.js";
10
16
  import {
11
17
  csrfTokenAction
12
- } from "./chunk-QDO2KSRJ.js";
18
+ } from "./chunk-HT4YLL7N.js";
13
19
  import {
14
- signInAction
15
- } from "./chunk-2RXNXMCZ.js";
20
+ callbackAction
21
+ } from "./chunk-KSWLO5ZU.js";
22
+ import "./chunk-GA2SMTJO.js";
23
+ import "./chunk-IVET23KF.js";
16
24
  import {
17
25
  sessionAction
18
- } from "./chunk-PTJUYB33.js";
19
- import {
20
- signOutAction
21
- } from "./chunk-NEVKX6K2.js";
22
- import "./chunk-QEZL7EYN.js";
26
+ } from "./chunk-JVFTCTTE.js";
23
27
  import {
24
- callbackAction
25
- } from "./chunk-UEH3LVON.js";
26
- import "./chunk-ZLR3LI6X.js";
27
- import "./chunk-4V4JNXVF.js";
28
+ signInAction
29
+ } from "./chunk-3EUWD5BB.js";
30
+ import "./chunk-N4SX7TZT.js";
28
31
  import "./chunk-FIPU4MLT.js";
29
32
  import "./chunk-IUYZQTJV.js";
30
- import "./chunk-FKRDCWBF.js";
31
33
  import {
32
34
  createCookieStore
33
- } from "./chunk-IMICRJ5U.js";
35
+ } from "./chunk-W6LG7BFW.js";
34
36
  import "./chunk-STHEPPUZ.js";
35
37
  import {
36
38
  createJoseInstance
37
39
  } from "./chunk-TLE4PXY3.js";
38
- import "./chunk-WD7AUHQ5.js";
39
40
  import "./chunk-N2APGLXA.js";
40
41
  import {
41
42
  onErrorHandler,
@@ -43,6 +44,8 @@ import {
43
44
  } from "./chunk-CXLATHS5.js";
44
45
  import "./chunk-EIL2FPSS.js";
45
46
  import "./chunk-RRLIF4PQ.js";
47
+ import "./chunk-ZNCZVF6U.js";
48
+ import "./chunk-YRCB5FLE.js";
46
49
 
47
50
  // src/index.ts
48
51
  import "dotenv/config";
package/dist/jose.cjs CHANGED
@@ -37,7 +37,7 @@ var import_config = require("dotenv/config");
37
37
  var import_jose = require("@aura-stack/jose");
38
38
 
39
39
  // src/secure.ts
40
- var import_node_crypto = __toESM(require("crypto"), 1);
40
+ var import_crypto = __toESM(require("crypto"), 1);
41
41
 
42
42
  // src/utils.ts
43
43
  var import_router = require("@aura-stack/router");
@@ -56,7 +56,7 @@ var AuthInternalError = class extends Error {
56
56
 
57
57
  // src/secure.ts
58
58
  var createDerivedSalt = (secret) => {
59
- return import_node_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
59
+ return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
60
60
  };
61
61
 
62
62
  // src/jose.ts
@@ -1,6 +1,7 @@
1
- export { B as BitbucketProfile, r as bitbucket } from '../index-EqsoyjrF.js';
1
+ export { B as BitbucketProfile, v as bitbucket } from '../index-DkaLJFn8.js';
2
2
  import '../@types/utility.js';
3
- import 'zod/v4';
3
+ import 'zod';
4
4
  import '../schemas.js';
5
5
  import '@aura-stack/router/cookie';
6
+ import '@aura-stack/jose';
6
7
  import '@aura-stack/jose/jose';
@@ -1,6 +1,7 @@
1
- export { D as DiscordProfile, N as Nameplate, p as discord } from '../index-EqsoyjrF.js';
2
- import 'zod/v4';
1
+ export { D as DiscordProfile, N as Nameplate, t as discord } from '../index-DkaLJFn8.js';
2
+ import 'zod';
3
3
  import '../schemas.js';
4
4
  import '@aura-stack/router/cookie';
5
+ import '@aura-stack/jose';
5
6
  import '@aura-stack/jose/jose';
6
7
  import '../@types/utility.js';
@@ -1,6 +1,7 @@
1
- export { F as FigmaProfile, q as figma } from '../index-EqsoyjrF.js';
2
- import 'zod/v4';
1
+ export { F as FigmaProfile, u as figma } from '../index-DkaLJFn8.js';
2
+ import 'zod';
3
3
  import '../schemas.js';
4
4
  import '@aura-stack/router/cookie';
5
+ import '@aura-stack/jose';
5
6
  import '@aura-stack/jose/jose';
6
7
  import '../@types/utility.js';
@@ -1,6 +1,7 @@
1
- export { t as GitHubProfile, u as github } from '../index-EqsoyjrF.js';
2
- import 'zod/v4';
1
+ export { w as GitHubProfile, y as github } from '../index-DkaLJFn8.js';
2
+ import 'zod';
3
3
  import '../schemas.js';
4
4
  import '@aura-stack/router/cookie';
5
+ import '@aura-stack/jose';
5
6
  import '@aura-stack/jose/jose';
6
7
  import '../@types/utility.js';
@@ -1,6 +1,7 @@
1
- export { G as GitLabProfile, o as gitlab } from '../index-EqsoyjrF.js';
2
- import 'zod/v4';
1
+ export { G as GitLabProfile, r as gitlab } from '../index-DkaLJFn8.js';
2
+ import 'zod';
3
3
  import '../schemas.js';
4
4
  import '@aura-stack/router/cookie';
5
+ import '@aura-stack/jose';
5
6
  import '@aura-stack/jose/jose';
6
7
  import '../@types/utility.js';