@aura-stack/auth 0.5.0 → 0.7.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 (220) hide show
  1. package/README.md +36 -1
  2. package/dist/@types/index.cjs +0 -18
  3. package/dist/@types/index.d.ts +2 -12
  4. package/dist/@types/index.js +0 -1
  5. package/dist/assert-_fBNnaOk.js +3 -0
  6. package/dist/assert-hDwQ_SPO.cjs +3 -0
  7. package/dist/client/index.cjs +1 -135
  8. package/dist/client/index.d.ts +11 -14
  9. package/dist/client/index.js +1 -10
  10. package/dist/crypto-D6_SoGMH.cjs +1 -0
  11. package/dist/crypto-DyrRzBSQ.js +1 -0
  12. package/dist/env-7as-tgzO.cjs +1 -0
  13. package/dist/env-CJtSi1eX.js +1 -0
  14. package/dist/errors-Czt_w1t_.js +1 -0
  15. package/dist/errors-DcK2ELlk.cjs +1 -0
  16. package/dist/identity-b8FCr0Oa.cjs +1 -0
  17. package/dist/index-C9U6ICDT.d.ts +2796 -0
  18. package/dist/index.cjs +1 -2427
  19. package/dist/index.d.ts +2 -14
  20. package/dist/index.js +1 -59
  21. package/dist/logger-DjXkgSn5.js +1 -0
  22. package/dist/logger-G5PinyEc.cjs +1 -0
  23. package/dist/oauth/atlassian.cjs +1 -57
  24. package/dist/oauth/atlassian.d.ts +2 -12
  25. package/dist/oauth/atlassian.js +1 -6
  26. package/dist/oauth/bitbucket.cjs +1 -49
  27. package/dist/oauth/bitbucket.d.ts +2 -12
  28. package/dist/oauth/bitbucket.js +1 -6
  29. package/dist/oauth/click-up.cjs +1 -0
  30. package/dist/oauth/click-up.d.ts +2 -0
  31. package/dist/oauth/click-up.js +1 -0
  32. package/dist/oauth/discord.cjs +1 -57
  33. package/dist/oauth/discord.d.ts +2 -12
  34. package/dist/oauth/discord.js +1 -6
  35. package/dist/oauth/dribbble.cjs +1 -0
  36. package/dist/oauth/dribbble.d.ts +2 -0
  37. package/dist/oauth/dribbble.js +1 -0
  38. package/dist/oauth/dropbox.cjs +1 -53
  39. package/dist/oauth/dropbox.d.ts +2 -12
  40. package/dist/oauth/dropbox.js +1 -6
  41. package/dist/oauth/figma.cjs +1 -49
  42. package/dist/oauth/figma.d.ts +2 -12
  43. package/dist/oauth/figma.js +1 -6
  44. package/dist/oauth/github.cjs +1 -49
  45. package/dist/oauth/github.d.ts +2 -12
  46. package/dist/oauth/github.js +1 -6
  47. package/dist/oauth/gitlab.cjs +1 -49
  48. package/dist/oauth/gitlab.d.ts +2 -12
  49. package/dist/oauth/gitlab.js +1 -6
  50. package/dist/oauth/index.cjs +1 -673
  51. package/dist/oauth/index.d.ts +2 -12
  52. package/dist/oauth/index.js +1 -68
  53. package/dist/oauth/mailchimp.cjs +1 -49
  54. package/dist/oauth/mailchimp.d.ts +2 -12
  55. package/dist/oauth/mailchimp.js +1 -6
  56. package/dist/oauth/notion.cjs +1 -131
  57. package/dist/oauth/notion.d.ts +2 -12
  58. package/dist/oauth/notion.js +1 -9
  59. package/dist/oauth/pinterest.cjs +1 -49
  60. package/dist/oauth/pinterest.d.ts +2 -12
  61. package/dist/oauth/pinterest.js +1 -6
  62. package/dist/oauth/spotify.cjs +1 -49
  63. package/dist/oauth/spotify.d.ts +2 -12
  64. package/dist/oauth/spotify.js +1 -6
  65. package/dist/oauth/strava.cjs +1 -49
  66. package/dist/oauth/strava.d.ts +2 -12
  67. package/dist/oauth/strava.js +1 -6
  68. package/dist/oauth/twitch.cjs +1 -95
  69. package/dist/oauth/twitch.d.ts +2 -12
  70. package/dist/oauth/twitch.js +1 -7
  71. package/dist/oauth/x.cjs +1 -49
  72. package/dist/oauth/x.d.ts +2 -12
  73. package/dist/oauth/x.js +1 -6
  74. package/dist/oauth-D3_mnBOx.js +1 -0
  75. package/dist/oauth-gPiWxjBd.cjs +1 -0
  76. package/dist/shared/crypto.cjs +1 -0
  77. package/dist/shared/crypto.d.ts +71 -0
  78. package/dist/shared/crypto.js +1 -0
  79. package/dist/shared/identity.cjs +1 -0
  80. package/dist/shared/identity.d.ts +2 -0
  81. package/dist/shared/identity.js +1 -0
  82. package/dist/shared/index.cjs +1 -0
  83. package/dist/shared/index.d.ts +5 -0
  84. package/dist/shared/index.js +1 -0
  85. package/package.json +37 -11
  86. package/dist/@types/router.d.cjs +0 -1
  87. package/dist/@types/router.d.d.ts +0 -16
  88. package/dist/@types/router.d.js +0 -0
  89. package/dist/@types/utility.cjs +0 -18
  90. package/dist/@types/utility.d.ts +0 -6
  91. package/dist/@types/utility.js +0 -1
  92. package/dist/actions/callback/access-token.cjs +0 -250
  93. package/dist/actions/callback/access-token.d.ts +0 -33
  94. package/dist/actions/callback/access-token.js +0 -9
  95. package/dist/actions/callback/callback.cjs +0 -715
  96. package/dist/actions/callback/callback.d.ts +0 -42
  97. package/dist/actions/callback/callback.js +0 -18
  98. package/dist/actions/callback/userinfo.cjs +0 -283
  99. package/dist/actions/callback/userinfo.d.ts +0 -25
  100. package/dist/actions/callback/userinfo.js +0 -13
  101. package/dist/actions/csrfToken/csrfToken.cjs +0 -189
  102. package/dist/actions/csrfToken/csrfToken.d.ts +0 -7
  103. package/dist/actions/csrfToken/csrfToken.js +0 -13
  104. package/dist/actions/index.cjs +0 -1161
  105. package/dist/actions/index.d.ts +0 -17
  106. package/dist/actions/index.js +0 -39
  107. package/dist/actions/session/session.cjs +0 -188
  108. package/dist/actions/session/session.d.ts +0 -7
  109. package/dist/actions/session/session.js +0 -12
  110. package/dist/actions/signIn/authorization-url.cjs +0 -288
  111. package/dist/actions/signIn/authorization-url.d.ts +0 -31
  112. package/dist/actions/signIn/authorization-url.js +0 -16
  113. package/dist/actions/signIn/authorization.cjs +0 -281
  114. package/dist/actions/signIn/authorization.d.ts +0 -54
  115. package/dist/actions/signIn/authorization.js +0 -19
  116. package/dist/actions/signIn/signIn.cjs +0 -595
  117. package/dist/actions/signIn/signIn.d.ts +0 -42
  118. package/dist/actions/signIn/signIn.js +0 -16
  119. package/dist/actions/signOut/signOut.cjs +0 -492
  120. package/dist/actions/signOut/signOut.d.ts +0 -16
  121. package/dist/actions/signOut/signOut.js +0 -15
  122. package/dist/api/createApi.cjs +0 -750
  123. package/dist/api/createApi.d.ts +0 -12
  124. package/dist/api/createApi.js +0 -19
  125. package/dist/api/getSession.cjs +0 -141
  126. package/dist/api/getSession.d.ts +0 -16
  127. package/dist/api/getSession.js +0 -10
  128. package/dist/api/signIn.cjs +0 -549
  129. package/dist/api/signIn.d.ts +0 -26
  130. package/dist/api/signIn.js +0 -15
  131. package/dist/api/signOut.cjs +0 -279
  132. package/dist/api/signOut.d.ts +0 -16
  133. package/dist/api/signOut.js +0 -13
  134. package/dist/assert.cjs +0 -194
  135. package/dist/assert.d.ts +0 -37
  136. package/dist/assert.js +0 -26
  137. package/dist/chunk-2A5B7GWR.js +0 -125
  138. package/dist/chunk-2GQLSIJ2.js +0 -40
  139. package/dist/chunk-2IR674WX.js +0 -44
  140. package/dist/chunk-3J5TUH2I.js +0 -50
  141. package/dist/chunk-4RWSYUKX.js +0 -98
  142. package/dist/chunk-4YHJ4IEQ.js +0 -25
  143. package/dist/chunk-54CZPKR4.js +0 -25
  144. package/dist/chunk-5LZ7TOM3.js +0 -25
  145. package/dist/chunk-5X7JZMEF.js +0 -0
  146. package/dist/chunk-7BE46WWS.js +0 -88
  147. package/dist/chunk-7YYXFKLR.js +0 -35
  148. package/dist/chunk-C3A37LQC.js +0 -33
  149. package/dist/chunk-CITNGXDA.js +0 -31
  150. package/dist/chunk-CWX724AG.js +0 -78
  151. package/dist/chunk-D2CSIUKP.js +0 -74
  152. package/dist/chunk-E6G5YCI6.js +0 -25
  153. package/dist/chunk-EBAMFRB7.js +0 -34
  154. package/dist/chunk-EEE7UM5T.js +0 -25
  155. package/dist/chunk-FPCVZUVG.js +0 -37
  156. package/dist/chunk-FW4W3REU.js +0 -25
  157. package/dist/chunk-GNNBM2WJ.js +0 -83
  158. package/dist/chunk-IPKO6UQN.js +0 -25
  159. package/dist/chunk-ITQ7352M.js +0 -0
  160. package/dist/chunk-JOCGX3RP.js +0 -59
  161. package/dist/chunk-KBXWTD6E.js +0 -94
  162. package/dist/chunk-KMMAZFSJ.js +0 -25
  163. package/dist/chunk-LATR3NIV.js +0 -117
  164. package/dist/chunk-LAYPUDQF.js +0 -39
  165. package/dist/chunk-LDU7A2JE.js +0 -25
  166. package/dist/chunk-LX3TJ2TJ.js +0 -294
  167. package/dist/chunk-NHZBQNRR.js +0 -143
  168. package/dist/chunk-OVHNRULD.js +0 -33
  169. package/dist/chunk-PDP3PHB3.js +0 -127
  170. package/dist/chunk-PG7UYFG5.js +0 -0
  171. package/dist/chunk-PHYNROD4.js +0 -47
  172. package/dist/chunk-QQEKY4XP.js +0 -29
  173. package/dist/chunk-U4RK4LKJ.js +0 -348
  174. package/dist/chunk-U5663F2U.js +0 -70
  175. package/dist/chunk-UN7X6SU5.js +0 -53
  176. package/dist/chunk-UZQJJD6A.js +0 -100
  177. package/dist/chunk-V6LLEAR4.js +0 -80
  178. package/dist/chunk-WHNDRO3N.js +0 -50
  179. package/dist/chunk-XY5R3EHH.js +0 -204
  180. package/dist/chunk-ZNCZVF6U.js +0 -14
  181. package/dist/client/client.cjs +0 -135
  182. package/dist/client/client.d.ts +0 -85
  183. package/dist/client/client.js +0 -9
  184. package/dist/context.cjs +0 -1237
  185. package/dist/context.d.ts +0 -16
  186. package/dist/context.js +0 -28
  187. package/dist/cookie.cjs +0 -277
  188. package/dist/cookie.d.ts +0 -89
  189. package/dist/cookie.js +0 -30
  190. package/dist/createAuth.cjs +0 -2320
  191. package/dist/createAuth.d.ts +0 -12
  192. package/dist/createAuth.js +0 -48
  193. package/dist/env.cjs +0 -78
  194. package/dist/env.d.ts +0 -10
  195. package/dist/env.js +0 -12
  196. package/dist/errors.cjs +0 -102
  197. package/dist/errors.d.ts +0 -60
  198. package/dist/errors.js +0 -22
  199. package/dist/headers.cjs +0 -61
  200. package/dist/headers.d.ts +0 -33
  201. package/dist/headers.js +0 -12
  202. package/dist/index-_aXtxb_s.d.ts +0 -1377
  203. package/dist/jose.cjs +0 -166
  204. package/dist/jose.d.ts +0 -12
  205. package/dist/jose.js +0 -20
  206. package/dist/logger.cjs +0 -424
  207. package/dist/logger.d.ts +0 -12
  208. package/dist/logger.js +0 -17
  209. package/dist/request.cjs +0 -38
  210. package/dist/request.d.ts +0 -13
  211. package/dist/request.js +0 -6
  212. package/dist/schemas.cjs +0 -158
  213. package/dist/schemas.d.ts +0 -229
  214. package/dist/schemas.js +0 -24
  215. package/dist/secure.cjs +0 -170
  216. package/dist/secure.d.ts +0 -41
  217. package/dist/secure.js +0 -20
  218. package/dist/utils.cjs +0 -329
  219. package/dist/utils.d.ts +0 -35
  220. package/dist/utils.js +0 -36
