@suveren/gateway 0.3.17 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/bin/suveren-gateway.js +419 -28
  2. package/content/integrations/calendar.json +20 -8
  3. package/content/integrations/crm.json +97 -23
  4. package/content/integrations/gmail.json +166 -29
  5. package/content/integrations/linkedin.json +15 -3
  6. package/content/integrations/mollie.json +2 -2
  7. package/dist/control-plane/index.mjs +333 -41
  8. package/dist/mcp-server/http.mjs +880 -210
  9. package/dist/ui/assets/index-BDQY7Z3H.js +105 -0
  10. package/dist/ui/assets/{index-DOt3SNnl.css → index-JHaCddDE.css} +1 -1
  11. package/dist/ui/index.html +2 -2
  12. package/node_modules/@hap/core/dist/index.d.mts +27 -0
  13. package/node_modules/@hap/core/dist/index.d.ts +27 -0
  14. package/node_modules/@hap/core/dist/index.js +13 -1
  15. package/node_modules/@hap/core/dist/index.mjs +13 -1
  16. package/node_modules/@hap/core/package.json +1 -1
  17. package/node_modules/@hap/core/src/gatekeeper.ts +47 -1
  18. package/node_modules/@hap/core/src/types.ts +27 -0
  19. package/node_modules/@hono/node-server/README.md +58 -25
  20. package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
  21. package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
  22. package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
  23. package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
  24. package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
  25. package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
  26. package/node_modules/@hono/node-server/dist/index.cjs +1173 -0
  27. package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
  28. package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
  29. package/node_modules/@hono/node-server/dist/index.mjs +1143 -637
  30. package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
  31. package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
  32. package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
  33. package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
  34. package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
  35. package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
  36. package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
  37. package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
  38. package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
  39. package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
  40. package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
  41. package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
  42. package/node_modules/@hono/node-server/package.json +65 -54
  43. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
  44. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
  45. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
  46. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
  47. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
  48. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
  49. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
  50. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  51. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
  52. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
  53. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
  54. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
  55. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
  56. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
  57. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
  58. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
  59. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
  60. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
  61. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
  62. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
  63. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
  64. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
  65. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
  66. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
  67. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
  68. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
  69. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
  70. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
  71. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
  72. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
  73. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
  74. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
  75. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
  76. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
  77. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
  78. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
  79. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
  80. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
  81. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
  82. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
  83. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
  84. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
  85. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
  86. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
  87. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
  88. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
  89. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
  90. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
  91. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
  92. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
  93. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
  94. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
  95. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
  96. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
  97. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
  98. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
  99. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
  100. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
  101. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
  102. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
  103. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
  104. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
  105. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
  106. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
  107. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
  108. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
  109. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
  110. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
  111. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
  112. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
  113. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
  114. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
  115. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/README.md +15 -14
  116. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/index.js +0 -8
  117. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/package.json +16 -12
  118. package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
  119. package/node_modules/@types/node/README.md +1 -1
  120. package/node_modules/@types/node/crypto.d.ts +1 -1
  121. package/node_modules/@types/node/package.json +2 -2
  122. package/node_modules/body-parser/HISTORY.md +7 -1
  123. package/node_modules/body-parser/lib/types/json.js +7 -3
  124. package/node_modules/body-parser/lib/types/raw.js +7 -3
  125. package/node_modules/body-parser/lib/types/text.js +7 -3
  126. package/node_modules/body-parser/lib/types/urlencoded.js +7 -3
  127. package/node_modules/body-parser/package.json +1 -1
  128. package/node_modules/express-rate-limit/dist/index.cjs +69 -5
  129. package/node_modules/express-rate-limit/dist/index.d.cts +16 -0
  130. package/node_modules/express-rate-limit/dist/index.d.mts +16 -0
  131. package/node_modules/express-rate-limit/dist/index.d.ts +16 -0
  132. package/node_modules/express-rate-limit/dist/index.mjs +55 -5
  133. package/node_modules/express-rate-limit/node_modules/debug/LICENSE +20 -0
  134. package/node_modules/express-rate-limit/node_modules/debug/README.md +481 -0
  135. package/node_modules/express-rate-limit/node_modules/debug/package.json +64 -0
  136. package/node_modules/express-rate-limit/node_modules/debug/src/browser.js +272 -0
  137. package/node_modules/express-rate-limit/node_modules/debug/src/common.js +292 -0
  138. package/node_modules/express-rate-limit/node_modules/debug/src/index.js +10 -0
  139. package/node_modules/express-rate-limit/node_modules/debug/src/node.js +263 -0
  140. package/node_modules/express-rate-limit/node_modules/ms/index.js +162 -0
  141. package/node_modules/express-rate-limit/node_modules/ms/license.md +21 -0
  142. package/node_modules/express-rate-limit/node_modules/ms/package.json +38 -0
  143. package/node_modules/express-rate-limit/node_modules/ms/readme.md +59 -0
  144. package/node_modules/express-rate-limit/package.json +12 -9
  145. package/node_modules/fast-uri/index.js +17 -0
  146. package/node_modules/fast-uri/package.json +1 -1
  147. package/node_modules/fast-uri/test/security.test.js +62 -0
  148. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -4
  149. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +12 -2
  150. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -4
  151. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +12 -2
  152. package/node_modules/hono/dist/cjs/client/client.js +10 -1
  153. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  154. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +5 -4
  155. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  156. package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
  157. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
  158. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
  159. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
  160. package/node_modules/hono/dist/cjs/request.js +8 -3
  161. package/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
  162. package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
  163. package/node_modules/hono/dist/cjs/utils/body.js +6 -0
  164. package/node_modules/hono/dist/cjs/utils/url.js +1 -1
  165. package/node_modules/hono/dist/client/client.js +10 -1
  166. package/node_modules/hono/dist/client/utils.js +1 -1
  167. package/node_modules/hono/dist/helper/streaming/sse.js +5 -4
  168. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  169. package/node_modules/hono/dist/middleware/compress/index.js +2 -1
  170. package/node_modules/hono/dist/middleware/etag/index.js +2 -1
  171. package/node_modules/hono/dist/middleware/method-override/index.js +5 -3
  172. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
  173. package/node_modules/hono/dist/request.js +8 -3
  174. package/node_modules/hono/dist/router/trie-router/node.js +9 -0
  175. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
  176. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
  177. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
  178. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +1 -1
  179. package/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
  180. package/node_modules/hono/dist/types/utils/types.d.ts +1 -1
  181. package/node_modules/hono/dist/utils/accept.js +1 -1
  182. package/node_modules/hono/dist/utils/body.js +6 -0
  183. package/node_modules/hono/dist/utils/url.js +1 -1
  184. package/node_modules/hono/package.json +4 -4
  185. package/node_modules/ip-address/README.md +102 -96
  186. package/node_modules/ip-address/dist/common.d.ts +23 -0
  187. package/node_modules/ip-address/dist/common.js +27 -4
  188. package/node_modules/ip-address/dist/common.js.map +1 -1
  189. package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
  190. package/node_modules/ip-address/dist/ipv4.js +21 -8
  191. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  192. package/node_modules/ip-address/dist/ipv6.d.ts +59 -1
  193. package/node_modules/ip-address/dist/ipv6.js +149 -41
  194. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  195. package/node_modules/ip-address/dist/v4/constants.js +5 -1
  196. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  197. package/node_modules/ip-address/dist/v6/constants.js +3 -2
  198. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  199. package/node_modules/ip-address/package.json +2 -2
  200. package/node_modules/jose/README.md +1 -4
  201. package/node_modules/jose/dist/types/jwks/remote.d.ts +3 -3
  202. package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  203. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +4 -1
  204. package/node_modules/jose/package.json +1 -1
  205. package/package.json +2 -2
  206. package/profiles/customers/0.4.profile.json +7 -4
  207. package/profiles/customers/0.5.profile.json +131 -0
  208. package/profiles/customers/0.6.profile.json +153 -0
  209. package/profiles/email/0.4.profile.json +8 -4
  210. package/profiles/index.json +2 -0
  211. package/server.js +10 -0
  212. package/dist/ui/assets/index-CTmWS7W4.js +0 -105
  213. package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
  214. package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
  215. package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
  216. package/node_modules/@hono/node-server/dist/globals.js +0 -29
  217. package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
  218. package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
  219. package/node_modules/@hono/node-server/dist/index.js +0 -702
  220. package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
  221. package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
  222. package/node_modules/@hono/node-server/dist/listener.js +0 -670
  223. package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
  224. package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
  225. package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
  226. package/node_modules/@hono/node-server/dist/request.js +0 -238
  227. package/node_modules/@hono/node-server/dist/request.mjs +0 -206
  228. package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
  229. package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
  230. package/node_modules/@hono/node-server/dist/response.js +0 -112
  231. package/node_modules/@hono/node-server/dist/response.mjs +0 -85
  232. package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
  233. package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
  234. package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
  235. package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
  236. package/node_modules/@hono/node-server/dist/server.js +0 -696
  237. package/node_modules/@hono/node-server/dist/server.mjs +0 -660
  238. package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
  239. package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
  240. package/node_modules/@hono/node-server/dist/types.js +0 -18
  241. package/node_modules/@hono/node-server/dist/types.mjs +0 -0
  242. package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
  243. package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
  244. package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
  245. package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
  246. package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
  247. package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
  248. package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
  249. package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
  250. package/node_modules/@hono/node-server/dist/utils.js +0 -99
  251. package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
  252. package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
  253. package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
  254. package/node_modules/@hono/node-server/dist/vercel.js +0 -677
  255. package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
