@aura-stack/auth 0.4.0 → 0.5.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 (149) hide show
  1. package/dist/@types/index.d.ts +6 -2
  2. package/dist/@types/router.d.d.ts +6 -2
  3. package/dist/actions/callback/access-token.cjs +103 -59
  4. package/dist/actions/callback/access-token.d.ts +7 -3
  5. package/dist/actions/callback/access-token.js +3 -3
  6. package/dist/actions/callback/callback.cjs +200 -134
  7. package/dist/actions/callback/callback.d.ts +32 -3
  8. package/dist/actions/callback/callback.js +11 -12
  9. package/dist/actions/callback/userinfo.cjs +103 -70
  10. package/dist/actions/callback/userinfo.d.ts +6 -2
  11. package/dist/actions/callback/userinfo.js +7 -8
  12. package/dist/actions/csrfToken/csrfToken.cjs +7 -15
  13. package/dist/actions/csrfToken/csrfToken.d.ts +3 -1
  14. package/dist/actions/csrfToken/csrfToken.js +7 -8
  15. package/dist/actions/index.cjs +502 -295
  16. package/dist/actions/index.d.ts +5 -2
  17. package/dist/actions/index.js +23 -20
  18. package/dist/actions/session/session.cjs +76 -24
  19. package/dist/actions/session/session.d.ts +3 -1
  20. package/dist/actions/session/session.js +6 -4
  21. package/dist/actions/signIn/authorization-url.cjs +288 -0
  22. package/dist/actions/signIn/authorization-url.d.ts +31 -0
  23. package/dist/actions/signIn/authorization-url.js +16 -0
  24. package/dist/actions/signIn/authorization.cjs +91 -132
  25. package/dist/actions/signIn/authorization.d.ts +17 -16
  26. package/dist/actions/signIn/authorization.js +8 -7
  27. package/dist/actions/signIn/signIn.cjs +319 -191
  28. package/dist/actions/signIn/signIn.d.ts +32 -3
  29. package/dist/actions/signIn/signIn.js +10 -9
  30. package/dist/actions/signOut/signOut.cjs +211 -212
  31. package/dist/actions/signOut/signOut.d.ts +9 -1
  32. package/dist/actions/signOut/signOut.js +9 -10
  33. package/dist/api/createApi.cjs +750 -0
  34. package/dist/api/createApi.d.ts +12 -0
  35. package/dist/api/createApi.js +19 -0
  36. package/dist/api/getSession.cjs +141 -0
  37. package/dist/api/getSession.d.ts +16 -0
  38. package/dist/api/getSession.js +10 -0
  39. package/dist/api/signIn.cjs +549 -0
  40. package/dist/api/signIn.d.ts +26 -0
  41. package/dist/api/signIn.js +15 -0
  42. package/dist/api/signOut.cjs +279 -0
  43. package/dist/api/signOut.d.ts +16 -0
  44. package/dist/api/signOut.js +13 -0
  45. package/dist/assert.cjs +42 -9
  46. package/dist/assert.d.ts +8 -4
  47. package/dist/assert.js +5 -5
  48. package/dist/{chunk-KJBAQZX2.js → chunk-2A5B7GWR.js} +44 -11
  49. package/dist/chunk-2GQLSIJ2.js +40 -0
  50. package/dist/chunk-2IR674WX.js +44 -0
  51. package/dist/chunk-3J5TUH2I.js +50 -0
  52. package/dist/chunk-4RWSYUKX.js +98 -0
  53. package/dist/chunk-5X7JZMEF.js +0 -0
  54. package/dist/{chunk-TZB6MUXN.js → chunk-7BE46WWS.js} +21 -11
  55. package/dist/chunk-7YYXFKLR.js +35 -0
  56. package/dist/chunk-C3A37LQC.js +33 -0
  57. package/dist/chunk-CITNGXDA.js +31 -0
  58. package/dist/chunk-CWX724AG.js +78 -0
  59. package/dist/chunk-D2CSIUKP.js +74 -0
  60. package/dist/{chunk-ICAZ4OVS.js → chunk-FPCVZUVG.js} +2 -2
  61. package/dist/{chunk-XGLBNXL4.js → chunk-GNNBM2WJ.js} +17 -9
  62. package/dist/chunk-JOCGX3RP.js +59 -0
  63. package/dist/chunk-KBXWTD6E.js +94 -0
  64. package/dist/{chunk-XUP6KKNG.js → chunk-LATR3NIV.js} +48 -37
  65. package/dist/chunk-LAYPUDQF.js +39 -0
  66. package/dist/chunk-LX3TJ2TJ.js +294 -0
  67. package/dist/{chunk-6MXFPFR3.js → chunk-NHZBQNRR.js} +19 -19
  68. package/dist/{chunk-TM5IPSNF.js → chunk-PDP3PHB3.js} +33 -19
  69. package/dist/chunk-PHYNROD4.js +47 -0
  70. package/dist/chunk-QQEKY4XP.js +29 -0
  71. package/dist/{chunk-VNCNJKS2.js → chunk-U4RK4LKJ.js} +82 -1
  72. package/dist/{chunk-RRLIF4PQ.js → chunk-U5663F2U.js} +16 -1
  73. package/dist/chunk-UN7X6SU5.js +53 -0
  74. package/dist/chunk-UZQJJD6A.js +100 -0
  75. package/dist/{chunk-NUDITUKX.js → chunk-V6LLEAR4.js} +22 -15
  76. package/dist/{chunk-4MYWAOLG.js → chunk-WHNDRO3N.js} +20 -1
  77. package/dist/{chunk-5W4BRQYG.js → chunk-XY5R3EHH.js} +6 -3
  78. package/dist/client/client.cjs +135 -0
  79. package/dist/client/client.d.ts +85 -0
  80. package/dist/client/client.js +9 -0
  81. package/dist/client/index.cjs +135 -0
  82. package/dist/client/index.d.ts +14 -0
  83. package/dist/client/index.js +10 -0
  84. package/dist/context.cjs +1237 -0
  85. package/dist/context.d.ts +16 -0
  86. package/dist/context.js +28 -0
  87. package/dist/cookie.cjs +33 -2
  88. package/dist/cookie.d.ts +9 -5
  89. package/dist/cookie.js +3 -2
  90. package/dist/createAuth.cjs +2320 -0
  91. package/dist/createAuth.d.ts +12 -0
  92. package/dist/createAuth.js +48 -0
  93. package/dist/env.cjs +24 -2
  94. package/dist/env.d.ts +4 -1
  95. package/dist/env.js +9 -3
  96. package/dist/errors.cjs +17 -0
  97. package/dist/errors.d.ts +13 -3
  98. package/dist/errors.js +5 -1
  99. package/dist/{index-CSyIJmCM.d.ts → index-_aXtxb_s.d.ts} +383 -13
  100. package/dist/index.cjs +2135 -1547
  101. package/dist/index.d.ts +9 -30
  102. package/dist/index.js +46 -119
  103. package/dist/jose.cjs +52 -14
  104. package/dist/jose.d.ts +12 -25
  105. package/dist/jose.js +11 -3
  106. package/dist/logger.cjs +132 -0
  107. package/dist/logger.d.ts +6 -2
  108. package/dist/logger.js +10 -1
  109. package/dist/oauth/atlassian.cjs +57 -0
  110. package/dist/oauth/atlassian.d.ts +12 -0
  111. package/dist/oauth/atlassian.js +6 -0
  112. package/dist/oauth/bitbucket.d.ts +6 -2
  113. package/dist/oauth/discord.d.ts +6 -2
  114. package/dist/oauth/dropbox.cjs +53 -0
  115. package/dist/oauth/dropbox.d.ts +12 -0
  116. package/dist/oauth/dropbox.js +6 -0
  117. package/dist/oauth/figma.d.ts +6 -2
  118. package/dist/oauth/github.d.ts +6 -2
  119. package/dist/oauth/gitlab.d.ts +6 -2
  120. package/dist/oauth/index.cjs +278 -88
  121. package/dist/oauth/index.d.ts +6 -2
  122. package/dist/oauth/index.js +27 -11
  123. package/dist/oauth/mailchimp.d.ts +6 -2
  124. package/dist/oauth/notion.cjs +131 -0
  125. package/dist/oauth/notion.d.ts +12 -0
  126. package/dist/oauth/notion.js +9 -0
  127. package/dist/oauth/pinterest.d.ts +6 -2
  128. package/dist/oauth/spotify.d.ts +6 -2
  129. package/dist/oauth/strava.d.ts +6 -2
  130. package/dist/oauth/twitch.cjs +95 -0
  131. package/dist/oauth/twitch.d.ts +12 -0
  132. package/dist/oauth/twitch.js +7 -0
  133. package/dist/oauth/x.d.ts +6 -2
  134. package/dist/schemas.cjs +84 -51
  135. package/dist/schemas.d.ts +103 -23
  136. package/dist/schemas.js +1 -1
  137. package/dist/secure.cjs +36 -36
  138. package/dist/secure.d.ts +10 -4
  139. package/dist/secure.js +7 -6
  140. package/dist/utils.cjs +109 -3
  141. package/dist/utils.d.ts +15 -4
  142. package/dist/utils.js +11 -4
  143. package/package.json +9 -5
  144. package/dist/chunk-4EKY7655.js +0 -123
  145. package/dist/chunk-7QF22LHP.js +0 -67
  146. package/dist/chunk-ALG3GIV4.js +0 -95
  147. package/dist/chunk-FRJFWTOY.js +0 -70
  148. package/dist/chunk-PHFH2MGS.js +0 -36
  149. package/dist/chunk-QQVSRXGX.js +0 -149
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/actions/callback/userinfo.ts
@@ -45,9 +35,6 @@ var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
45
35
  return response;