package/dist/utils.cjs DELETED
@@ -1,329 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/utils.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- AURA_AUTH_VERSION: () => AURA_AUTH_VERSION,
24
- createBasicAuthHeader: () => createBasicAuthHeader,
25
- createErrorHandler: () => createErrorHandler,
26
- createStructuredData: () => createStructuredData,
27
- equals: () => equals,
28
- extractPath: () => extractPath,
29
- formatZodError: () => formatZodError,
30
- getBaseURL: () => getBaseURL,
31
- getErrorName: () => getErrorName,
32
- toCastCase: () => toCastCase,
33
- toISOString: () => toISOString,
34
- toSnakeCase: () => toSnakeCase,
35
- toUpperCase: () => toUpperCase,
36
- useSecureCookies: () => useSecureCookies,
37
- validateRedirectTo: () => validateRedirectTo
38
- });
39
- module.exports = __toCommonJS(utils_exports);
40
- var import_router = require("@aura-stack/router");
41
-
42
- // src/errors.ts
43
- var OAuthProtocolError = class extends Error {
44
- type = "OAUTH_PROTOCOL_ERROR";
45
- error;
46
- errorURI;
47
- constructor(error, description, errorURI, options) {
48
- super(description, options);
49
- this.error = error;
50
- this.errorURI = errorURI;
51
- this.name = new.target.name;
52
- Error.captureStackTrace(this, new.target);
53
- }
54
- };
55
- var AuthInternalError = class extends Error {
56
- type = "AUTH_INTERNAL_ERROR";
57
- code;
58
- constructor(code, message, options) {
59
- super(message, options);
60
- this.code = code;
61
- this.name = new.target.name;
62
- Error.captureStackTrace(this, new.target);
63
- }
64
- };
65
- var AuthSecurityError = class extends Error {
66
- type = "AUTH_SECURITY_ERROR";
67
- code;
68
- constructor(code, message, options) {
69
- super(message, options);
70
- this.code = code;
71
- this.name = new.target.name;
72
- Error.captureStackTrace(this, new.target);
73
- }
74
- };
75
- var isOAuthProtocolError = (error) => {
76
- return error instanceof OAuthProtocolError;
77
- };
78
- var isAuthInternalError = (error) => {
79
- return error instanceof AuthInternalError;
80
- };
81
- var isAuthSecurityError = (error) => {
82
- return error instanceof AuthSecurityError;
83
- };
84
-
85
- // src/env.ts
86
- var import_meta = {};
87
- var env = new Proxy({}, {
88
- get(_, prop) {
89
- if (typeof prop !== "string") return void 0;
90
- const hasProperty = (process2) => {
91
- return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
92
- };
93
- try {
94
- if (typeof process !== "undefined" && hasProperty(process.env)) {
95
- return process.env[prop];
96
- }
97
- if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
98
- return import_meta.env[prop];
99
- }
100
- if (typeof Deno !== "undefined" && Deno.env?.get) {
101
- return Deno.env.get(prop);
102
- }
103
- if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
104
- return Bun.env[prop];
105
- }
106
- const globalValue = globalThis[prop];
107
- return typeof globalValue === "string" ? globalValue : void 0;
108
- } catch {
109
- return void 0;
110
- }
111
- }
112
- });
113
- var getEnv = (key) => {
114
- const keys = [`AURA_AUTH_${key.toUpperCase()}`, `AURA_${key.toUpperCase()}`, `AUTH_${key.toUpperCase()}`, key.toUpperCase()];
115
- return env[keys.find((k) => env[k]) ?? ""];
116
- };
117
-
118
- // src/assert.ts
119
- var import_crypto = require("@aura-stack/jose/crypto");
120
- var unsafeChars = [
121
- "<",
122
- ">",
123
- '"',
124
- "`",
125
- " ",
126
- "\r",
127
- "\n",
128
- " ",
129
- "\\",
130
- "%2F",
131
- "%5C",
132
- "%2f",
133
- "%5c",
134
- "\r\n",
135
- "%0A",
136
- "%0D",
137
- "%0a",
138
- "%0d",
139
- "..",
140
- "//",
141
- "///",
142
- "...",
143
- "%20",
144
- "\0"
145
- ];
146
- var isValidURL = (value) => {
147
- if (!new RegExp(/^https?:\/\/[^/]/).test(value)) {
148
- return false;
149
- }
150
- const match = value.match(/^(https?:\/\/)(.*)$/);
151
- if (!match) return false;
152
- const rest = match[2];
153
- for (const char of unsafeChars) {
154
- if (rest.includes(char)) return false;
155
- }
156
- const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()?#*+,;=:@-]*)*\/?$/;
157
- return regex.test(match[0]);
158
- };
159
- var isRelativeURL = (value) => {
160
- if (value.length > 100) return false;
161
- for (const char of unsafeChars) {
162
- if (value.includes(char)) return false;
163
- }
164
- const regex = /^\/[a-zA-Z0-9\-_\/.?&=#]*\/?$/;
165
- return regex.test(value);
166
- };
167
-
168
- // src/utils.ts
169
- var AURA_AUTH_VERSION = "0.4.0";
170
- var toSnakeCase = (str) => {
171
- return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
172
- };
173
- var toUpperCase = (str) => {
174
- return str.toUpperCase();
175
- };
176
- var toCastCase = (obj, type = "snake") => {
177
- return Object.entries(obj).reduce((previous, [key, value]) => {
178
- const newKey = type === "snake" ? toSnakeCase(key) : toUpperCase(key);
179
- return { ...previous, [newKey]: value };
180
- }, {});
181
- };
182
- var equals = (a, b) => {
183
- if (a === null || b === null || a === void 0 || b === void 0) return false;
184
- return a === b;
185
- };
186
- var createErrorHandler = (logger) => {
187
- return (error) => {
188
- if ((0, import_router.isRouterError)(error)) {
189
- const { message, status, statusText } = error;
190
- logger?.log("ROUTER_INTERNAL_ERROR");
191
- return Response.json({ type: "ROUTER_ERROR", code: "ROUTER_INTERNAL_ERROR", message }, { status, statusText });
192
- }
193
- if ((0, import_router.isInvalidZodSchemaError)(error)) {
194
- logger?.log("INVALID_REQUEST");
195
- return Response.json({ type: "ROUTER_ERROR", code: "INVALID_REQUEST", message: error.errors }, { status: 422 });
196
- }
197
- if (isOAuthProtocolError(error)) {
198
- const { error: errorCode, message, type, errorURI } = error;
199
- logger?.log("OAUTH_PROTOCOL_ERROR", {
200
- structuredData: {
201
- error: errorCode,
202
- error_description: message,
203
- error_uri: errorURI ?? ""
204
- }
205
- });
206
- return Response.json(
207
- {
208
- type,
209
- message
210
- },
211
- { status: 400 }
212
- );
213
- }
214
- if (isAuthInternalError(error)) {
215
- const { type, code, message } = error;
216
- logger?.log("INVALID_OAUTH_CONFIGURATION", {
217
- structuredData: {
218
- error: code,
219
- error_description: message
220
- }
221
- });
222
- return Response.json(
223
- {
224
- type,
225
- message
226
- },
227
- { status: 400 }
228
- );
229
- }
230
- if (isAuthSecurityError(error)) {
231
- const { type, code, message } = error;
232
- logger?.log("INVALID_OAUTH_CONFIGURATION", {
233
- structuredData: {
234
- error: code,
235
- error_description: message
236
- }
237
- });
238
- return Response.json(
239
- {
240
- type,
241
- code,
242
- message
243
- },
244
- { status: 400 }
245
- );
246
- }
247
- logger?.log("SERVER_ERROR");
248
- return Response.json(
249
- { type: "SERVER_ERROR", code: "SERVER_ERROR", message: "An unexpected error occurred" },
250
- { status: 500 }
251
- );
252
- };
253
- };
254
- var getBaseURL = (request) => {
255
- const url = new URL(request.url);
256
- return `${url.origin}${url.pathname}`;
257
- };
258
- var toISOString = (date) => {
259
- return new Date(date).toISOString();
260
- };
261
- var useSecureCookies = (request, trustedProxyHeaders) => {
262
- const headers = request instanceof Headers ? request : request.headers;
263
- const url = request instanceof Headers ? null : request.url;
264
- return trustedProxyHeaders ? url?.startsWith("https://") || headers.get("X-Forwarded-Proto") === "https" || (headers.get("Forwarded")?.includes("proto=https") ?? false) : url?.startsWith("https://") ?? false;
265
- };
266
- var formatZodError = (error) => {
267
- if (!error.issues || error.issues.length === 0) {
268
- return {};
269
- }
270
- return error.issues.reduce((previous, issue) => {
271
- const key = issue.path.join(".");
272
- return {
273
- ...previous,
274
- [key]: {
275
- code: issue.code,
276
- message: issue.message
277
- }
278
- };
279
- }, {});
280
- };
281
- var extractPath = (url) => {
282
- const pathRegex = /^https?:\/\/[a-zA-Z0-9_\-\.]+(:\d+)?(\/.*)$/;
283
- const match = url.match(pathRegex);
284
- return match && match[2] ? match[2] : "/";
285
- };
286
- var createStructuredData = (data, sdID = "metadata") => {
287
- const entries = Object.entries(data);
288
- if (entries.length === 0) return `[${sdID}]`;
289
- const values = entries.map(([key, value]) => `${key}="${String(value).replace(/(["\\\]])/g, "\\$1")}"`).join(" ");
290
- return `[${sdID} ${values}]`;
291
- };
292
- var getErrorName = (error) => {
293
- if (error instanceof Error) {
294
- return error.name;
295
- }
296
- return typeof error === "string" ? error : "UnknownError";
297
- };
298
- var createBasicAuthHeader = (username, password) => {
299
- const getUsername = getEnv(username.toUpperCase()) ?? username;
300
- const getPassword = getEnv(password.toUpperCase()) ?? password;
301
- if (!getUsername || !getPassword) {
302
- throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", "Missing client credentials for OAuth provider configuration.");
303
- }
304
- const credentials = `${getUsername}:${getPassword}`;
305
- return `Basic ${btoa(credentials)}`;
306
- };
307
- var validateRedirectTo = (url) => {
308
- if (!isRelativeURL(url) && !isValidURL(url)) return "/";
309
- if (isRelativeURL(url)) return url;
310
- return "/";
311
- };
312
- // Annotate the CommonJS export names for ESM import in node:
313
- 0 && (module.exports = {
314
- AURA_AUTH_VERSION,
315
- createBasicAuthHeader,
316
- createErrorHandler,
317
- createStructuredData,
318
- equals,
319
- extractPath,
320
- formatZodError,
321
- getBaseURL,
322
- getErrorName,
323
- toCastCase,
324
- toISOString,
325
- toSnakeCase,
326
- toUpperCase,
327
- useSecureCookies,
328
- validateRedirectTo
329
- });
package/dist/utils.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import { RouterConfig } from '@aura-stack/router';
2
- import { ZodError } from 'zod';
3
- import { a as InternalLogger, f as APIErrorMap } from './index-_aXtxb_s.js';
4
- import './schemas.js';
5
- import 'zod/v4';
6
- import '@aura-stack/jose';
7
- import '@aura-stack/jose/jose';
8
- import '@aura-stack/jose/crypto';
9
- import '@aura-stack/router/cookie';
10
- import './@types/utility.js';
11
- import 'jose';
12
- import 'zod/v4/core';
13
-
14
- declare const AURA_AUTH_VERSION = "0.4.0";
15
- declare const toSnakeCase: (str: string) => string;
16
- declare const toUpperCase: (str: string) => string;
17
- declare const toCastCase: <Obj extends Record<string, string>, Type extends "snake" | "upper">(obj: Obj, type?: Type) => Type extends "snake" ? { [K in keyof Obj as `${string & K}`]: Obj[K]; } : { [K in keyof Obj as Uppercase<string & K>]: Obj[K]; };
18
- declare const equals: (a: string | number | undefined | null, b: string | number | undefined | null) => boolean;
19
- declare const createErrorHandler: (logger?: InternalLogger) => RouterConfig["onError"];
20
- declare const getBaseURL: (request: Request) => string;
21
- declare const toISOString: (date: Date | string | number) => string;
22
- declare const useSecureCookies: (request: Request | Headers, trustedProxyHeaders: boolean) => boolean;
23
- declare const formatZodError: <T extends Record<string, unknown> = Record<string, unknown>>(error: ZodError<T>) => APIErrorMap;
24
- declare const extractPath: (url: string) => string;
25
- declare const createStructuredData: (data: Record<string, string | number | boolean>, sdID?: string) => string;
26
- declare const getErrorName: (error: unknown) => string;
27
- declare const createBasicAuthHeader: (username: string, password: string) => string;
28
- /**
29
- * Validates and sanitizes redirect URLs to prevent open redirect attacks.
30
- * Only relative URLs (starting with /) are allowed; absolute URLs are
31
- * rejected and replaced with "/" to enforce same-origin redirects.
32
- */
33
- declare const validateRedirectTo: (url: string) => string;
34
-
35
- export { AURA_AUTH_VERSION, createBasicAuthHeader, createErrorHandler, createStructuredData, equals, extractPath, formatZodError, getBaseURL, getErrorName, toCastCase, toISOString, toSnakeCase, toUpperCase, useSecureCookies, validateRedirectTo };
package/dist/utils.js DELETED
@@ -1,36 +0,0 @@
1
- import {
2
- AURA_AUTH_VERSION,
3
- createBasicAuthHeader,
4
- createErrorHandler,
5
- createStructuredData,
6
- equals,
7
- extractPath,
8
- formatZodError,
9
- getBaseURL,
10
- getErrorName,
11
- toCastCase,
12
- toISOString,
13
- toSnakeCase,
14
- toUpperCase,
15
- useSecureCookies,
16
- validateRedirectTo
17
- } from "./chunk-LX3TJ2TJ.js";
18
- import "./chunk-WHNDRO3N.js";
19
- import "./chunk-U5663F2U.js";
20
- export {
21
- AURA_AUTH_VERSION,
22
- createBasicAuthHeader,
23
- createErrorHandler,
24
- createStructuredData,
25
- equals,
26
- extractPath,
27
- formatZodError,
28
- getBaseURL,
29
- getErrorName,
30
- toCastCase,
31
- toISOString,
32
- toSnakeCase,
33
- toUpperCase,
34
- useSecureCookies,
35
- validateRedirectTo
36
- };