@@ -348,10 +348,7 @@ var defaultIsContentTypeBinary = (contentType) => {
348
348
  );
349
349
  };
350
350
  var isContentEncodingBinary = (contentEncoding) => {
351
- if (contentEncoding === null) {
352
- return false;
353
- }
354
- return /^(gzip|deflate|compress|br)/.test(contentEncoding);
351
+ return !!contentEncoding && !/^identity$/i.test(contentEncoding);
355
352
  };
356
353
  export {
357
354
  ALBProcessor,
@@ -15,21 +15,31 @@ var convertHeaders = (headers) => {
15
15
  var handle = (app) => {
16
16
  return async (event, ...args) => {
17
17
  const [context, callback] = args;
18
+ let callbackError = null;
19
+ let callbackResult;
18
20
  const res = await app.fetch(createRequest(event), {
19
21
  event,
20
22
  context,
21
23
  callback: (err, result) => {
24
+ if (!callbackError && !callbackResult) {
25
+ callbackError = err;
26
+ callbackResult = result;
27
+ }
22
28
  callback?.(err, result);
23
29
  },
24
30
  config: event.Records[0].cf.config,
25
31
  request: event.Records[0].cf.request,
26
32
  response: event.Records[0].cf.response
27
33
  });
28
- return createResult(res);
34
+ if (callbackError) {
35
+ throw callbackError;
36
+ }
37
+ return callbackResult ?? createResult(res);
29
38
  };
30
39
  };
31
40
  var createResult = async (res) => {
32
- const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "");
41
+ const contentEncoding = res.headers.get("content-encoding");
42
+ const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "") || !!contentEncoding && !/^identity$/i.test(contentEncoding);
33
43
  const body = isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text();
34
44
  return {
35
45
  status: res.status.toString(),
@@ -378,10 +378,7 @@ const defaultIsContentTypeBinary = (contentType) => {
378
378
  );
379
379
  };
380
380
  const isContentEncodingBinary = (contentEncoding) => {
381
- if (contentEncoding === null) {
382
- return false;
383
- }
384
- return /^(gzip|deflate|compress|br)/.test(contentEncoding);
381
+ return !!contentEncoding && !/^identity$/i.test(contentEncoding);
385
382
  };
386
383
  // Annotate the CommonJS export names for ESM import in node:
387
384
  0 && (module.exports = {
@@ -48,21 +48,31 @@ const convertHeaders = (headers) => {
48
48
  const handle = (app) => {
49
49
  return async (event, ...args) => {
50
50
  const [context, callback] = args;
51
+ let callbackError = null;
52
+ let callbackResult;
51
53
  const res = await app.fetch(createRequest(event), {
52
54
  event,
53
55
  context,
54
56
  callback: (err, result) => {
57
+ if (!callbackError && !callbackResult) {
58
+ callbackError = err;
59
+ callbackResult = result;
60
+ }
55
61
  callback?.(err, result);
56
62
  },
57
63
  config: event.Records[0].cf.config,
58
64
  request: event.Records[0].cf.request,
59
65
  response: event.Records[0].cf.response
60
66
  });
61
- return createResult(res);
67
+ if (callbackError) {
68
+ throw callbackError;
69
+ }
70
+ return callbackResult ?? createResult(res);
62
71
  };
63
72
  };
64
73
  const createResult = async (res) => {
65
- const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "");
74
+ const contentEncoding = res.headers.get("content-encoding");
75
+ const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "") || !!contentEncoding && !/^identity$/i.test(contentEncoding);
66
76
  const body = isBase64Encoded ? (0, import_encode.encodeBase64)(await res.arrayBuffer()) : await res.text();
67
77
  return {
68
78
  status: res.status.toString(),
@@ -184,7 +184,16 @@ const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
184
184
  });
185
185
  if (method) {
186
186
  options ??= {};
187
- const args = (0, import_utils.deepMerge)(options, { ...opts.args[1] });
187
+ const reqOptions = { ...opts.args[1] };
188
+ const baseHeaders = options.headers;
189
+ const reqHeaders = reqOptions.headers;
190
+ if (baseHeaders && reqHeaders) {
191
+ reqOptions.headers = async () => ({
192
+ ...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders,
193
+ ...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders
194
+ });
195
+ }
196
+ const args = (0, import_utils.deepMerge)(options, reqOptions);
188
197
  return req.fetch(opts.args[0], args);
189
198
  }
190
199
  return req;
@@ -36,7 +36,7 @@ const mergePath = (base, path) => {
36
36
  };
37
37
  const replaceUrlParam = (urlString, params) => {
38
38
  for (const [k, v] of Object.entries(params)) {
39
- const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
39
+ const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
40
40
  urlString = urlString.replace(reg, v ? `/${v}` : "");
41
41
  }
42
42
  return urlString;
@@ -33,16 +33,17 @@ class SSEStreamingApi extends import_stream.StreamingApi {
33
33
  const dataLines = data.split(/\r\n|\r|\n/).map((line) => {
34
34
  return `data: ${line}`;
35
35
  }).join("\n");
36
- for (const key of ["event", "id", "retry"]) {
37
- if (message[key] && /[\r\n]/.test(message[key])) {
36
+ for (const key of ["event", "id"]) {
37
+ const value = message[key];
38
+ if (value && /[\r\n]/.test(value)) {
38
39
  throw new Error(`${key} must not contain "\\r" or "\\n"`);
39
40
  }
40
41
  }
41
42
  const sseData = [
42
43
  message.event && `event: ${message.event}`,
43
44
  dataLines,
44
- message.id && `id: ${message.id}`,
45
- message.retry && `retry: ${message.retry}`
45
+ message.id !== void 0 && `id: ${message.id}`,
46
+ message.retry !== void 0 && `retry: ${message.retry}`
46
47
  ].filter(Boolean).join("\n") + "\n\n";
47
48
  await this.write(sseData);
48
49
  }
@@ -55,7 +55,7 @@ const cache = (options) => {
55
55
  );
56
56
  const addHeader = (c, responseVary) => {
57
57
  if (cacheControlDirectives) {
58
- const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
58
+ const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
59
59
  for (const directive of cacheControlDirectives) {
60
60
  let [name, value] = directive.trim().split("=", 2);
61
61
  name = name.toLowerCase();
@@ -57,7 +57,8 @@ const compress = (options) => {
57
57
  return async function compress2(ctx, next) {
58
58
  await next();
59
59
  const contentLength = ctx.res.headers.get("Content-Length");
60
- if (ctx.res.headers.has("Content-Encoding") || // already encoded
60
+ if (ctx.res.status === 206 || // partial content, Content-Range refers to the uncompressed bytes
61
+ ctx.res.headers.has("Content-Encoding") || // already encoded
61
62
  ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
62
63
  ctx.req.method === "HEAD" || // HEAD request
63
64
  contentLength && Number(contentLength) < threshold || // content-length below threshold
@@ -70,7 +70,8 @@ const etag = (options) => {
70
70
  }
71
71
  etag3 = weak ? `W/"${hash}"` : `"${hash}"`;
72
72
  }
73
- if (etagMatches(etag3, ifNoneMatch)) {
73
+ const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD") && res.ok : etagMatches(etag3, ifNoneMatch);
74
+ if (matched) {
74
75
  c.res = new Response(null, {
75
76
  status: 304,
76
77
  statusText: "Not Modified",
@@ -80,11 +80,13 @@ const methodOverride = (options) => async function methodOverride2(c, next) {
80
80
  if (method) {
81
81
  const url = new URL(c.req.url);
82
82
  url.searchParams.delete(queryName);
83
- const request = new Request(url.toString(), {
83
+ const requestInit = {
84
84
  body: c.req.raw.body,
85
85
  headers: c.req.raw.headers,
86
- method
87
- });
86
+ method,
87
+ duplex: c.req.raw.body ? "half" : void 0
88
+ };
89
+ const request = new Request(url.toString(), requestInit);
88
90
  return app.fetch(request, c.env, getExecutionCtx(c));
89
91
  }
90
92
  }
@@ -71,14 +71,20 @@ const secureHeaders = (customOptions) => {
71
71
  const headersToSet = getFilteredHeaders(options);
72
72
  const callbacks = [];
73
73
  if (options.contentSecurityPolicy) {
74
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicy);
74
+ const [callback, value] = getCSPDirectives(
75
+ options.contentSecurityPolicy,
76
+ "Content-Security-Policy"
77
+ );
75
78
  if (callback) {
76
79
  callbacks.push(callback);
77
80
  }
78
81
  headersToSet.push(["Content-Security-Policy", value]);
79
82
  }
80
83
  if (options.contentSecurityPolicyReportOnly) {
81
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
84
+ const [callback, value] = getCSPDirectives(
85
+ options.contentSecurityPolicyReportOnly,
86
+ "Content-Security-Policy-Report-Only"
87
+ );
82
88
  if (callback) {
83
89
  callbacks.push(callback);
84
90
  }
@@ -111,7 +117,7 @@ function getFilteredHeaders(options) {
111
117
  return typeof overrideValue === "string" ? [defaultValue[0], overrideValue] : defaultValue;
112
118
  });
113
119
  }
114
- function getCSPDirectives(contentSecurityPolicy) {
120
+ function getCSPDirectives(contentSecurityPolicy, headerName) {
115
121
  const callbacks = [];
116
122
  const resultValues = [];
117
123
  for (const [directive, value] of Object.entries(contentSecurityPolicy)) {
@@ -136,7 +142,7 @@ function getCSPDirectives(contentSecurityPolicy) {
136
142
  resultValues.pop();
137
143
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
138
144
  (ctx, headersToSet) => headersToSet.map((values) => {
139
- if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
145
+ if (values[0] === headerName) {
140
146
  const clone = values[1].slice();
141
147
  callbacks.forEach((cb) => {
142
148
  cb(ctx, clone);
@@ -98,7 +98,7 @@ class HonoRequest {
98
98
  if (name) {
99
99
  return this.raw.headers.get(name) ?? void 0;
100
100
  }
101
- const headerData = {};
101
+ const headerData = /* @__PURE__ */ Object.create(null);
102
102
  this.raw.headers.forEach((value, key) => {
103
103
  headerData[key] = value;
104
104
  });
@@ -316,11 +316,16 @@ const cloneRawRequest = async (req) => {
316
316
  message: "Cannot clone request: body was already consumed and not cached. Please use HonoRequest methods (e.g., req.json(), req.text()) instead of consuming req.raw directly."
317
317
  });
318
318
  }
319
+ const body = await req[cacheKey]();
320
+ const headers = req.header();
321
+ if (body instanceof FormData) {
322
+ delete headers["content-type"];
323
+ }
319
324
  const requestInit = {
320
- body: await req[cacheKey](),
325
+ body,
321
326
  cache: req.raw.cache,
322
327
  credentials: req.raw.credentials,
323
- headers: req.header(),
328
+ headers,
324
329
  integrity: req.raw.integrity,
325
330
  keepalive: req.raw.keepalive,
326
331
  method: req.method,
@@ -155,6 +155,15 @@ class Node {
155
155
  if (m) {
156
156
  params[name] = m[0];
157
157
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
158
+ if (m[0].length === restPathString.length && child.#children["*"]) {
159
+ this.#pushHandlerSets(
160
+ handlerSets,
161
+ child.#children["*"],
162
+ method,
163
+ node.#params,
164
+ params
165
+ );
166
+ }
158
167
  if (hasChildren(child.#children)) {
159
168
  child.#params = params;
160
169
  const componentCount = m[0].match(/\//)?.length ?? 0;
@@ -146,7 +146,7 @@ const getNextParam = (acceptHeader, startIndex) => {
146
146
  const getNextAcceptValue = (acceptHeader, startIndex) => {
147
147
  const accept = {
148
148
  type: "",
149
- params: {},
149
+ params: /* @__PURE__ */ Object.create(null),
150
150
  q: 1
151
151
  };
152
152
  startIndex = consumeWhitespace(acceptHeader, startIndex);
@@ -33,6 +33,12 @@ const parseBody = async (request, options = /* @__PURE__ */ Object.create(null))
33
33
  return {};
34
34
  };
35
35
  async function parseFormData(request, options) {
36
+ if (!isRawRequest(request) && request.bodyCache.formData) {
37
+ return convertFormDataToBodyData(
38
+ await request.bodyCache.formData,
39
+ options
40
+ );
41
+ }
36
42
  const headers = isRawRequest(request) ? request.headers : request.raw.headers;
37
43
  const arrayBuffer = await request.arrayBuffer();
38
44
  const formDataPromise = (0, import_buffer.bufferToFormData)(arrayBuffer, headers.get("Content-Type") || "");
@@ -192,7 +192,7 @@ const _getQueryParam = (url, key, multiple) => {
192
192
  return void 0;
193
193
  }
194
194
  }
195
- const results = {};
195
+ const results = /* @__PURE__ */ Object.create(null);
196
196
  encoded ??= /[%+]/.test(url);
197
197
  let keyIndex = url.indexOf("?", 8);
198
198
  while (keyIndex !== -1) {
@@ -170,7 +170,16 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
170
170
  });
171
171
  if (method) {
172
172
  options ??= {};
173
- const args = deepMerge(options, { ...opts.args[1] });
173
+ const reqOptions = { ...opts.args[1] };
174
+ const baseHeaders = options.headers;
175
+ const reqHeaders = reqOptions.headers;
176
+ if (baseHeaders && reqHeaders) {
177
+ reqOptions.headers = async () => ({
178
+ ...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders,
179
+ ...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders
180
+ });
181
+ }
182
+ const args = deepMerge(options, reqOptions);
174
183
  return req.fetch(opts.args[0], args);
175
184
  }
176
185
  return req;
@@ -8,7 +8,7 @@ var mergePath = (base, path) => {
8
8
  };
9
9
  var replaceUrlParam = (urlString, params) => {
10
10
  for (const [k, v] of Object.entries(params)) {
11
- const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
11
+ const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
12
12
  urlString = urlString.replace(reg, v ? `/${v}` : "");
13
13
  }
14
14
  return urlString;
@@ -11,16 +11,17 @@ var SSEStreamingApi = class extends StreamingApi {
11
11
  const dataLines = data.split(/\r\n|\r|\n/).map((line) => {
12
12
  return `data: ${line}`;
13
13
  }).join("\n");
14
- for (const key of ["event", "id", "retry"]) {
15
- if (message[key] && /[\r\n]/.test(message[key])) {
14
+ for (const key of ["event", "id"]) {
15
+ const value = message[key];
16
+ if (value && /[\r\n]/.test(value)) {
16
17
  throw new Error(`${key} must not contain "\\r" or "\\n"`);
17
18
  }
18
19
  }
19
20
  const sseData = [
20
21
  message.event && `event: ${message.event}`,
21
22
  dataLines,
22
- message.id && `id: ${message.id}`,
23
- message.retry && `retry: ${message.retry}`
23
+ message.id !== void 0 && `id: ${message.id}`,
24
+ message.retry !== void 0 && `retry: ${message.retry}`
24
25
  ].filter(Boolean).join("\n") + "\n\n";
25
26
  await this.write(sseData);
26
27
  }
@@ -34,7 +34,7 @@ var cache = (options) => {
34
34
  );
35
35
  const addHeader = (c, responseVary) => {
36
36
  if (cacheControlDirectives) {
37
- const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
37
+ const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
38
38
  for (const directive of cacheControlDirectives) {
39
39
  let [name, value] = directive.trim().split("=", 2);
40
40
  name = name.toLowerCase();
@@ -35,7 +35,8 @@ var compress = (options) => {
35
35
  return async function compress2(ctx, next) {
36
36
  await next();
37
37
  const contentLength = ctx.res.headers.get("Content-Length");
38
- if (ctx.res.headers.has("Content-Encoding") || // already encoded
38
+ if (ctx.res.status === 206 || // partial content, Content-Range refers to the uncompressed bytes
39
+ ctx.res.headers.has("Content-Encoding") || // already encoded
39
40
  ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
40
41
  ctx.req.method === "HEAD" || // HEAD request
41
42
  contentLength && Number(contentLength) < threshold || // content-length below threshold
@@ -48,7 +48,8 @@ var etag = (options) => {
48
48
  }
49
49
  etag3 = weak ? `W/"${hash}"` : `"${hash}"`;
50
50
  }
51
- if (etagMatches(etag3, ifNoneMatch)) {
51
+ const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD") && res.ok : etagMatches(etag3, ifNoneMatch);
52
+ if (matched) {
52
53
  c.res = new Response(null, {
53
54
  status: 304,
54
55
  statusText: "Not Modified",
@@ -59,11 +59,13 @@ var methodOverride = (options) => async function methodOverride2(c, next) {
59
59
  if (method) {
60
60
  const url = new URL(c.req.url);
61
61
  url.searchParams.delete(queryName);
62
- const request = new Request(url.toString(), {
62
+ const requestInit = {
63
63
  body: c.req.raw.body,
64
64
  headers: c.req.raw.headers,
65
- method
66
- });
65
+ method,
66
+ duplex: c.req.raw.body ? "half" : void 0
67
+ };
68
+ const request = new Request(url.toString(), requestInit);
67
69
  return app.fetch(request, c.env, getExecutionCtx(c));
68
70
  }
69
71
  }
@@ -49,14 +49,20 @@ var secureHeaders = (customOptions) => {
49
49
  const headersToSet = getFilteredHeaders(options);
50
50
  const callbacks = [];
51
51
  if (options.contentSecurityPolicy) {
52
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicy);
52
+ const [callback, value] = getCSPDirectives(
53
+ options.contentSecurityPolicy,
54
+ "Content-Security-Policy"
55
+ );
53
56
  if (callback) {
54
57
  callbacks.push(callback);
55
58
  }
56
59
  headersToSet.push(["Content-Security-Policy", value]);
57
60
  }
58
61
  if (options.contentSecurityPolicyReportOnly) {
59
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
62
+ const [callback, value] = getCSPDirectives(
63
+ options.contentSecurityPolicyReportOnly,
64
+ "Content-Security-Policy-Report-Only"
65
+ );
60
66
  if (callback) {
61
67
  callbacks.push(callback);
62
68
  }
@@ -89,7 +95,7 @@ function getFilteredHeaders(options) {
89
95
  return typeof overrideValue === "string" ? [defaultValue[0], overrideValue] : defaultValue;
90
96
  });
91
97
  }
92
- function getCSPDirectives(contentSecurityPolicy) {
98
+ function getCSPDirectives(contentSecurityPolicy, headerName) {
93
99
  const callbacks = [];
94
100
  const resultValues = [];
95
101
  for (const [directive, value] of Object.entries(contentSecurityPolicy)) {
@@ -114,7 +120,7 @@ function getCSPDirectives(contentSecurityPolicy) {
114
120
  resultValues.pop();
115
121
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
116
122
  (ctx, headersToSet) => headersToSet.map((values) => {
117
- if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
123
+ if (values[0] === headerName) {
118
124
  const clone = values[1].slice();
119
125
  callbacks.forEach((cb) => {
120
126
  cb(ctx, clone);
@@ -76,7 +76,7 @@ var HonoRequest = class {
76
76
  if (name) {
77
77
  return this.raw.headers.get(name) ?? void 0;
78
78
  }
79
- const headerData = {};
79
+ const headerData = /* @__PURE__ */ Object.create(null);
80
80
  this.raw.headers.forEach((value, key) => {
81
81
  headerData[key] = value;
82
82
  });
@@ -294,11 +294,16 @@ var cloneRawRequest = async (req) => {
294
294
  message: "Cannot clone request: body was already consumed and not cached. Please use HonoRequest methods (e.g., req.json(), req.text()) instead of consuming req.raw directly."
295
295
  });
296
296
  }
297
+ const body = await req[cacheKey]();
298
+ const headers = req.header();
299
+ if (body instanceof FormData) {
300
+ delete headers["content-type"];
301
+ }
297
302
  const requestInit = {
298
- body: await req[cacheKey](),
303
+ body,
299
304
  cache: req.raw.cache,
300
305
  credentials: req.raw.credentials,
301
- headers: req.header(),
306
+ headers,
302
307
  integrity: req.raw.integrity,
303
308
  keepalive: req.raw.keepalive,
304
309
  method: req.method,
@@ -134,6 +134,15 @@ var Node = class _Node {
134
134
  if (m) {
135
135
  params[name] = m[0];
136
136
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
137
+ if (m[0].length === restPathString.length && child.#children["*"]) {
138
+ this.#pushHandlerSets(
139
+ handlerSets,
140
+ child.#children["*"],
141
+ method,
142
+ node.#params,
143
+ params
144
+ );
145
+ }
137
146
  if (hasChildren(child.#children)) {
138
147
  child.#params = params;
139
148
  const componentCount = m[0].match(/\//)?.length ?? 0;
@@ -96,6 +96,15 @@ interface Authorizer {
96
96
  userArn: string;
97
97
  userId: string;
98
98
  };
99
+ jwt?: {
100
+ claims: Record<string, string | number | boolean | string[]>;
101
+ scopes: string[] | null;
102
+ };
103
+ /**
104
+ * The `context` object returned by a Lambda (REQUEST) authorizer.
105
+ * It is `null` when the authorizer returns no context.
106
+ */
107
+ lambda?: Record<string, unknown> | null;
99
108
  }
100
109
  export interface ApiGatewayRequestContextV2 {
101
110
  accountId: string;
@@ -81,7 +81,7 @@ interface CloudFrontResult {
81
81
  body?: string;
82
82
  bodyEncoding?: 'text' | 'base64';
83
83
  }
84
- export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>);
84
+ export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult | CloudFrontRequest>);
85
85
  export declare const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array<ArrayBuffer> | undefined;
86
86
  export declare const isContentTypeBinary: (contentType: string) => boolean;
87
87
  export {};
@@ -31,7 +31,7 @@ export type WSReadyState = 0 | 1 | 2 | 3;
31
31
  * An argument for WSContext class
32
32
  */
33
33
  export interface WSContextInit<T = unknown> {
34
- send(data: string | ArrayBuffer | Uint8Array, options: SendOptions): void;
34
+ send(data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options: SendOptions): void;
35
35
  close(code?: number, reason?: string): void;
36
36
  raw?: T;
37
37
  readyState: WSReadyState;
@@ -71,7 +71,7 @@ export declare const every: (...middleware: (MiddlewareHandler | Condition)[]) =
71
71
  * @example
72
72
  * ```ts
73
73
  * import { except } from 'hono/combine'
74
- * import { bearerAuth } from 'hono/bearer-auth
74
+ * import { bearerAuth } from 'hono/bearer-auth'
75
75
  *
76
76
  * // If client is accessing public API, then skip authentication.
77
77
  * // Otherwise, require a valid token.
@@ -98,5 +98,23 @@ export declare function validateOptions(options: DetectorOptions): void;
98
98
  * Language detector middleware factory
99
99
  * @param userOptions Configuration options for the language detector
100
100
  * @returns Hono middleware function
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * type Variables = LanguageVariables
105
+ * const app = new Hono<{ Variables: Variables }>()
106
+ *
107
+ * app.use(
108
+ * languageDetector({
109
+ * supportedLanguages: ['en', 'ja'], // Must include fallback
110
+ * fallbackLanguage: 'en', // Required
111
+ * })
112
+ * )
113
+ *
114
+ * app.get('/', (c) => {
115
+ * const lang = c.get('language')
116
+ * return c.text(`Current language: ${lang}`)
117
+ * })
118
+ * ```
101
119
  */
102
120
  export declare const languageDetector: (userOptions: Partial<DetectorOptions>) => MiddlewareHandler;
@@ -42,7 +42,7 @@ export type JSONParsed<T, TError = bigint | ReadonlyArray<bigint>> = T extends {
42
42
  toJSON(): unknown;
43
43
  } ? {} : JSONParsed<J, TError> : T extends JSONPrimitive ? T : T extends InvalidJSONValue ? never : T extends ReadonlyArray<unknown> ? {
44
44
  [K in keyof T]: JSONParsed<InvalidToNull<T[K]>, TError>;
45
- } : T extends Set<unknown> | Map<unknown, unknown> | Record<string, never> ? {} : T extends object ? T[keyof T] extends TError ? never : {
45
+ } extends infer A ? A extends ReadonlyArray<unknown> ? A : JSONParsed<InvalidToNull<T[number]>, TError>[] : never : T extends Set<unknown> | Map<unknown, unknown> | Record<string, never> ? {} : T extends object ? T[keyof T] extends TError ? never : {
46
46
  [K in keyof OmitSymbolKeys<T> as IsInvalid<T[K]> extends true ? never : K]: boolean extends IsInvalid<T[K]> ? JSONParsed<T[K], TError> | undefined : JSONParsed<T[K], TError>;
47
47
  } : T extends unknown ? T extends TError ? never : JSONValue : never;
48
48
  /**
@@ -125,7 +125,7 @@ var getNextParam = (acceptHeader, startIndex) => {
125
125
  var getNextAcceptValue = (acceptHeader, startIndex) => {
126
126
  const accept = {
127
127
  type: "",
128
- params: {},
128
+ params: /* @__PURE__ */ Object.create(null),
129
129
  q: 1
130
130
  };
131
131
  startIndex = consumeWhitespace(acceptHeader, startIndex);
@@ -12,6 +12,12 @@ var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) =
12
12
  return {};
13
13
  };
14
14
  async function parseFormData(request, options) {
15
+ if (!isRawRequest(request) && request.bodyCache.formData) {
16
+ return convertFormDataToBodyData(
17
+ await request.bodyCache.formData,
18
+ options
19
+ );
20
+ }
15
21
  const headers = isRawRequest(request) ? request.headers : request.raw.headers;
16
22
  const arrayBuffer = await request.arrayBuffer();
17
23
  const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
@@ -159,7 +159,7 @@ var _getQueryParam = (url, key, multiple) => {
159
159
  return void 0;
160
160
  }
161
161
  }
162
- const results = {};
162
+ const results = /* @__PURE__ */ Object.create(null);
163
163
  encoded ??= /[%+]/.test(url);
164
164
  let keyIndex = url.indexOf("?", 8);
165
165
  while (keyIndex !== -1) {