46
36
  };
47
37
 
48
- // src/secure.ts
49
- var import_crypto = __toESM(require("crypto"), 1);
50
-
51
38
  // src/utils.ts
52
39
  var import_router = require("@aura-stack/router");
53
40
 
@@ -100,49 +87,90 @@ var env = new Proxy({}, {
100
87
  }
101
88
  });
102
89
 
90
+ // src/assert.ts
91
+ var import_crypto = require("@aura-stack/jose/crypto");
92
+
93
+ // src/utils.ts
94
+ var AURA_AUTH_VERSION = "0.4.0";
95
+
103
96
  // src/jose.ts
104
97
  var import_jose = require("@aura-stack/jose");
98
+ var import_jose2 = require("@aura-stack/jose/jose");
99
+ var import_crypto2 = require("@aura-stack/jose/crypto");
105
100
 
106
101
  // src/secure.ts
107
102
  var generateSecure = (length = 32) => {
108
- return import_crypto.default.randomBytes(length).toString("base64url");
103
+ return import_jose2.base64url.encode((0, import_crypto2.getRandomBytes)(length));
109
104
  };
110
105
 
111
106
  // src/schemas.ts
112
- var import_zod = require("zod");
113
- var OAuthProviderCredentialsSchema = (0, import_zod.object)({
114
- id: (0, import_zod.string)(),
115
- name: (0, import_zod.string)(),
116
- authorizeURL: (0, import_zod.string)().url(),
117
- accessToken: (0, import_zod.string)().url(),
118
- scope: (0, import_zod.string)(),
119
- userInfo: (0, import_zod.string)().url(),
120
- responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
121
- clientId: (0, import_zod.string)(),
122
- clientSecret: (0, import_zod.string)(),
123
- profile: import_zod.z.function().optional()
107
+ var import_v4 = require("zod/v4");
108
+ var AuthorizeConfigSchema = import_v4.z.union([
109
+ (0, import_v4.string)().url(),
110
+ (0, import_v4.object)({
111
+ url: (0, import_v4.string)().url(),
112
+ params: (0, import_v4.object)({
113
+ responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
114
+ scope: (0, import_v4.string)().optional()
115
+ })
116
+ })
117
+ ]);
118
+ var AccessTokenConfigSchema = import_v4.z.union([
119
+ (0, import_v4.string)().url(),
120
+ (0, import_v4.object)({
121
+ url: (0, import_v4.string)().url(),
122
+ headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional()
123
+ })
124
+ ]);
125
+ var UserInfoConfigSchema = import_v4.z.union([
126
+ (0, import_v4.string)().url(),
127
+ (0, import_v4.object)({
128
+ url: (0, import_v4.string)().url(),
129
+ headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional(),
130
+ method: (0, import_v4.string)().optional()
131
+ })
132
+ ]);
133
+ var OAuthProviderCredentialsSchema = (0, import_v4.object)({
134
+ id: (0, import_v4.string)(),
135
+ name: (0, import_v4.string)(),
136
+ authorize: AuthorizeConfigSchema.optional(),
137
+ /** @deprecated */
138
+ authorizeURL: (0, import_v4.string)().url().optional(),
139
+ accessToken: AccessTokenConfigSchema,
140
+ /** @deprecated */
141
+ scope: (0, import_v4.string)().optional(),
142
+ userInfo: UserInfoConfigSchema,
143
+ /** @deprecated */
144
+ responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
145
+ clientId: (0, import_v4.string)(),
146
+ clientSecret: (0, import_v4.string)(),
147
+ profile: import_v4.z.function().optional()
124
148
  });
125
- var OAuthProviderConfigSchema = (0, import_zod.object)({
126
- authorizeURL: (0, import_zod.string)().url(),
127
- accessToken: (0, import_zod.string)().url(),
128
- scope: (0, import_zod.string)().optional(),
129
- userInfo: (0, import_zod.string)().url(),
130
- responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
131
- clientId: (0, import_zod.string)(),
132
- clientSecret: (0, import_zod.string)()
149
+ var OAuthProviderConfigSchema = (0, import_v4.object)({
150
+ authorize: AuthorizeConfigSchema.optional(),
151
+ /** @deprecated */
152
+ authorizeURL: (0, import_v4.string)().url().optional(),
153
+ accessToken: AccessTokenConfigSchema,
154
+ /** @deprecated */
155
+ scope: (0, import_v4.string)().optional(),
156
+ userInfo: UserInfoConfigSchema,
157
+ /** @deprecated */
158
+ responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
159
+ clientId: (0, import_v4.string)(),
160
+ clientSecret: (0, import_v4.string)()
133
161
  });
134
162
  var OAuthAuthorization = OAuthProviderConfigSchema.extend({
135
- redirectURI: (0, import_zod.string)(),
136
- state: (0, import_zod.string)(),
137
- codeChallenge: (0, import_zod.string)(),
138
- codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
163
+ redirectURI: (0, import_v4.string)(),
164
+ state: (0, import_v4.string)(),
165
+ codeChallenge: (0, import_v4.string)(),
166
+ codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
139
167
  });
140
- var OAuthAuthorizationResponse = (0, import_zod.object)({
141
- state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
142
- code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
168
+ var OAuthAuthorizationResponse = (0, import_v4.object)({
169
+ state: (0, import_v4.string)({ message: "Missing state parameter in the OAuth authorization response." }),
170
+ code: (0, import_v4.string)({ message: "Missing code parameter in the OAuth authorization response." })
143
171
  });
144
- var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
145
- error: (0, import_zod.enum)([
172
+ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
173
+ error: (0, import_v4.enum)([
146
174
  "invalid_request",
147
175
  "unauthorized_client",
148
176
  "access_denied",
@@ -151,24 +179,24 @@ var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
151
179
  "server_error",
152
180
  "temporarily_unavailable"
153
181
  ]),
154
- error_description: (0, import_zod.string)().optional(),
155
- error_uri: (0, import_zod.string)().optional(),
156
- state: (0, import_zod.string)()
182
+ error_description: (0, import_v4.string)().optional(),
183
+ error_uri: (0, import_v4.string)().optional(),
184
+ state: (0, import_v4.string)()
157
185
  });
158
186
  var OAuthAccessToken = OAuthProviderConfigSchema.extend({
159
- redirectURI: (0, import_zod.string)(),
160
- code: (0, import_zod.string)(),
161
- codeVerifier: (0, import_zod.string)().min(43).max(128)
187
+ redirectURI: (0, import_v4.string)(),
188
+ code: (0, import_v4.string)(),
189
+ codeVerifier: (0, import_v4.string)().min(43).max(128)
162
190
  });
163
- var OAuthAccessTokenResponse = (0, import_zod.object)({
164
- access_token: (0, import_zod.string)(),
165
- token_type: (0, import_zod.string)().optional(),
166
- expires_in: (0, import_zod.number)().optional(),
167
- refresh_token: (0, import_zod.string)().optional(),
168
- scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
191
+ var OAuthAccessTokenResponse = (0, import_v4.object)({
192
+ access_token: (0, import_v4.string)(),
193
+ token_type: (0, import_v4.string)().optional(),
194
+ expires_in: (0, import_v4.number)().optional(),
195
+ refresh_token: (0, import_v4.string)().optional(),
196
+ scope: (0, import_v4.union)([(0, import_v4.string)().optional().or((0, import_v4.null)()), (0, import_v4.array)((0, import_v4.string)()).optional()])
169
197
  });
170
- var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
171
- error: (0, import_zod.enum)([
198
+ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
199
+ error: (0, import_v4.enum)([
172
200
  "invalid_request",
173
201
  "invalid_client",
174
202
  "invalid_grant",
@@ -176,16 +204,16 @@ var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
176
204
  "unsupported_grant_type",
177
205
  "invalid_scope"
178
206
  ]),
179
- error_description: (0, import_zod.string)().optional(),
180
- error_uri: (0, import_zod.string)().optional()
207
+ error_description: (0, import_v4.string)().optional(),
208
+ error_uri: (0, import_v4.string)().optional()
181
209
  });
182
- var OAuthErrorResponse = (0, import_zod.object)({
183
- error: (0, import_zod.string)(),
184
- error_description: (0, import_zod.string)().optional()
210
+ var OAuthErrorResponse = (0, import_v4.object)({
211
+ error: (0, import_v4.string)(),
212
+ error_description: (0, import_v4.string)().optional()
185
213
  });
186
- var OAuthEnvSchema = (0, import_zod.object)({
187
- clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
188
- clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
214
+ var OAuthEnvSchema = (0, import_v4.object)({
215
+ clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
216
+ clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
189
217
  });
190
218
 
191
219
  // src/actions/callback/userinfo.ts
@@ -199,18 +227,23 @@ var getDefaultUserInfo = (profile) => {
199
227
  };
200
228
  };
201
229
  var getUserInfo = async (oauthConfig, accessToken, logger) => {
202
- const userinfoEndpoint = oauthConfig.userInfo;
230
+ const userInfoConfig = oauthConfig.userInfo;
231
+ const userinfoURL = typeof userInfoConfig === "string" ? userInfoConfig : userInfoConfig.url;
232
+ const extraHeaders = typeof userInfoConfig === "string" ? void 0 : userInfoConfig.headers;
233
+ const method = typeof userInfoConfig === "string" ? "GET" : (userInfoConfig.method ?? "GET").toUpperCase();
203
234
  try {
204
235
  logger?.log("OAUTH_USERINFO_REQUEST_INITIATED", {
205
236
  structuredData: {
206
- endpoint: userinfoEndpoint
237
+ endpoint: userinfoURL
207
238
  }
208
239
  });
209
- const response = await fetchAsync(userinfoEndpoint, {
210
- method: "GET",
240
+ const response = await fetchAsync(userinfoURL, {
241
+ method,
211
242
  headers: {
243
+ "User-Agent": `Aura Auth/${AURA_AUTH_VERSION}`,
212
244
  Accept: "application/json",
213
- Authorization: `Bearer ${accessToken}`
245
+ Authorization: `Bearer ${accessToken}`,
246
+ ...extraHeaders ?? {}
214
247
  }
215
248
  });
216
249
  if (!response.ok) {
@@ -1,11 +1,15 @@
1
- import { h as OAuthProviderCredentials, I as InternalLogger, U as User } from '../../index-CSyIJmCM.js';
1
+ import { j as OAuthProviderCredentials, a as InternalLogger, U as User } from '../../index-_aXtxb_s.js';
2
2
  import 'zod';
3
3
  import '../../schemas.js';
4
- import '../../jose.js';
4
+ import 'zod/v4';
5
5
  import '@aura-stack/jose';
6
6
  import '@aura-stack/jose/jose';
7
+ import '@aura-stack/jose/crypto';
7
8
  import '@aura-stack/router/cookie';
8
9
  import '../../@types/utility.js';
10
+ import 'jose';
11
+ import '@aura-stack/router';
12
+ import 'zod/v4/core';
9
13
 
10
14
  /**
11
15
  * Get user information from the OAuth provider's userinfo endpoint using the provided access token.
@@ -1,14 +1,13 @@
1
1
  import {
2
2
  getUserInfo
3
- } from "../../chunk-XGLBNXL4.js";
3
+ } from "../../chunk-GNNBM2WJ.js";
4
4
  import "../../chunk-ZNCZVF6U.js";
5
- import "../../chunk-KJBAQZX2.js";
6
- import "../../chunk-NUDITUKX.js";
7
- import "../../chunk-4EKY7655.js";
8
- import "../../chunk-QQVSRXGX.js";
9
- import "../../chunk-FRJFWTOY.js";
10
- import "../../chunk-4MYWAOLG.js";
11
- import "../../chunk-RRLIF4PQ.js";
5
+ import "../../chunk-V6LLEAR4.js";
6
+ import "../../chunk-2A5B7GWR.js";
7
+ import "../../chunk-UZQJJD6A.js";
8
+ import "../../chunk-LX3TJ2TJ.js";
9
+ import "../../chunk-WHNDRO3N.js";
10
+ import "../../chunk-U5663F2U.js";
12
11
  export {
13
12
  getUserInfo
14
13
  };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/actions/csrfToken/csrfToken.ts
@@ -35,9 +25,6 @@ __export(csrfToken_exports, {
35
25
  module.exports = __toCommonJS(csrfToken_exports);
36
26
  var import_router2 = require("@aura-stack/router");
37
27
 
38
- // src/secure.ts
39
- var import_crypto = __toESM(require("crypto"), 1);
40
-
41
28
  // src/utils.ts
42
29
  var import_router = require("@aura-stack/router");
43
30
 
@@ -82,8 +69,13 @@ var env = new Proxy({}, {
82
69
  }
83
70
  });
84
71
 
72
+ // src/assert.ts
73
+ var import_crypto = require("@aura-stack/jose/crypto");
74
+
85
75
  // src/jose.ts
86
76
  var import_jose = require("@aura-stack/jose");
77
+ var import_jose2 = require("@aura-stack/jose/jose");
78
+ var import_crypto2 = require("@aura-stack/jose/crypto");
87
79
  var jwtVerificationOptions = {
88
80
  algorithms: ["HS256"],
89
81
  typ: "JWT"
@@ -91,7 +83,7 @@ var jwtVerificationOptions = {
91
83
 
92
84
  // src/secure.ts
93
85
  var generateSecure = (length = 32) => {
94
- return import_crypto.default.randomBytes(length).toString("base64url");
86
+ return import_jose2.base64url.encode((0, import_crypto2.getRandomBytes)(length));
95
87
  };
96
88
  var createCSRF = async (jose, csrfCookie) => {
97
89
  try {
@@ -159,7 +151,7 @@ var expiredCookieAttributes = {
159
151
  secure: true
160
152
  };
161
153
  var getCookie = (request, cookieName) => {
162
- const cookies = request.headers.get("Cookie");
154
+ const cookies = request instanceof Request ? request.headers.get("Cookie") : request.get("Cookie");
163
155
  if (!cookies) {
164
156
  throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
165
157
  }
@@ -1,5 +1,7 @@
1
1
  import * as _aura_stack_router from '@aura-stack/router';
2
2
 
3
- declare const csrfTokenAction: _aura_stack_router.RouteEndpoint<"GET", "/csrfToken", {}>;
3
+ declare const csrfTokenAction: _aura_stack_router.RouteEndpoint<"GET", "/csrfToken", {
4
+ schemas?: _aura_stack_router.EndpointSchemas | undefined;
5
+ }>;
4
6
 
5
7
  export { csrfTokenAction };
@@ -1,14 +1,13 @@
1
1
  import {
2
2
  csrfTokenAction
3
- } from "../../chunk-ICAZ4OVS.js";
4
- import "../../chunk-NUDITUKX.js";
5
- import "../../chunk-4EKY7655.js";
6
- import "../../chunk-QQVSRXGX.js";
7
- import "../../chunk-5W4BRQYG.js";
3
+ } from "../../chunk-FPCVZUVG.js";
4
+ import "../../chunk-V6LLEAR4.js";
5
+ import "../../chunk-UZQJJD6A.js";
6
+ import "../../chunk-LX3TJ2TJ.js";
7
+ import "../../chunk-XY5R3EHH.js";
8
+ import "../../chunk-WHNDRO3N.js";
9
+ import "../../chunk-U5663F2U.js";
8
10
  import "../../chunk-EBAMFRB7.js";
9
- import "../../chunk-FRJFWTOY.js";
10
- import "../../chunk-4MYWAOLG.js";
11
- import "../../chunk-RRLIF4PQ.js";
12
11
  export {
13
12
  csrfTokenAction
14
13
  };