noodleseed-cli 0.1.15 → 0.1.16

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 (558) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/cli.js.map +1 -1
  3. package/dist/project.d.ts +1 -1
  4. package/dist/project.d.ts.map +1 -1
  5. package/dist/project.js +103 -3
  6. package/dist/project.js.map +1 -1
  7. package/node_modules/@modelcontextprotocol/sdk/package.json +0 -2
  8. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -2
  9. package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
  10. package/node_modules/@noodle-borg/authoring/dist/index.js +2 -1
  11. package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
  12. package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
  13. package/node_modules/@noodle-borg/compiler/dist/compile.js +30 -2
  14. package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
  15. package/node_modules/@noodle-borg/compiler/dist/index.d.ts +1 -0
  16. package/node_modules/@noodle-borg/compiler/dist/index.d.ts.map +1 -1
  17. package/node_modules/@noodle-borg/compiler/dist/index.js +1 -0
  18. package/node_modules/@noodle-borg/compiler/dist/index.js.map +1 -1
  19. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +14866 -2
  20. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
  21. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +12 -2
  22. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
  23. package/node_modules/@noodle-borg/compiler/dist/widget-ui.d.ts +95 -0
  24. package/node_modules/@noodle-borg/compiler/dist/widget-ui.d.ts.map +1 -0
  25. package/node_modules/@noodle-borg/compiler/dist/widget-ui.js +177 -0
  26. package/node_modules/@noodle-borg/compiler/dist/widget-ui.js.map +1 -0
  27. package/node_modules/@noodle-borg/compiler/node_modules/.bin/yaml +3 -3
  28. package/node_modules/@noodle-borg/connector-defs/node_modules/.bin/yaml +3 -3
  29. package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.d.ts.map +1 -1
  30. package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.js +60 -3
  31. package/node_modules/@noodle-borg/protocol/dist/widget/bootstrap.js.map +1 -1
  32. package/node_modules/@noodle-borg/service/package.json +0 -1
  33. package/node_modules/cors/package.json +0 -1
  34. package/node_modules/cross-spawn/node_modules/.bin/node-which +3 -3
  35. package/package.json +1 -56
  36. package/node_modules/accepts/HISTORY.md +0 -250
  37. package/node_modules/accepts/LICENSE +0 -23
  38. package/node_modules/accepts/README.md +0 -140
  39. package/node_modules/accepts/index.js +0 -238
  40. package/node_modules/accepts/package.json +0 -47
  41. package/node_modules/body-parser/LICENSE +0 -23
  42. package/node_modules/body-parser/README.md +0 -494
  43. package/node_modules/body-parser/index.js +0 -71
  44. package/node_modules/body-parser/lib/read.js +0 -247
  45. package/node_modules/body-parser/lib/types/json.js +0 -158
  46. package/node_modules/body-parser/lib/types/raw.js +0 -42
  47. package/node_modules/body-parser/lib/types/text.js +0 -36
  48. package/node_modules/body-parser/lib/types/urlencoded.js +0 -142
  49. package/node_modules/body-parser/lib/utils.js +0 -98
  50. package/node_modules/body-parser/package.json +0 -52
  51. package/node_modules/call-bind-apply-helpers/.eslintrc +0 -17
  52. package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +0 -12
  53. package/node_modules/call-bind-apply-helpers/.nycrc +0 -9
  54. package/node_modules/call-bind-apply-helpers/CHANGELOG.md +0 -30
  55. package/node_modules/call-bind-apply-helpers/LICENSE +0 -21
  56. package/node_modules/call-bind-apply-helpers/README.md +0 -62
  57. package/node_modules/call-bind-apply-helpers/actualApply.d.ts +0 -1
  58. package/node_modules/call-bind-apply-helpers/actualApply.js +0 -10
  59. package/node_modules/call-bind-apply-helpers/applyBind.d.ts +0 -19
  60. package/node_modules/call-bind-apply-helpers/applyBind.js +0 -10
  61. package/node_modules/call-bind-apply-helpers/functionApply.d.ts +0 -1
  62. package/node_modules/call-bind-apply-helpers/functionApply.js +0 -4
  63. package/node_modules/call-bind-apply-helpers/functionCall.d.ts +0 -1
  64. package/node_modules/call-bind-apply-helpers/functionCall.js +0 -4
  65. package/node_modules/call-bind-apply-helpers/index.d.ts +0 -64
  66. package/node_modules/call-bind-apply-helpers/index.js +0 -15
  67. package/node_modules/call-bind-apply-helpers/package.json +0 -85
  68. package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +0 -3
  69. package/node_modules/call-bind-apply-helpers/reflectApply.js +0 -4
  70. package/node_modules/call-bind-apply-helpers/test/index.js +0 -63
  71. package/node_modules/call-bind-apply-helpers/tsconfig.json +0 -9
  72. package/node_modules/call-bound/.eslintrc +0 -13
  73. package/node_modules/call-bound/.github/FUNDING.yml +0 -12
  74. package/node_modules/call-bound/.nycrc +0 -9
  75. package/node_modules/call-bound/CHANGELOG.md +0 -42
  76. package/node_modules/call-bound/LICENSE +0 -21
  77. package/node_modules/call-bound/README.md +0 -53
  78. package/node_modules/call-bound/index.d.ts +0 -94
  79. package/node_modules/call-bound/index.js +0 -19
  80. package/node_modules/call-bound/package.json +0 -99
  81. package/node_modules/call-bound/test/index.js +0 -61
  82. package/node_modules/call-bound/tsconfig.json +0 -10
  83. package/node_modules/content-disposition/LICENSE +0 -22
  84. package/node_modules/content-disposition/README.md +0 -141
  85. package/node_modules/content-disposition/index.js +0 -536
  86. package/node_modules/content-disposition/package.json +0 -40
  87. package/node_modules/cookie/LICENSE +0 -24
  88. package/node_modules/cookie/README.md +0 -317
  89. package/node_modules/cookie/SECURITY.md +0 -25
  90. package/node_modules/cookie/index.js +0 -335
  91. package/node_modules/cookie/package.json +0 -44
  92. package/node_modules/cookie-signature/History.md +0 -70
  93. package/node_modules/cookie-signature/LICENSE +0 -22
  94. package/node_modules/cookie-signature/Readme.md +0 -23
  95. package/node_modules/cookie-signature/index.js +0 -47
  96. package/node_modules/cookie-signature/package.json +0 -28
  97. package/node_modules/debug/LICENSE +0 -20
  98. package/node_modules/debug/README.md +0 -481
  99. package/node_modules/debug/package.json +0 -64
  100. package/node_modules/debug/src/browser.js +0 -272
  101. package/node_modules/debug/src/common.js +0 -292
  102. package/node_modules/debug/src/index.js +0 -10
  103. package/node_modules/debug/src/node.js +0 -263
  104. package/node_modules/dunder-proto/.eslintrc +0 -5
  105. package/node_modules/dunder-proto/.github/FUNDING.yml +0 -12
  106. package/node_modules/dunder-proto/.nycrc +0 -13
  107. package/node_modules/dunder-proto/CHANGELOG.md +0 -24
  108. package/node_modules/dunder-proto/LICENSE +0 -21
  109. package/node_modules/dunder-proto/README.md +0 -54
  110. package/node_modules/dunder-proto/get.d.ts +0 -5
  111. package/node_modules/dunder-proto/get.js +0 -30
  112. package/node_modules/dunder-proto/package.json +0 -76
  113. package/node_modules/dunder-proto/set.d.ts +0 -5
  114. package/node_modules/dunder-proto/set.js +0 -35
  115. package/node_modules/dunder-proto/test/get.js +0 -34
  116. package/node_modules/dunder-proto/test/index.js +0 -4
  117. package/node_modules/dunder-proto/test/set.js +0 -50
  118. package/node_modules/dunder-proto/tsconfig.json +0 -9
  119. package/node_modules/ee-first/LICENSE +0 -22
  120. package/node_modules/ee-first/README.md +0 -80
  121. package/node_modules/ee-first/index.js +0 -95
  122. package/node_modules/ee-first/package.json +0 -29
  123. package/node_modules/encodeurl/LICENSE +0 -22
  124. package/node_modules/encodeurl/README.md +0 -109
  125. package/node_modules/encodeurl/index.js +0 -60
  126. package/node_modules/encodeurl/package.json +0 -40
  127. package/node_modules/es-define-property/.eslintrc +0 -13
  128. package/node_modules/es-define-property/.github/FUNDING.yml +0 -12
  129. package/node_modules/es-define-property/.nycrc +0 -9
  130. package/node_modules/es-define-property/CHANGELOG.md +0 -29
  131. package/node_modules/es-define-property/LICENSE +0 -21
  132. package/node_modules/es-define-property/README.md +0 -49
  133. package/node_modules/es-define-property/index.d.ts +0 -3
  134. package/node_modules/es-define-property/index.js +0 -14
  135. package/node_modules/es-define-property/package.json +0 -81
  136. package/node_modules/es-define-property/test/index.js +0 -56
  137. package/node_modules/es-define-property/tsconfig.json +0 -10
  138. package/node_modules/es-errors/.eslintrc +0 -5
  139. package/node_modules/es-errors/.github/FUNDING.yml +0 -12
  140. package/node_modules/es-errors/CHANGELOG.md +0 -40
  141. package/node_modules/es-errors/LICENSE +0 -21
  142. package/node_modules/es-errors/README.md +0 -55
  143. package/node_modules/es-errors/eval.d.ts +0 -3
  144. package/node_modules/es-errors/eval.js +0 -4
  145. package/node_modules/es-errors/index.d.ts +0 -3
  146. package/node_modules/es-errors/index.js +0 -4
  147. package/node_modules/es-errors/package.json +0 -80
  148. package/node_modules/es-errors/range.d.ts +0 -3
  149. package/node_modules/es-errors/range.js +0 -4
  150. package/node_modules/es-errors/ref.d.ts +0 -3
  151. package/node_modules/es-errors/ref.js +0 -4
  152. package/node_modules/es-errors/syntax.d.ts +0 -3
  153. package/node_modules/es-errors/syntax.js +0 -4
  154. package/node_modules/es-errors/test/index.js +0 -19
  155. package/node_modules/es-errors/tsconfig.json +0 -49
  156. package/node_modules/es-errors/type.d.ts +0 -3
  157. package/node_modules/es-errors/type.js +0 -4
  158. package/node_modules/es-errors/uri.d.ts +0 -3
  159. package/node_modules/es-errors/uri.js +0 -4
  160. package/node_modules/es-object-atoms/.eslintrc +0 -16
  161. package/node_modules/es-object-atoms/.github/FUNDING.yml +0 -12
  162. package/node_modules/es-object-atoms/CHANGELOG.md +0 -44
  163. package/node_modules/es-object-atoms/LICENSE +0 -21
  164. package/node_modules/es-object-atoms/README.md +0 -63
  165. package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +0 -3
  166. package/node_modules/es-object-atoms/RequireObjectCoercible.js +0 -11
  167. package/node_modules/es-object-atoms/ToObject.d.ts +0 -7
  168. package/node_modules/es-object-atoms/ToObject.js +0 -10
  169. package/node_modules/es-object-atoms/index.d.ts +0 -3
  170. package/node_modules/es-object-atoms/index.js +0 -4
  171. package/node_modules/es-object-atoms/isObject.d.ts +0 -3
  172. package/node_modules/es-object-atoms/isObject.js +0 -6
  173. package/node_modules/es-object-atoms/package.json +0 -79
  174. package/node_modules/es-object-atoms/test/index.js +0 -38
  175. package/node_modules/es-object-atoms/tsconfig.json +0 -7
  176. package/node_modules/escape-html/LICENSE +0 -24
  177. package/node_modules/escape-html/Readme.md +0 -43
  178. package/node_modules/escape-html/index.js +0 -78
  179. package/node_modules/escape-html/package.json +0 -24
  180. package/node_modules/etag/HISTORY.md +0 -83
  181. package/node_modules/etag/LICENSE +0 -22
  182. package/node_modules/etag/README.md +0 -159
  183. package/node_modules/etag/index.js +0 -131
  184. package/node_modules/etag/package.json +0 -47
  185. package/node_modules/express/LICENSE +0 -24
  186. package/node_modules/express/Readme.md +0 -276
  187. package/node_modules/express/index.js +0 -11
  188. package/node_modules/express/lib/application.js +0 -631
  189. package/node_modules/express/lib/express.js +0 -81
  190. package/node_modules/express/lib/request.js +0 -514
  191. package/node_modules/express/lib/response.js +0 -1053
  192. package/node_modules/express/lib/utils.js +0 -271
  193. package/node_modules/express/lib/view.js +0 -205
  194. package/node_modules/express/package.json +0 -99
  195. package/node_modules/express-rate-limit/dist/index.cjs +0 -1016
  196. package/node_modules/express-rate-limit/dist/index.d.cts +0 -672
  197. package/node_modules/express-rate-limit/dist/index.d.mts +0 -672
  198. package/node_modules/express-rate-limit/dist/index.d.ts +0 -672
  199. package/node_modules/express-rate-limit/dist/index.mjs +0 -986
  200. package/node_modules/express-rate-limit/license.md +0 -20
  201. package/node_modules/express-rate-limit/package.json +0 -113
  202. package/node_modules/express-rate-limit/readme.md +0 -139
  203. package/node_modules/express-rate-limit/tsconfig.json +0 -8
  204. package/node_modules/finalhandler/HISTORY.md +0 -239
  205. package/node_modules/finalhandler/LICENSE +0 -22
  206. package/node_modules/finalhandler/README.md +0 -150
  207. package/node_modules/finalhandler/index.js +0 -293
  208. package/node_modules/finalhandler/package.json +0 -47
  209. package/node_modules/forwarded/HISTORY.md +0 -21
  210. package/node_modules/forwarded/LICENSE +0 -22
  211. package/node_modules/forwarded/README.md +0 -57
  212. package/node_modules/forwarded/index.js +0 -90
  213. package/node_modules/forwarded/package.json +0 -45
  214. package/node_modules/fresh/HISTORY.md +0 -80
  215. package/node_modules/fresh/LICENSE +0 -23
  216. package/node_modules/fresh/README.md +0 -117
  217. package/node_modules/fresh/index.js +0 -136
  218. package/node_modules/fresh/package.json +0 -46
  219. package/node_modules/function-bind/.eslintrc +0 -21
  220. package/node_modules/function-bind/.github/FUNDING.yml +0 -12
  221. package/node_modules/function-bind/.github/SECURITY.md +0 -3
  222. package/node_modules/function-bind/.nycrc +0 -13
  223. package/node_modules/function-bind/CHANGELOG.md +0 -136
  224. package/node_modules/function-bind/LICENSE +0 -20
  225. package/node_modules/function-bind/README.md +0 -46
  226. package/node_modules/function-bind/implementation.js +0 -84
  227. package/node_modules/function-bind/index.js +0 -5
  228. package/node_modules/function-bind/package.json +0 -87
  229. package/node_modules/function-bind/test/.eslintrc +0 -9
  230. package/node_modules/function-bind/test/index.js +0 -252
  231. package/node_modules/get-intrinsic/.eslintrc +0 -42
  232. package/node_modules/get-intrinsic/.github/FUNDING.yml +0 -12
  233. package/node_modules/get-intrinsic/.nycrc +0 -9
  234. package/node_modules/get-intrinsic/CHANGELOG.md +0 -186
  235. package/node_modules/get-intrinsic/LICENSE +0 -21
  236. package/node_modules/get-intrinsic/README.md +0 -71
  237. package/node_modules/get-intrinsic/index.js +0 -378
  238. package/node_modules/get-intrinsic/package.json +0 -97
  239. package/node_modules/get-intrinsic/test/GetIntrinsic.js +0 -274
  240. package/node_modules/get-proto/.eslintrc +0 -10
  241. package/node_modules/get-proto/.github/FUNDING.yml +0 -12
  242. package/node_modules/get-proto/.nycrc +0 -9
  243. package/node_modules/get-proto/CHANGELOG.md +0 -21
  244. package/node_modules/get-proto/LICENSE +0 -21
  245. package/node_modules/get-proto/Object.getPrototypeOf.d.ts +0 -5
  246. package/node_modules/get-proto/Object.getPrototypeOf.js +0 -6
  247. package/node_modules/get-proto/README.md +0 -50
  248. package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +0 -3
  249. package/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -4
  250. package/node_modules/get-proto/index.d.ts +0 -5
  251. package/node_modules/get-proto/index.js +0 -27
  252. package/node_modules/get-proto/package.json +0 -81
  253. package/node_modules/get-proto/test/index.js +0 -68
  254. package/node_modules/get-proto/tsconfig.json +0 -9
  255. package/node_modules/gopd/.eslintrc +0 -16
  256. package/node_modules/gopd/.github/FUNDING.yml +0 -12
  257. package/node_modules/gopd/CHANGELOG.md +0 -45
  258. package/node_modules/gopd/LICENSE +0 -21
  259. package/node_modules/gopd/README.md +0 -40
  260. package/node_modules/gopd/gOPD.d.ts +0 -1
  261. package/node_modules/gopd/gOPD.js +0 -4
  262. package/node_modules/gopd/index.d.ts +0 -5
  263. package/node_modules/gopd/index.js +0 -15
  264. package/node_modules/gopd/package.json +0 -77
  265. package/node_modules/gopd/test/index.js +0 -36
  266. package/node_modules/gopd/tsconfig.json +0 -9
  267. package/node_modules/has-symbols/.eslintrc +0 -11
  268. package/node_modules/has-symbols/.github/FUNDING.yml +0 -12
  269. package/node_modules/has-symbols/.nycrc +0 -9
  270. package/node_modules/has-symbols/CHANGELOG.md +0 -91
  271. package/node_modules/has-symbols/LICENSE +0 -21
  272. package/node_modules/has-symbols/README.md +0 -46
  273. package/node_modules/has-symbols/index.d.ts +0 -3
  274. package/node_modules/has-symbols/index.js +0 -14
  275. package/node_modules/has-symbols/package.json +0 -111
  276. package/node_modules/has-symbols/shams.d.ts +0 -3
  277. package/node_modules/has-symbols/shams.js +0 -45
  278. package/node_modules/has-symbols/test/index.js +0 -22
  279. package/node_modules/has-symbols/test/shams/core-js.js +0 -29
  280. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +0 -29
  281. package/node_modules/has-symbols/test/tests.js +0 -58
  282. package/node_modules/has-symbols/tsconfig.json +0 -10
  283. package/node_modules/hasown/.github/FUNDING.yml +0 -12
  284. package/node_modules/hasown/.nycrc +0 -13
  285. package/node_modules/hasown/CHANGELOG.md +0 -58
  286. package/node_modules/hasown/LICENSE +0 -21
  287. package/node_modules/hasown/README.md +0 -40
  288. package/node_modules/hasown/eslint.config.mjs +0 -6
  289. package/node_modules/hasown/index.d.ts +0 -3
  290. package/node_modules/hasown/index.js +0 -8
  291. package/node_modules/hasown/package.json +0 -91
  292. package/node_modules/hasown/tsconfig.json +0 -6
  293. package/node_modules/ip-address/LICENSE +0 -19
  294. package/node_modules/ip-address/README.md +0 -278
  295. package/node_modules/ip-address/dist/address-error.d.ts +0 -4
  296. package/node_modules/ip-address/dist/address-error.js +0 -12
  297. package/node_modules/ip-address/dist/address-error.js.map +0 -1
  298. package/node_modules/ip-address/dist/common.d.ts +0 -20
  299. package/node_modules/ip-address/dist/common.js +0 -67
  300. package/node_modules/ip-address/dist/common.js.map +0 -1
  301. package/node_modules/ip-address/dist/ip-address.d.ts +0 -7
  302. package/node_modules/ip-address/dist/ip-address.js +0 -35
  303. package/node_modules/ip-address/dist/ip-address.js.map +0 -1
  304. package/node_modules/ip-address/dist/ipv4.d.ts +0 -267
  305. package/node_modules/ip-address/dist/ipv4.js +0 -485
  306. package/node_modules/ip-address/dist/ipv4.js.map +0 -1
  307. package/node_modules/ip-address/dist/ipv6.d.ts +0 -489
  308. package/node_modules/ip-address/dist/ipv6.js +0 -1217
  309. package/node_modules/ip-address/dist/ipv6.js.map +0 -1
  310. package/node_modules/ip-address/dist/v4/constants.d.ts +0 -4
  311. package/node_modules/ip-address/dist/v4/constants.js +0 -8
  312. package/node_modules/ip-address/dist/v4/constants.js.map +0 -1
  313. package/node_modules/ip-address/dist/v6/constants.d.ts +0 -44
  314. package/node_modules/ip-address/dist/v6/constants.js +0 -81
  315. package/node_modules/ip-address/dist/v6/constants.js.map +0 -1
  316. package/node_modules/ip-address/dist/v6/helpers.d.ts +0 -18
  317. package/node_modules/ip-address/dist/v6/helpers.js +0 -54
  318. package/node_modules/ip-address/dist/v6/helpers.js.map +0 -1
  319. package/node_modules/ip-address/dist/v6/regular-expressions.d.ts +0 -5
  320. package/node_modules/ip-address/dist/v6/regular-expressions.js +0 -95
  321. package/node_modules/ip-address/dist/v6/regular-expressions.js.map +0 -1
  322. package/node_modules/ip-address/package.json +0 -88
  323. package/node_modules/is-promise/LICENSE +0 -19
  324. package/node_modules/is-promise/index.d.ts +0 -2
  325. package/node_modules/is-promise/index.js +0 -6
  326. package/node_modules/is-promise/index.mjs +0 -3
  327. package/node_modules/is-promise/package.json +0 -30
  328. package/node_modules/is-promise/readme.md +0 -33
  329. package/node_modules/math-intrinsics/.eslintrc +0 -16
  330. package/node_modules/math-intrinsics/.github/FUNDING.yml +0 -12
  331. package/node_modules/math-intrinsics/CHANGELOG.md +0 -24
  332. package/node_modules/math-intrinsics/LICENSE +0 -21
  333. package/node_modules/math-intrinsics/README.md +0 -50
  334. package/node_modules/math-intrinsics/abs.d.ts +0 -1
  335. package/node_modules/math-intrinsics/abs.js +0 -4
  336. package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +0 -3
  337. package/node_modules/math-intrinsics/constants/maxArrayLength.js +0 -4
  338. package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +0 -3
  339. package/node_modules/math-intrinsics/constants/maxSafeInteger.js +0 -5
  340. package/node_modules/math-intrinsics/constants/maxValue.d.ts +0 -3
  341. package/node_modules/math-intrinsics/constants/maxValue.js +0 -5
  342. package/node_modules/math-intrinsics/floor.d.ts +0 -1
  343. package/node_modules/math-intrinsics/floor.js +0 -4
  344. package/node_modules/math-intrinsics/isFinite.d.ts +0 -3
  345. package/node_modules/math-intrinsics/isFinite.js +0 -12
  346. package/node_modules/math-intrinsics/isInteger.d.ts +0 -3
  347. package/node_modules/math-intrinsics/isInteger.js +0 -16
  348. package/node_modules/math-intrinsics/isNaN.d.ts +0 -1
  349. package/node_modules/math-intrinsics/isNaN.js +0 -6
  350. package/node_modules/math-intrinsics/isNegativeZero.d.ts +0 -3
  351. package/node_modules/math-intrinsics/isNegativeZero.js +0 -6
  352. package/node_modules/math-intrinsics/max.d.ts +0 -1
  353. package/node_modules/math-intrinsics/max.js +0 -4
  354. package/node_modules/math-intrinsics/min.d.ts +0 -1
  355. package/node_modules/math-intrinsics/min.js +0 -4
  356. package/node_modules/math-intrinsics/mod.d.ts +0 -3
  357. package/node_modules/math-intrinsics/mod.js +0 -9
  358. package/node_modules/math-intrinsics/package.json +0 -86
  359. package/node_modules/math-intrinsics/pow.d.ts +0 -1
  360. package/node_modules/math-intrinsics/pow.js +0 -4
  361. package/node_modules/math-intrinsics/round.d.ts +0 -1
  362. package/node_modules/math-intrinsics/round.js +0 -4
  363. package/node_modules/math-intrinsics/sign.d.ts +0 -3
  364. package/node_modules/math-intrinsics/sign.js +0 -11
  365. package/node_modules/math-intrinsics/test/index.js +0 -192
  366. package/node_modules/math-intrinsics/tsconfig.json +0 -3
  367. package/node_modules/media-typer/HISTORY.md +0 -50
  368. package/node_modules/media-typer/LICENSE +0 -22
  369. package/node_modules/media-typer/README.md +0 -93
  370. package/node_modules/media-typer/index.js +0 -143
  371. package/node_modules/media-typer/package.json +0 -33
  372. package/node_modules/merge-descriptors/index.d.ts +0 -11
  373. package/node_modules/merge-descriptors/index.js +0 -26
  374. package/node_modules/merge-descriptors/license +0 -11
  375. package/node_modules/merge-descriptors/package.json +0 -50
  376. package/node_modules/merge-descriptors/readme.md +0 -55
  377. package/node_modules/mime-db/HISTORY.md +0 -541
  378. package/node_modules/mime-db/LICENSE +0 -23
  379. package/node_modules/mime-db/README.md +0 -109
  380. package/node_modules/mime-db/db.json +0 -9342
  381. package/node_modules/mime-db/index.js +0 -12
  382. package/node_modules/mime-db/package.json +0 -56
  383. package/node_modules/mime-types/HISTORY.md +0 -428
  384. package/node_modules/mime-types/LICENSE +0 -23
  385. package/node_modules/mime-types/README.md +0 -126
  386. package/node_modules/mime-types/index.js +0 -211
  387. package/node_modules/mime-types/mimeScore.js +0 -57
  388. package/node_modules/mime-types/package.json +0 -49
  389. package/node_modules/ms/index.js +0 -162
  390. package/node_modules/ms/license.md +0 -21
  391. package/node_modules/ms/package.json +0 -38
  392. package/node_modules/ms/readme.md +0 -59
  393. package/node_modules/negotiator/HISTORY.md +0 -114
  394. package/node_modules/negotiator/LICENSE +0 -24
  395. package/node_modules/negotiator/README.md +0 -212
  396. package/node_modules/negotiator/index.js +0 -83
  397. package/node_modules/negotiator/lib/charset.js +0 -169
  398. package/node_modules/negotiator/lib/encoding.js +0 -205
  399. package/node_modules/negotiator/lib/language.js +0 -179
  400. package/node_modules/negotiator/lib/mediaType.js +0 -294
  401. package/node_modules/negotiator/package.json +0 -43
  402. package/node_modules/object-inspect/.eslintrc +0 -53
  403. package/node_modules/object-inspect/.github/FUNDING.yml +0 -12
  404. package/node_modules/object-inspect/.nycrc +0 -13
  405. package/node_modules/object-inspect/CHANGELOG.md +0 -424
  406. package/node_modules/object-inspect/LICENSE +0 -21
  407. package/node_modules/object-inspect/example/all.js +0 -23
  408. package/node_modules/object-inspect/example/circular.js +0 -6
  409. package/node_modules/object-inspect/example/fn.js +0 -5
  410. package/node_modules/object-inspect/example/inspect.js +0 -10
  411. package/node_modules/object-inspect/index.js +0 -544
  412. package/node_modules/object-inspect/package-support.json +0 -20
  413. package/node_modules/object-inspect/package.json +0 -105
  414. package/node_modules/object-inspect/readme.markdown +0 -84
  415. package/node_modules/object-inspect/test/bigint.js +0 -58
  416. package/node_modules/object-inspect/test/browser/dom.js +0 -15
  417. package/node_modules/object-inspect/test/circular.js +0 -16
  418. package/node_modules/object-inspect/test/deep.js +0 -12
  419. package/node_modules/object-inspect/test/element.js +0 -53
  420. package/node_modules/object-inspect/test/err.js +0 -48
  421. package/node_modules/object-inspect/test/fakes.js +0 -29
  422. package/node_modules/object-inspect/test/fn.js +0 -76
  423. package/node_modules/object-inspect/test/global.js +0 -17
  424. package/node_modules/object-inspect/test/has.js +0 -15
  425. package/node_modules/object-inspect/test/holes.js +0 -15
  426. package/node_modules/object-inspect/test/indent-option.js +0 -271
  427. package/node_modules/object-inspect/test/inspect.js +0 -139
  428. package/node_modules/object-inspect/test/lowbyte.js +0 -12
  429. package/node_modules/object-inspect/test/number.js +0 -58
  430. package/node_modules/object-inspect/test/quoteStyle.js +0 -26
  431. package/node_modules/object-inspect/test/toStringTag.js +0 -40
  432. package/node_modules/object-inspect/test/undef.js +0 -12
  433. package/node_modules/object-inspect/test/values.js +0 -261
  434. package/node_modules/object-inspect/test-core-js.js +0 -26
  435. package/node_modules/object-inspect/util.inspect.js +0 -1
  436. package/node_modules/on-finished/HISTORY.md +0 -98
  437. package/node_modules/on-finished/LICENSE +0 -23
  438. package/node_modules/on-finished/README.md +0 -162
  439. package/node_modules/on-finished/index.js +0 -234
  440. package/node_modules/on-finished/package.json +0 -39
  441. package/node_modules/once/LICENSE +0 -15
  442. package/node_modules/once/README.md +0 -79
  443. package/node_modules/once/once.js +0 -42
  444. package/node_modules/once/package.json +0 -33
  445. package/node_modules/parseurl/HISTORY.md +0 -58
  446. package/node_modules/parseurl/LICENSE +0 -24
  447. package/node_modules/parseurl/README.md +0 -133
  448. package/node_modules/parseurl/index.js +0 -158
  449. package/node_modules/parseurl/package.json +0 -40
  450. package/node_modules/path-to-regexp/LICENSE +0 -21
  451. package/node_modules/path-to-regexp/Readme.md +0 -224
  452. package/node_modules/path-to-regexp/dist/index.d.ts +0 -147
  453. package/node_modules/path-to-regexp/dist/index.js +0 -431
  454. package/node_modules/path-to-regexp/dist/index.js.map +0 -1
  455. package/node_modules/path-to-regexp/package.json +0 -64
  456. package/node_modules/proxy-addr/HISTORY.md +0 -161
  457. package/node_modules/proxy-addr/LICENSE +0 -22
  458. package/node_modules/proxy-addr/README.md +0 -139
  459. package/node_modules/proxy-addr/index.js +0 -327
  460. package/node_modules/proxy-addr/package.json +0 -47
  461. package/node_modules/qs/.editorconfig +0 -46
  462. package/node_modules/qs/.github/FUNDING.yml +0 -12
  463. package/node_modules/qs/.github/SECURITY.md +0 -11
  464. package/node_modules/qs/.github/THREAT_MODEL.md +0 -78
  465. package/node_modules/qs/.nycrc +0 -13
  466. package/node_modules/qs/CHANGELOG.md +0 -822
  467. package/node_modules/qs/LICENSE.md +0 -29
  468. package/node_modules/qs/README.md +0 -758
  469. package/node_modules/qs/dist/qs.js +0 -141
  470. package/node_modules/qs/eslint.config.mjs +0 -57
  471. package/node_modules/qs/lib/formats.js +0 -23
  472. package/node_modules/qs/lib/index.js +0 -11
  473. package/node_modules/qs/lib/parse.js +0 -403
  474. package/node_modules/qs/lib/stringify.js +0 -363
  475. package/node_modules/qs/lib/utils.js +0 -342
  476. package/node_modules/qs/package.json +0 -94
  477. package/node_modules/qs/test/empty-keys-cases.js +0 -267
  478. package/node_modules/qs/test/parse.js +0 -1703
  479. package/node_modules/qs/test/stringify.js +0 -1448
  480. package/node_modules/qs/test/utils.js +0 -432
  481. package/node_modules/range-parser/HISTORY.md +0 -56
  482. package/node_modules/range-parser/LICENSE +0 -23
  483. package/node_modules/range-parser/README.md +0 -84
  484. package/node_modules/range-parser/index.js +0 -162
  485. package/node_modules/range-parser/package.json +0 -44
  486. package/node_modules/router/HISTORY.md +0 -228
  487. package/node_modules/router/LICENSE +0 -23
  488. package/node_modules/router/README.md +0 -416
  489. package/node_modules/router/index.js +0 -748
  490. package/node_modules/router/lib/layer.js +0 -247
  491. package/node_modules/router/lib/route.js +0 -242
  492. package/node_modules/router/package.json +0 -44
  493. package/node_modules/send/LICENSE +0 -23
  494. package/node_modules/send/README.md +0 -317
  495. package/node_modules/send/index.js +0 -997
  496. package/node_modules/send/package.json +0 -63
  497. package/node_modules/serve-static/LICENSE +0 -25
  498. package/node_modules/serve-static/README.md +0 -253
  499. package/node_modules/serve-static/index.js +0 -208
  500. package/node_modules/serve-static/package.json +0 -44
  501. package/node_modules/side-channel/.editorconfig +0 -9
  502. package/node_modules/side-channel/.eslintrc +0 -12
  503. package/node_modules/side-channel/.github/FUNDING.yml +0 -12
  504. package/node_modules/side-channel/.nycrc +0 -13
  505. package/node_modules/side-channel/CHANGELOG.md +0 -110
  506. package/node_modules/side-channel/LICENSE +0 -21
  507. package/node_modules/side-channel/README.md +0 -61
  508. package/node_modules/side-channel/index.d.ts +0 -14
  509. package/node_modules/side-channel/index.js +0 -43
  510. package/node_modules/side-channel/package.json +0 -85
  511. package/node_modules/side-channel/test/index.js +0 -104
  512. package/node_modules/side-channel/tsconfig.json +0 -9
  513. package/node_modules/side-channel-list/.editorconfig +0 -9
  514. package/node_modules/side-channel-list/.eslintrc +0 -11
  515. package/node_modules/side-channel-list/.github/FUNDING.yml +0 -12
  516. package/node_modules/side-channel-list/.nycrc +0 -13
  517. package/node_modules/side-channel-list/CHANGELOG.md +0 -36
  518. package/node_modules/side-channel-list/LICENSE +0 -21
  519. package/node_modules/side-channel-list/README.md +0 -62
  520. package/node_modules/side-channel-list/index.d.ts +0 -13
  521. package/node_modules/side-channel-list/index.js +0 -111
  522. package/node_modules/side-channel-list/list.d.ts +0 -14
  523. package/node_modules/side-channel-list/package.json +0 -77
  524. package/node_modules/side-channel-list/test/index.js +0 -154
  525. package/node_modules/side-channel-list/tsconfig.json +0 -9
  526. package/node_modules/side-channel-map/.editorconfig +0 -9
  527. package/node_modules/side-channel-map/.eslintrc +0 -11
  528. package/node_modules/side-channel-map/.github/FUNDING.yml +0 -12
  529. package/node_modules/side-channel-map/.nycrc +0 -13
  530. package/node_modules/side-channel-map/CHANGELOG.md +0 -22
  531. package/node_modules/side-channel-map/LICENSE +0 -21
  532. package/node_modules/side-channel-map/README.md +0 -62
  533. package/node_modules/side-channel-map/index.d.ts +0 -15
  534. package/node_modules/side-channel-map/index.js +0 -68
  535. package/node_modules/side-channel-map/package.json +0 -80
  536. package/node_modules/side-channel-map/test/index.js +0 -114
  537. package/node_modules/side-channel-map/tsconfig.json +0 -9
  538. package/node_modules/side-channel-weakmap/.editorconfig +0 -9
  539. package/node_modules/side-channel-weakmap/.eslintrc +0 -12
  540. package/node_modules/side-channel-weakmap/.github/FUNDING.yml +0 -12
  541. package/node_modules/side-channel-weakmap/.nycrc +0 -13
  542. package/node_modules/side-channel-weakmap/CHANGELOG.md +0 -28
  543. package/node_modules/side-channel-weakmap/LICENSE +0 -21
  544. package/node_modules/side-channel-weakmap/README.md +0 -62
  545. package/node_modules/side-channel-weakmap/index.d.ts +0 -15
  546. package/node_modules/side-channel-weakmap/index.js +0 -84
  547. package/node_modules/side-channel-weakmap/package.json +0 -87
  548. package/node_modules/side-channel-weakmap/test/index.js +0 -114
  549. package/node_modules/side-channel-weakmap/tsconfig.json +0 -9
  550. package/node_modules/type-is/HISTORY.md +0 -292
  551. package/node_modules/type-is/LICENSE +0 -23
  552. package/node_modules/type-is/README.md +0 -198
  553. package/node_modules/type-is/index.js +0 -240
  554. package/node_modules/type-is/package.json +0 -51
  555. package/node_modules/wrappy/LICENSE +0 -15
  556. package/node_modules/wrappy/README.md +0 -36
  557. package/node_modules/wrappy/package.json +0 -29
  558. package/node_modules/wrappy/wrappy.js +0 -33
