@aura-stack/auth 0.2.0 → 0.4.0-rc.1

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