@@ -1,1016 +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
- // source/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- MemoryStore: () => MemoryStore,
24
- default: () => rate_limit_default,
25
- ipKeyGenerator: () => ipKeyGenerator,
26
- rateLimit: () => rate_limit_default
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
- // source/ip-key-generator.ts
31
- var import_node_net = require("node:net");
32
- var import_ip_address = require("ip-address");
33
- function ipKeyGenerator(ip, ipv6Subnet = 56) {
34
- if ((0, import_node_net.isIPv6)(ip)) {
35
- const address = new import_ip_address.Address6(ip);
36
- if (address.is4()) return address.to4().correctForm();
37
- if (ipv6Subnet) {
38
- const subnet = new import_ip_address.Address6(`${ip}/${ipv6Subnet}`);
39
- return subnet.networkForm();
40
- }
41
- }
42
- return ip;
43
- }
44
-
45
- // source/memory-store.ts
46
- var MemoryStore = class {
47
- constructor(validations2) {
48
- this.validations = validations2;
49
- /**
50
- * These two maps store usage (requests) and reset time by key (for example, IP
51
- * addresses or API keys).
52
- *
53
- * They are split into two to avoid having to iterate through the entire set to
54
- * determine which ones need reset. Instead, `Client`s are moved from `previous`
55
- * to `current` as they hit the endpoint. Once `windowMs` has elapsed, all clients
56
- * left in `previous`, i.e., those that have not made any recent requests, are
57
- * known to be expired and can be deleted in bulk.
58
- */
59
- this.previous = /* @__PURE__ */ new Map();
60
- this.current = /* @__PURE__ */ new Map();
61
- /**
62
- * Confirmation that the keys incremented in once instance of MemoryStore
63
- * cannot affect other instances.
64
- */
65
- this.localKeys = true;
66
- }
67
- /**
68
- * Method that initializes the store.
69
- *
70
- * @param options {Options} - The options used to setup the middleware.
71
- */
72
- init(options) {
73
- this.windowMs = options.windowMs;
74
- this.validations?.windowMs(this.windowMs);
75
- if (this.interval) clearInterval(this.interval);
76
- this.interval = setInterval(() => {
77
- this.clearExpired();
78
- }, this.windowMs);
79
- this.interval.unref?.();
80
- }
81
- /**
82
- * Method to fetch a client's hit count and reset time.
83
- *
84
- * @param key {string} - The identifier for a client.
85
- *
86
- * @returns {ClientRateLimitInfo | undefined} - The number of hits and reset time for that client.
87
- *
88
- * @public
89
- */
90
- async get(key) {
91
- return this.current.get(key) ?? this.previous.get(key);
92
- }
93
- /**
94
- * Method to increment a client's hit counter.
95
- *
96
- * @param key {string} - The identifier for a client.
97
- *
98
- * @returns {ClientRateLimitInfo} - The number of hits and reset time for that client.
99
- *
100
- * @public
101
- */
102
- async increment(key) {
103
- const client = this.getClient(key);
104
- const now = Date.now();
105
- if (client.resetTime.getTime() <= now) {
106
- this.resetClient(client, now);
107
- }
108
- client.totalHits++;
109
- return client;
110
- }
111
- /**
112
- * Method to decrement a client's hit counter.
113
- *
114
- * @param key {string} - The identifier for a client.
115
- *
116
- * @public
117
- */
118
- async decrement(key) {
119
- const client = this.getClient(key);
120
- if (client.totalHits > 0) client.totalHits--;
121
- }
122
- /**
123
- * Method to reset a client's hit counter.
124
- *
125
- * @param key {string} - The identifier for a client.
126
- *
127
- * @public
128
- */
129
- async resetKey(key) {
130
- this.current.delete(key);
131
- this.previous.delete(key);
132
- }
133
- /**
134
- * Method to reset everyone's hit counter.
135
- *
136
- * @public
137
- */
138
- async resetAll() {
139
- this.current.clear();
140
- this.previous.clear();
141
- }
142
- /**
143
- * Method to stop the timer (if currently running) and prevent any memory
144
- * leaks.
145
- *
146
- * @public
147
- */
148
- shutdown() {
149
- clearInterval(this.interval);
150
- void this.resetAll();
151
- }
152
- /**
153
- * Recycles a client by setting its hit count to zero, and reset time to
154
- * `windowMs` milliseconds from now.
155
- *
156
- * NOT to be confused with `#resetKey()`, which removes a client from both the
157
- * `current` and `previous` maps.
158
- *
159
- * @param client {Client} - The client to recycle.
160
- * @param now {number} - The current time, to which the `windowMs` is added to get the `resetTime` for the client.
161
- *
162
- * @return {Client} - The modified client that was passed in, to allow for chaining.
163
- */
164
- resetClient(client, now = Date.now()) {
165
- client.totalHits = 0;
166
- client.resetTime.setTime(now + this.windowMs);
167
- return client;
168
- }
169
- /**
170
- * Retrieves or creates a client, given a key. Also ensures that the client being
171
- * returned is in the `current` map.
172
- *
173
- * @param key {string} - The key under which the client is (or is to be) stored.
174
- *
175
- * @returns {Client} - The requested client.
176
- */
177
- getClient(key) {
178
- if (this.current.has(key)) return this.current.get(key);
179
- let client;
180
- if (this.previous.has(key)) {
181
- client = this.previous.get(key);
182
- this.previous.delete(key);
183
- } else {
184
- client = { totalHits: 0, resetTime: /* @__PURE__ */ new Date() };
185
- this.resetClient(client);
186
- }
187
- this.current.set(key, client);
188
- return client;
189
- }
190
- /**
191
- * Move current clients to previous, create a new map for current.
192
- *
193
- * This function is called every `windowMs`.
194
- */
195
- clearExpired() {
196
- this.previous = this.current;
197
- this.current = /* @__PURE__ */ new Map();
198
- }
199
- };
200
-
201
- // source/rate-limit.ts
202
- var import_node_net3 = require("node:net");
203
-
204
- // source/console-logger.ts
205
- var ConsoleLogger = {
206
- warn(...args) {
207
- console.warn(...args.reverse());
208
- },
209
- error(...args) {
210
- console.error(...args.reverse());
211
- }
212
- };
213
-
214
- // source/headers.ts
215
- var import_node_buffer = require("node:buffer");
216
- var import_node_crypto = require("node:crypto");
217
- var SUPPORTED_DRAFT_VERSIONS = [
218
- "draft-6",
219
- "draft-7",
220
- "draft-8"
221
- ];
222
- var getResetSeconds = (windowMs, resetTime) => {
223
- let resetSeconds;
224
- if (resetTime) {
225
- const deltaSeconds = Math.ceil((resetTime.getTime() - Date.now()) / 1e3);
226
- resetSeconds = Math.max(0, deltaSeconds);
227
- } else {
228
- resetSeconds = Math.ceil(windowMs / 1e3);
229
- }
230
- return resetSeconds;
231
- };
232
- var getPartitionKey = (key) => {
233
- const hash = (0, import_node_crypto.createHash)("sha256");
234
- hash.update(key);
235
- const partitionKey = hash.digest("hex").slice(0, 12);
236
- return import_node_buffer.Buffer.from(partitionKey).toString("base64");
237
- };
238
- var setLegacyHeaders = (response, info) => {
239
- if (response.headersSent) return;
240
- response.setHeader("X-RateLimit-Limit", info.limit.toString());
241
- response.setHeader("X-RateLimit-Remaining", info.remaining.toString());
242
- if (info.resetTime instanceof Date) {
243
- response.setHeader("Date", (/* @__PURE__ */ new Date()).toUTCString());
244
- response.setHeader(
245
- "X-RateLimit-Reset",
246
- Math.ceil(info.resetTime.getTime() / 1e3).toString()
247
- );
248
- }
249
- };
250
- var setDraft6Headers = (response, info, windowMs) => {
251
- if (response.headersSent) return;
252
- const windowSeconds = Math.ceil(windowMs / 1e3);
253
- const resetSeconds = getResetSeconds(windowMs, info.resetTime);
254
- response.setHeader("RateLimit-Policy", `${info.limit};w=${windowSeconds}`);
255
- response.setHeader("RateLimit-Limit", info.limit.toString());
256
- response.setHeader("RateLimit-Remaining", info.remaining.toString());
257
- if (typeof resetSeconds === "number")
258
- response.setHeader("RateLimit-Reset", resetSeconds.toString());
259
- };
260
- var setDraft7Headers = (response, info, windowMs) => {
261
- if (response.headersSent) return;
262
- const windowSeconds = Math.ceil(windowMs / 1e3);
263
- const resetSeconds = getResetSeconds(windowMs, info.resetTime);
264
- response.setHeader("RateLimit-Policy", `${info.limit};w=${windowSeconds}`);
265
- response.setHeader(
266
- "RateLimit",
267
- `limit=${info.limit}, remaining=${info.remaining}, reset=${resetSeconds}`
268
- );
269
- };
270
- var setDraft8Headers = (response, info, windowMs, name, key) => {
271
- if (response.headersSent) return;
272
- const windowSeconds = Math.ceil(windowMs / 1e3);
273
- const resetSeconds = getResetSeconds(windowMs, info.resetTime);
274
- const partitionKey = getPartitionKey(key);
275
- const header = `r=${info.remaining}; t=${resetSeconds}`;
276
- const policy = `q=${info.limit}; w=${windowSeconds}; pk=:${partitionKey}:`;
277
- response.append("RateLimit", `"${name}"; ${header}`);
278
- response.append("RateLimit-Policy", `"${name}"; ${policy}`);
279
- };
280
- var setRetryAfterHeader = (response, info, windowMs) => {
281
- if (response.headersSent) return;
282
- const resetSeconds = getResetSeconds(windowMs, info.resetTime);
283
- response.setHeader("Retry-After", resetSeconds.toString());
284
- };
285
-
286
- // source/utils.ts
287
- var omitUndefinedProperties = (passedOptions) => {
288
- const omittedOptions = {};
289
- for (const k of Object.keys(passedOptions)) {
290
- const key = k;
291
- if (passedOptions[key] !== void 0) {
292
- omittedOptions[key] = passedOptions[key];
293
- }
294
- }
295
- return omittedOptions;
296
- };
297
-
298
- // source/validations.ts
299
- var import_node_net2 = require("node:net");
300
- var ValidationError = class extends Error {
301
- /**
302
- * The code must be a string, in snake case and all capital, that starts with
303
- * the substring `ERR_ERL_`.
304
- *
305
- * The message must be a string, starting with an uppercase character,
306
- * describing the issue in detail.
307
- */
308
- constructor(code, message) {
309
- const url = `https://express-rate-limit.github.io/${code}/`;
310
- super(`${message} See ${url} for more information.`);
311
- this.name = this.constructor.name;
312
- this.code = code;
313
- this.help = url;
314
- }
315
- };
316
- var ChangeWarning = class extends ValidationError {
317
- };
318
- var usedStores = /* @__PURE__ */ new Set();
319
- var singleCountKeys = /* @__PURE__ */ new WeakMap();
320
- var validations = {
321
- enabled: {
322
- default: true
323
- },
324
- // Should be EnabledValidations type, but that's a circular reference
325
- disable() {
326
- for (const k of Object.keys(this.enabled)) this.enabled[k] = false;
327
- },
328
- /**
329
- * Checks whether the IP address is valid, and that it does not have a port
330
- * number in it.
331
- *
332
- * See https://github.com/express-rate-limit/express-rate-limit/wiki/Error-Codes#err_erl_invalid_ip_address.
333
- *
334
- * @param ip {string | undefined} - The IP address provided by Express as request.ip.
335
- *
336
- * @returns {void}
337
- */
338
- ip(ip) {
339
- if (ip === void 0) {
340
- throw new ValidationError(
341
- "ERR_ERL_UNDEFINED_IP_ADDRESS",
342
- `An undefined 'request.ip' was detected. This might indicate a misconfiguration or the connection being destroyed prematurely.`
343
- );
344
- }
345
- if (!(0, import_node_net2.isIP)(ip)) {
346
- throw new ValidationError(
347
- "ERR_ERL_INVALID_IP_ADDRESS",
348
- `An invalid 'request.ip' (${ip}) was detected. Consider passing a custom 'keyGenerator' function to the rate limiter.`
349
- );
350
- }
351
- },
352
- /**
353
- * Makes sure the trust proxy setting is not set to `true`.
354
- *
355
- * See https://github.com/express-rate-limit/express-rate-limit/wiki/Error-Codes#err_erl_permissive_trust_proxy.
356
- *
357
- * @param request {Request} - The Express request object.
358
- *
359
- * @returns {void}
360
- */
361
- trustProxy(request) {
362
- if (request.app.get("trust proxy") === true) {
363
- throw new ValidationError(
364
- "ERR_ERL_PERMISSIVE_TRUST_PROXY",
365
- `The Express 'trust proxy' setting is true, which allows anyone to trivially bypass IP-based rate limiting.`
366
- );
367
- }
368
- },
369
- /**
370
- * Makes sure the trust proxy setting is set in case the `X-Forwarded-For`
371
- * header is present.
372
- *
373
- * See https://github.com/express-rate-limit/express-rate-limit/wiki/Error-Codes#err_erl_unset_trust_proxy.
374
- *
375
- * @param request {Request} - The Express request object.
376
- *
377
- * @returns {void}
378
- */
379
- xForwardedForHeader(request) {
380
- if (request.headers["x-forwarded-for"] && request.app.get("trust proxy") === false) {
381
- throw new ValidationError(
382
- "ERR_ERL_UNEXPECTED_X_FORWARDED_FOR",
383
- `The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users.`
384
- );
385
- }
386
- },
387
- /**
388
- * Alert the user if the Forwarded header is set (standardized version of X-Forwarded-For - not supported by express as of version 5.1.0)
389
- *
390
- * @param request {Request} - The Express request object.
391
- *
392
- * @returns {void}
393
- */
394
- forwardedHeader(request) {
395
- if (request.headers.forwarded && request.ip === request.socket?.remoteAddress) {
396
- throw new ValidationError(
397
- "ERR_ERL_FORWARDED_HEADER",
398
- `The 'Forwarded' header (standardized X-Forwarded-For) is set but currently being ignored. Add a custom keyGenerator to use a value from this header.`
399
- );
400
- }
401
- },
402
- /**
403
- * Ensures totalHits value from store is a positive integer.
404
- *
405
- * @param hits {any} - The `totalHits` returned by the store.
406
- */
407
- positiveHits(hits) {
408
- if (typeof hits !== "number" || hits < 1 || hits !== Math.round(hits)) {
409
- throw new ValidationError(
410
- "ERR_ERL_INVALID_HITS",
411
- `The totalHits value returned from the store must be a positive integer, got ${hits}`
412
- );
413
- }
414
- },
415
- /**
416
- * Ensures a single store instance is not used with multiple express-rate-limit instances
417
- */
418
- unsharedStore(store) {
419
- if (usedStores.has(store)) {
420
- const maybeUniquePrefix = store?.localKeys ? "" : " (with a unique prefix)";
421
- throw new ValidationError(
422
- "ERR_ERL_STORE_REUSE",
423
- `A Store instance must not be shared across multiple rate limiters. Create a new instance of ${store.constructor.name}${maybeUniquePrefix} for each limiter instead.`
424
- );
425
- }
426
- usedStores.add(store);
427
- },
428
- /**
429
- * Ensures a given key is incremented only once per request.
430
- *
431
- * @param request {Request} - The Express request object.
432
- * @param store {Store} - The store class.
433
- * @param key {string} - The key used to store the client's hit count.
434
- *
435
- * @returns {void}
436
- */
437
- singleCount(request, store, key) {
438
- let storeKeys = singleCountKeys.get(request);
439
- if (!storeKeys) {
440
- storeKeys = /* @__PURE__ */ new Map();
441
- singleCountKeys.set(request, storeKeys);
442
- }
443
- const storeKey = store.localKeys ? store : store.constructor.name;
444
- let keys = storeKeys.get(storeKey);
445
- if (!keys) {
446
- keys = [];
447
- storeKeys.set(storeKey, keys);
448
- }
449
- const prefixedKey = `${store.prefix ?? ""}${key}`;
450
- if (keys.includes(prefixedKey)) {
451
- throw new ValidationError(
452
- "ERR_ERL_DOUBLE_COUNT",
453
- `The hit count for ${key} was incremented more than once for a single request.`
454
- );
455
- }
456
- keys.push(prefixedKey);
457
- },
458
- /**
459
- * Warns the user that the behaviour for `max: 0` / `limit: 0` is
460
- * changing in the next major release.
461
- *
462
- * @param limit {number} - The maximum number of hits per client.
463
- *
464
- * @returns {void}
465
- */
466
- limit(limit) {
467
- if (limit === 0) {
468
- throw new ChangeWarning(
469
- "WRN_ERL_MAX_ZERO",
470
- "Setting limit or max to 0 disables rate limiting in express-rate-limit v6 and older, but will cause all requests to be blocked in v7"
471
- );
472
- }
473
- },
474
- /**
475
- * Warns the user that the `draft_polli_ratelimit_headers` option is deprecated
476
- * and will be removed in the next major release.
477
- *
478
- * @param draft_polli_ratelimit_headers {any | undefined} - The now-deprecated setting that was used to enable standard headers.
479
- *
480
- * @returns {void}
481
- */
482
- draftPolliHeaders(draft_polli_ratelimit_headers) {
483
- if (draft_polli_ratelimit_headers) {
484
- throw new ChangeWarning(
485
- "WRN_ERL_DEPRECATED_DRAFT_POLLI_HEADERS",
486
- `The draft_polli_ratelimit_headers configuration option is deprecated and has been removed in express-rate-limit v7, please set standardHeaders: 'draft-6' instead.`
487
- );
488
- }
489
- },
490
- /**
491
- * Warns the user that the `onLimitReached` option is deprecated and
492
- * will be removed in the next major release.
493
- *
494
- * @param onLimitReached {any | undefined} - The maximum number of hits per client.
495
- *
496
- * @returns {void}
497
- */
498
- onLimitReached(onLimitReached) {
499
- if (onLimitReached) {
500
- throw new ChangeWarning(
501
- "WRN_ERL_DEPRECATED_ON_LIMIT_REACHED",
502
- "The onLimitReached configuration option is deprecated and has been removed in express-rate-limit v7."
503
- );
504
- }
505
- },
506
- /**
507
- * Warns the user when an invalid/unsupported version of the draft spec is passed.
508
- *
509
- * @param version {any | undefined} - The version passed by the user.
510
- *
511
- * @returns {void}
512
- */
513
- headersDraftVersion(version) {
514
- if (typeof version !== "string" || // @ts-expect-error This is fine. If version is not in the array, it will just return false.
515
- !SUPPORTED_DRAFT_VERSIONS.includes(version)) {
516
- const versionString = SUPPORTED_DRAFT_VERSIONS.join(", ");
517
- throw new ValidationError(
518
- "ERR_ERL_HEADERS_UNSUPPORTED_DRAFT_VERSION",
519
- `standardHeaders: only the following versions of the IETF draft specification are supported: ${versionString}.`
520
- );
521
- }
522
- },
523
- /**
524
- * Warns the user when the selected headers option requires a reset time but
525
- * the store does not provide one.
526
- *
527
- * @param resetTime {Date | undefined} - The timestamp when the client's hit count will be reset.
528
- *
529
- * @returns {void}
530
- */
531
- headersResetTime(resetTime) {
532
- if (!resetTime) {
533
- throw new ValidationError(
534
- "ERR_ERL_HEADERS_NO_RESET",
535
- `standardHeaders: 'draft-7' requires a 'resetTime', but the store did not provide one. The 'windowMs' value will be used instead, which may cause clients to wait longer than necessary.`
536
- );
537
- }
538
- },
539
- knownOptions(passedOptions) {
540
- if (!passedOptions) return;
541
- const optionsMap = {
542
- windowMs: true,
543
- limit: true,
544
- message: true,
545
- statusCode: true,
546
- legacyHeaders: true,
547
- standardHeaders: true,
548
- identifier: true,
549
- requestPropertyName: true,
550
- skipFailedRequests: true,
551
- skipSuccessfulRequests: true,
552
- keyGenerator: true,
553
- ipv6Subnet: true,
554
- handler: true,
555
- skip: true,
556
- requestWasSuccessful: true,
557
- store: true,
558
- validate: true,
559
- headers: true,
560
- max: true,
561
- passOnStoreError: true,
562
- logger: true
563
- };
564
- const validOptions = Object.keys(optionsMap).concat(
565
- "draft_polli_ratelimit_headers",
566
- // not a valid option anymore, but we have a more specific check for this one, so don't warn for it here
567
- // from express-slow-down - https://github.com/express-rate-limit/express-slow-down/blob/main/source/types.ts#L65
568
- "delayAfter",
569
- "delayMs",
570
- "maxDelayMs"
571
- );
572
- for (const key of Object.keys(passedOptions)) {
573
- if (!validOptions.includes(key)) {
574
- throw new ValidationError(
575
- "ERR_ERL_UNKNOWN_OPTION",
576
- `Unexpected configuration option: ${key}`
577
- // todo: suggest a valid option with a short levenstein distance?
578
- );
579
- }
580
- }
581
- },
582
- /**
583
- * Checks the options.validate setting to ensure that only recognized
584
- * validations are enabled or disabled.
585
- *
586
- * If any unrecognized values are found, an error is logged that
587
- * includes the list of supported validations.
588
- */
589
- validationsConfig() {
590
- const supportedValidations = Object.keys(this).filter(
591
- (k) => !["enabled", "disable"].includes(k)
592
- );
593
- supportedValidations.push("default");
594
- for (const key of Object.keys(this.enabled)) {
595
- if (!supportedValidations.includes(key)) {
596
- throw new ValidationError(
597
- "ERR_ERL_UNKNOWN_VALIDATION",
598
- `options.validate.${key} is not recognized. Supported validate options are: ${supportedValidations.join(
599
- ", "
600
- )}.`
601
- );
602
- }
603
- }
604
- },
605
- /**
606
- * Checks to see if the instance was created inside of a request handler,
607
- * which would prevent it from working correctly, with the default memory
608
- * store (or any other store with localKeys.)
609
- */
610
- creationStack(store) {
611
- const { stack } = new Error(
612
- "express-rate-limit validation check (set options.validate.creationStack=false to disable)"
613
- );
614
- if (stack?.includes("Layer.handle [as handle_request]") || // express v4
615
- stack?.includes("Layer.handleRequest")) {
616
- if (!store.localKeys) {
617
- throw new ValidationError(
618
- "ERR_ERL_CREATED_IN_REQUEST_HANDLER",
619
- "express-rate-limit instance should *usually* be created at app initialization, not when responding to a request."
620
- );
621
- }
622
- throw new ValidationError(
623
- "ERR_ERL_CREATED_IN_REQUEST_HANDLER",
624
- "express-rate-limit instance should be created at app initialization, not when responding to a request."
625
- );
626
- }
627
- },
628
- ipv6Subnet(ipv6Subnet) {
629
- if (ipv6Subnet === false) {
630
- return;
631
- }
632
- if (!Number.isInteger(ipv6Subnet) || ipv6Subnet < 32 || ipv6Subnet > 64) {
633
- throw new ValidationError(
634
- "ERR_ERL_IPV6_SUBNET",
635
- `Unexpected ipv6Subnet value: ${ipv6Subnet}. Expected an integer between 32 and 64 (usually 48-64).`
636
- );
637
- }
638
- },
639
- ipv6SubnetOrKeyGenerator(options) {
640
- if (options.ipv6Subnet !== void 0 && options.keyGenerator) {
641
- throw new ValidationError(
642
- "ERR_ERL_IPV6SUBNET_OR_KEYGENERATOR",
643
- `Incompatible options: the 'ipv6Subnet' option is ignored when a custom 'keyGenerator' function is also set.`
644
- );
645
- }
646
- },
647
- keyGeneratorIpFallback(keyGenerator) {
648
- if (!keyGenerator) {
649
- return;
650
- }
651
- const src = keyGenerator.toString();
652
- if ((src.includes("req.ip") || src.includes("request.ip")) && !src.includes("ipKeyGenerator")) {
653
- throw new ValidationError(
654
- "ERR_ERL_KEY_GEN_IPV6",
655
- "Custom keyGenerator appears to use request IP without calling the ipKeyGenerator helper function for IPv6 addresses. This could allow IPv6 users to bypass limits."
656
- );
657
- }
658
- },
659
- /**
660
- * Checks to see if the window duration is greater than 2^32 - 1. This is only
661
- * called by the default MemoryStore, since it uses Node's setInterval method.
662
- *
663
- * See https://nodejs.org/api/timers.html#setintervalcallback-delay-args.
664
- */
665
- windowMs(windowMs) {
666
- const SET_TIMEOUT_MAX = 2 ** 31 - 1;
667
- if (typeof windowMs !== "number" || Number.isNaN(windowMs) || windowMs < 1 || windowMs > SET_TIMEOUT_MAX) {
668
- throw new ValidationError(
669
- "ERR_ERL_WINDOW_MS",
670
- `Invalid windowMs value: ${windowMs}${typeof windowMs !== "number" ? ` (${typeof windowMs})` : ""}, must be a number between 1 and ${SET_TIMEOUT_MAX} when using the default MemoryStore`
671
- );
672
- }
673
- }
674
- };
675
- function validateLogger(logger) {
676
- if (typeof logger !== "object" || typeof logger.error !== "function" || typeof logger.warn !== "function") {
677
- throw new TypeError(
678
- "Provided logger does not implement the Logger interface"
679
- );
680
- }
681
- }
682
- var getValidations = (_enabled, logger) => {
683
- validateLogger(logger);
684
- let enabled;
685
- if (typeof _enabled === "boolean") {
686
- enabled = {
687
- default: _enabled
688
- };
689
- } else {
690
- enabled = {
691
- default: true,
692
- ..._enabled
693
- };
694
- }
695
- const wrappedValidations = { enabled };
696
- for (const [name, validation] of Object.entries(validations)) {
697
- if (typeof validation === "function")
698
- wrappedValidations[name] = (...args) => {
699
- if (!(enabled[name] ?? enabled.default)) {
700
- return;
701
- }
702
- try {
703
- ;
704
- validation.apply(
705
- wrappedValidations,
706
- args
707
- );
708
- } catch (error) {
709
- if (error instanceof ChangeWarning) logger.warn(error);
710
- else logger.error(error);
711
- }
712
- };
713
- }
714
- return wrappedValidations;
715
- };
716
-
717
- // source/rate-limit.ts
718
- var isLegacyStore = (store) => (
719
- // Check that `incr` exists but `increment` does not - store authors might want
720
- // to keep both around for backwards compatibility.
721
- typeof store.incr === "function" && typeof store.increment !== "function"
722
- );
723
- var promisifyStore = (passedStore) => {
724
- if (!isLegacyStore(passedStore)) {
725
- return passedStore;
726
- }
727
- const legacyStore = passedStore;
728
- class PromisifiedStore {
729
- async increment(key) {
730
- return new Promise((resolve, reject) => {
731
- legacyStore.incr(
732
- key,
733
- (error, totalHits, resetTime) => {
734
- if (error) reject(error);
735
- resolve({ totalHits, resetTime });
736
- }
737
- );
738
- });
739
- }
740
- async decrement(key) {
741
- return legacyStore.decrement(key);
742
- }
743
- async resetKey(key) {
744
- return legacyStore.resetKey(key);
745
- }
746
- /* istanbul ignore next */
747
- async resetAll() {
748
- if (typeof legacyStore.resetAll === "function")
749
- return legacyStore.resetAll();
750
- }
751
- }
752
- return new PromisifiedStore();
753
- };
754
- var getOptionsFromConfig = (config) => {
755
- const { validations: validations2, ...directlyPassableEntries } = config;
756
- return {
757
- ...directlyPassableEntries,
758
- validate: validations2.enabled
759
- };
760
- };
761
- var parseOptions = (passedOptions) => {
762
- const notUndefinedOptions = omitUndefinedProperties(passedOptions);
763
- const logger = passedOptions.logger ?? ConsoleLogger;
764
- const validations2 = getValidations(
765
- notUndefinedOptions?.validate ?? true,
766
- logger
767
- );
768
- validations2.validationsConfig();
769
- validations2.knownOptions(passedOptions);
770
- validations2.draftPolliHeaders(
771
- // @ts-expect-error see the note above.
772
- notUndefinedOptions.draft_polli_ratelimit_headers
773
- );
774
- validations2.onLimitReached(notUndefinedOptions.onLimitReached);
775
- if (notUndefinedOptions.ipv6Subnet !== void 0 && typeof notUndefinedOptions.ipv6Subnet !== "function") {
776
- validations2.ipv6Subnet(notUndefinedOptions.ipv6Subnet);
777
- }
778
- validations2.keyGeneratorIpFallback(notUndefinedOptions.keyGenerator);
779
- validations2.ipv6SubnetOrKeyGenerator(notUndefinedOptions);
780
- let standardHeaders = notUndefinedOptions.standardHeaders ?? false;
781
- if (standardHeaders === true) standardHeaders = "draft-6";
782
- const config = {
783
- windowMs: 60 * 1e3,
784
- limit: passedOptions.max ?? 5,
785
- // `max` is deprecated, but support it anyways.
786
- message: "Too many requests, please try again later.",
787
- statusCode: 429,
788
- legacyHeaders: passedOptions.headers ?? true,
789
- identifier(request, _response) {
790
- let duration = "";
791
- const property = config.requestPropertyName;
792
- const { limit } = request[property];
793
- const seconds = config.windowMs / 1e3;
794
- const minutes = config.windowMs / (1e3 * 60);
795
- const hours = config.windowMs / (1e3 * 60 * 60);
796
- const days = config.windowMs / (1e3 * 60 * 60 * 24);
797
- if (seconds < 60) duration = `${seconds}sec`;
798
- else if (minutes < 60) duration = `${minutes}min`;
799
- else if (hours < 24) duration = `${hours}hr${hours > 1 ? "s" : ""}`;
800
- else duration = `${days}day${days > 1 ? "s" : ""}`;
801
- return `${limit}-in-${duration}`;
802
- },
803
- requestPropertyName: "rateLimit",
804
- skipFailedRequests: false,
805
- skipSuccessfulRequests: false,
806
- requestWasSuccessful: (_request, response) => response.statusCode < 400,
807
- skip: (_request, _response) => false,
808
- async keyGenerator(request, response) {
809
- validations2.ip(request.ip);
810
- validations2.trustProxy(request);
811
- validations2.xForwardedForHeader(request);
812
- validations2.forwardedHeader(request);
813
- const ip = request.ip;
814
- let subnet = 56;
815
- if ((0, import_node_net3.isIPv6)(ip)) {
816
- subnet = typeof config.ipv6Subnet === "function" ? await config.ipv6Subnet(request, response) : config.ipv6Subnet;
817
- if (typeof config.ipv6Subnet === "function")
818
- validations2.ipv6Subnet(subnet);
819
- }
820
- return ipKeyGenerator(ip, subnet);
821
- },
822
- ipv6Subnet: 56,
823
- async handler(request, response, _next, _optionsUsed) {
824
- response.status(config.statusCode);
825
- const message = typeof config.message === "function" ? await config.message(
826
- request,
827
- response
828
- ) : config.message;
829
- if (!response.writableEnded) response.send(message);
830
- },
831
- passOnStoreError: false,
832
- // Allow the default options to be overridden by the passed options.
833
- ...notUndefinedOptions,
834
- // `standardHeaders` is resolved into a draft version above, use that.
835
- standardHeaders,
836
- // Note that this field is declared after the user's options are spread in,
837
- // so that this field doesn't get overridden with an un-promisified store!
838
- store: promisifyStore(
839
- notUndefinedOptions.store ?? new MemoryStore(validations2)
840
- ),
841
- // Print an error to the console if a few known misconfigurations are detected.
842
- validations: validations2,
843
- logger
844
- };
845
- if (typeof config.store.increment !== "function" || typeof config.store.decrement !== "function" || typeof config.store.resetKey !== "function" || config.store.resetAll !== void 0 && typeof config.store.resetAll !== "function" || config.store.init !== void 0 && typeof config.store.init !== "function") {
846
- throw new TypeError(
847
- "An invalid store was passed. Please ensure that the store is a class that implements the `Store` interface."
848
- );
849
- }
850
- return config;
851
- };
852
- var handleAsyncErrors = (fn) => async (request, response, next) => {
853
- try {
854
- await Promise.resolve(fn(request, response, next)).catch(next);
855
- } catch (error) {
856
- next(error);
857
- }
858
- };
859
- var rateLimit = (passedOptions) => {
860
- const config = parseOptions(passedOptions ?? {});
861
- const options = getOptionsFromConfig(config);
862
- config.validations.creationStack(config.store);
863
- config.validations.unsharedStore(config.store);
864
- if (typeof config.store.init === "function") {
865
- try {
866
- const storeInit = config.store.init(options);
867
- if (storeInit instanceof Promise) {
868
- storeInit.catch(
869
- (error) => config.logger.error(
870
- error,
871
- "express-rate-limit: async error during store initialization."
872
- )
873
- );
874
- }
875
- } catch (error) {
876
- config.logger.error(
877
- error,
878
- "express-rate-limit: error during store initialization."
879
- );
880
- }
881
- }
882
- const middleware = handleAsyncErrors(
883
- async (request, response, next) => {
884
- const closePromise = config.skipFailedRequests && new Promise((resolve) => response.once("close", resolve));
885
- const finishPromise = (config.skipFailedRequests || config.skipSuccessfulRequests) && new Promise((resolve) => response.once("finish", resolve));
886
- const errorPromise = config.skipFailedRequests && new Promise((resolve) => response.once("error", resolve));
887
- const skip = await config.skip(request, response);
888
- if (skip) {
889
- next();
890
- return;
891
- }
892
- const augmentedRequest = request;
893
- const key = await config.keyGenerator(request, response);
894
- let totalHits = 0;
895
- let resetTime;
896
- try {
897
- const incrementResult = await config.store.increment(key);
898
- totalHits = incrementResult.totalHits;
899
- resetTime = incrementResult.resetTime;
900
- } catch (error) {
901
- if (config.passOnStoreError) {
902
- config.logger.error(
903
- error,
904
- "express-rate-limit: error from store, allowing request without rate-limiting."
905
- );
906
- next();
907
- return;
908
- }
909
- throw error;
910
- }
911
- config.validations.positiveHits(totalHits);
912
- config.validations.singleCount(request, config.store, key);
913
- const retrieveLimit = typeof config.limit === "function" ? config.limit(request, response) : config.limit;
914
- const limit = await retrieveLimit;
915
- config.validations.limit(limit);
916
- const info = {
917
- limit,
918
- used: totalHits,
919
- remaining: Math.max(limit - totalHits, 0),
920
- resetTime,
921
- key
922
- };
923
- Object.defineProperty(info, "current", {
924
- configurable: false,
925
- enumerable: false,
926
- value: totalHits
927
- });
928
- augmentedRequest[config.requestPropertyName] = info;
929
- if (config.legacyHeaders && !response.headersSent) {
930
- setLegacyHeaders(response, info);
931
- }
932
- if (config.standardHeaders && !response.headersSent) {
933
- switch (config.standardHeaders) {
934
- case "draft-6": {
935
- setDraft6Headers(response, info, config.windowMs);
936
- break;
937
- }
938
- case "draft-7": {
939
- config.validations.headersResetTime(info.resetTime);
940
- setDraft7Headers(response, info, config.windowMs);
941
- break;
942
- }
943
- case "draft-8": {
944
- const retrieveName = typeof config.identifier === "function" ? config.identifier(request, response) : config.identifier;
945
- const name = await retrieveName;
946
- config.validations.headersResetTime(info.resetTime);
947
- setDraft8Headers(response, info, config.windowMs, name, key);
948
- break;
949
- }
950
- default: {
951
- config.validations.headersDraftVersion(config.standardHeaders);
952
- break;
953
- }
954
- }
955
- }
956
- if (config.skipFailedRequests || config.skipSuccessfulRequests) {
957
- let decremented = false;
958
- const decrementKey = async () => {
959
- if (!decremented) {
960
- await config.store.decrement(key);
961
- decremented = true;
962
- }
963
- };
964
- if (config.skipFailedRequests) {
965
- if (finishPromise) {
966
- void finishPromise.then(async () => {
967
- if (!await config.requestWasSuccessful(request, response))
968
- await decrementKey();
969
- });
970
- }
971
- if (closePromise) {
972
- void closePromise.then(async () => {
973
- if (!response.writableEnded) await decrementKey();
974
- });
975
- }
976
- if (errorPromise) {
977
- void errorPromise.then(async () => {
978
- await decrementKey();
979
- });
980
- }
981
- }
982
- if (config.skipSuccessfulRequests) {
983
- if (finishPromise) {
984
- void finishPromise.then(async () => {
985
- if (await config.requestWasSuccessful(request, response))
986
- await decrementKey();
987
- });
988
- }
989
- }
990
- }
991
- config.validations.disable();
992
- if (totalHits > limit) {
993
- if (config.legacyHeaders || config.standardHeaders) {
994
- setRetryAfterHeader(response, info, config.windowMs);
995
- }
996
- config.handler(request, response, next, options);
997
- return;
998
- }
999
- next();
1000
- }
1001
- );
1002
- const getThrowFn = () => {
1003
- throw new Error("The current store does not support the get/getKey method");
1004
- };
1005
- middleware.resetKey = config.store.resetKey.bind(config.store);
1006
- middleware.getKey = typeof config.store.get === "function" ? config.store.get.bind(config.store) : getThrowFn;
1007
- return middleware;
1008
- };
1009
- var rate_limit_default = rateLimit;
1010
- // Annotate the CommonJS export names for ESM import in node:
1011
- 0 && (module.exports = {
1012
- MemoryStore,
1013
- ipKeyGenerator,
1014
- rateLimit
1015
- });
1016
- module.exports = Object.assign(rateLimit, module.exports);