@1delta/margin-fetcher 0.0.245 → 0.0.246

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 (719) hide show
  1. package/package.json +4 -4
  2. package/dist/_esm-QP3LOJYU.js +0 -3898
  3. package/dist/_esm-QP3LOJYU.js.map +0 -1
  4. package/dist/abis/aave/AaveOracle.d.ts +0 -50
  5. package/dist/abis/aave/AaveOracle.d.ts.map +0 -1
  6. package/dist/abis/aave/AavePoolAndDataProvider.d.ts +0 -1618
  7. package/dist/abis/aave/AavePoolAndDataProvider.d.ts.map +0 -1
  8. package/dist/abis/aave/AavePoolV3Upgraded.d.ts +0 -1134
  9. package/dist/abis/aave/AavePoolV3Upgraded.d.ts.map +0 -1
  10. package/dist/abis/aave/AaveV3ProtocolDataProvider.d.ts +0 -420
  11. package/dist/abis/aave/AaveV3ProtocolDataProvider.d.ts.map +0 -1
  12. package/dist/abis/aave/VariableDebtToken.d.ts +0 -635
  13. package/dist/abis/aave/VariableDebtToken.d.ts.map +0 -1
  14. package/dist/abis/aave-v2/ProtocolDataProvider.d.ts +0 -238
  15. package/dist/abis/aave-v2/ProtocolDataProvider.d.ts.map +0 -1
  16. package/dist/abis/aave-v2/YLDR.d.ts +0 -209
  17. package/dist/abis/aave-v2/YLDR.d.ts.map +0 -1
  18. package/dist/abis/aave-v3/AavePoolDataProviderLegacy.d.ts +0 -406
  19. package/dist/abis/aave-v3/AavePoolDataProviderLegacy.d.ts.map +0 -1
  20. package/dist/abis/aave-v3/AavePoolLegacy.d.ts +0 -819
  21. package/dist/abis/aave-v3/AavePoolLegacy.d.ts.map +0 -1
  22. package/dist/abis/aave-v3/YLDR.d.ts +0 -36
  23. package/dist/abis/aave-v3/YLDR.d.ts.map +0 -1
  24. package/dist/abis/aurelius/Rewarder.d.ts +0 -90
  25. package/dist/abis/aurelius/Rewarder.d.ts.map +0 -1
  26. package/dist/abis/compound-v2/BenqiLens.d.ts +0 -253
  27. package/dist/abis/compound-v2/BenqiLens.d.ts.map +0 -1
  28. package/dist/abis/compound-v2/CollateralToken.d.ts +0 -58
  29. package/dist/abis/compound-v2/CollateralToken.d.ts.map +0 -1
  30. package/dist/abis/compound-v2/CompoundLens.d.ts +0 -656
  31. package/dist/abis/compound-v2/CompoundLens.d.ts.map +0 -1
  32. package/dist/abis/compound-v2/Comptroller.d.ts +0 -16
  33. package/dist/abis/compound-v2/Comptroller.d.ts.map +0 -1
  34. package/dist/abis/compound-v2/CreamLens.d.ts +0 -158
  35. package/dist/abis/compound-v2/CreamLens.d.ts.map +0 -1
  36. package/dist/abis/compound-v2/SegmentLens.d.ts +0 -89
  37. package/dist/abis/compound-v2/SegmentLens.d.ts.map +0 -1
  38. package/dist/abis/compound-v2/SumerLens.d.ts +0 -331
  39. package/dist/abis/compound-v2/SumerLens.d.ts.map +0 -1
  40. package/dist/abis/compound-v2/TakaraMarketState.d.ts +0 -73
  41. package/dist/abis/compound-v2/TakaraMarketState.d.ts.map +0 -1
  42. package/dist/abis/compound-v2/TectonicLens.d.ts +0 -125
  43. package/dist/abis/compound-v2/TectonicLens.d.ts.map +0 -1
  44. package/dist/abis/compound-v2/VenusLens.d.ts +0 -1007
  45. package/dist/abis/compound-v2/VenusLens.d.ts.map +0 -1
  46. package/dist/abis/compound-v2/VenusLensLegacy.d.ts +0 -109
  47. package/dist/abis/compound-v2/VenusLensLegacy.d.ts.map +0 -1
  48. package/dist/abis/compound-v3/Comet.d.ts +0 -1382
  49. package/dist/abis/compound-v3/Comet.d.ts.map +0 -1
  50. package/dist/abis/compound-v3/CometExt.d.ts +0 -411
  51. package/dist/abis/compound-v3/CometExt.d.ts.map +0 -1
  52. package/dist/abis/compound-v3/CometLens.d.ts +0 -152
  53. package/dist/abis/compound-v3/CometLens.d.ts.map +0 -1
  54. package/dist/abis/compound-v3/CometRewards.d.ts +0 -253
  55. package/dist/abis/compound-v3/CometRewards.d.ts.map +0 -1
  56. package/dist/abis/compound-v3/IrGetter.d.ts +0 -24
  57. package/dist/abis/compound-v3/IrGetter.d.ts.map +0 -1
  58. package/dist/abis/euler/accountLens.d.ts +0 -191
  59. package/dist/abis/euler/accountLens.d.ts.map +0 -1
  60. package/dist/abis/euler/eVault.d.ts +0 -206
  61. package/dist/abis/euler/eVault.d.ts.map +0 -1
  62. package/dist/abis/euler/evc.d.ts +0 -81
  63. package/dist/abis/euler/evc.d.ts.map +0 -1
  64. package/dist/abis/euler/genericFactory.d.ts +0 -26
  65. package/dist/abis/euler/genericFactory.d.ts.map +0 -1
  66. package/dist/abis/euler/index.d.ts +0 -8
  67. package/dist/abis/euler/index.d.ts.map +0 -1
  68. package/dist/abis/euler/orchestrator.d.ts +0 -176
  69. package/dist/abis/euler/orchestrator.d.ts.map +0 -1
  70. package/dist/abis/euler/payments.d.ts +0 -140
  71. package/dist/abis/euler/payments.d.ts.map +0 -1
  72. package/dist/abis/euler/priceLens.d.ts +0 -58
  73. package/dist/abis/euler/priceLens.d.ts.map +0 -1
  74. package/dist/abis/euler/vaultLens.d.ts +0 -336
  75. package/dist/abis/euler/vaultLens.d.ts.map +0 -1
  76. package/dist/abis/flashloan-united/flashAbi.d.ts +0 -54
  77. package/dist/abis/flashloan-united/flashAbi.d.ts.map +0 -1
  78. package/dist/abis/init/InitLens.d.ts +0 -158
  79. package/dist/abis/init/InitLens.d.ts.map +0 -1
  80. package/dist/abis/lendle/IncentivesController.d.ts +0 -404
  81. package/dist/abis/lendle/IncentivesController.d.ts.map +0 -1
  82. package/dist/abis/lendle/MultiFeeDistribution.d.ts +0 -624
  83. package/dist/abis/lendle/MultiFeeDistribution.d.ts.map +0 -1
  84. package/dist/abis/meridian/PullRewardsIncentivesController.d.ts +0 -74
  85. package/dist/abis/meridian/PullRewardsIncentivesController.d.ts.map +0 -1
  86. package/dist/abis/multicall/Multicall.d.ts +0 -80
  87. package/dist/abis/multicall/Multicall.d.ts.map +0 -1
  88. package/dist/abis/oracle/AaveOracle.d.ts +0 -50
  89. package/dist/abis/oracle/AaveOracle.d.ts.map +0 -1
  90. package/dist/abis/oracle/Api3Oracle.d.ts +0 -48
  91. package/dist/abis/oracle/Api3Oracle.d.ts.map +0 -1
  92. package/dist/abis/oracle/ChainLinkAggregator.d.ts +0 -154
  93. package/dist/abis/oracle/ChainLinkAggregator.d.ts.map +0 -1
  94. package/dist/abis/oracle/ProxyOracle.d.ts +0 -26
  95. package/dist/abis/oracle/ProxyOracle.d.ts.map +0 -1
  96. package/dist/abis/oracle/RWADynamicOracle.d.ts +0 -12
  97. package/dist/abis/oracle/RWADynamicOracle.d.ts.map +0 -1
  98. package/dist/abis/oracle/UniV3.d.ts +0 -12
  99. package/dist/abis/oracle/UniV3.d.ts.map +0 -1
  100. package/dist/abis/oracle/UniswapV2Pair.d.ts +0 -513
  101. package/dist/abis/oracle/UniswapV2Pair.d.ts.map +0 -1
  102. package/dist/abis/silo-v2/InterestRateModelV2.d.ts +0 -52
  103. package/dist/abis/silo-v2/InterestRateModelV2.d.ts.map +0 -1
  104. package/dist/abis/silo-v2/Silo.d.ts +0 -101
  105. package/dist/abis/silo-v2/Silo.d.ts.map +0 -1
  106. package/dist/abis/silo-v2/SiloConfig.d.ts +0 -78
  107. package/dist/abis/silo-v2/SiloConfig.d.ts.map +0 -1
  108. package/dist/abis/silo-v2/SiloLens.d.ts +0 -50
  109. package/dist/abis/silo-v2/SiloLens.d.ts.map +0 -1
  110. package/dist/abis/silo-v2/index.d.ts +0 -4
  111. package/dist/abis/silo-v2/index.d.ts.map +0 -1
  112. package/dist/assets/index.d.ts +0 -21
  113. package/dist/assets/index.d.ts.map +0 -1
  114. package/dist/assets/liquidityThresholds.d.ts +0 -39
  115. package/dist/assets/liquidityThresholds.d.ts.map +0 -1
  116. package/dist/ccip-SQXTDOS7.js +0 -5
  117. package/dist/ccip-SQXTDOS7.js.map +0 -1
  118. package/dist/chunk-BYTNVMX7.js +0 -369
  119. package/dist/chunk-BYTNVMX7.js.map +0 -1
  120. package/dist/chunk-KQ6K6D2V.js +0 -4149
  121. package/dist/chunk-KQ6K6D2V.js.map +0 -1
  122. package/dist/chunk-PR4QN5HX.js +0 -39
  123. package/dist/chunk-PR4QN5HX.js.map +0 -1
  124. package/dist/flash-liquidity/assets.d.ts +0 -21
  125. package/dist/flash-liquidity/assets.d.ts.map +0 -1
  126. package/dist/flash-liquidity/fetchLiquidity.d.ts +0 -4
  127. package/dist/flash-liquidity/fetchLiquidity.d.ts.map +0 -1
  128. package/dist/flash-liquidity/index.d.ts +0 -3
  129. package/dist/flash-liquidity/index.d.ts.map +0 -1
  130. package/dist/flash-liquidity/types.d.ts +0 -24
  131. package/dist/flash-liquidity/types.d.ts.map +0 -1
  132. package/dist/flash-liquidity/utils.d.ts +0 -12
  133. package/dist/flash-liquidity/utils.d.ts.map +0 -1
  134. package/dist/index.d.ts +0 -25
  135. package/dist/index.d.ts.map +0 -1
  136. package/dist/index.js +0 -34145
  137. package/dist/index.js.map +0 -1
  138. package/dist/lending/index.d.ts +0 -8
  139. package/dist/lending/index.d.ts.map +0 -1
  140. package/dist/lending/margin/base/borrow.d.ts +0 -24
  141. package/dist/lending/margin/base/borrow.d.ts.map +0 -1
  142. package/dist/lending/margin/base/deposit.d.ts +0 -24
  143. package/dist/lending/margin/base/deposit.d.ts.map +0 -1
  144. package/dist/lending/margin/base/index.d.ts +0 -10
  145. package/dist/lending/margin/base/index.d.ts.map +0 -1
  146. package/dist/lending/margin/base/repay.d.ts +0 -24
  147. package/dist/lending/margin/base/repay.d.ts.map +0 -1
  148. package/dist/lending/margin/base/standard/borrow.d.ts +0 -10
  149. package/dist/lending/margin/base/standard/borrow.d.ts.map +0 -1
  150. package/dist/lending/margin/base/standard/deposit.d.ts +0 -10
  151. package/dist/lending/margin/base/standard/deposit.d.ts.map +0 -1
  152. package/dist/lending/margin/base/standard/repay.d.ts +0 -10
  153. package/dist/lending/margin/base/standard/repay.d.ts.map +0 -1
  154. package/dist/lending/margin/base/standard/withdraw.d.ts +0 -10
  155. package/dist/lending/margin/base/standard/withdraw.d.ts.map +0 -1
  156. package/dist/lending/margin/base/sumer/borrow.d.ts +0 -12
  157. package/dist/lending/margin/base/sumer/borrow.d.ts.map +0 -1
  158. package/dist/lending/margin/base/sumer/deposit.d.ts +0 -11
  159. package/dist/lending/margin/base/sumer/deposit.d.ts.map +0 -1
  160. package/dist/lending/margin/base/sumer/index.d.ts +0 -7
  161. package/dist/lending/margin/base/sumer/index.d.ts.map +0 -1
  162. package/dist/lending/margin/base/sumer/repay.d.ts +0 -12
  163. package/dist/lending/margin/base/sumer/repay.d.ts.map +0 -1
  164. package/dist/lending/margin/base/sumer/types.d.ts +0 -27
  165. package/dist/lending/margin/base/sumer/types.d.ts.map +0 -1
  166. package/dist/lending/margin/base/sumer/waterfall.d.ts +0 -30
  167. package/dist/lending/margin/base/sumer/waterfall.d.ts.map +0 -1
  168. package/dist/lending/margin/base/sumer/withdraw.d.ts +0 -10
  169. package/dist/lending/margin/base/sumer/withdraw.d.ts.map +0 -1
  170. package/dist/lending/margin/base/utils.d.ts +0 -21
  171. package/dist/lending/margin/base/utils.d.ts.map +0 -1
  172. package/dist/lending/margin/base/withdraw.d.ts +0 -23
  173. package/dist/lending/margin/base/withdraw.d.ts.map +0 -1
  174. package/dist/lending/margin/base/yield/getIntrinsicYieldChange.d.ts +0 -22
  175. package/dist/lending/margin/base/yield/getIntrinsicYieldChange.d.ts.map +0 -1
  176. package/dist/lending/margin/base/yield/getOrganicYieldChange.d.ts +0 -22
  177. package/dist/lending/margin/base/yield/getOrganicYieldChange.d.ts.map +0 -1
  178. package/dist/lending/margin/base/yield/getRewardYieldChange.d.ts +0 -24
  179. package/dist/lending/margin/base/yield/getRewardYieldChange.d.ts.map +0 -1
  180. package/dist/lending/margin/base/yield/index.d.ts +0 -4
  181. package/dist/lending/margin/base/yield/index.d.ts.map +0 -1
  182. package/dist/lending/margin/e-mode/index.d.ts +0 -33
  183. package/dist/lending/margin/e-mode/index.d.ts.map +0 -1
  184. package/dist/lending/margin/loop/compute/computeCloseDeltas.d.ts +0 -8
  185. package/dist/lending/margin/loop/compute/computeCloseDeltas.d.ts.map +0 -1
  186. package/dist/lending/margin/loop/compute/computeCollateralSwapDeltas.d.ts +0 -8
  187. package/dist/lending/margin/loop/compute/computeCollateralSwapDeltas.d.ts.map +0 -1
  188. package/dist/lending/margin/loop/compute/computeDebtSwapDeltas.d.ts +0 -8
  189. package/dist/lending/margin/loop/compute/computeDebtSwapDeltas.d.ts.map +0 -1
  190. package/dist/lending/margin/loop/compute/computeOpenDeltas.d.ts +0 -8
  191. package/dist/lending/margin/loop/compute/computeOpenDeltas.d.ts.map +0 -1
  192. package/dist/lending/margin/loop/compute/computeZapDeltas.d.ts +0 -8
  193. package/dist/lending/margin/loop/compute/computeZapDeltas.d.ts.map +0 -1
  194. package/dist/lending/margin/loop/compute/index.d.ts +0 -6
  195. package/dist/lending/margin/loop/compute/index.d.ts.map +0 -1
  196. package/dist/lending/margin/loop/index.d.ts +0 -6
  197. package/dist/lending/margin/loop/index.d.ts.map +0 -1
  198. package/dist/lending/margin/loop/ranges/getMaxAmountClose.d.ts +0 -19
  199. package/dist/lending/margin/loop/ranges/getMaxAmountClose.d.ts.map +0 -1
  200. package/dist/lending/margin/loop/ranges/getMaxAmountCollateralSwap.d.ts +0 -18
  201. package/dist/lending/margin/loop/ranges/getMaxAmountCollateralSwap.d.ts.map +0 -1
  202. package/dist/lending/margin/loop/ranges/getMaxAmountCollateralSwap.test.d.ts +0 -2
  203. package/dist/lending/margin/loop/ranges/getMaxAmountCollateralSwap.test.d.ts.map +0 -1
  204. package/dist/lending/margin/loop/ranges/getMaxAmountDebtSwap.d.ts +0 -20
  205. package/dist/lending/margin/loop/ranges/getMaxAmountDebtSwap.d.ts.map +0 -1
  206. package/dist/lending/margin/loop/ranges/getMaxAmountOpen.d.ts +0 -30
  207. package/dist/lending/margin/loop/ranges/getMaxAmountOpen.d.ts.map +0 -1
  208. package/dist/lending/margin/loop/ranges/index.d.ts +0 -5
  209. package/dist/lending/margin/loop/ranges/index.d.ts.map +0 -1
  210. package/dist/lending/margin/loop/types.d.ts +0 -32
  211. package/dist/lending/margin/loop/types.d.ts.map +0 -1
  212. package/dist/lending/margin/loop/utils.d.ts +0 -15
  213. package/dist/lending/margin/loop/utils.d.ts.map +0 -1
  214. package/dist/lending/margin/loop/yield/getIntrinsicYieldChange.d.ts +0 -6
  215. package/dist/lending/margin/loop/yield/getIntrinsicYieldChange.d.ts.map +0 -1
  216. package/dist/lending/margin/loop/yield/getOraganicYieldChange.d.ts +0 -6
  217. package/dist/lending/margin/loop/yield/getOraganicYieldChange.d.ts.map +0 -1
  218. package/dist/lending/margin/loop/yield/getRewardYieldChange.d.ts +0 -22
  219. package/dist/lending/margin/loop/yield/getRewardYieldChange.d.ts.map +0 -1
  220. package/dist/lending/margin/loop/yield/index.d.ts +0 -4
  221. package/dist/lending/margin/loop/yield/index.d.ts.map +0 -1
  222. package/dist/lending/public-data/aave-v2-type/misc.d.ts +0 -8
  223. package/dist/lending/public-data/aave-v2-type/misc.d.ts.map +0 -1
  224. package/dist/lending/public-data/aave-v2-type/publicCallBuild.d.ts +0 -6
  225. package/dist/lending/public-data/aave-v2-type/publicCallBuild.d.ts.map +0 -1
  226. package/dist/lending/public-data/aave-v2-type/publicCallParse.d.ts +0 -7
  227. package/dist/lending/public-data/aave-v2-type/publicCallParse.d.ts.map +0 -1
  228. package/dist/lending/public-data/aave-v3-type/publicCallBuild.d.ts +0 -4
  229. package/dist/lending/public-data/aave-v3-type/publicCallBuild.d.ts.map +0 -1
  230. package/dist/lending/public-data/aave-v3-type/publicCallParse.d.ts +0 -8
  231. package/dist/lending/public-data/aave-v3-type/publicCallParse.d.ts.map +0 -1
  232. package/dist/lending/public-data/aave-v4-type/fetcher/normalize.d.ts +0 -231
  233. package/dist/lending/public-data/aave-v4-type/fetcher/normalize.d.ts.map +0 -1
  234. package/dist/lending/public-data/aave-v4-type/fetcher/types.d.ts +0 -128
  235. package/dist/lending/public-data/aave-v4-type/fetcher/types.d.ts.map +0 -1
  236. package/dist/lending/public-data/aave-v4-type/publicCallBuild.d.ts +0 -51
  237. package/dist/lending/public-data/aave-v4-type/publicCallBuild.d.ts.map +0 -1
  238. package/dist/lending/public-data/aave-v4-type/publicCallParse.d.ts +0 -18
  239. package/dist/lending/public-data/aave-v4-type/publicCallParse.d.ts.map +0 -1
  240. package/dist/lending/public-data/addresses/aave.d.ts +0 -10
  241. package/dist/lending/public-data/addresses/aave.d.ts.map +0 -1
  242. package/dist/lending/public-data/addresses/aaveV2.d.ts +0 -6
  243. package/dist/lending/public-data/addresses/aaveV2.d.ts.map +0 -1
  244. package/dist/lending/public-data/addresses/aurelius.d.ts +0 -12
  245. package/dist/lending/public-data/addresses/aurelius.d.ts.map +0 -1
  246. package/dist/lending/public-data/addresses/compoundV2.d.ts +0 -17
  247. package/dist/lending/public-data/addresses/compoundV2.d.ts.map +0 -1
  248. package/dist/lending/public-data/addresses/compoundV3.d.ts +0 -8
  249. package/dist/lending/public-data/addresses/compoundV3.d.ts.map +0 -1
  250. package/dist/lending/public-data/addresses/hana.d.ts +0 -6
  251. package/dist/lending/public-data/addresses/hana.d.ts.map +0 -1
  252. package/dist/lending/public-data/addresses/init.d.ts +0 -5
  253. package/dist/lending/public-data/addresses/init.d.ts.map +0 -1
  254. package/dist/lending/public-data/addresses/lendle.d.ts +0 -12
  255. package/dist/lending/public-data/addresses/lendle.d.ts.map +0 -1
  256. package/dist/lending/public-data/addresses/meridian.d.ts +0 -15
  257. package/dist/lending/public-data/addresses/meridian.d.ts.map +0 -1
  258. package/dist/lending/public-data/addresses/takotako.d.ts +0 -12
  259. package/dist/lending/public-data/addresses/takotako.d.ts.map +0 -1
  260. package/dist/lending/public-data/compound-v2/convert/benqi.d.ts +0 -52
  261. package/dist/lending/public-data/compound-v2/convert/benqi.d.ts.map +0 -1
  262. package/dist/lending/public-data/compound-v2/convert/standard.d.ts +0 -50
  263. package/dist/lending/public-data/compound-v2/convert/standard.d.ts.map +0 -1
  264. package/dist/lending/public-data/compound-v2/convert/sumer.d.ts +0 -54
  265. package/dist/lending/public-data/compound-v2/convert/sumer.d.ts.map +0 -1
  266. package/dist/lending/public-data/compound-v2/convert/takara.d.ts +0 -48
  267. package/dist/lending/public-data/compound-v2/convert/takara.d.ts.map +0 -1
  268. package/dist/lending/public-data/compound-v2/convert/tectonic.d.ts +0 -50
  269. package/dist/lending/public-data/compound-v2/convert/tectonic.d.ts.map +0 -1
  270. package/dist/lending/public-data/compound-v2/convert/types.d.ts +0 -30
  271. package/dist/lending/public-data/compound-v2/convert/types.d.ts.map +0 -1
  272. package/dist/lending/public-data/compound-v2/getters/benqi.d.ts +0 -62
  273. package/dist/lending/public-data/compound-v2/getters/benqi.d.ts.map +0 -1
  274. package/dist/lending/public-data/compound-v2/getters/lodestar.d.ts +0 -106
  275. package/dist/lending/public-data/compound-v2/getters/lodestar.d.ts.map +0 -1
  276. package/dist/lending/public-data/compound-v2/getters/moonwell.d.ts +0 -32
  277. package/dist/lending/public-data/compound-v2/getters/moonwell.d.ts.map +0 -1
  278. package/dist/lending/public-data/compound-v2/getters/sumer.d.ts +0 -103
  279. package/dist/lending/public-data/compound-v2/getters/sumer.d.ts.map +0 -1
  280. package/dist/lending/public-data/compound-v2/getters/takara.d.ts +0 -33
  281. package/dist/lending/public-data/compound-v2/getters/takara.d.ts.map +0 -1
  282. package/dist/lending/public-data/compound-v2/getters/tectonic.d.ts +0 -42
  283. package/dist/lending/public-data/compound-v2/getters/tectonic.d.ts.map +0 -1
  284. package/dist/lending/public-data/compound-v2/getters/types.d.ts +0 -12
  285. package/dist/lending/public-data/compound-v2/getters/types.d.ts.map +0 -1
  286. package/dist/lending/public-data/compound-v2/getters/venus.d.ts +0 -86
  287. package/dist/lending/public-data/compound-v2/getters/venus.d.ts.map +0 -1
  288. package/dist/lending/public-data/compound-v2/publicCallBuild.d.ts +0 -461
  289. package/dist/lending/public-data/compound-v2/publicCallBuild.d.ts.map +0 -1
  290. package/dist/lending/public-data/compound-v2/publicCallParse.d.ts +0 -6
  291. package/dist/lending/public-data/compound-v2/publicCallParse.d.ts.map +0 -1
  292. package/dist/lending/public-data/compound-v3/publicCallBuild.d.ts +0 -2
  293. package/dist/lending/public-data/compound-v3/publicCallBuild.d.ts.map +0 -1
  294. package/dist/lending/public-data/compound-v3/publicCallParse.d.ts +0 -10
  295. package/dist/lending/public-data/compound-v3/publicCallParse.d.ts.map +0 -1
  296. package/dist/lending/public-data/euler/fetcher/cluster.d.ts +0 -21
  297. package/dist/lending/public-data/euler/fetcher/cluster.d.ts.map +0 -1
  298. package/dist/lending/public-data/euler/fetcher/normalize.d.ts +0 -174
  299. package/dist/lending/public-data/euler/fetcher/normalize.d.ts.map +0 -1
  300. package/dist/lending/public-data/euler/fetcher/types.d.ts +0 -113
  301. package/dist/lending/public-data/euler/fetcher/types.d.ts.map +0 -1
  302. package/dist/lending/public-data/euler/publicCallBuild.d.ts +0 -335
  303. package/dist/lending/public-data/euler/publicCallBuild.d.ts.map +0 -1
  304. package/dist/lending/public-data/euler/publicCallParse.d.ts +0 -9
  305. package/dist/lending/public-data/euler/publicCallParse.d.ts.map +0 -1
  306. package/dist/lending/public-data/fetchLender.d.ts +0 -11
  307. package/dist/lending/public-data/fetchLender.d.ts.map +0 -1
  308. package/dist/lending/public-data/fetchLenderAll.d.ts +0 -8
  309. package/dist/lending/public-data/fetchLenderAll.d.ts.map +0 -1
  310. package/dist/lending/public-data/fetchLenderExt.d.ts +0 -8
  311. package/dist/lending/public-data/fetchLenderExt.d.ts.map +0 -1
  312. package/dist/lending/public-data/fluid/index.d.ts +0 -3
  313. package/dist/lending/public-data/fluid/index.d.ts.map +0 -1
  314. package/dist/lending/public-data/fluid/publicCallBuild.d.ts +0 -49
  315. package/dist/lending/public-data/fluid/publicCallBuild.d.ts.map +0 -1
  316. package/dist/lending/public-data/fluid/publicCallParse.d.ts +0 -18
  317. package/dist/lending/public-data/fluid/publicCallParse.d.ts.map +0 -1
  318. package/dist/lending/public-data/gearbox/index.d.ts +0 -3
  319. package/dist/lending/public-data/gearbox/index.d.ts.map +0 -1
  320. package/dist/lending/public-data/gearbox/publicCallBuild.d.ts +0 -17
  321. package/dist/lending/public-data/gearbox/publicCallBuild.d.ts.map +0 -1
  322. package/dist/lending/public-data/gearbox/publicCallParse.d.ts +0 -27
  323. package/dist/lending/public-data/gearbox/publicCallParse.d.ts.map +0 -1
  324. package/dist/lending/public-data/init/publicCallBuild.d.ts +0 -7
  325. package/dist/lending/public-data/init/publicCallBuild.d.ts.map +0 -1
  326. package/dist/lending/public-data/init/publicCallParse.d.ts +0 -10
  327. package/dist/lending/public-data/init/publicCallParse.d.ts.map +0 -1
  328. package/dist/lending/public-data/lista/getMarketsFromChain.d.ts +0 -4
  329. package/dist/lending/public-data/lista/getMarketsFromChain.d.ts.map +0 -1
  330. package/dist/lending/public-data/lista/getMarketsOnChain.d.ts +0 -6
  331. package/dist/lending/public-data/lista/getMarketsOnChain.d.ts.map +0 -1
  332. package/dist/lending/public-data/lista/publicCallBuild.d.ts +0 -9
  333. package/dist/lending/public-data/lista/publicCallBuild.d.ts.map +0 -1
  334. package/dist/lending/public-data/morpho/convertPublic.d.ts +0 -7
  335. package/dist/lending/public-data/morpho/convertPublic.d.ts.map +0 -1
  336. package/dist/lending/public-data/morpho/fetchMorphoGoldsky.d.ts +0 -105
  337. package/dist/lending/public-data/morpho/fetchMorphoGoldsky.d.ts.map +0 -1
  338. package/dist/lending/public-data/morpho/fetchPublic.d.ts +0 -3
  339. package/dist/lending/public-data/morpho/fetchPublic.d.ts.map +0 -1
  340. package/dist/lending/public-data/morpho/getMarketsFromChain.d.ts +0 -4
  341. package/dist/lending/public-data/morpho/getMarketsFromChain.d.ts.map +0 -1
  342. package/dist/lending/public-data/morpho/index.d.ts +0 -3
  343. package/dist/lending/public-data/morpho/index.d.ts.map +0 -1
  344. package/dist/lending/public-data/morpho/publicCallBuild.d.ts +0 -16
  345. package/dist/lending/public-data/morpho/publicCallBuild.d.ts.map +0 -1
  346. package/dist/lending/public-data/morpho/utils/evmParser.d.ts +0 -50
  347. package/dist/lending/public-data/morpho/utils/evmParser.d.ts.map +0 -1
  348. package/dist/lending/public-data/morpho/utils/mathLib.d.ts +0 -135
  349. package/dist/lending/public-data/morpho/utils/mathLib.d.ts.map +0 -1
  350. package/dist/lending/public-data/morpho/utils/parsers.d.ts +0 -10
  351. package/dist/lending/public-data/morpho/utils/parsers.d.ts.map +0 -1
  352. package/dist/lending/public-data/silo-v2/convertPublic.d.ts +0 -28
  353. package/dist/lending/public-data/silo-v2/convertPublic.d.ts.map +0 -1
  354. package/dist/lending/public-data/silo-v2/fetchPublic.d.ts +0 -85
  355. package/dist/lending/public-data/silo-v2/fetchPublic.d.ts.map +0 -1
  356. package/dist/lending/public-data/silo-v2/irmRates.d.ts +0 -38
  357. package/dist/lending/public-data/silo-v2/irmRates.d.ts.map +0 -1
  358. package/dist/lending/public-data/silo-v2/publicCallBuild.d.ts +0 -25
  359. package/dist/lending/public-data/silo-v2/publicCallBuild.d.ts.map +0 -1
  360. package/dist/lending/public-data/silo-v2/publicCallParse.d.ts +0 -25
  361. package/dist/lending/public-data/silo-v2/publicCallParse.d.ts.map +0 -1
  362. package/dist/lending/public-data/silo-v3/convertPublic.d.ts +0 -9
  363. package/dist/lending/public-data/silo-v3/convertPublic.d.ts.map +0 -1
  364. package/dist/lending/public-data/silo-v3/publicCallBuild.d.ts +0 -22
  365. package/dist/lending/public-data/silo-v3/publicCallBuild.d.ts.map +0 -1
  366. package/dist/lending/public-data/silo-v3/publicCallParse.d.ts +0 -9
  367. package/dist/lending/public-data/silo-v3/publicCallParse.d.ts.map +0 -1
  368. package/dist/lending/user-data/aave-v2-type/userCallBuild.d.ts +0 -3
  369. package/dist/lending/user-data/aave-v2-type/userCallBuild.d.ts.map +0 -1
  370. package/dist/lending/user-data/aave-v2-type/userCallParse.d.ts +0 -3
  371. package/dist/lending/user-data/aave-v2-type/userCallParse.d.ts.map +0 -1
  372. package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts +0 -3
  373. package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts.map +0 -1
  374. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts +0 -3
  375. package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts.map +0 -1
  376. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts +0 -4
  377. package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts.map +0 -1
  378. package/dist/lending/user-data/aave-v4-type/createAaveV4UserState.d.ts +0 -23
  379. package/dist/lending/user-data/aave-v4-type/createAaveV4UserState.d.ts.map +0 -1
  380. package/dist/lending/user-data/aave-v4-type/userCallBuild.d.ts +0 -26
  381. package/dist/lending/user-data/aave-v4-type/userCallBuild.d.ts.map +0 -1
  382. package/dist/lending/user-data/aave-v4-type/userCallParse.d.ts +0 -26
  383. package/dist/lending/user-data/aave-v4-type/userCallParse.d.ts.map +0 -1
  384. package/dist/lending/user-data/abis.d.ts +0 -3
  385. package/dist/lending/user-data/abis.d.ts.map +0 -1
  386. package/dist/lending/user-data/compound-v2/index.d.ts +0 -3
  387. package/dist/lending/user-data/compound-v2/index.d.ts.map +0 -1
  388. package/dist/lending/user-data/compound-v2/userCallBuild.d.ts +0 -3
  389. package/dist/lending/user-data/compound-v2/userCallBuild.d.ts.map +0 -1
  390. package/dist/lending/user-data/compound-v2/userCallParse.d.ts +0 -3
  391. package/dist/lending/user-data/compound-v2/userCallParse.d.ts.map +0 -1
  392. package/dist/lending/user-data/compound-v3/index.d.ts +0 -3
  393. package/dist/lending/user-data/compound-v3/index.d.ts.map +0 -1
  394. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts +0 -3
  395. package/dist/lending/user-data/compound-v3/userCallBuild.d.ts.map +0 -1
  396. package/dist/lending/user-data/compound-v3/userCallParse.d.ts +0 -24
  397. package/dist/lending/user-data/compound-v3/userCallParse.d.ts.map +0 -1
  398. package/dist/lending/user-data/euler/userCallBuild.d.ts +0 -53
  399. package/dist/lending/user-data/euler/userCallBuild.d.ts.map +0 -1
  400. package/dist/lending/user-data/euler/userCallParse.d.ts +0 -18
  401. package/dist/lending/user-data/euler/userCallParse.d.ts.map +0 -1
  402. package/dist/lending/user-data/fetch-balances/e2e.d.ts +0 -43
  403. package/dist/lending/user-data/fetch-balances/e2e.d.ts.map +0 -1
  404. package/dist/lending/user-data/fetch-balances/index.d.ts +0 -5
  405. package/dist/lending/user-data/fetch-balances/index.d.ts.map +0 -1
  406. package/dist/lending/user-data/fetch-balances/parse.d.ts +0 -14
  407. package/dist/lending/user-data/fetch-balances/parse.d.ts.map +0 -1
  408. package/dist/lending/user-data/fetch-balances/prepare.d.ts +0 -3
  409. package/dist/lending/user-data/fetch-balances/prepare.d.ts.map +0 -1
  410. package/dist/lending/user-data/fetch-balances/types.d.ts +0 -93
  411. package/dist/lending/user-data/fetch-balances/types.d.ts.map +0 -1
  412. package/dist/lending/user-data/fluid/index.d.ts +0 -3
  413. package/dist/lending/user-data/fluid/index.d.ts.map +0 -1
  414. package/dist/lending/user-data/fluid/userCallBuild.d.ts +0 -21
  415. package/dist/lending/user-data/fluid/userCallBuild.d.ts.map +0 -1
  416. package/dist/lending/user-data/fluid/userCallParse.d.ts +0 -19
  417. package/dist/lending/user-data/fluid/userCallParse.d.ts.map +0 -1
  418. package/dist/lending/user-data/gearbox/index.d.ts +0 -3
  419. package/dist/lending/user-data/gearbox/index.d.ts.map +0 -1
  420. package/dist/lending/user-data/gearbox/userCallBuild.d.ts +0 -19
  421. package/dist/lending/user-data/gearbox/userCallBuild.d.ts.map +0 -1
  422. package/dist/lending/user-data/gearbox/userCallParse.d.ts +0 -25
  423. package/dist/lending/user-data/gearbox/userCallParse.d.ts.map +0 -1
  424. package/dist/lending/user-data/index.d.ts +0 -6
  425. package/dist/lending/user-data/index.d.ts.map +0 -1
  426. package/dist/lending/user-data/init/userCallBuild.d.ts +0 -4
  427. package/dist/lending/user-data/init/userCallBuild.d.ts.map +0 -1
  428. package/dist/lending/user-data/init/userCallParse.d.ts +0 -3
  429. package/dist/lending/user-data/init/userCallParse.d.ts.map +0 -1
  430. package/dist/lending/user-data/morpho/decoder.d.ts +0 -40
  431. package/dist/lending/user-data/morpho/decoder.d.ts.map +0 -1
  432. package/dist/lending/user-data/morpho/index.d.ts +0 -4
  433. package/dist/lending/user-data/morpho/index.d.ts.map +0 -1
  434. package/dist/lending/user-data/morpho/morphoLib.d.ts +0 -5
  435. package/dist/lending/user-data/morpho/morphoLib.d.ts.map +0 -1
  436. package/dist/lending/user-data/morpho/types.d.ts +0 -12
  437. package/dist/lending/user-data/morpho/types.d.ts.map +0 -1
  438. package/dist/lending/user-data/morpho/userCallBuild.d.ts +0 -8
  439. package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +0 -1
  440. package/dist/lending/user-data/morpho/userCallParse.d.ts +0 -14
  441. package/dist/lending/user-data/morpho/userCallParse.d.ts.map +0 -1
  442. package/dist/lending/user-data/silo-v2/userCallBuild.d.ts +0 -21
  443. package/dist/lending/user-data/silo-v2/userCallBuild.d.ts.map +0 -1
  444. package/dist/lending/user-data/silo-v2/userCallParse.d.ts +0 -23
  445. package/dist/lending/user-data/silo-v2/userCallParse.d.ts.map +0 -1
  446. package/dist/lending/user-data/silo-v3/userCallBuild.d.ts +0 -5
  447. package/dist/lending/user-data/silo-v3/userCallBuild.d.ts.map +0 -1
  448. package/dist/lending/user-data/silo-v3/userCallParse.d.ts +0 -30
  449. package/dist/lending/user-data/silo-v3/userCallParse.d.ts.map +0 -1
  450. package/dist/lending/user-data/summary/buildPortfolioTotals.d.ts +0 -19
  451. package/dist/lending/user-data/summary/buildPortfolioTotals.d.ts.map +0 -1
  452. package/dist/lending/user-data/summary/buildSummaries.d.ts +0 -28
  453. package/dist/lending/user-data/summary/buildSummaries.d.ts.map +0 -1
  454. package/dist/lending/user-data/summary/index.d.ts +0 -5
  455. package/dist/lending/user-data/summary/index.d.ts.map +0 -1
  456. package/dist/lending/user-data/summary/types.d.ts +0 -104
  457. package/dist/lending/user-data/summary/types.d.ts.map +0 -1
  458. package/dist/lending/user-data/summary/utils.d.ts +0 -57
  459. package/dist/lending/user-data/summary/utils.d.ts.map +0 -1
  460. package/dist/lending/user-data/utils/createEulerMultiAccountTypeUserState.d.ts +0 -54
  461. package/dist/lending/user-data/utils/createEulerMultiAccountTypeUserState.d.ts.map +0 -1
  462. package/dist/lending/user-data/utils/createGeneralUserState.d.ts +0 -6
  463. package/dist/lending/user-data/utils/createGeneralUserState.d.ts.map +0 -1
  464. package/dist/lending/user-data/utils/createMultiAccountStyleUserState.d.ts +0 -9
  465. package/dist/lending/user-data/utils/createMultiAccountStyleUserState.d.ts.map +0 -1
  466. package/dist/lending/user-data/utils/createSumerUserState.d.ts +0 -6
  467. package/dist/lending/user-data/utils/createSumerUserState.d.ts.map +0 -1
  468. package/dist/lending/user-data/utils/formatting/generalFormatters.d.ts +0 -55
  469. package/dist/lending/user-data/utils/formatting/generalFormatters.d.ts.map +0 -1
  470. package/dist/lending/user-data/utils/formatting/index.d.ts +0 -2
  471. package/dist/lending/user-data/utils/formatting/index.d.ts.map +0 -1
  472. package/dist/lending/user-data/utils/getBalanceForMarketUid.d.ts +0 -5
  473. package/dist/lending/user-data/utils/getBalanceForMarketUid.d.ts.map +0 -1
  474. package/dist/lending/user-data/utils/index.d.ts +0 -12
  475. package/dist/lending/user-data/utils/index.d.ts.map +0 -1
  476. package/dist/lending/user-data/utils/oraclePrice.d.ts +0 -11
  477. package/dist/lending/user-data/utils/oraclePrice.d.ts.map +0 -1
  478. package/dist/lending/user-data/utils/types.d.ts +0 -155
  479. package/dist/lending/user-data/utils/types.d.ts.map +0 -1
  480. package/dist/lending/user-data/with-permissions/e2e.d.ts +0 -10
  481. package/dist/lending/user-data/with-permissions/e2e.d.ts.map +0 -1
  482. package/dist/lending/user-data/with-permissions/evaluate.d.ts +0 -32
  483. package/dist/lending/user-data/with-permissions/evaluate.d.ts.map +0 -1
  484. package/dist/lending/user-data/with-permissions/index.d.ts +0 -6
  485. package/dist/lending/user-data/with-permissions/index.d.ts.map +0 -1
  486. package/dist/lending/user-data/with-permissions/parse.d.ts +0 -9
  487. package/dist/lending/user-data/with-permissions/parse.d.ts.map +0 -1
  488. package/dist/lending/user-data/with-permissions/prepare.d.ts +0 -14
  489. package/dist/lending/user-data/with-permissions/prepare.d.ts.map +0 -1
  490. package/dist/lending/user-data/with-permissions/types.d.ts +0 -77
  491. package/dist/lending/user-data/with-permissions/types.d.ts.map +0 -1
  492. package/dist/lending-pools/computeLenderDataFromPools.d.ts +0 -10
  493. package/dist/lending-pools/computeLenderDataFromPools.d.ts.map +0 -1
  494. package/dist/lending-pools/computeLendingPools.d.ts +0 -23
  495. package/dist/lending-pools/computeLendingPools.d.ts.map +0 -1
  496. package/dist/lending-pools/index.d.ts +0 -3
  497. package/dist/lending-pools/index.d.ts.map +0 -1
  498. package/dist/prices/index.d.ts +0 -3
  499. package/dist/prices/index.d.ts.map +0 -1
  500. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts +0 -64
  501. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +0 -1
  502. package/dist/prices/oracle-prices/fetchers/aave.d.ts +0 -91
  503. package/dist/prices/oracle-prices/fetchers/aave.d.ts.map +0 -1
  504. package/dist/prices/oracle-prices/fetchers/aaveV4.d.ts +0 -31
  505. package/dist/prices/oracle-prices/fetchers/aaveV4.d.ts.map +0 -1
  506. package/dist/prices/oracle-prices/fetchers/compoundV2.d.ts +0 -68
  507. package/dist/prices/oracle-prices/fetchers/compoundV2.d.ts.map +0 -1
  508. package/dist/prices/oracle-prices/fetchers/compoundV3.d.ts +0 -85
  509. package/dist/prices/oracle-prices/fetchers/compoundV3.d.ts.map +0 -1
  510. package/dist/prices/oracle-prices/fetchers/euler.d.ts +0 -417
  511. package/dist/prices/oracle-prices/fetchers/euler.d.ts.map +0 -1
  512. package/dist/prices/oracle-prices/fetchers/fluid.d.ts +0 -1131
  513. package/dist/prices/oracle-prices/fetchers/fluid.d.ts.map +0 -1
  514. package/dist/prices/oracle-prices/fetchers/gearbox.d.ts +0 -601
  515. package/dist/prices/oracle-prices/fetchers/gearbox.d.ts.map +0 -1
  516. package/dist/prices/oracle-prices/fetchers/index.d.ts +0 -12
  517. package/dist/prices/oracle-prices/fetchers/index.d.ts.map +0 -1
  518. package/dist/prices/oracle-prices/fetchers/lista.d.ts +0 -91
  519. package/dist/prices/oracle-prices/fetchers/lista.d.ts.map +0 -1
  520. package/dist/prices/oracle-prices/fetchers/morpho.d.ts +0 -95
  521. package/dist/prices/oracle-prices/fetchers/morpho.d.ts.map +0 -1
  522. package/dist/prices/oracle-prices/fetchers/siloV2.d.ts +0 -108
  523. package/dist/prices/oracle-prices/fetchers/siloV2.d.ts.map +0 -1
  524. package/dist/prices/oracle-prices/fetchers/siloV2Graphql.d.ts +0 -54
  525. package/dist/prices/oracle-prices/fetchers/siloV2Graphql.d.ts.map +0 -1
  526. package/dist/prices/oracle-prices/fetchers/siloV3.d.ts +0 -52
  527. package/dist/prices/oracle-prices/fetchers/siloV3.d.ts.map +0 -1
  528. package/dist/prices/oracle-prices/fetchers/siloV3Graphql.d.ts +0 -30
  529. package/dist/prices/oracle-prices/fetchers/siloV3Graphql.d.ts.map +0 -1
  530. package/dist/prices/oracle-prices/index.d.ts +0 -11
  531. package/dist/prices/oracle-prices/index.d.ts.map +0 -1
  532. package/dist/prices/oracle-prices/selectAssetGroupPrices.d.ts +0 -10
  533. package/dist/prices/oracle-prices/selectAssetGroupPrices.d.ts.map +0 -1
  534. package/dist/prices/oracle-prices/types.d.ts +0 -341
  535. package/dist/prices/oracle-prices/types.d.ts.map +0 -1
  536. package/dist/prices/pendle/fetchPendlePrices.d.ts +0 -47
  537. package/dist/prices/pendle/fetchPendlePrices.d.ts.map +0 -1
  538. package/dist/prices/pendle/index.d.ts +0 -2
  539. package/dist/prices/pendle/index.d.ts.map +0 -1
  540. package/dist/secp256k1-XP7IUONI.js +0 -2208
  541. package/dist/secp256k1-XP7IUONI.js.map +0 -1
  542. package/dist/token/fetchTokenBalance.d.ts +0 -50
  543. package/dist/token/fetchTokenBalance.d.ts.map +0 -1
  544. package/dist/token/fetchTokenMetadata.d.ts +0 -11
  545. package/dist/token/fetchTokenMetadata.d.ts.map +0 -1
  546. package/dist/token/index.d.ts +0 -4
  547. package/dist/token/index.d.ts.map +0 -1
  548. package/dist/token/types.d.ts +0 -32
  549. package/dist/token/types.d.ts.map +0 -1
  550. package/dist/types/apiReturnType.d.ts +0 -77
  551. package/dist/types/apiReturnType.d.ts.map +0 -1
  552. package/dist/types/general.d.ts +0 -18
  553. package/dist/types/general.d.ts.map +0 -1
  554. package/dist/types/index.d.ts +0 -6
  555. package/dist/types/index.d.ts.map +0 -1
  556. package/dist/types/lender/aave-v2-types.d.ts +0 -89
  557. package/dist/types/lender/aave-v2-types.d.ts.map +0 -1
  558. package/dist/types/lender/aave-v3-types.d.ts +0 -168
  559. package/dist/types/lender/aave-v3-types.d.ts.map +0 -1
  560. package/dist/types/lender/compound-v2-types.d.ts +0 -52
  561. package/dist/types/lender/compound-v2-types.d.ts.map +0 -1
  562. package/dist/types/lender/compound-v3-types.d.ts +0 -31
  563. package/dist/types/lender/compound-v3-types.d.ts.map +0 -1
  564. package/dist/types/lender/init-types.d.ts +0 -52
  565. package/dist/types/lender/init-types.d.ts.map +0 -1
  566. package/dist/types/lender/morpho-types.d.ts +0 -139
  567. package/dist/types/lender/morpho-types.d.ts.map +0 -1
  568. package/dist/types/lenderTypes.d.ts +0 -253
  569. package/dist/types/lenderTypes.d.ts.map +0 -1
  570. package/dist/types/misc.d.ts +0 -47
  571. package/dist/types/misc.d.ts.map +0 -1
  572. package/dist/types/providers.d.ts +0 -15
  573. package/dist/types/providers.d.ts.map +0 -1
  574. package/dist/utils/constants.d.ts +0 -8
  575. package/dist/utils/constants.d.ts.map +0 -1
  576. package/dist/utils/index.d.ts +0 -13
  577. package/dist/utils/index.d.ts.map +0 -1
  578. package/dist/utils/marketName.d.ts +0 -2
  579. package/dist/utils/marketName.d.ts.map +0 -1
  580. package/dist/utils/marketUid.d.ts +0 -9
  581. package/dist/utils/marketUid.d.ts.map +0 -1
  582. package/dist/utils/multicall.d.ts +0 -16
  583. package/dist/utils/multicall.d.ts.map +0 -1
  584. package/dist/utils/parsing.d.ts +0 -24
  585. package/dist/utils/parsing.d.ts.map +0 -1
  586. package/dist/utils/rpcCall.d.ts +0 -65
  587. package/dist/utils/rpcCall.d.ts.map +0 -1
  588. package/dist/utils/rpcParse.d.ts +0 -19
  589. package/dist/utils/rpcParse.d.ts.map +0 -1
  590. package/dist/vaults/fluid/fetchPublic.d.ts +0 -21
  591. package/dist/vaults/fluid/fetchPublic.d.ts.map +0 -1
  592. package/dist/vaults/fluid/index.d.ts +0 -5
  593. package/dist/vaults/fluid/index.d.ts.map +0 -1
  594. package/dist/vaults/fluid/publicCallBuild.d.ts +0 -16
  595. package/dist/vaults/fluid/publicCallBuild.d.ts.map +0 -1
  596. package/dist/vaults/fluid/publicCallParse.d.ts +0 -15
  597. package/dist/vaults/fluid/publicCallParse.d.ts.map +0 -1
  598. package/dist/vaults/fluid/types.d.ts +0 -57
  599. package/dist/vaults/fluid/types.d.ts.map +0 -1
  600. package/dist/vaults/gearbox/fetchPublic.d.ts +0 -23
  601. package/dist/vaults/gearbox/fetchPublic.d.ts.map +0 -1
  602. package/dist/vaults/gearbox/index.d.ts +0 -5
  603. package/dist/vaults/gearbox/index.d.ts.map +0 -1
  604. package/dist/vaults/gearbox/publicCallBuild.d.ts +0 -14
  605. package/dist/vaults/gearbox/publicCallBuild.d.ts.map +0 -1
  606. package/dist/vaults/gearbox/publicCallParse.d.ts +0 -13
  607. package/dist/vaults/gearbox/publicCallParse.d.ts.map +0 -1
  608. package/dist/vaults/gearbox/types.d.ts +0 -61
  609. package/dist/vaults/gearbox/types.d.ts.map +0 -1
  610. package/dist/vaults/index.d.ts +0 -3
  611. package/dist/vaults/index.d.ts.map +0 -1
  612. package/dist/yields/fetchGeneralYields.d.ts +0 -4
  613. package/dist/yields/fetchGeneralYields.d.ts.map +0 -1
  614. package/dist/yields/helpers.d.ts +0 -8
  615. package/dist/yields/helpers.d.ts.map +0 -1
  616. package/dist/yields/index.d.ts +0 -6
  617. package/dist/yields/index.d.ts.map +0 -1
  618. package/dist/yields/intrinsic/fetchers/angle.d.ts +0 -3
  619. package/dist/yields/intrinsic/fetchers/angle.d.ts.map +0 -1
  620. package/dist/yields/intrinsic/fetchers/avant.d.ts +0 -5
  621. package/dist/yields/intrinsic/fetchers/avant.d.ts.map +0 -1
  622. package/dist/yields/intrinsic/fetchers/cap.d.ts +0 -3
  623. package/dist/yields/intrinsic/fetchers/cap.d.ts.map +0 -1
  624. package/dist/yields/intrinsic/fetchers/coinbase.d.ts +0 -3
  625. package/dist/yields/intrinsic/fetchers/coinbase.d.ts.map +0 -1
  626. package/dist/yields/intrinsic/fetchers/ethena.d.ts +0 -3
  627. package/dist/yields/intrinsic/fetchers/ethena.d.ts.map +0 -1
  628. package/dist/yields/intrinsic/fetchers/etherfi.d.ts +0 -8
  629. package/dist/yields/intrinsic/fetchers/etherfi.d.ts.map +0 -1
  630. package/dist/yields/intrinsic/fetchers/falcon.d.ts +0 -3
  631. package/dist/yields/intrinsic/fetchers/falcon.d.ts.map +0 -1
  632. package/dist/yields/intrinsic/fetchers/gmx.d.ts +0 -3
  633. package/dist/yields/intrinsic/fetchers/gmx.d.ts.map +0 -1
  634. package/dist/yields/intrinsic/fetchers/hyperbeat.d.ts +0 -4
  635. package/dist/yields/intrinsic/fetchers/hyperbeat.d.ts.map +0 -1
  636. package/dist/yields/intrinsic/fetchers/hyperlend.d.ts +0 -3
  637. package/dist/yields/intrinsic/fetchers/hyperlend.d.ts.map +0 -1
  638. package/dist/yields/intrinsic/fetchers/hyperliquid.d.ts +0 -4
  639. package/dist/yields/intrinsic/fetchers/hyperliquid.d.ts.map +0 -1
  640. package/dist/yields/intrinsic/fetchers/infinifi.d.ts +0 -3
  641. package/dist/yields/intrinsic/fetchers/infinifi.d.ts.map +0 -1
  642. package/dist/yields/intrinsic/fetchers/jito.d.ts +0 -3
  643. package/dist/yields/intrinsic/fetchers/jito.d.ts.map +0 -1
  644. package/dist/yields/intrinsic/fetchers/kelp.d.ts +0 -3
  645. package/dist/yields/intrinsic/fetchers/kelp.d.ts.map +0 -1
  646. package/dist/yields/intrinsic/fetchers/lido.d.ts +0 -4
  647. package/dist/yields/intrinsic/fetchers/lido.d.ts.map +0 -1
  648. package/dist/yields/intrinsic/fetchers/mantle.d.ts +0 -3
  649. package/dist/yields/intrinsic/fetchers/mantle.d.ts.map +0 -1
  650. package/dist/yields/intrinsic/fetchers/maple.d.ts +0 -3
  651. package/dist/yields/intrinsic/fetchers/maple.d.ts.map +0 -1
  652. package/dist/yields/intrinsic/fetchers/midas.d.ts +0 -3
  653. package/dist/yields/intrinsic/fetchers/midas.d.ts.map +0 -1
  654. package/dist/yields/intrinsic/fetchers/morphoVaults.d.ts +0 -3
  655. package/dist/yields/intrinsic/fetchers/morphoVaults.d.ts.map +0 -1
  656. package/dist/yields/intrinsic/fetchers/ondo.d.ts +0 -3
  657. package/dist/yields/intrinsic/fetchers/ondo.d.ts.map +0 -1
  658. package/dist/yields/intrinsic/fetchers/pendle.d.ts +0 -3
  659. package/dist/yields/intrinsic/fetchers/pendle.d.ts.map +0 -1
  660. package/dist/yields/intrinsic/fetchers/puffer.d.ts +0 -3
  661. package/dist/yields/intrinsic/fetchers/puffer.d.ts.map +0 -1
  662. package/dist/yields/intrinsic/fetchers/renzo.d.ts +0 -3
  663. package/dist/yields/intrinsic/fetchers/renzo.d.ts.map +0 -1
  664. package/dist/yields/intrinsic/fetchers/reserve.d.ts +0 -3
  665. package/dist/yields/intrinsic/fetchers/reserve.d.ts.map +0 -1
  666. package/dist/yields/intrinsic/fetchers/reservoir.d.ts +0 -3
  667. package/dist/yields/intrinsic/fetchers/reservoir.d.ts.map +0 -1
  668. package/dist/yields/intrinsic/fetchers/resolv.d.ts +0 -4
  669. package/dist/yields/intrinsic/fetchers/resolv.d.ts.map +0 -1
  670. package/dist/yields/intrinsic/fetchers/rocketpool.d.ts +0 -3
  671. package/dist/yields/intrinsic/fetchers/rocketpool.d.ts.map +0 -1
  672. package/dist/yields/intrinsic/fetchers/savax.d.ts +0 -3
  673. package/dist/yields/intrinsic/fetchers/savax.d.ts.map +0 -1
  674. package/dist/yields/intrinsic/fetchers/sky.d.ts +0 -3
  675. package/dist/yields/intrinsic/fetchers/sky.d.ts.map +0 -1
  676. package/dist/yields/intrinsic/fetchers/stS.d.ts +0 -3
  677. package/dist/yields/intrinsic/fetchers/stS.d.ts.map +0 -1
  678. package/dist/yields/intrinsic/fetchers/stader.d.ts +0 -4
  679. package/dist/yields/intrinsic/fetchers/stader.d.ts.map +0 -1
  680. package/dist/yields/intrinsic/fetchers/stakewise.d.ts +0 -3
  681. package/dist/yields/intrinsic/fetchers/stakewise.d.ts.map +0 -1
  682. package/dist/yields/intrinsic/fetchers/superreturn.d.ts +0 -3
  683. package/dist/yields/intrinsic/fetchers/superreturn.d.ts.map +0 -1
  684. package/dist/yields/intrinsic/fetchers/swell.d.ts +0 -3
  685. package/dist/yields/intrinsic/fetchers/swell.d.ts.map +0 -1
  686. package/dist/yields/intrinsic/fetchers/theo.d.ts +0 -3
  687. package/dist/yields/intrinsic/fetchers/theo.d.ts.map +0 -1
  688. package/dist/yields/intrinsic/fetchers/trufin.d.ts +0 -3
  689. package/dist/yields/intrinsic/fetchers/trufin.d.ts.map +0 -1
  690. package/dist/yields/intrinsic/fetchers/usdai.d.ts +0 -3
  691. package/dist/yields/intrinsic/fetchers/usdai.d.ts.map +0 -1
  692. package/dist/yields/intrinsic/fetchers/usdx.d.ts +0 -4
  693. package/dist/yields/intrinsic/fetchers/usdx.d.ts.map +0 -1
  694. package/dist/yields/intrinsic/fetchers/usual.d.ts +0 -4
  695. package/dist/yields/intrinsic/fetchers/usual.d.ts.map +0 -1
  696. package/dist/yields/intrinsic/fetchers/yearnKatana.d.ts +0 -3
  697. package/dist/yields/intrinsic/fetchers/yearnKatana.d.ts.map +0 -1
  698. package/dist/yields/intrinsic/fetchers/yieldfi.d.ts +0 -3
  699. package/dist/yields/intrinsic/fetchers/yieldfi.d.ts.map +0 -1
  700. package/dist/yields/intrinsic/fetchers/yieldnest.d.ts +0 -3
  701. package/dist/yields/intrinsic/fetchers/yieldnest.d.ts.map +0 -1
  702. package/dist/yields/intrinsic/fetchers/yoProtocol.d.ts +0 -3
  703. package/dist/yields/intrinsic/fetchers/yoProtocol.d.ts.map +0 -1
  704. package/dist/yields/intrinsic/fetchers/yuzu.d.ts +0 -3
  705. package/dist/yields/intrinsic/fetchers/yuzu.d.ts.map +0 -1
  706. package/dist/yields/intrinsic/index.d.ts +0 -5
  707. package/dist/yields/intrinsic/index.d.ts.map +0 -1
  708. package/dist/yields/rewards/fetchLenderRewards.d.ts +0 -9
  709. package/dist/yields/rewards/fetchLenderRewards.d.ts.map +0 -1
  710. package/dist/yields/rewards/index.d.ts +0 -5
  711. package/dist/yields/rewards/index.d.ts.map +0 -1
  712. package/dist/yields/rewards/merkl.d.ts +0 -22
  713. package/dist/yields/rewards/merkl.d.ts.map +0 -1
  714. package/dist/yields/rewards/types.d.ts +0 -68
  715. package/dist/yields/rewards/types.d.ts.map +0 -1
  716. package/dist/yields/types.d.ts +0 -44
  717. package/dist/yields/types.d.ts.map +0 -1
  718. package/dist/yields/yieldTypes.d.ts +0 -76
  719. package/dist/yields/yieldTypes.d.ts.map +0 -1
@@ -1,3898 +0,0 @@
1
- import { __commonJS, __require, __export, __toESM } from './chunk-PR4QN5HX.js';
2
-
3
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/constants.js
4
- var require_constants = __commonJS({
5
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/constants.js"(exports$1, module) {
6
- var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
7
- var hasBlob = typeof Blob !== "undefined";
8
- if (hasBlob) BINARY_TYPES.push("blob");
9
- module.exports = {
10
- BINARY_TYPES,
11
- EMPTY_BUFFER: Buffer.alloc(0),
12
- GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
13
- hasBlob,
14
- kForOnEventAttribute: /* @__PURE__ */ Symbol("kIsForOnEventAttribute"),
15
- kListener: /* @__PURE__ */ Symbol("kListener"),
16
- kStatusCode: /* @__PURE__ */ Symbol("status-code"),
17
- kWebSocket: /* @__PURE__ */ Symbol("websocket"),
18
- NOOP: () => {
19
- }
20
- };
21
- }
22
- });
23
-
24
- // ../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js
25
- var require_node_gyp_build = __commonJS({
26
- "../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports$1, module) {
27
- var fs = __require("fs");
28
- var path = __require("path");
29
- var os = __require("os");
30
- var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
31
- var vars = process.config && process.config.variables || {};
32
- var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
33
- var abi = process.versions.modules;
34
- var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
35
- var arch = process.env.npm_config_arch || os.arch();
36
- var platform = process.env.npm_config_platform || os.platform();
37
- var libc = process.env.LIBC || (isAlpine(platform) ? "musl" : "glibc");
38
- var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
39
- var uv = (process.versions.uv || "").split(".")[0];
40
- module.exports = load;
41
- function load(dir) {
42
- return runtimeRequire(load.resolve(dir));
43
- }
44
- load.resolve = load.path = function(dir) {
45
- dir = path.resolve(dir || ".");
46
- try {
47
- var name = runtimeRequire(path.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
48
- if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
49
- } catch (err) {
50
- }
51
- if (!prebuildsOnly) {
52
- var release = getFirst(path.join(dir, "build/Release"), matchBuild);
53
- if (release) return release;
54
- var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
55
- if (debug) return debug;
56
- }
57
- var prebuild = resolve(dir);
58
- if (prebuild) return prebuild;
59
- var nearby = resolve(path.dirname(process.execPath));
60
- if (nearby) return nearby;
61
- var target = [
62
- "platform=" + platform,
63
- "arch=" + arch,
64
- "runtime=" + runtime,
65
- "abi=" + abi,
66
- "uv=" + uv,
67
- armv ? "armv=" + armv : "",
68
- "libc=" + libc,
69
- "node=" + process.versions.node,
70
- process.versions.electron ? "electron=" + process.versions.electron : "",
71
- typeof __webpack_require__ === "function" ? "webpack=true" : ""
72
- // eslint-disable-line
73
- ].filter(Boolean).join(" ");
74
- throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
75
- function resolve(dir2) {
76
- var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
77
- var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
78
- if (!tuple) return;
79
- var prebuilds = path.join(dir2, "prebuilds", tuple.name);
80
- var parsed = readdirSync(prebuilds).map(parseTags);
81
- var candidates = parsed.filter(matchTags(runtime, abi));
82
- var winner = candidates.sort(compareTags(runtime))[0];
83
- if (winner) return path.join(prebuilds, winner.file);
84
- }
85
- };
86
- function readdirSync(dir) {
87
- try {
88
- return fs.readdirSync(dir);
89
- } catch (err) {
90
- return [];
91
- }
92
- }
93
- function getFirst(dir, filter) {
94
- var files = readdirSync(dir).filter(filter);
95
- return files[0] && path.join(dir, files[0]);
96
- }
97
- function matchBuild(name) {
98
- return /\.node$/.test(name);
99
- }
100
- function parseTuple(name) {
101
- var arr = name.split("-");
102
- if (arr.length !== 2) return;
103
- var platform2 = arr[0];
104
- var architectures = arr[1].split("+");
105
- if (!platform2) return;
106
- if (!architectures.length) return;
107
- if (!architectures.every(Boolean)) return;
108
- return { name, platform: platform2, architectures };
109
- }
110
- function matchTuple(platform2, arch2) {
111
- return function(tuple) {
112
- if (tuple == null) return false;
113
- if (tuple.platform !== platform2) return false;
114
- return tuple.architectures.includes(arch2);
115
- };
116
- }
117
- function compareTuples(a, b) {
118
- return a.architectures.length - b.architectures.length;
119
- }
120
- function parseTags(file) {
121
- var arr = file.split(".");
122
- var extension = arr.pop();
123
- var tags = { file, specificity: 0 };
124
- if (extension !== "node") return;
125
- for (var i = 0; i < arr.length; i++) {
126
- var tag = arr[i];
127
- if (tag === "node" || tag === "electron" || tag === "node-webkit") {
128
- tags.runtime = tag;
129
- } else if (tag === "napi") {
130
- tags.napi = true;
131
- } else if (tag.slice(0, 3) === "abi") {
132
- tags.abi = tag.slice(3);
133
- } else if (tag.slice(0, 2) === "uv") {
134
- tags.uv = tag.slice(2);
135
- } else if (tag.slice(0, 4) === "armv") {
136
- tags.armv = tag.slice(4);
137
- } else if (tag === "glibc" || tag === "musl") {
138
- tags.libc = tag;
139
- } else {
140
- continue;
141
- }
142
- tags.specificity++;
143
- }
144
- return tags;
145
- }
146
- function matchTags(runtime2, abi2) {
147
- return function(tags) {
148
- if (tags == null) return false;
149
- if (tags.runtime && tags.runtime !== runtime2 && !runtimeAgnostic(tags)) return false;
150
- if (tags.abi && tags.abi !== abi2 && !tags.napi) return false;
151
- if (tags.uv && tags.uv !== uv) return false;
152
- if (tags.armv && tags.armv !== armv) return false;
153
- if (tags.libc && tags.libc !== libc) return false;
154
- return true;
155
- };
156
- }
157
- function runtimeAgnostic(tags) {
158
- return tags.runtime === "node" && tags.napi;
159
- }
160
- function compareTags(runtime2) {
161
- return function(a, b) {
162
- if (a.runtime !== b.runtime) {
163
- return a.runtime === runtime2 ? -1 : 1;
164
- } else if (a.abi !== b.abi) {
165
- return a.abi ? -1 : 1;
166
- } else if (a.specificity !== b.specificity) {
167
- return a.specificity > b.specificity ? -1 : 1;
168
- } else {
169
- return 0;
170
- }
171
- };
172
- }
173
- function isNwjs() {
174
- return !!(process.versions && process.versions.nw);
175
- }
176
- function isElectron() {
177
- if (process.versions && process.versions.electron) return true;
178
- if (process.env.ELECTRON_RUN_AS_NODE) return true;
179
- return typeof window !== "undefined" && window.process && window.process.type === "renderer";
180
- }
181
- function isAlpine(platform2) {
182
- return platform2 === "linux" && fs.existsSync("/etc/alpine-release");
183
- }
184
- load.parseTags = parseTags;
185
- load.matchTags = matchTags;
186
- load.compareTags = compareTags;
187
- load.parseTuple = parseTuple;
188
- load.matchTuple = matchTuple;
189
- load.compareTuples = compareTuples;
190
- }
191
- });
192
-
193
- // ../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js
194
- var require_node_gyp_build2 = __commonJS({
195
- "../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js"(exports$1, module) {
196
- var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
197
- if (typeof runtimeRequire.addon === "function") {
198
- module.exports = runtimeRequire.addon.bind(runtimeRequire);
199
- } else {
200
- module.exports = require_node_gyp_build();
201
- }
202
- }
203
- });
204
-
205
- // ../../node_modules/.pnpm/bufferutil@4.1.0/node_modules/bufferutil/fallback.js
206
- var require_fallback = __commonJS({
207
- "../../node_modules/.pnpm/bufferutil@4.1.0/node_modules/bufferutil/fallback.js"(exports$1, module) {
208
- var mask = (source, mask2, output, offset, length) => {
209
- for (var i = 0; i < length; i++) {
210
- output[offset + i] = source[i] ^ mask2[i & 3];
211
- }
212
- };
213
- var unmask = (buffer, mask2) => {
214
- const length = buffer.length;
215
- for (var i = 0; i < length; i++) {
216
- buffer[i] ^= mask2[i & 3];
217
- }
218
- };
219
- module.exports = { mask, unmask };
220
- }
221
- });
222
-
223
- // ../../node_modules/.pnpm/bufferutil@4.1.0/node_modules/bufferutil/index.js
224
- var require_bufferutil = __commonJS({
225
- "../../node_modules/.pnpm/bufferutil@4.1.0/node_modules/bufferutil/index.js"(exports$1, module) {
226
- try {
227
- module.exports = require_node_gyp_build2()(__dirname);
228
- } catch (e) {
229
- module.exports = require_fallback();
230
- }
231
- }
232
- });
233
-
234
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/buffer-util.js
235
- var require_buffer_util = __commonJS({
236
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/buffer-util.js"(exports$1, module) {
237
- var { EMPTY_BUFFER } = require_constants();
238
- var FastBuffer = Buffer[Symbol.species];
239
- function concat(list, totalLength) {
240
- if (list.length === 0) return EMPTY_BUFFER;
241
- if (list.length === 1) return list[0];
242
- const target = Buffer.allocUnsafe(totalLength);
243
- let offset = 0;
244
- for (let i = 0; i < list.length; i++) {
245
- const buf = list[i];
246
- target.set(buf, offset);
247
- offset += buf.length;
248
- }
249
- if (offset < totalLength) {
250
- return new FastBuffer(target.buffer, target.byteOffset, offset);
251
- }
252
- return target;
253
- }
254
- function _mask(source, mask, output, offset, length) {
255
- for (let i = 0; i < length; i++) {
256
- output[offset + i] = source[i] ^ mask[i & 3];
257
- }
258
- }
259
- function _unmask(buffer, mask) {
260
- for (let i = 0; i < buffer.length; i++) {
261
- buffer[i] ^= mask[i & 3];
262
- }
263
- }
264
- function toArrayBuffer(buf) {
265
- if (buf.length === buf.buffer.byteLength) {
266
- return buf.buffer;
267
- }
268
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
269
- }
270
- function toBuffer(data) {
271
- toBuffer.readOnly = true;
272
- if (Buffer.isBuffer(data)) return data;
273
- let buf;
274
- if (data instanceof ArrayBuffer) {
275
- buf = new FastBuffer(data);
276
- } else if (ArrayBuffer.isView(data)) {
277
- buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
278
- } else {
279
- buf = Buffer.from(data);
280
- toBuffer.readOnly = false;
281
- }
282
- return buf;
283
- }
284
- module.exports = {
285
- concat,
286
- mask: _mask,
287
- toArrayBuffer,
288
- toBuffer,
289
- unmask: _unmask
290
- };
291
- if (!process.env.WS_NO_BUFFER_UTIL) {
292
- try {
293
- const bufferUtil = require_bufferutil();
294
- module.exports.mask = function(source, mask, output, offset, length) {
295
- if (length < 48) _mask(source, mask, output, offset, length);
296
- else bufferUtil.mask(source, mask, output, offset, length);
297
- };
298
- module.exports.unmask = function(buffer, mask) {
299
- if (buffer.length < 32) _unmask(buffer, mask);
300
- else bufferUtil.unmask(buffer, mask);
301
- };
302
- } catch (e) {
303
- }
304
- }
305
- }
306
- });
307
-
308
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/limiter.js
309
- var require_limiter = __commonJS({
310
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/limiter.js"(exports$1, module) {
311
- var kDone = /* @__PURE__ */ Symbol("kDone");
312
- var kRun = /* @__PURE__ */ Symbol("kRun");
313
- var Limiter = class {
314
- /**
315
- * Creates a new `Limiter`.
316
- *
317
- * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
318
- * to run concurrently
319
- */
320
- constructor(concurrency) {
321
- this[kDone] = () => {
322
- this.pending--;
323
- this[kRun]();
324
- };
325
- this.concurrency = concurrency || Infinity;
326
- this.jobs = [];
327
- this.pending = 0;
328
- }
329
- /**
330
- * Adds a job to the queue.
331
- *
332
- * @param {Function} job The job to run
333
- * @public
334
- */
335
- add(job) {
336
- this.jobs.push(job);
337
- this[kRun]();
338
- }
339
- /**
340
- * Removes a job from the queue and runs it if possible.
341
- *
342
- * @private
343
- */
344
- [kRun]() {
345
- if (this.pending === this.concurrency) return;
346
- if (this.jobs.length) {
347
- const job = this.jobs.shift();
348
- this.pending++;
349
- job(this[kDone]);
350
- }
351
- }
352
- };
353
- module.exports = Limiter;
354
- }
355
- });
356
-
357
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/permessage-deflate.js
358
- var require_permessage_deflate = __commonJS({
359
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/permessage-deflate.js"(exports$1, module) {
360
- var zlib = __require("zlib");
361
- var bufferUtil = require_buffer_util();
362
- var Limiter = require_limiter();
363
- var { kStatusCode } = require_constants();
364
- var FastBuffer = Buffer[Symbol.species];
365
- var TRAILER = Buffer.from([0, 0, 255, 255]);
366
- var kPerMessageDeflate = /* @__PURE__ */ Symbol("permessage-deflate");
367
- var kTotalLength = /* @__PURE__ */ Symbol("total-length");
368
- var kCallback = /* @__PURE__ */ Symbol("callback");
369
- var kBuffers = /* @__PURE__ */ Symbol("buffers");
370
- var kError = /* @__PURE__ */ Symbol("error");
371
- var zlibLimiter;
372
- var PerMessageDeflate = class {
373
- /**
374
- * Creates a PerMessageDeflate instance.
375
- *
376
- * @param {Object} [options] Configuration options
377
- * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
378
- * for, or request, a custom client window size
379
- * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
380
- * acknowledge disabling of client context takeover
381
- * @param {Number} [options.concurrencyLimit=10] The number of concurrent
382
- * calls to zlib
383
- * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
384
- * use of a custom server window size
385
- * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
386
- * disabling of server context takeover
387
- * @param {Number} [options.threshold=1024] Size (in bytes) below which
388
- * messages should not be compressed if context takeover is disabled
389
- * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
390
- * deflate
391
- * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
392
- * inflate
393
- * @param {Boolean} [isServer=false] Create the instance in either server or
394
- * client mode
395
- * @param {Number} [maxPayload=0] The maximum allowed message length
396
- */
397
- constructor(options, isServer, maxPayload) {
398
- this._maxPayload = maxPayload | 0;
399
- this._options = options || {};
400
- this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
401
- this._isServer = !!isServer;
402
- this._deflate = null;
403
- this._inflate = null;
404
- this.params = null;
405
- if (!zlibLimiter) {
406
- const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
407
- zlibLimiter = new Limiter(concurrency);
408
- }
409
- }
410
- /**
411
- * @type {String}
412
- */
413
- static get extensionName() {
414
- return "permessage-deflate";
415
- }
416
- /**
417
- * Create an extension negotiation offer.
418
- *
419
- * @return {Object} Extension parameters
420
- * @public
421
- */
422
- offer() {
423
- const params = {};
424
- if (this._options.serverNoContextTakeover) {
425
- params.server_no_context_takeover = true;
426
- }
427
- if (this._options.clientNoContextTakeover) {
428
- params.client_no_context_takeover = true;
429
- }
430
- if (this._options.serverMaxWindowBits) {
431
- params.server_max_window_bits = this._options.serverMaxWindowBits;
432
- }
433
- if (this._options.clientMaxWindowBits) {
434
- params.client_max_window_bits = this._options.clientMaxWindowBits;
435
- } else if (this._options.clientMaxWindowBits == null) {
436
- params.client_max_window_bits = true;
437
- }
438
- return params;
439
- }
440
- /**
441
- * Accept an extension negotiation offer/response.
442
- *
443
- * @param {Array} configurations The extension negotiation offers/reponse
444
- * @return {Object} Accepted configuration
445
- * @public
446
- */
447
- accept(configurations) {
448
- configurations = this.normalizeParams(configurations);
449
- this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
450
- return this.params;
451
- }
452
- /**
453
- * Releases all resources used by the extension.
454
- *
455
- * @public
456
- */
457
- cleanup() {
458
- if (this._inflate) {
459
- this._inflate.close();
460
- this._inflate = null;
461
- }
462
- if (this._deflate) {
463
- const callback = this._deflate[kCallback];
464
- this._deflate.close();
465
- this._deflate = null;
466
- if (callback) {
467
- callback(
468
- new Error(
469
- "The deflate stream was closed while data was being processed"
470
- )
471
- );
472
- }
473
- }
474
- }
475
- /**
476
- * Accept an extension negotiation offer.
477
- *
478
- * @param {Array} offers The extension negotiation offers
479
- * @return {Object} Accepted configuration
480
- * @private
481
- */
482
- acceptAsServer(offers) {
483
- const opts = this._options;
484
- const accepted = offers.find((params) => {
485
- if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
486
- return false;
487
- }
488
- return true;
489
- });
490
- if (!accepted) {
491
- throw new Error("None of the extension offers can be accepted");
492
- }
493
- if (opts.serverNoContextTakeover) {
494
- accepted.server_no_context_takeover = true;
495
- }
496
- if (opts.clientNoContextTakeover) {
497
- accepted.client_no_context_takeover = true;
498
- }
499
- if (typeof opts.serverMaxWindowBits === "number") {
500
- accepted.server_max_window_bits = opts.serverMaxWindowBits;
501
- }
502
- if (typeof opts.clientMaxWindowBits === "number") {
503
- accepted.client_max_window_bits = opts.clientMaxWindowBits;
504
- } else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
505
- delete accepted.client_max_window_bits;
506
- }
507
- return accepted;
508
- }
509
- /**
510
- * Accept the extension negotiation response.
511
- *
512
- * @param {Array} response The extension negotiation response
513
- * @return {Object} Accepted configuration
514
- * @private
515
- */
516
- acceptAsClient(response) {
517
- const params = response[0];
518
- if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
519
- throw new Error('Unexpected parameter "client_no_context_takeover"');
520
- }
521
- if (!params.client_max_window_bits) {
522
- if (typeof this._options.clientMaxWindowBits === "number") {
523
- params.client_max_window_bits = this._options.clientMaxWindowBits;
524
- }
525
- } else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
526
- throw new Error(
527
- 'Unexpected or invalid parameter "client_max_window_bits"'
528
- );
529
- }
530
- return params;
531
- }
532
- /**
533
- * Normalize parameters.
534
- *
535
- * @param {Array} configurations The extension negotiation offers/reponse
536
- * @return {Array} The offers/response with normalized parameters
537
- * @private
538
- */
539
- normalizeParams(configurations) {
540
- configurations.forEach((params) => {
541
- Object.keys(params).forEach((key) => {
542
- let value = params[key];
543
- if (value.length > 1) {
544
- throw new Error(`Parameter "${key}" must have only a single value`);
545
- }
546
- value = value[0];
547
- if (key === "client_max_window_bits") {
548
- if (value !== true) {
549
- const num = +value;
550
- if (!Number.isInteger(num) || num < 8 || num > 15) {
551
- throw new TypeError(
552
- `Invalid value for parameter "${key}": ${value}`
553
- );
554
- }
555
- value = num;
556
- } else if (!this._isServer) {
557
- throw new TypeError(
558
- `Invalid value for parameter "${key}": ${value}`
559
- );
560
- }
561
- } else if (key === "server_max_window_bits") {
562
- const num = +value;
563
- if (!Number.isInteger(num) || num < 8 || num > 15) {
564
- throw new TypeError(
565
- `Invalid value for parameter "${key}": ${value}`
566
- );
567
- }
568
- value = num;
569
- } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
570
- if (value !== true) {
571
- throw new TypeError(
572
- `Invalid value for parameter "${key}": ${value}`
573
- );
574
- }
575
- } else {
576
- throw new Error(`Unknown parameter "${key}"`);
577
- }
578
- params[key] = value;
579
- });
580
- });
581
- return configurations;
582
- }
583
- /**
584
- * Decompress data. Concurrency limited.
585
- *
586
- * @param {Buffer} data Compressed data
587
- * @param {Boolean} fin Specifies whether or not this is the last fragment
588
- * @param {Function} callback Callback
589
- * @public
590
- */
591
- decompress(data, fin, callback) {
592
- zlibLimiter.add((done) => {
593
- this._decompress(data, fin, (err, result) => {
594
- done();
595
- callback(err, result);
596
- });
597
- });
598
- }
599
- /**
600
- * Compress data. Concurrency limited.
601
- *
602
- * @param {(Buffer|String)} data Data to compress
603
- * @param {Boolean} fin Specifies whether or not this is the last fragment
604
- * @param {Function} callback Callback
605
- * @public
606
- */
607
- compress(data, fin, callback) {
608
- zlibLimiter.add((done) => {
609
- this._compress(data, fin, (err, result) => {
610
- done();
611
- callback(err, result);
612
- });
613
- });
614
- }
615
- /**
616
- * Decompress data.
617
- *
618
- * @param {Buffer} data Compressed data
619
- * @param {Boolean} fin Specifies whether or not this is the last fragment
620
- * @param {Function} callback Callback
621
- * @private
622
- */
623
- _decompress(data, fin, callback) {
624
- const endpoint = this._isServer ? "client" : "server";
625
- if (!this._inflate) {
626
- const key = `${endpoint}_max_window_bits`;
627
- const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
628
- this._inflate = zlib.createInflateRaw({
629
- ...this._options.zlibInflateOptions,
630
- windowBits
631
- });
632
- this._inflate[kPerMessageDeflate] = this;
633
- this._inflate[kTotalLength] = 0;
634
- this._inflate[kBuffers] = [];
635
- this._inflate.on("error", inflateOnError);
636
- this._inflate.on("data", inflateOnData);
637
- }
638
- this._inflate[kCallback] = callback;
639
- this._inflate.write(data);
640
- if (fin) this._inflate.write(TRAILER);
641
- this._inflate.flush(() => {
642
- const err = this._inflate[kError];
643
- if (err) {
644
- this._inflate.close();
645
- this._inflate = null;
646
- callback(err);
647
- return;
648
- }
649
- const data2 = bufferUtil.concat(
650
- this._inflate[kBuffers],
651
- this._inflate[kTotalLength]
652
- );
653
- if (this._inflate._readableState.endEmitted) {
654
- this._inflate.close();
655
- this._inflate = null;
656
- } else {
657
- this._inflate[kTotalLength] = 0;
658
- this._inflate[kBuffers] = [];
659
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
660
- this._inflate.reset();
661
- }
662
- }
663
- callback(null, data2);
664
- });
665
- }
666
- /**
667
- * Compress data.
668
- *
669
- * @param {(Buffer|String)} data Data to compress
670
- * @param {Boolean} fin Specifies whether or not this is the last fragment
671
- * @param {Function} callback Callback
672
- * @private
673
- */
674
- _compress(data, fin, callback) {
675
- const endpoint = this._isServer ? "server" : "client";
676
- if (!this._deflate) {
677
- const key = `${endpoint}_max_window_bits`;
678
- const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
679
- this._deflate = zlib.createDeflateRaw({
680
- ...this._options.zlibDeflateOptions,
681
- windowBits
682
- });
683
- this._deflate[kTotalLength] = 0;
684
- this._deflate[kBuffers] = [];
685
- this._deflate.on("data", deflateOnData);
686
- }
687
- this._deflate[kCallback] = callback;
688
- this._deflate.write(data);
689
- this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
690
- if (!this._deflate) {
691
- return;
692
- }
693
- let data2 = bufferUtil.concat(
694
- this._deflate[kBuffers],
695
- this._deflate[kTotalLength]
696
- );
697
- if (fin) {
698
- data2 = new FastBuffer(data2.buffer, data2.byteOffset, data2.length - 4);
699
- }
700
- this._deflate[kCallback] = null;
701
- this._deflate[kTotalLength] = 0;
702
- this._deflate[kBuffers] = [];
703
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
704
- this._deflate.reset();
705
- }
706
- callback(null, data2);
707
- });
708
- }
709
- };
710
- module.exports = PerMessageDeflate;
711
- function deflateOnData(chunk) {
712
- this[kBuffers].push(chunk);
713
- this[kTotalLength] += chunk.length;
714
- }
715
- function inflateOnData(chunk) {
716
- this[kTotalLength] += chunk.length;
717
- if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
718
- this[kBuffers].push(chunk);
719
- return;
720
- }
721
- this[kError] = new RangeError("Max payload size exceeded");
722
- this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
723
- this[kError][kStatusCode] = 1009;
724
- this.removeListener("data", inflateOnData);
725
- this.reset();
726
- }
727
- function inflateOnError(err) {
728
- this[kPerMessageDeflate]._inflate = null;
729
- if (this[kError]) {
730
- this[kCallback](this[kError]);
731
- return;
732
- }
733
- err[kStatusCode] = 1007;
734
- this[kCallback](err);
735
- }
736
- }
737
- });
738
-
739
- // ../../node_modules/.pnpm/utf-8-validate@6.0.6/node_modules/utf-8-validate/fallback.js
740
- var require_fallback2 = __commonJS({
741
- "../../node_modules/.pnpm/utf-8-validate@6.0.6/node_modules/utf-8-validate/fallback.js"(exports$1, module) {
742
- function isValidUTF8(buf) {
743
- const len = buf.length;
744
- let i = 0;
745
- while (i < len) {
746
- if ((buf[i] & 128) === 0) {
747
- i++;
748
- } else if ((buf[i] & 224) === 192) {
749
- if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
750
- return false;
751
- }
752
- i += 2;
753
- } else if ((buf[i] & 240) === 224) {
754
- if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // overlong
755
- buf[i] === 237 && (buf[i + 1] & 224) === 160) {
756
- return false;
757
- }
758
- i += 3;
759
- } else if ((buf[i] & 248) === 240) {
760
- if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // overlong
761
- buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
762
- return false;
763
- }
764
- i += 4;
765
- } else {
766
- return false;
767
- }
768
- }
769
- return true;
770
- }
771
- module.exports = isValidUTF8;
772
- }
773
- });
774
-
775
- // ../../node_modules/.pnpm/utf-8-validate@6.0.6/node_modules/utf-8-validate/index.js
776
- var require_utf_8_validate = __commonJS({
777
- "../../node_modules/.pnpm/utf-8-validate@6.0.6/node_modules/utf-8-validate/index.js"(exports$1, module) {
778
- try {
779
- module.exports = require_node_gyp_build2()(__dirname);
780
- } catch (e) {
781
- module.exports = require_fallback2();
782
- }
783
- }
784
- });
785
-
786
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/validation.js
787
- var require_validation = __commonJS({
788
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/validation.js"(exports$1, module) {
789
- var { isUtf8 } = __require("buffer");
790
- var { hasBlob } = require_constants();
791
- var tokenChars = [
792
- 0,
793
- 0,
794
- 0,
795
- 0,
796
- 0,
797
- 0,
798
- 0,
799
- 0,
800
- 0,
801
- 0,
802
- 0,
803
- 0,
804
- 0,
805
- 0,
806
- 0,
807
- 0,
808
- // 0 - 15
809
- 0,
810
- 0,
811
- 0,
812
- 0,
813
- 0,
814
- 0,
815
- 0,
816
- 0,
817
- 0,
818
- 0,
819
- 0,
820
- 0,
821
- 0,
822
- 0,
823
- 0,
824
- 0,
825
- // 16 - 31
826
- 0,
827
- 1,
828
- 0,
829
- 1,
830
- 1,
831
- 1,
832
- 1,
833
- 1,
834
- 0,
835
- 0,
836
- 1,
837
- 1,
838
- 0,
839
- 1,
840
- 1,
841
- 0,
842
- // 32 - 47
843
- 1,
844
- 1,
845
- 1,
846
- 1,
847
- 1,
848
- 1,
849
- 1,
850
- 1,
851
- 1,
852
- 1,
853
- 0,
854
- 0,
855
- 0,
856
- 0,
857
- 0,
858
- 0,
859
- // 48 - 63
860
- 0,
861
- 1,
862
- 1,
863
- 1,
864
- 1,
865
- 1,
866
- 1,
867
- 1,
868
- 1,
869
- 1,
870
- 1,
871
- 1,
872
- 1,
873
- 1,
874
- 1,
875
- 1,
876
- // 64 - 79
877
- 1,
878
- 1,
879
- 1,
880
- 1,
881
- 1,
882
- 1,
883
- 1,
884
- 1,
885
- 1,
886
- 1,
887
- 1,
888
- 0,
889
- 0,
890
- 0,
891
- 1,
892
- 1,
893
- // 80 - 95
894
- 1,
895
- 1,
896
- 1,
897
- 1,
898
- 1,
899
- 1,
900
- 1,
901
- 1,
902
- 1,
903
- 1,
904
- 1,
905
- 1,
906
- 1,
907
- 1,
908
- 1,
909
- 1,
910
- // 96 - 111
911
- 1,
912
- 1,
913
- 1,
914
- 1,
915
- 1,
916
- 1,
917
- 1,
918
- 1,
919
- 1,
920
- 1,
921
- 1,
922
- 0,
923
- 1,
924
- 0,
925
- 1,
926
- 0
927
- // 112 - 127
928
- ];
929
- function isValidStatusCode(code) {
930
- return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
931
- }
932
- function _isValidUTF8(buf) {
933
- const len = buf.length;
934
- let i = 0;
935
- while (i < len) {
936
- if ((buf[i] & 128) === 0) {
937
- i++;
938
- } else if ((buf[i] & 224) === 192) {
939
- if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
940
- return false;
941
- }
942
- i += 2;
943
- } else if ((buf[i] & 240) === 224) {
944
- if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // Overlong
945
- buf[i] === 237 && (buf[i + 1] & 224) === 160) {
946
- return false;
947
- }
948
- i += 3;
949
- } else if ((buf[i] & 248) === 240) {
950
- if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // Overlong
951
- buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
952
- return false;
953
- }
954
- i += 4;
955
- } else {
956
- return false;
957
- }
958
- }
959
- return true;
960
- }
961
- function isBlob(value) {
962
- return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
963
- }
964
- module.exports = {
965
- isBlob,
966
- isValidStatusCode,
967
- isValidUTF8: _isValidUTF8,
968
- tokenChars
969
- };
970
- if (isUtf8) {
971
- module.exports.isValidUTF8 = function(buf) {
972
- return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
973
- };
974
- } else if (!process.env.WS_NO_UTF_8_VALIDATE) {
975
- try {
976
- const isValidUTF8 = require_utf_8_validate();
977
- module.exports.isValidUTF8 = function(buf) {
978
- return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
979
- };
980
- } catch (e) {
981
- }
982
- }
983
- }
984
- });
985
-
986
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/receiver.js
987
- var require_receiver = __commonJS({
988
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/receiver.js"(exports$1, module) {
989
- var { Writable } = __require("stream");
990
- var PerMessageDeflate = require_permessage_deflate();
991
- var {
992
- BINARY_TYPES,
993
- EMPTY_BUFFER,
994
- kStatusCode,
995
- kWebSocket
996
- } = require_constants();
997
- var { concat, toArrayBuffer, unmask } = require_buffer_util();
998
- var { isValidStatusCode, isValidUTF8 } = require_validation();
999
- var FastBuffer = Buffer[Symbol.species];
1000
- var GET_INFO = 0;
1001
- var GET_PAYLOAD_LENGTH_16 = 1;
1002
- var GET_PAYLOAD_LENGTH_64 = 2;
1003
- var GET_MASK = 3;
1004
- var GET_DATA = 4;
1005
- var INFLATING = 5;
1006
- var DEFER_EVENT = 6;
1007
- var Receiver2 = class extends Writable {
1008
- /**
1009
- * Creates a Receiver instance.
1010
- *
1011
- * @param {Object} [options] Options object
1012
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
1013
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
1014
- * multiple times in the same tick
1015
- * @param {String} [options.binaryType=nodebuffer] The type for binary data
1016
- * @param {Object} [options.extensions] An object containing the negotiated
1017
- * extensions
1018
- * @param {Boolean} [options.isServer=false] Specifies whether to operate in
1019
- * client or server mode
1020
- * @param {Number} [options.maxPayload=0] The maximum allowed message length
1021
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
1022
- * not to skip UTF-8 validation for text and close messages
1023
- */
1024
- constructor(options = {}) {
1025
- super();
1026
- this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
1027
- this._binaryType = options.binaryType || BINARY_TYPES[0];
1028
- this._extensions = options.extensions || {};
1029
- this._isServer = !!options.isServer;
1030
- this._maxPayload = options.maxPayload | 0;
1031
- this._skipUTF8Validation = !!options.skipUTF8Validation;
1032
- this[kWebSocket] = void 0;
1033
- this._bufferedBytes = 0;
1034
- this._buffers = [];
1035
- this._compressed = false;
1036
- this._payloadLength = 0;
1037
- this._mask = void 0;
1038
- this._fragmented = 0;
1039
- this._masked = false;
1040
- this._fin = false;
1041
- this._opcode = 0;
1042
- this._totalPayloadLength = 0;
1043
- this._messageLength = 0;
1044
- this._fragments = [];
1045
- this._errored = false;
1046
- this._loop = false;
1047
- this._state = GET_INFO;
1048
- }
1049
- /**
1050
- * Implements `Writable.prototype._write()`.
1051
- *
1052
- * @param {Buffer} chunk The chunk of data to write
1053
- * @param {String} encoding The character encoding of `chunk`
1054
- * @param {Function} cb Callback
1055
- * @private
1056
- */
1057
- _write(chunk, encoding, cb) {
1058
- if (this._opcode === 8 && this._state == GET_INFO) return cb();
1059
- this._bufferedBytes += chunk.length;
1060
- this._buffers.push(chunk);
1061
- this.startLoop(cb);
1062
- }
1063
- /**
1064
- * Consumes `n` bytes from the buffered data.
1065
- *
1066
- * @param {Number} n The number of bytes to consume
1067
- * @return {Buffer} The consumed bytes
1068
- * @private
1069
- */
1070
- consume(n) {
1071
- this._bufferedBytes -= n;
1072
- if (n === this._buffers[0].length) return this._buffers.shift();
1073
- if (n < this._buffers[0].length) {
1074
- const buf = this._buffers[0];
1075
- this._buffers[0] = new FastBuffer(
1076
- buf.buffer,
1077
- buf.byteOffset + n,
1078
- buf.length - n
1079
- );
1080
- return new FastBuffer(buf.buffer, buf.byteOffset, n);
1081
- }
1082
- const dst = Buffer.allocUnsafe(n);
1083
- do {
1084
- const buf = this._buffers[0];
1085
- const offset = dst.length - n;
1086
- if (n >= buf.length) {
1087
- dst.set(this._buffers.shift(), offset);
1088
- } else {
1089
- dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
1090
- this._buffers[0] = new FastBuffer(
1091
- buf.buffer,
1092
- buf.byteOffset + n,
1093
- buf.length - n
1094
- );
1095
- }
1096
- n -= buf.length;
1097
- } while (n > 0);
1098
- return dst;
1099
- }
1100
- /**
1101
- * Starts the parsing loop.
1102
- *
1103
- * @param {Function} cb Callback
1104
- * @private
1105
- */
1106
- startLoop(cb) {
1107
- this._loop = true;
1108
- do {
1109
- switch (this._state) {
1110
- case GET_INFO:
1111
- this.getInfo(cb);
1112
- break;
1113
- case GET_PAYLOAD_LENGTH_16:
1114
- this.getPayloadLength16(cb);
1115
- break;
1116
- case GET_PAYLOAD_LENGTH_64:
1117
- this.getPayloadLength64(cb);
1118
- break;
1119
- case GET_MASK:
1120
- this.getMask();
1121
- break;
1122
- case GET_DATA:
1123
- this.getData(cb);
1124
- break;
1125
- case INFLATING:
1126
- case DEFER_EVENT:
1127
- this._loop = false;
1128
- return;
1129
- }
1130
- } while (this._loop);
1131
- if (!this._errored) cb();
1132
- }
1133
- /**
1134
- * Reads the first two bytes of a frame.
1135
- *
1136
- * @param {Function} cb Callback
1137
- * @private
1138
- */
1139
- getInfo(cb) {
1140
- if (this._bufferedBytes < 2) {
1141
- this._loop = false;
1142
- return;
1143
- }
1144
- const buf = this.consume(2);
1145
- if ((buf[0] & 48) !== 0) {
1146
- const error = this.createError(
1147
- RangeError,
1148
- "RSV2 and RSV3 must be clear",
1149
- true,
1150
- 1002,
1151
- "WS_ERR_UNEXPECTED_RSV_2_3"
1152
- );
1153
- cb(error);
1154
- return;
1155
- }
1156
- const compressed = (buf[0] & 64) === 64;
1157
- if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
1158
- const error = this.createError(
1159
- RangeError,
1160
- "RSV1 must be clear",
1161
- true,
1162
- 1002,
1163
- "WS_ERR_UNEXPECTED_RSV_1"
1164
- );
1165
- cb(error);
1166
- return;
1167
- }
1168
- this._fin = (buf[0] & 128) === 128;
1169
- this._opcode = buf[0] & 15;
1170
- this._payloadLength = buf[1] & 127;
1171
- if (this._opcode === 0) {
1172
- if (compressed) {
1173
- const error = this.createError(
1174
- RangeError,
1175
- "RSV1 must be clear",
1176
- true,
1177
- 1002,
1178
- "WS_ERR_UNEXPECTED_RSV_1"
1179
- );
1180
- cb(error);
1181
- return;
1182
- }
1183
- if (!this._fragmented) {
1184
- const error = this.createError(
1185
- RangeError,
1186
- "invalid opcode 0",
1187
- true,
1188
- 1002,
1189
- "WS_ERR_INVALID_OPCODE"
1190
- );
1191
- cb(error);
1192
- return;
1193
- }
1194
- this._opcode = this._fragmented;
1195
- } else if (this._opcode === 1 || this._opcode === 2) {
1196
- if (this._fragmented) {
1197
- const error = this.createError(
1198
- RangeError,
1199
- `invalid opcode ${this._opcode}`,
1200
- true,
1201
- 1002,
1202
- "WS_ERR_INVALID_OPCODE"
1203
- );
1204
- cb(error);
1205
- return;
1206
- }
1207
- this._compressed = compressed;
1208
- } else if (this._opcode > 7 && this._opcode < 11) {
1209
- if (!this._fin) {
1210
- const error = this.createError(
1211
- RangeError,
1212
- "FIN must be set",
1213
- true,
1214
- 1002,
1215
- "WS_ERR_EXPECTED_FIN"
1216
- );
1217
- cb(error);
1218
- return;
1219
- }
1220
- if (compressed) {
1221
- const error = this.createError(
1222
- RangeError,
1223
- "RSV1 must be clear",
1224
- true,
1225
- 1002,
1226
- "WS_ERR_UNEXPECTED_RSV_1"
1227
- );
1228
- cb(error);
1229
- return;
1230
- }
1231
- if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
1232
- const error = this.createError(
1233
- RangeError,
1234
- `invalid payload length ${this._payloadLength}`,
1235
- true,
1236
- 1002,
1237
- "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
1238
- );
1239
- cb(error);
1240
- return;
1241
- }
1242
- } else {
1243
- const error = this.createError(
1244
- RangeError,
1245
- `invalid opcode ${this._opcode}`,
1246
- true,
1247
- 1002,
1248
- "WS_ERR_INVALID_OPCODE"
1249
- );
1250
- cb(error);
1251
- return;
1252
- }
1253
- if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
1254
- this._masked = (buf[1] & 128) === 128;
1255
- if (this._isServer) {
1256
- if (!this._masked) {
1257
- const error = this.createError(
1258
- RangeError,
1259
- "MASK must be set",
1260
- true,
1261
- 1002,
1262
- "WS_ERR_EXPECTED_MASK"
1263
- );
1264
- cb(error);
1265
- return;
1266
- }
1267
- } else if (this._masked) {
1268
- const error = this.createError(
1269
- RangeError,
1270
- "MASK must be clear",
1271
- true,
1272
- 1002,
1273
- "WS_ERR_UNEXPECTED_MASK"
1274
- );
1275
- cb(error);
1276
- return;
1277
- }
1278
- if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
1279
- else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
1280
- else this.haveLength(cb);
1281
- }
1282
- /**
1283
- * Gets extended payload length (7+16).
1284
- *
1285
- * @param {Function} cb Callback
1286
- * @private
1287
- */
1288
- getPayloadLength16(cb) {
1289
- if (this._bufferedBytes < 2) {
1290
- this._loop = false;
1291
- return;
1292
- }
1293
- this._payloadLength = this.consume(2).readUInt16BE(0);
1294
- this.haveLength(cb);
1295
- }
1296
- /**
1297
- * Gets extended payload length (7+64).
1298
- *
1299
- * @param {Function} cb Callback
1300
- * @private
1301
- */
1302
- getPayloadLength64(cb) {
1303
- if (this._bufferedBytes < 8) {
1304
- this._loop = false;
1305
- return;
1306
- }
1307
- const buf = this.consume(8);
1308
- const num = buf.readUInt32BE(0);
1309
- if (num > Math.pow(2, 53 - 32) - 1) {
1310
- const error = this.createError(
1311
- RangeError,
1312
- "Unsupported WebSocket frame: payload length > 2^53 - 1",
1313
- false,
1314
- 1009,
1315
- "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
1316
- );
1317
- cb(error);
1318
- return;
1319
- }
1320
- this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
1321
- this.haveLength(cb);
1322
- }
1323
- /**
1324
- * Payload length has been read.
1325
- *
1326
- * @param {Function} cb Callback
1327
- * @private
1328
- */
1329
- haveLength(cb) {
1330
- if (this._payloadLength && this._opcode < 8) {
1331
- this._totalPayloadLength += this._payloadLength;
1332
- if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
1333
- const error = this.createError(
1334
- RangeError,
1335
- "Max payload size exceeded",
1336
- false,
1337
- 1009,
1338
- "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
1339
- );
1340
- cb(error);
1341
- return;
1342
- }
1343
- }
1344
- if (this._masked) this._state = GET_MASK;
1345
- else this._state = GET_DATA;
1346
- }
1347
- /**
1348
- * Reads mask bytes.
1349
- *
1350
- * @private
1351
- */
1352
- getMask() {
1353
- if (this._bufferedBytes < 4) {
1354
- this._loop = false;
1355
- return;
1356
- }
1357
- this._mask = this.consume(4);
1358
- this._state = GET_DATA;
1359
- }
1360
- /**
1361
- * Reads data bytes.
1362
- *
1363
- * @param {Function} cb Callback
1364
- * @private
1365
- */
1366
- getData(cb) {
1367
- let data = EMPTY_BUFFER;
1368
- if (this._payloadLength) {
1369
- if (this._bufferedBytes < this._payloadLength) {
1370
- this._loop = false;
1371
- return;
1372
- }
1373
- data = this.consume(this._payloadLength);
1374
- if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
1375
- unmask(data, this._mask);
1376
- }
1377
- }
1378
- if (this._opcode > 7) {
1379
- this.controlMessage(data, cb);
1380
- return;
1381
- }
1382
- if (this._compressed) {
1383
- this._state = INFLATING;
1384
- this.decompress(data, cb);
1385
- return;
1386
- }
1387
- if (data.length) {
1388
- this._messageLength = this._totalPayloadLength;
1389
- this._fragments.push(data);
1390
- }
1391
- this.dataMessage(cb);
1392
- }
1393
- /**
1394
- * Decompresses data.
1395
- *
1396
- * @param {Buffer} data Compressed data
1397
- * @param {Function} cb Callback
1398
- * @private
1399
- */
1400
- decompress(data, cb) {
1401
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
1402
- perMessageDeflate.decompress(data, this._fin, (err, buf) => {
1403
- if (err) return cb(err);
1404
- if (buf.length) {
1405
- this._messageLength += buf.length;
1406
- if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
1407
- const error = this.createError(
1408
- RangeError,
1409
- "Max payload size exceeded",
1410
- false,
1411
- 1009,
1412
- "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
1413
- );
1414
- cb(error);
1415
- return;
1416
- }
1417
- this._fragments.push(buf);
1418
- }
1419
- this.dataMessage(cb);
1420
- if (this._state === GET_INFO) this.startLoop(cb);
1421
- });
1422
- }
1423
- /**
1424
- * Handles a data message.
1425
- *
1426
- * @param {Function} cb Callback
1427
- * @private
1428
- */
1429
- dataMessage(cb) {
1430
- if (!this._fin) {
1431
- this._state = GET_INFO;
1432
- return;
1433
- }
1434
- const messageLength = this._messageLength;
1435
- const fragments = this._fragments;
1436
- this._totalPayloadLength = 0;
1437
- this._messageLength = 0;
1438
- this._fragmented = 0;
1439
- this._fragments = [];
1440
- if (this._opcode === 2) {
1441
- let data;
1442
- if (this._binaryType === "nodebuffer") {
1443
- data = concat(fragments, messageLength);
1444
- } else if (this._binaryType === "arraybuffer") {
1445
- data = toArrayBuffer(concat(fragments, messageLength));
1446
- } else if (this._binaryType === "blob") {
1447
- data = new Blob(fragments);
1448
- } else {
1449
- data = fragments;
1450
- }
1451
- if (this._allowSynchronousEvents) {
1452
- this.emit("message", data, true);
1453
- this._state = GET_INFO;
1454
- } else {
1455
- this._state = DEFER_EVENT;
1456
- setImmediate(() => {
1457
- this.emit("message", data, true);
1458
- this._state = GET_INFO;
1459
- this.startLoop(cb);
1460
- });
1461
- }
1462
- } else {
1463
- const buf = concat(fragments, messageLength);
1464
- if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
1465
- const error = this.createError(
1466
- Error,
1467
- "invalid UTF-8 sequence",
1468
- true,
1469
- 1007,
1470
- "WS_ERR_INVALID_UTF8"
1471
- );
1472
- cb(error);
1473
- return;
1474
- }
1475
- if (this._state === INFLATING || this._allowSynchronousEvents) {
1476
- this.emit("message", buf, false);
1477
- this._state = GET_INFO;
1478
- } else {
1479
- this._state = DEFER_EVENT;
1480
- setImmediate(() => {
1481
- this.emit("message", buf, false);
1482
- this._state = GET_INFO;
1483
- this.startLoop(cb);
1484
- });
1485
- }
1486
- }
1487
- }
1488
- /**
1489
- * Handles a control message.
1490
- *
1491
- * @param {Buffer} data Data to handle
1492
- * @return {(Error|RangeError|undefined)} A possible error
1493
- * @private
1494
- */
1495
- controlMessage(data, cb) {
1496
- if (this._opcode === 8) {
1497
- if (data.length === 0) {
1498
- this._loop = false;
1499
- this.emit("conclude", 1005, EMPTY_BUFFER);
1500
- this.end();
1501
- } else {
1502
- const code = data.readUInt16BE(0);
1503
- if (!isValidStatusCode(code)) {
1504
- const error = this.createError(
1505
- RangeError,
1506
- `invalid status code ${code}`,
1507
- true,
1508
- 1002,
1509
- "WS_ERR_INVALID_CLOSE_CODE"
1510
- );
1511
- cb(error);
1512
- return;
1513
- }
1514
- const buf = new FastBuffer(
1515
- data.buffer,
1516
- data.byteOffset + 2,
1517
- data.length - 2
1518
- );
1519
- if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
1520
- const error = this.createError(
1521
- Error,
1522
- "invalid UTF-8 sequence",
1523
- true,
1524
- 1007,
1525
- "WS_ERR_INVALID_UTF8"
1526
- );
1527
- cb(error);
1528
- return;
1529
- }
1530
- this._loop = false;
1531
- this.emit("conclude", code, buf);
1532
- this.end();
1533
- }
1534
- this._state = GET_INFO;
1535
- return;
1536
- }
1537
- if (this._allowSynchronousEvents) {
1538
- this.emit(this._opcode === 9 ? "ping" : "pong", data);
1539
- this._state = GET_INFO;
1540
- } else {
1541
- this._state = DEFER_EVENT;
1542
- setImmediate(() => {
1543
- this.emit(this._opcode === 9 ? "ping" : "pong", data);
1544
- this._state = GET_INFO;
1545
- this.startLoop(cb);
1546
- });
1547
- }
1548
- }
1549
- /**
1550
- * Builds an error object.
1551
- *
1552
- * @param {function(new:Error|RangeError)} ErrorCtor The error constructor
1553
- * @param {String} message The error message
1554
- * @param {Boolean} prefix Specifies whether or not to add a default prefix to
1555
- * `message`
1556
- * @param {Number} statusCode The status code
1557
- * @param {String} errorCode The exposed error code
1558
- * @return {(Error|RangeError)} The error
1559
- * @private
1560
- */
1561
- createError(ErrorCtor, message, prefix, statusCode, errorCode) {
1562
- this._loop = false;
1563
- this._errored = true;
1564
- const err = new ErrorCtor(
1565
- prefix ? `Invalid WebSocket frame: ${message}` : message
1566
- );
1567
- Error.captureStackTrace(err, this.createError);
1568
- err.code = errorCode;
1569
- err[kStatusCode] = statusCode;
1570
- return err;
1571
- }
1572
- };
1573
- module.exports = Receiver2;
1574
- }
1575
- });
1576
-
1577
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/sender.js
1578
- var require_sender = __commonJS({
1579
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/sender.js"(exports$1, module) {
1580
- var { Duplex } = __require("stream");
1581
- var { randomFillSync } = __require("crypto");
1582
- var PerMessageDeflate = require_permessage_deflate();
1583
- var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
1584
- var { isBlob, isValidStatusCode } = require_validation();
1585
- var { mask: applyMask, toBuffer } = require_buffer_util();
1586
- var kByteLength = /* @__PURE__ */ Symbol("kByteLength");
1587
- var maskBuffer = Buffer.alloc(4);
1588
- var RANDOM_POOL_SIZE = 8 * 1024;
1589
- var randomPool;
1590
- var randomPoolPointer = RANDOM_POOL_SIZE;
1591
- var DEFAULT = 0;
1592
- var DEFLATING = 1;
1593
- var GET_BLOB_DATA = 2;
1594
- var Sender2 = class _Sender {
1595
- /**
1596
- * Creates a Sender instance.
1597
- *
1598
- * @param {Duplex} socket The connection socket
1599
- * @param {Object} [extensions] An object containing the negotiated extensions
1600
- * @param {Function} [generateMask] The function used to generate the masking
1601
- * key
1602
- */
1603
- constructor(socket, extensions, generateMask) {
1604
- this._extensions = extensions || {};
1605
- if (generateMask) {
1606
- this._generateMask = generateMask;
1607
- this._maskBuffer = Buffer.alloc(4);
1608
- }
1609
- this._socket = socket;
1610
- this._firstFragment = true;
1611
- this._compress = false;
1612
- this._bufferedBytes = 0;
1613
- this._queue = [];
1614
- this._state = DEFAULT;
1615
- this.onerror = NOOP;
1616
- this[kWebSocket] = void 0;
1617
- }
1618
- /**
1619
- * Frames a piece of data according to the HyBi WebSocket protocol.
1620
- *
1621
- * @param {(Buffer|String)} data The data to frame
1622
- * @param {Object} options Options object
1623
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1624
- * FIN bit
1625
- * @param {Function} [options.generateMask] The function used to generate the
1626
- * masking key
1627
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1628
- * `data`
1629
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1630
- * key
1631
- * @param {Number} options.opcode The opcode
1632
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1633
- * modified
1634
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1635
- * RSV1 bit
1636
- * @return {(Buffer|String)[]} The framed data
1637
- * @public
1638
- */
1639
- static frame(data, options) {
1640
- let mask;
1641
- let merge = false;
1642
- let offset = 2;
1643
- let skipMasking = false;
1644
- if (options.mask) {
1645
- mask = options.maskBuffer || maskBuffer;
1646
- if (options.generateMask) {
1647
- options.generateMask(mask);
1648
- } else {
1649
- if (randomPoolPointer === RANDOM_POOL_SIZE) {
1650
- if (randomPool === void 0) {
1651
- randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
1652
- }
1653
- randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
1654
- randomPoolPointer = 0;
1655
- }
1656
- mask[0] = randomPool[randomPoolPointer++];
1657
- mask[1] = randomPool[randomPoolPointer++];
1658
- mask[2] = randomPool[randomPoolPointer++];
1659
- mask[3] = randomPool[randomPoolPointer++];
1660
- }
1661
- skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
1662
- offset = 6;
1663
- }
1664
- let dataLength;
1665
- if (typeof data === "string") {
1666
- if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) {
1667
- dataLength = options[kByteLength];
1668
- } else {
1669
- data = Buffer.from(data);
1670
- dataLength = data.length;
1671
- }
1672
- } else {
1673
- dataLength = data.length;
1674
- merge = options.mask && options.readOnly && !skipMasking;
1675
- }
1676
- let payloadLength = dataLength;
1677
- if (dataLength >= 65536) {
1678
- offset += 8;
1679
- payloadLength = 127;
1680
- } else if (dataLength > 125) {
1681
- offset += 2;
1682
- payloadLength = 126;
1683
- }
1684
- const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
1685
- target[0] = options.fin ? options.opcode | 128 : options.opcode;
1686
- if (options.rsv1) target[0] |= 64;
1687
- target[1] = payloadLength;
1688
- if (payloadLength === 126) {
1689
- target.writeUInt16BE(dataLength, 2);
1690
- } else if (payloadLength === 127) {
1691
- target[2] = target[3] = 0;
1692
- target.writeUIntBE(dataLength, 4, 6);
1693
- }
1694
- if (!options.mask) return [target, data];
1695
- target[1] |= 128;
1696
- target[offset - 4] = mask[0];
1697
- target[offset - 3] = mask[1];
1698
- target[offset - 2] = mask[2];
1699
- target[offset - 1] = mask[3];
1700
- if (skipMasking) return [target, data];
1701
- if (merge) {
1702
- applyMask(data, mask, target, offset, dataLength);
1703
- return [target];
1704
- }
1705
- applyMask(data, mask, data, 0, dataLength);
1706
- return [target, data];
1707
- }
1708
- /**
1709
- * Sends a close message to the other peer.
1710
- *
1711
- * @param {Number} [code] The status code component of the body
1712
- * @param {(String|Buffer)} [data] The message component of the body
1713
- * @param {Boolean} [mask=false] Specifies whether or not to mask the message
1714
- * @param {Function} [cb] Callback
1715
- * @public
1716
- */
1717
- close(code, data, mask, cb) {
1718
- let buf;
1719
- if (code === void 0) {
1720
- buf = EMPTY_BUFFER;
1721
- } else if (typeof code !== "number" || !isValidStatusCode(code)) {
1722
- throw new TypeError("First argument must be a valid error code number");
1723
- } else if (data === void 0 || !data.length) {
1724
- buf = Buffer.allocUnsafe(2);
1725
- buf.writeUInt16BE(code, 0);
1726
- } else {
1727
- const length = Buffer.byteLength(data);
1728
- if (length > 123) {
1729
- throw new RangeError("The message must not be greater than 123 bytes");
1730
- }
1731
- buf = Buffer.allocUnsafe(2 + length);
1732
- buf.writeUInt16BE(code, 0);
1733
- if (typeof data === "string") {
1734
- buf.write(data, 2);
1735
- } else {
1736
- buf.set(data, 2);
1737
- }
1738
- }
1739
- const options = {
1740
- [kByteLength]: buf.length,
1741
- fin: true,
1742
- generateMask: this._generateMask,
1743
- mask,
1744
- maskBuffer: this._maskBuffer,
1745
- opcode: 8,
1746
- readOnly: false,
1747
- rsv1: false
1748
- };
1749
- if (this._state !== DEFAULT) {
1750
- this.enqueue([this.dispatch, buf, false, options, cb]);
1751
- } else {
1752
- this.sendFrame(_Sender.frame(buf, options), cb);
1753
- }
1754
- }
1755
- /**
1756
- * Sends a ping message to the other peer.
1757
- *
1758
- * @param {*} data The message to send
1759
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1760
- * @param {Function} [cb] Callback
1761
- * @public
1762
- */
1763
- ping(data, mask, cb) {
1764
- let byteLength;
1765
- let readOnly;
1766
- if (typeof data === "string") {
1767
- byteLength = Buffer.byteLength(data);
1768
- readOnly = false;
1769
- } else if (isBlob(data)) {
1770
- byteLength = data.size;
1771
- readOnly = false;
1772
- } else {
1773
- data = toBuffer(data);
1774
- byteLength = data.length;
1775
- readOnly = toBuffer.readOnly;
1776
- }
1777
- if (byteLength > 125) {
1778
- throw new RangeError("The data size must not be greater than 125 bytes");
1779
- }
1780
- const options = {
1781
- [kByteLength]: byteLength,
1782
- fin: true,
1783
- generateMask: this._generateMask,
1784
- mask,
1785
- maskBuffer: this._maskBuffer,
1786
- opcode: 9,
1787
- readOnly,
1788
- rsv1: false
1789
- };
1790
- if (isBlob(data)) {
1791
- if (this._state !== DEFAULT) {
1792
- this.enqueue([this.getBlobData, data, false, options, cb]);
1793
- } else {
1794
- this.getBlobData(data, false, options, cb);
1795
- }
1796
- } else if (this._state !== DEFAULT) {
1797
- this.enqueue([this.dispatch, data, false, options, cb]);
1798
- } else {
1799
- this.sendFrame(_Sender.frame(data, options), cb);
1800
- }
1801
- }
1802
- /**
1803
- * Sends a pong message to the other peer.
1804
- *
1805
- * @param {*} data The message to send
1806
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1807
- * @param {Function} [cb] Callback
1808
- * @public
1809
- */
1810
- pong(data, mask, cb) {
1811
- let byteLength;
1812
- let readOnly;
1813
- if (typeof data === "string") {
1814
- byteLength = Buffer.byteLength(data);
1815
- readOnly = false;
1816
- } else if (isBlob(data)) {
1817
- byteLength = data.size;
1818
- readOnly = false;
1819
- } else {
1820
- data = toBuffer(data);
1821
- byteLength = data.length;
1822
- readOnly = toBuffer.readOnly;
1823
- }
1824
- if (byteLength > 125) {
1825
- throw new RangeError("The data size must not be greater than 125 bytes");
1826
- }
1827
- const options = {
1828
- [kByteLength]: byteLength,
1829
- fin: true,
1830
- generateMask: this._generateMask,
1831
- mask,
1832
- maskBuffer: this._maskBuffer,
1833
- opcode: 10,
1834
- readOnly,
1835
- rsv1: false
1836
- };
1837
- if (isBlob(data)) {
1838
- if (this._state !== DEFAULT) {
1839
- this.enqueue([this.getBlobData, data, false, options, cb]);
1840
- } else {
1841
- this.getBlobData(data, false, options, cb);
1842
- }
1843
- } else if (this._state !== DEFAULT) {
1844
- this.enqueue([this.dispatch, data, false, options, cb]);
1845
- } else {
1846
- this.sendFrame(_Sender.frame(data, options), cb);
1847
- }
1848
- }
1849
- /**
1850
- * Sends a data message to the other peer.
1851
- *
1852
- * @param {*} data The message to send
1853
- * @param {Object} options Options object
1854
- * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
1855
- * or text
1856
- * @param {Boolean} [options.compress=false] Specifies whether or not to
1857
- * compress `data`
1858
- * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
1859
- * last one
1860
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1861
- * `data`
1862
- * @param {Function} [cb] Callback
1863
- * @public
1864
- */
1865
- send(data, options, cb) {
1866
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
1867
- let opcode = options.binary ? 2 : 1;
1868
- let rsv1 = options.compress;
1869
- let byteLength;
1870
- let readOnly;
1871
- if (typeof data === "string") {
1872
- byteLength = Buffer.byteLength(data);
1873
- readOnly = false;
1874
- } else if (isBlob(data)) {
1875
- byteLength = data.size;
1876
- readOnly = false;
1877
- } else {
1878
- data = toBuffer(data);
1879
- byteLength = data.length;
1880
- readOnly = toBuffer.readOnly;
1881
- }
1882
- if (this._firstFragment) {
1883
- this._firstFragment = false;
1884
- if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
1885
- rsv1 = byteLength >= perMessageDeflate._threshold;
1886
- }
1887
- this._compress = rsv1;
1888
- } else {
1889
- rsv1 = false;
1890
- opcode = 0;
1891
- }
1892
- if (options.fin) this._firstFragment = true;
1893
- const opts = {
1894
- [kByteLength]: byteLength,
1895
- fin: options.fin,
1896
- generateMask: this._generateMask,
1897
- mask: options.mask,
1898
- maskBuffer: this._maskBuffer,
1899
- opcode,
1900
- readOnly,
1901
- rsv1
1902
- };
1903
- if (isBlob(data)) {
1904
- if (this._state !== DEFAULT) {
1905
- this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
1906
- } else {
1907
- this.getBlobData(data, this._compress, opts, cb);
1908
- }
1909
- } else if (this._state !== DEFAULT) {
1910
- this.enqueue([this.dispatch, data, this._compress, opts, cb]);
1911
- } else {
1912
- this.dispatch(data, this._compress, opts, cb);
1913
- }
1914
- }
1915
- /**
1916
- * Gets the contents of a blob as binary data.
1917
- *
1918
- * @param {Blob} blob The blob
1919
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1920
- * the data
1921
- * @param {Object} options Options object
1922
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1923
- * FIN bit
1924
- * @param {Function} [options.generateMask] The function used to generate the
1925
- * masking key
1926
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1927
- * `data`
1928
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1929
- * key
1930
- * @param {Number} options.opcode The opcode
1931
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1932
- * modified
1933
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1934
- * RSV1 bit
1935
- * @param {Function} [cb] Callback
1936
- * @private
1937
- */
1938
- getBlobData(blob, compress, options, cb) {
1939
- this._bufferedBytes += options[kByteLength];
1940
- this._state = GET_BLOB_DATA;
1941
- blob.arrayBuffer().then((arrayBuffer) => {
1942
- if (this._socket.destroyed) {
1943
- const err = new Error(
1944
- "The socket was closed while the blob was being read"
1945
- );
1946
- process.nextTick(callCallbacks, this, err, cb);
1947
- return;
1948
- }
1949
- this._bufferedBytes -= options[kByteLength];
1950
- const data = toBuffer(arrayBuffer);
1951
- if (!compress) {
1952
- this._state = DEFAULT;
1953
- this.sendFrame(_Sender.frame(data, options), cb);
1954
- this.dequeue();
1955
- } else {
1956
- this.dispatch(data, compress, options, cb);
1957
- }
1958
- }).catch((err) => {
1959
- process.nextTick(onError, this, err, cb);
1960
- });
1961
- }
1962
- /**
1963
- * Dispatches a message.
1964
- *
1965
- * @param {(Buffer|String)} data The message to send
1966
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1967
- * `data`
1968
- * @param {Object} options Options object
1969
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1970
- * FIN bit
1971
- * @param {Function} [options.generateMask] The function used to generate the
1972
- * masking key
1973
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1974
- * `data`
1975
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1976
- * key
1977
- * @param {Number} options.opcode The opcode
1978
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1979
- * modified
1980
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1981
- * RSV1 bit
1982
- * @param {Function} [cb] Callback
1983
- * @private
1984
- */
1985
- dispatch(data, compress, options, cb) {
1986
- if (!compress) {
1987
- this.sendFrame(_Sender.frame(data, options), cb);
1988
- return;
1989
- }
1990
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
1991
- this._bufferedBytes += options[kByteLength];
1992
- this._state = DEFLATING;
1993
- perMessageDeflate.compress(data, options.fin, (_, buf) => {
1994
- if (this._socket.destroyed) {
1995
- const err = new Error(
1996
- "The socket was closed while data was being compressed"
1997
- );
1998
- callCallbacks(this, err, cb);
1999
- return;
2000
- }
2001
- this._bufferedBytes -= options[kByteLength];
2002
- this._state = DEFAULT;
2003
- options.readOnly = false;
2004
- this.sendFrame(_Sender.frame(buf, options), cb);
2005
- this.dequeue();
2006
- });
2007
- }
2008
- /**
2009
- * Executes queued send operations.
2010
- *
2011
- * @private
2012
- */
2013
- dequeue() {
2014
- while (this._state === DEFAULT && this._queue.length) {
2015
- const params = this._queue.shift();
2016
- this._bufferedBytes -= params[3][kByteLength];
2017
- Reflect.apply(params[0], this, params.slice(1));
2018
- }
2019
- }
2020
- /**
2021
- * Enqueues a send operation.
2022
- *
2023
- * @param {Array} params Send operation parameters.
2024
- * @private
2025
- */
2026
- enqueue(params) {
2027
- this._bufferedBytes += params[3][kByteLength];
2028
- this._queue.push(params);
2029
- }
2030
- /**
2031
- * Sends a frame.
2032
- *
2033
- * @param {(Buffer | String)[]} list The frame to send
2034
- * @param {Function} [cb] Callback
2035
- * @private
2036
- */
2037
- sendFrame(list, cb) {
2038
- if (list.length === 2) {
2039
- this._socket.cork();
2040
- this._socket.write(list[0]);
2041
- this._socket.write(list[1], cb);
2042
- this._socket.uncork();
2043
- } else {
2044
- this._socket.write(list[0], cb);
2045
- }
2046
- }
2047
- };
2048
- module.exports = Sender2;
2049
- function callCallbacks(sender, err, cb) {
2050
- if (typeof cb === "function") cb(err);
2051
- for (let i = 0; i < sender._queue.length; i++) {
2052
- const params = sender._queue[i];
2053
- const callback = params[params.length - 1];
2054
- if (typeof callback === "function") callback(err);
2055
- }
2056
- }
2057
- function onError(sender, err, cb) {
2058
- callCallbacks(sender, err, cb);
2059
- sender.onerror(err);
2060
- }
2061
- }
2062
- });
2063
-
2064
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/event-target.js
2065
- var require_event_target = __commonJS({
2066
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/event-target.js"(exports$1, module) {
2067
- var { kForOnEventAttribute, kListener } = require_constants();
2068
- var kCode = /* @__PURE__ */ Symbol("kCode");
2069
- var kData = /* @__PURE__ */ Symbol("kData");
2070
- var kError = /* @__PURE__ */ Symbol("kError");
2071
- var kMessage = /* @__PURE__ */ Symbol("kMessage");
2072
- var kReason = /* @__PURE__ */ Symbol("kReason");
2073
- var kTarget = /* @__PURE__ */ Symbol("kTarget");
2074
- var kType = /* @__PURE__ */ Symbol("kType");
2075
- var kWasClean = /* @__PURE__ */ Symbol("kWasClean");
2076
- var Event = class {
2077
- /**
2078
- * Create a new `Event`.
2079
- *
2080
- * @param {String} type The name of the event
2081
- * @throws {TypeError} If the `type` argument is not specified
2082
- */
2083
- constructor(type) {
2084
- this[kTarget] = null;
2085
- this[kType] = type;
2086
- }
2087
- /**
2088
- * @type {*}
2089
- */
2090
- get target() {
2091
- return this[kTarget];
2092
- }
2093
- /**
2094
- * @type {String}
2095
- */
2096
- get type() {
2097
- return this[kType];
2098
- }
2099
- };
2100
- Object.defineProperty(Event.prototype, "target", { enumerable: true });
2101
- Object.defineProperty(Event.prototype, "type", { enumerable: true });
2102
- var CloseEvent = class extends Event {
2103
- /**
2104
- * Create a new `CloseEvent`.
2105
- *
2106
- * @param {String} type The name of the event
2107
- * @param {Object} [options] A dictionary object that allows for setting
2108
- * attributes via object members of the same name
2109
- * @param {Number} [options.code=0] The status code explaining why the
2110
- * connection was closed
2111
- * @param {String} [options.reason=''] A human-readable string explaining why
2112
- * the connection was closed
2113
- * @param {Boolean} [options.wasClean=false] Indicates whether or not the
2114
- * connection was cleanly closed
2115
- */
2116
- constructor(type, options = {}) {
2117
- super(type);
2118
- this[kCode] = options.code === void 0 ? 0 : options.code;
2119
- this[kReason] = options.reason === void 0 ? "" : options.reason;
2120
- this[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;
2121
- }
2122
- /**
2123
- * @type {Number}
2124
- */
2125
- get code() {
2126
- return this[kCode];
2127
- }
2128
- /**
2129
- * @type {String}
2130
- */
2131
- get reason() {
2132
- return this[kReason];
2133
- }
2134
- /**
2135
- * @type {Boolean}
2136
- */
2137
- get wasClean() {
2138
- return this[kWasClean];
2139
- }
2140
- };
2141
- Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
2142
- Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
2143
- Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
2144
- var ErrorEvent = class extends Event {
2145
- /**
2146
- * Create a new `ErrorEvent`.
2147
- *
2148
- * @param {String} type The name of the event
2149
- * @param {Object} [options] A dictionary object that allows for setting
2150
- * attributes via object members of the same name
2151
- * @param {*} [options.error=null] The error that generated this event
2152
- * @param {String} [options.message=''] The error message
2153
- */
2154
- constructor(type, options = {}) {
2155
- super(type);
2156
- this[kError] = options.error === void 0 ? null : options.error;
2157
- this[kMessage] = options.message === void 0 ? "" : options.message;
2158
- }
2159
- /**
2160
- * @type {*}
2161
- */
2162
- get error() {
2163
- return this[kError];
2164
- }
2165
- /**
2166
- * @type {String}
2167
- */
2168
- get message() {
2169
- return this[kMessage];
2170
- }
2171
- };
2172
- Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
2173
- Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
2174
- var MessageEvent = class extends Event {
2175
- /**
2176
- * Create a new `MessageEvent`.
2177
- *
2178
- * @param {String} type The name of the event
2179
- * @param {Object} [options] A dictionary object that allows for setting
2180
- * attributes via object members of the same name
2181
- * @param {*} [options.data=null] The message content
2182
- */
2183
- constructor(type, options = {}) {
2184
- super(type);
2185
- this[kData] = options.data === void 0 ? null : options.data;
2186
- }
2187
- /**
2188
- * @type {*}
2189
- */
2190
- get data() {
2191
- return this[kData];
2192
- }
2193
- };
2194
- Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
2195
- var EventTarget = {
2196
- /**
2197
- * Register an event listener.
2198
- *
2199
- * @param {String} type A string representing the event type to listen for
2200
- * @param {(Function|Object)} handler The listener to add
2201
- * @param {Object} [options] An options object specifies characteristics about
2202
- * the event listener
2203
- * @param {Boolean} [options.once=false] A `Boolean` indicating that the
2204
- * listener should be invoked at most once after being added. If `true`,
2205
- * the listener would be automatically removed when invoked.
2206
- * @public
2207
- */
2208
- addEventListener(type, handler, options = {}) {
2209
- for (const listener of this.listeners(type)) {
2210
- if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
2211
- return;
2212
- }
2213
- }
2214
- let wrapper;
2215
- if (type === "message") {
2216
- wrapper = function onMessage(data, isBinary) {
2217
- const event = new MessageEvent("message", {
2218
- data: isBinary ? data : data.toString()
2219
- });
2220
- event[kTarget] = this;
2221
- callListener(handler, this, event);
2222
- };
2223
- } else if (type === "close") {
2224
- wrapper = function onClose(code, message) {
2225
- const event = new CloseEvent("close", {
2226
- code,
2227
- reason: message.toString(),
2228
- wasClean: this._closeFrameReceived && this._closeFrameSent
2229
- });
2230
- event[kTarget] = this;
2231
- callListener(handler, this, event);
2232
- };
2233
- } else if (type === "error") {
2234
- wrapper = function onError(error) {
2235
- const event = new ErrorEvent("error", {
2236
- error,
2237
- message: error.message
2238
- });
2239
- event[kTarget] = this;
2240
- callListener(handler, this, event);
2241
- };
2242
- } else if (type === "open") {
2243
- wrapper = function onOpen() {
2244
- const event = new Event("open");
2245
- event[kTarget] = this;
2246
- callListener(handler, this, event);
2247
- };
2248
- } else {
2249
- return;
2250
- }
2251
- wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
2252
- wrapper[kListener] = handler;
2253
- if (options.once) {
2254
- this.once(type, wrapper);
2255
- } else {
2256
- this.on(type, wrapper);
2257
- }
2258
- },
2259
- /**
2260
- * Remove an event listener.
2261
- *
2262
- * @param {String} type A string representing the event type to remove
2263
- * @param {(Function|Object)} handler The listener to remove
2264
- * @public
2265
- */
2266
- removeEventListener(type, handler) {
2267
- for (const listener of this.listeners(type)) {
2268
- if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
2269
- this.removeListener(type, listener);
2270
- break;
2271
- }
2272
- }
2273
- }
2274
- };
2275
- module.exports = {
2276
- CloseEvent,
2277
- ErrorEvent,
2278
- Event,
2279
- EventTarget,
2280
- MessageEvent
2281
- };
2282
- function callListener(listener, thisArg, event) {
2283
- if (typeof listener === "object" && listener.handleEvent) {
2284
- listener.handleEvent.call(listener, event);
2285
- } else {
2286
- listener.call(thisArg, event);
2287
- }
2288
- }
2289
- }
2290
- });
2291
-
2292
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/extension.js
2293
- var require_extension = __commonJS({
2294
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/extension.js"(exports$1, module) {
2295
- var { tokenChars } = require_validation();
2296
- function push(dest, name, elem) {
2297
- if (dest[name] === void 0) dest[name] = [elem];
2298
- else dest[name].push(elem);
2299
- }
2300
- function parse(header) {
2301
- const offers = /* @__PURE__ */ Object.create(null);
2302
- let params = /* @__PURE__ */ Object.create(null);
2303
- let mustUnescape = false;
2304
- let isEscaping = false;
2305
- let inQuotes = false;
2306
- let extensionName;
2307
- let paramName;
2308
- let start = -1;
2309
- let code = -1;
2310
- let end = -1;
2311
- let i = 0;
2312
- for (; i < header.length; i++) {
2313
- code = header.charCodeAt(i);
2314
- if (extensionName === void 0) {
2315
- if (end === -1 && tokenChars[code] === 1) {
2316
- if (start === -1) start = i;
2317
- } else if (i !== 0 && (code === 32 || code === 9)) {
2318
- if (end === -1 && start !== -1) end = i;
2319
- } else if (code === 59 || code === 44) {
2320
- if (start === -1) {
2321
- throw new SyntaxError(`Unexpected character at index ${i}`);
2322
- }
2323
- if (end === -1) end = i;
2324
- const name = header.slice(start, end);
2325
- if (code === 44) {
2326
- push(offers, name, params);
2327
- params = /* @__PURE__ */ Object.create(null);
2328
- } else {
2329
- extensionName = name;
2330
- }
2331
- start = end = -1;
2332
- } else {
2333
- throw new SyntaxError(`Unexpected character at index ${i}`);
2334
- }
2335
- } else if (paramName === void 0) {
2336
- if (end === -1 && tokenChars[code] === 1) {
2337
- if (start === -1) start = i;
2338
- } else if (code === 32 || code === 9) {
2339
- if (end === -1 && start !== -1) end = i;
2340
- } else if (code === 59 || code === 44) {
2341
- if (start === -1) {
2342
- throw new SyntaxError(`Unexpected character at index ${i}`);
2343
- }
2344
- if (end === -1) end = i;
2345
- push(params, header.slice(start, end), true);
2346
- if (code === 44) {
2347
- push(offers, extensionName, params);
2348
- params = /* @__PURE__ */ Object.create(null);
2349
- extensionName = void 0;
2350
- }
2351
- start = end = -1;
2352
- } else if (code === 61 && start !== -1 && end === -1) {
2353
- paramName = header.slice(start, i);
2354
- start = end = -1;
2355
- } else {
2356
- throw new SyntaxError(`Unexpected character at index ${i}`);
2357
- }
2358
- } else {
2359
- if (isEscaping) {
2360
- if (tokenChars[code] !== 1) {
2361
- throw new SyntaxError(`Unexpected character at index ${i}`);
2362
- }
2363
- if (start === -1) start = i;
2364
- else if (!mustUnescape) mustUnescape = true;
2365
- isEscaping = false;
2366
- } else if (inQuotes) {
2367
- if (tokenChars[code] === 1) {
2368
- if (start === -1) start = i;
2369
- } else if (code === 34 && start !== -1) {
2370
- inQuotes = false;
2371
- end = i;
2372
- } else if (code === 92) {
2373
- isEscaping = true;
2374
- } else {
2375
- throw new SyntaxError(`Unexpected character at index ${i}`);
2376
- }
2377
- } else if (code === 34 && header.charCodeAt(i - 1) === 61) {
2378
- inQuotes = true;
2379
- } else if (end === -1 && tokenChars[code] === 1) {
2380
- if (start === -1) start = i;
2381
- } else if (start !== -1 && (code === 32 || code === 9)) {
2382
- if (end === -1) end = i;
2383
- } else if (code === 59 || code === 44) {
2384
- if (start === -1) {
2385
- throw new SyntaxError(`Unexpected character at index ${i}`);
2386
- }
2387
- if (end === -1) end = i;
2388
- let value = header.slice(start, end);
2389
- if (mustUnescape) {
2390
- value = value.replace(/\\/g, "");
2391
- mustUnescape = false;
2392
- }
2393
- push(params, paramName, value);
2394
- if (code === 44) {
2395
- push(offers, extensionName, params);
2396
- params = /* @__PURE__ */ Object.create(null);
2397
- extensionName = void 0;
2398
- }
2399
- paramName = void 0;
2400
- start = end = -1;
2401
- } else {
2402
- throw new SyntaxError(`Unexpected character at index ${i}`);
2403
- }
2404
- }
2405
- }
2406
- if (start === -1 || inQuotes || code === 32 || code === 9) {
2407
- throw new SyntaxError("Unexpected end of input");
2408
- }
2409
- if (end === -1) end = i;
2410
- const token = header.slice(start, end);
2411
- if (extensionName === void 0) {
2412
- push(offers, token, params);
2413
- } else {
2414
- if (paramName === void 0) {
2415
- push(params, token, true);
2416
- } else if (mustUnescape) {
2417
- push(params, paramName, token.replace(/\\/g, ""));
2418
- } else {
2419
- push(params, paramName, token);
2420
- }
2421
- push(offers, extensionName, params);
2422
- }
2423
- return offers;
2424
- }
2425
- function format(extensions) {
2426
- return Object.keys(extensions).map((extension) => {
2427
- let configurations = extensions[extension];
2428
- if (!Array.isArray(configurations)) configurations = [configurations];
2429
- return configurations.map((params) => {
2430
- return [extension].concat(
2431
- Object.keys(params).map((k) => {
2432
- let values = params[k];
2433
- if (!Array.isArray(values)) values = [values];
2434
- return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
2435
- })
2436
- ).join("; ");
2437
- }).join(", ");
2438
- }).join(", ");
2439
- }
2440
- module.exports = { format, parse };
2441
- }
2442
- });
2443
-
2444
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/websocket.js
2445
- var require_websocket = __commonJS({
2446
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/websocket.js"(exports$1, module) {
2447
- var EventEmitter = __require("events");
2448
- var https = __require("https");
2449
- var http = __require("http");
2450
- var net = __require("net");
2451
- var tls = __require("tls");
2452
- var { randomBytes, createHash } = __require("crypto");
2453
- var { Duplex, Readable } = __require("stream");
2454
- var { URL } = __require("url");
2455
- var PerMessageDeflate = require_permessage_deflate();
2456
- var Receiver2 = require_receiver();
2457
- var Sender2 = require_sender();
2458
- var { isBlob } = require_validation();
2459
- var {
2460
- BINARY_TYPES,
2461
- EMPTY_BUFFER,
2462
- GUID,
2463
- kForOnEventAttribute,
2464
- kListener,
2465
- kStatusCode,
2466
- kWebSocket,
2467
- NOOP
2468
- } = require_constants();
2469
- var {
2470
- EventTarget: { addEventListener, removeEventListener }
2471
- } = require_event_target();
2472
- var { format, parse } = require_extension();
2473
- var { toBuffer } = require_buffer_util();
2474
- var closeTimeout = 30 * 1e3;
2475
- var kAborted = /* @__PURE__ */ Symbol("kAborted");
2476
- var protocolVersions = [8, 13];
2477
- var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
2478
- var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
2479
- var WebSocket4 = class _WebSocket extends EventEmitter {
2480
- /**
2481
- * Create a new `WebSocket`.
2482
- *
2483
- * @param {(String|URL)} address The URL to which to connect
2484
- * @param {(String|String[])} [protocols] The subprotocols
2485
- * @param {Object} [options] Connection options
2486
- */
2487
- constructor(address, protocols, options) {
2488
- super();
2489
- this._binaryType = BINARY_TYPES[0];
2490
- this._closeCode = 1006;
2491
- this._closeFrameReceived = false;
2492
- this._closeFrameSent = false;
2493
- this._closeMessage = EMPTY_BUFFER;
2494
- this._closeTimer = null;
2495
- this._errorEmitted = false;
2496
- this._extensions = {};
2497
- this._paused = false;
2498
- this._protocol = "";
2499
- this._readyState = _WebSocket.CONNECTING;
2500
- this._receiver = null;
2501
- this._sender = null;
2502
- this._socket = null;
2503
- if (address !== null) {
2504
- this._bufferedAmount = 0;
2505
- this._isServer = false;
2506
- this._redirects = 0;
2507
- if (protocols === void 0) {
2508
- protocols = [];
2509
- } else if (!Array.isArray(protocols)) {
2510
- if (typeof protocols === "object" && protocols !== null) {
2511
- options = protocols;
2512
- protocols = [];
2513
- } else {
2514
- protocols = [protocols];
2515
- }
2516
- }
2517
- initAsClient(this, address, protocols, options);
2518
- } else {
2519
- this._autoPong = options.autoPong;
2520
- this._isServer = true;
2521
- }
2522
- }
2523
- /**
2524
- * For historical reasons, the custom "nodebuffer" type is used by the default
2525
- * instead of "blob".
2526
- *
2527
- * @type {String}
2528
- */
2529
- get binaryType() {
2530
- return this._binaryType;
2531
- }
2532
- set binaryType(type) {
2533
- if (!BINARY_TYPES.includes(type)) return;
2534
- this._binaryType = type;
2535
- if (this._receiver) this._receiver._binaryType = type;
2536
- }
2537
- /**
2538
- * @type {Number}
2539
- */
2540
- get bufferedAmount() {
2541
- if (!this._socket) return this._bufferedAmount;
2542
- return this._socket._writableState.length + this._sender._bufferedBytes;
2543
- }
2544
- /**
2545
- * @type {String}
2546
- */
2547
- get extensions() {
2548
- return Object.keys(this._extensions).join();
2549
- }
2550
- /**
2551
- * @type {Boolean}
2552
- */
2553
- get isPaused() {
2554
- return this._paused;
2555
- }
2556
- /**
2557
- * @type {Function}
2558
- */
2559
- /* istanbul ignore next */
2560
- get onclose() {
2561
- return null;
2562
- }
2563
- /**
2564
- * @type {Function}
2565
- */
2566
- /* istanbul ignore next */
2567
- get onerror() {
2568
- return null;
2569
- }
2570
- /**
2571
- * @type {Function}
2572
- */
2573
- /* istanbul ignore next */
2574
- get onopen() {
2575
- return null;
2576
- }
2577
- /**
2578
- * @type {Function}
2579
- */
2580
- /* istanbul ignore next */
2581
- get onmessage() {
2582
- return null;
2583
- }
2584
- /**
2585
- * @type {String}
2586
- */
2587
- get protocol() {
2588
- return this._protocol;
2589
- }
2590
- /**
2591
- * @type {Number}
2592
- */
2593
- get readyState() {
2594
- return this._readyState;
2595
- }
2596
- /**
2597
- * @type {String}
2598
- */
2599
- get url() {
2600
- return this._url;
2601
- }
2602
- /**
2603
- * Set up the socket and the internal resources.
2604
- *
2605
- * @param {Duplex} socket The network socket between the server and client
2606
- * @param {Buffer} head The first packet of the upgraded stream
2607
- * @param {Object} options Options object
2608
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
2609
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
2610
- * multiple times in the same tick
2611
- * @param {Function} [options.generateMask] The function used to generate the
2612
- * masking key
2613
- * @param {Number} [options.maxPayload=0] The maximum allowed message size
2614
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2615
- * not to skip UTF-8 validation for text and close messages
2616
- * @private
2617
- */
2618
- setSocket(socket, head, options) {
2619
- const receiver = new Receiver2({
2620
- allowSynchronousEvents: options.allowSynchronousEvents,
2621
- binaryType: this.binaryType,
2622
- extensions: this._extensions,
2623
- isServer: this._isServer,
2624
- maxPayload: options.maxPayload,
2625
- skipUTF8Validation: options.skipUTF8Validation
2626
- });
2627
- const sender = new Sender2(socket, this._extensions, options.generateMask);
2628
- this._receiver = receiver;
2629
- this._sender = sender;
2630
- this._socket = socket;
2631
- receiver[kWebSocket] = this;
2632
- sender[kWebSocket] = this;
2633
- socket[kWebSocket] = this;
2634
- receiver.on("conclude", receiverOnConclude);
2635
- receiver.on("drain", receiverOnDrain);
2636
- receiver.on("error", receiverOnError);
2637
- receiver.on("message", receiverOnMessage);
2638
- receiver.on("ping", receiverOnPing);
2639
- receiver.on("pong", receiverOnPong);
2640
- sender.onerror = senderOnError;
2641
- if (socket.setTimeout) socket.setTimeout(0);
2642
- if (socket.setNoDelay) socket.setNoDelay();
2643
- if (head.length > 0) socket.unshift(head);
2644
- socket.on("close", socketOnClose);
2645
- socket.on("data", socketOnData);
2646
- socket.on("end", socketOnEnd);
2647
- socket.on("error", socketOnError);
2648
- this._readyState = _WebSocket.OPEN;
2649
- this.emit("open");
2650
- }
2651
- /**
2652
- * Emit the `'close'` event.
2653
- *
2654
- * @private
2655
- */
2656
- emitClose() {
2657
- if (!this._socket) {
2658
- this._readyState = _WebSocket.CLOSED;
2659
- this.emit("close", this._closeCode, this._closeMessage);
2660
- return;
2661
- }
2662
- if (this._extensions[PerMessageDeflate.extensionName]) {
2663
- this._extensions[PerMessageDeflate.extensionName].cleanup();
2664
- }
2665
- this._receiver.removeAllListeners();
2666
- this._readyState = _WebSocket.CLOSED;
2667
- this.emit("close", this._closeCode, this._closeMessage);
2668
- }
2669
- /**
2670
- * Start a closing handshake.
2671
- *
2672
- * +----------+ +-----------+ +----------+
2673
- * - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
2674
- * | +----------+ +-----------+ +----------+ |
2675
- * +----------+ +-----------+ |
2676
- * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
2677
- * +----------+ +-----------+ |
2678
- * | | | +---+ |
2679
- * +------------------------+-->|fin| - - - -
2680
- * | +---+ | +---+
2681
- * - - - - -|fin|<---------------------+
2682
- * +---+
2683
- *
2684
- * @param {Number} [code] Status code explaining why the connection is closing
2685
- * @param {(String|Buffer)} [data] The reason why the connection is
2686
- * closing
2687
- * @public
2688
- */
2689
- close(code, data) {
2690
- if (this.readyState === _WebSocket.CLOSED) return;
2691
- if (this.readyState === _WebSocket.CONNECTING) {
2692
- const msg = "WebSocket was closed before the connection was established";
2693
- abortHandshake(this, this._req, msg);
2694
- return;
2695
- }
2696
- if (this.readyState === _WebSocket.CLOSING) {
2697
- if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
2698
- this._socket.end();
2699
- }
2700
- return;
2701
- }
2702
- this._readyState = _WebSocket.CLOSING;
2703
- this._sender.close(code, data, !this._isServer, (err) => {
2704
- if (err) return;
2705
- this._closeFrameSent = true;
2706
- if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
2707
- this._socket.end();
2708
- }
2709
- });
2710
- setCloseTimer(this);
2711
- }
2712
- /**
2713
- * Pause the socket.
2714
- *
2715
- * @public
2716
- */
2717
- pause() {
2718
- if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
2719
- return;
2720
- }
2721
- this._paused = true;
2722
- this._socket.pause();
2723
- }
2724
- /**
2725
- * Send a ping.
2726
- *
2727
- * @param {*} [data] The data to send
2728
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2729
- * @param {Function} [cb] Callback which is executed when the ping is sent
2730
- * @public
2731
- */
2732
- ping(data, mask, cb) {
2733
- if (this.readyState === _WebSocket.CONNECTING) {
2734
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2735
- }
2736
- if (typeof data === "function") {
2737
- cb = data;
2738
- data = mask = void 0;
2739
- } else if (typeof mask === "function") {
2740
- cb = mask;
2741
- mask = void 0;
2742
- }
2743
- if (typeof data === "number") data = data.toString();
2744
- if (this.readyState !== _WebSocket.OPEN) {
2745
- sendAfterClose(this, data, cb);
2746
- return;
2747
- }
2748
- if (mask === void 0) mask = !this._isServer;
2749
- this._sender.ping(data || EMPTY_BUFFER, mask, cb);
2750
- }
2751
- /**
2752
- * Send a pong.
2753
- *
2754
- * @param {*} [data] The data to send
2755
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2756
- * @param {Function} [cb] Callback which is executed when the pong is sent
2757
- * @public
2758
- */
2759
- pong(data, mask, cb) {
2760
- if (this.readyState === _WebSocket.CONNECTING) {
2761
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2762
- }
2763
- if (typeof data === "function") {
2764
- cb = data;
2765
- data = mask = void 0;
2766
- } else if (typeof mask === "function") {
2767
- cb = mask;
2768
- mask = void 0;
2769
- }
2770
- if (typeof data === "number") data = data.toString();
2771
- if (this.readyState !== _WebSocket.OPEN) {
2772
- sendAfterClose(this, data, cb);
2773
- return;
2774
- }
2775
- if (mask === void 0) mask = !this._isServer;
2776
- this._sender.pong(data || EMPTY_BUFFER, mask, cb);
2777
- }
2778
- /**
2779
- * Resume the socket.
2780
- *
2781
- * @public
2782
- */
2783
- resume() {
2784
- if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
2785
- return;
2786
- }
2787
- this._paused = false;
2788
- if (!this._receiver._writableState.needDrain) this._socket.resume();
2789
- }
2790
- /**
2791
- * Send a data message.
2792
- *
2793
- * @param {*} data The message to send
2794
- * @param {Object} [options] Options object
2795
- * @param {Boolean} [options.binary] Specifies whether `data` is binary or
2796
- * text
2797
- * @param {Boolean} [options.compress] Specifies whether or not to compress
2798
- * `data`
2799
- * @param {Boolean} [options.fin=true] Specifies whether the fragment is the
2800
- * last one
2801
- * @param {Boolean} [options.mask] Specifies whether or not to mask `data`
2802
- * @param {Function} [cb] Callback which is executed when data is written out
2803
- * @public
2804
- */
2805
- send(data, options, cb) {
2806
- if (this.readyState === _WebSocket.CONNECTING) {
2807
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2808
- }
2809
- if (typeof options === "function") {
2810
- cb = options;
2811
- options = {};
2812
- }
2813
- if (typeof data === "number") data = data.toString();
2814
- if (this.readyState !== _WebSocket.OPEN) {
2815
- sendAfterClose(this, data, cb);
2816
- return;
2817
- }
2818
- const opts = {
2819
- binary: typeof data !== "string",
2820
- mask: !this._isServer,
2821
- compress: true,
2822
- fin: true,
2823
- ...options
2824
- };
2825
- if (!this._extensions[PerMessageDeflate.extensionName]) {
2826
- opts.compress = false;
2827
- }
2828
- this._sender.send(data || EMPTY_BUFFER, opts, cb);
2829
- }
2830
- /**
2831
- * Forcibly close the connection.
2832
- *
2833
- * @public
2834
- */
2835
- terminate() {
2836
- if (this.readyState === _WebSocket.CLOSED) return;
2837
- if (this.readyState === _WebSocket.CONNECTING) {
2838
- const msg = "WebSocket was closed before the connection was established";
2839
- abortHandshake(this, this._req, msg);
2840
- return;
2841
- }
2842
- if (this._socket) {
2843
- this._readyState = _WebSocket.CLOSING;
2844
- this._socket.destroy();
2845
- }
2846
- }
2847
- };
2848
- Object.defineProperty(WebSocket4, "CONNECTING", {
2849
- enumerable: true,
2850
- value: readyStates.indexOf("CONNECTING")
2851
- });
2852
- Object.defineProperty(WebSocket4.prototype, "CONNECTING", {
2853
- enumerable: true,
2854
- value: readyStates.indexOf("CONNECTING")
2855
- });
2856
- Object.defineProperty(WebSocket4, "OPEN", {
2857
- enumerable: true,
2858
- value: readyStates.indexOf("OPEN")
2859
- });
2860
- Object.defineProperty(WebSocket4.prototype, "OPEN", {
2861
- enumerable: true,
2862
- value: readyStates.indexOf("OPEN")
2863
- });
2864
- Object.defineProperty(WebSocket4, "CLOSING", {
2865
- enumerable: true,
2866
- value: readyStates.indexOf("CLOSING")
2867
- });
2868
- Object.defineProperty(WebSocket4.prototype, "CLOSING", {
2869
- enumerable: true,
2870
- value: readyStates.indexOf("CLOSING")
2871
- });
2872
- Object.defineProperty(WebSocket4, "CLOSED", {
2873
- enumerable: true,
2874
- value: readyStates.indexOf("CLOSED")
2875
- });
2876
- Object.defineProperty(WebSocket4.prototype, "CLOSED", {
2877
- enumerable: true,
2878
- value: readyStates.indexOf("CLOSED")
2879
- });
2880
- [
2881
- "binaryType",
2882
- "bufferedAmount",
2883
- "extensions",
2884
- "isPaused",
2885
- "protocol",
2886
- "readyState",
2887
- "url"
2888
- ].forEach((property) => {
2889
- Object.defineProperty(WebSocket4.prototype, property, { enumerable: true });
2890
- });
2891
- ["open", "error", "close", "message"].forEach((method) => {
2892
- Object.defineProperty(WebSocket4.prototype, `on${method}`, {
2893
- enumerable: true,
2894
- get() {
2895
- for (const listener of this.listeners(method)) {
2896
- if (listener[kForOnEventAttribute]) return listener[kListener];
2897
- }
2898
- return null;
2899
- },
2900
- set(handler) {
2901
- for (const listener of this.listeners(method)) {
2902
- if (listener[kForOnEventAttribute]) {
2903
- this.removeListener(method, listener);
2904
- break;
2905
- }
2906
- }
2907
- if (typeof handler !== "function") return;
2908
- this.addEventListener(method, handler, {
2909
- [kForOnEventAttribute]: true
2910
- });
2911
- }
2912
- });
2913
- });
2914
- WebSocket4.prototype.addEventListener = addEventListener;
2915
- WebSocket4.prototype.removeEventListener = removeEventListener;
2916
- module.exports = WebSocket4;
2917
- function initAsClient(websocket, address, protocols, options) {
2918
- const opts = {
2919
- allowSynchronousEvents: true,
2920
- autoPong: true,
2921
- protocolVersion: protocolVersions[1],
2922
- maxPayload: 100 * 1024 * 1024,
2923
- skipUTF8Validation: false,
2924
- perMessageDeflate: true,
2925
- followRedirects: false,
2926
- maxRedirects: 10,
2927
- ...options,
2928
- socketPath: void 0,
2929
- hostname: void 0,
2930
- protocol: void 0,
2931
- timeout: void 0,
2932
- method: "GET",
2933
- host: void 0,
2934
- path: void 0,
2935
- port: void 0
2936
- };
2937
- websocket._autoPong = opts.autoPong;
2938
- if (!protocolVersions.includes(opts.protocolVersion)) {
2939
- throw new RangeError(
2940
- `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
2941
- );
2942
- }
2943
- let parsedUrl;
2944
- if (address instanceof URL) {
2945
- parsedUrl = address;
2946
- } else {
2947
- try {
2948
- parsedUrl = new URL(address);
2949
- } catch (e) {
2950
- throw new SyntaxError(`Invalid URL: ${address}`);
2951
- }
2952
- }
2953
- if (parsedUrl.protocol === "http:") {
2954
- parsedUrl.protocol = "ws:";
2955
- } else if (parsedUrl.protocol === "https:") {
2956
- parsedUrl.protocol = "wss:";
2957
- }
2958
- websocket._url = parsedUrl.href;
2959
- const isSecure = parsedUrl.protocol === "wss:";
2960
- const isIpcUrl = parsedUrl.protocol === "ws+unix:";
2961
- let invalidUrlMessage;
2962
- if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
2963
- invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;
2964
- } else if (isIpcUrl && !parsedUrl.pathname) {
2965
- invalidUrlMessage = "The URL's pathname is empty";
2966
- } else if (parsedUrl.hash) {
2967
- invalidUrlMessage = "The URL contains a fragment identifier";
2968
- }
2969
- if (invalidUrlMessage) {
2970
- const err = new SyntaxError(invalidUrlMessage);
2971
- if (websocket._redirects === 0) {
2972
- throw err;
2973
- } else {
2974
- emitErrorAndClose(websocket, err);
2975
- return;
2976
- }
2977
- }
2978
- const defaultPort = isSecure ? 443 : 80;
2979
- const key = randomBytes(16).toString("base64");
2980
- const request = isSecure ? https.request : http.request;
2981
- const protocolSet = /* @__PURE__ */ new Set();
2982
- let perMessageDeflate;
2983
- opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
2984
- opts.defaultPort = opts.defaultPort || defaultPort;
2985
- opts.port = parsedUrl.port || defaultPort;
2986
- opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
2987
- opts.headers = {
2988
- ...opts.headers,
2989
- "Sec-WebSocket-Version": opts.protocolVersion,
2990
- "Sec-WebSocket-Key": key,
2991
- Connection: "Upgrade",
2992
- Upgrade: "websocket"
2993
- };
2994
- opts.path = parsedUrl.pathname + parsedUrl.search;
2995
- opts.timeout = opts.handshakeTimeout;
2996
- if (opts.perMessageDeflate) {
2997
- perMessageDeflate = new PerMessageDeflate(
2998
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
2999
- false,
3000
- opts.maxPayload
3001
- );
3002
- opts.headers["Sec-WebSocket-Extensions"] = format({
3003
- [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
3004
- });
3005
- }
3006
- if (protocols.length) {
3007
- for (const protocol of protocols) {
3008
- if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
3009
- throw new SyntaxError(
3010
- "An invalid or duplicated subprotocol was specified"
3011
- );
3012
- }
3013
- protocolSet.add(protocol);
3014
- }
3015
- opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
3016
- }
3017
- if (opts.origin) {
3018
- if (opts.protocolVersion < 13) {
3019
- opts.headers["Sec-WebSocket-Origin"] = opts.origin;
3020
- } else {
3021
- opts.headers.Origin = opts.origin;
3022
- }
3023
- }
3024
- if (parsedUrl.username || parsedUrl.password) {
3025
- opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
3026
- }
3027
- if (isIpcUrl) {
3028
- const parts = opts.path.split(":");
3029
- opts.socketPath = parts[0];
3030
- opts.path = parts[1];
3031
- }
3032
- let req;
3033
- if (opts.followRedirects) {
3034
- if (websocket._redirects === 0) {
3035
- websocket._originalIpc = isIpcUrl;
3036
- websocket._originalSecure = isSecure;
3037
- websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
3038
- const headers = options && options.headers;
3039
- options = { ...options, headers: {} };
3040
- if (headers) {
3041
- for (const [key2, value] of Object.entries(headers)) {
3042
- options.headers[key2.toLowerCase()] = value;
3043
- }
3044
- }
3045
- } else if (websocket.listenerCount("redirect") === 0) {
3046
- const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
3047
- if (!isSameHost || websocket._originalSecure && !isSecure) {
3048
- delete opts.headers.authorization;
3049
- delete opts.headers.cookie;
3050
- if (!isSameHost) delete opts.headers.host;
3051
- opts.auth = void 0;
3052
- }
3053
- }
3054
- if (opts.auth && !options.headers.authorization) {
3055
- options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
3056
- }
3057
- req = websocket._req = request(opts);
3058
- if (websocket._redirects) {
3059
- websocket.emit("redirect", websocket.url, req);
3060
- }
3061
- } else {
3062
- req = websocket._req = request(opts);
3063
- }
3064
- if (opts.timeout) {
3065
- req.on("timeout", () => {
3066
- abortHandshake(websocket, req, "Opening handshake has timed out");
3067
- });
3068
- }
3069
- req.on("error", (err) => {
3070
- if (req === null || req[kAborted]) return;
3071
- req = websocket._req = null;
3072
- emitErrorAndClose(websocket, err);
3073
- });
3074
- req.on("response", (res) => {
3075
- const location = res.headers.location;
3076
- const statusCode = res.statusCode;
3077
- if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
3078
- if (++websocket._redirects > opts.maxRedirects) {
3079
- abortHandshake(websocket, req, "Maximum redirects exceeded");
3080
- return;
3081
- }
3082
- req.abort();
3083
- let addr;
3084
- try {
3085
- addr = new URL(location, address);
3086
- } catch (e) {
3087
- const err = new SyntaxError(`Invalid URL: ${location}`);
3088
- emitErrorAndClose(websocket, err);
3089
- return;
3090
- }
3091
- initAsClient(websocket, addr, protocols, options);
3092
- } else if (!websocket.emit("unexpected-response", req, res)) {
3093
- abortHandshake(
3094
- websocket,
3095
- req,
3096
- `Unexpected server response: ${res.statusCode}`
3097
- );
3098
- }
3099
- });
3100
- req.on("upgrade", (res, socket, head) => {
3101
- websocket.emit("upgrade", res);
3102
- if (websocket.readyState !== WebSocket4.CONNECTING) return;
3103
- req = websocket._req = null;
3104
- const upgrade = res.headers.upgrade;
3105
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
3106
- abortHandshake(websocket, socket, "Invalid Upgrade header");
3107
- return;
3108
- }
3109
- const digest = createHash("sha1").update(key + GUID).digest("base64");
3110
- if (res.headers["sec-websocket-accept"] !== digest) {
3111
- abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
3112
- return;
3113
- }
3114
- const serverProt = res.headers["sec-websocket-protocol"];
3115
- let protError;
3116
- if (serverProt !== void 0) {
3117
- if (!protocolSet.size) {
3118
- protError = "Server sent a subprotocol but none was requested";
3119
- } else if (!protocolSet.has(serverProt)) {
3120
- protError = "Server sent an invalid subprotocol";
3121
- }
3122
- } else if (protocolSet.size) {
3123
- protError = "Server sent no subprotocol";
3124
- }
3125
- if (protError) {
3126
- abortHandshake(websocket, socket, protError);
3127
- return;
3128
- }
3129
- if (serverProt) websocket._protocol = serverProt;
3130
- const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
3131
- if (secWebSocketExtensions !== void 0) {
3132
- if (!perMessageDeflate) {
3133
- const message = "Server sent a Sec-WebSocket-Extensions header but no extension was requested";
3134
- abortHandshake(websocket, socket, message);
3135
- return;
3136
- }
3137
- let extensions;
3138
- try {
3139
- extensions = parse(secWebSocketExtensions);
3140
- } catch (err) {
3141
- const message = "Invalid Sec-WebSocket-Extensions header";
3142
- abortHandshake(websocket, socket, message);
3143
- return;
3144
- }
3145
- const extensionNames = Object.keys(extensions);
3146
- if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
3147
- const message = "Server indicated an extension that was not requested";
3148
- abortHandshake(websocket, socket, message);
3149
- return;
3150
- }
3151
- try {
3152
- perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
3153
- } catch (err) {
3154
- const message = "Invalid Sec-WebSocket-Extensions header";
3155
- abortHandshake(websocket, socket, message);
3156
- return;
3157
- }
3158
- websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
3159
- }
3160
- websocket.setSocket(socket, head, {
3161
- allowSynchronousEvents: opts.allowSynchronousEvents,
3162
- generateMask: opts.generateMask,
3163
- maxPayload: opts.maxPayload,
3164
- skipUTF8Validation: opts.skipUTF8Validation
3165
- });
3166
- });
3167
- if (opts.finishRequest) {
3168
- opts.finishRequest(req, websocket);
3169
- } else {
3170
- req.end();
3171
- }
3172
- }
3173
- function emitErrorAndClose(websocket, err) {
3174
- websocket._readyState = WebSocket4.CLOSING;
3175
- websocket._errorEmitted = true;
3176
- websocket.emit("error", err);
3177
- websocket.emitClose();
3178
- }
3179
- function netConnect(options) {
3180
- options.path = options.socketPath;
3181
- return net.connect(options);
3182
- }
3183
- function tlsConnect(options) {
3184
- options.path = void 0;
3185
- if (!options.servername && options.servername !== "") {
3186
- options.servername = net.isIP(options.host) ? "" : options.host;
3187
- }
3188
- return tls.connect(options);
3189
- }
3190
- function abortHandshake(websocket, stream, message) {
3191
- websocket._readyState = WebSocket4.CLOSING;
3192
- const err = new Error(message);
3193
- Error.captureStackTrace(err, abortHandshake);
3194
- if (stream.setHeader) {
3195
- stream[kAborted] = true;
3196
- stream.abort();
3197
- if (stream.socket && !stream.socket.destroyed) {
3198
- stream.socket.destroy();
3199
- }
3200
- process.nextTick(emitErrorAndClose, websocket, err);
3201
- } else {
3202
- stream.destroy(err);
3203
- stream.once("error", websocket.emit.bind(websocket, "error"));
3204
- stream.once("close", websocket.emitClose.bind(websocket));
3205
- }
3206
- }
3207
- function sendAfterClose(websocket, data, cb) {
3208
- if (data) {
3209
- const length = isBlob(data) ? data.size : toBuffer(data).length;
3210
- if (websocket._socket) websocket._sender._bufferedBytes += length;
3211
- else websocket._bufferedAmount += length;
3212
- }
3213
- if (cb) {
3214
- const err = new Error(
3215
- `WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`
3216
- );
3217
- process.nextTick(cb, err);
3218
- }
3219
- }
3220
- function receiverOnConclude(code, reason) {
3221
- const websocket = this[kWebSocket];
3222
- websocket._closeFrameReceived = true;
3223
- websocket._closeMessage = reason;
3224
- websocket._closeCode = code;
3225
- if (websocket._socket[kWebSocket] === void 0) return;
3226
- websocket._socket.removeListener("data", socketOnData);
3227
- process.nextTick(resume, websocket._socket);
3228
- if (code === 1005) websocket.close();
3229
- else websocket.close(code, reason);
3230
- }
3231
- function receiverOnDrain() {
3232
- const websocket = this[kWebSocket];
3233
- if (!websocket.isPaused) websocket._socket.resume();
3234
- }
3235
- function receiverOnError(err) {
3236
- const websocket = this[kWebSocket];
3237
- if (websocket._socket[kWebSocket] !== void 0) {
3238
- websocket._socket.removeListener("data", socketOnData);
3239
- process.nextTick(resume, websocket._socket);
3240
- websocket.close(err[kStatusCode]);
3241
- }
3242
- if (!websocket._errorEmitted) {
3243
- websocket._errorEmitted = true;
3244
- websocket.emit("error", err);
3245
- }
3246
- }
3247
- function receiverOnFinish() {
3248
- this[kWebSocket].emitClose();
3249
- }
3250
- function receiverOnMessage(data, isBinary) {
3251
- this[kWebSocket].emit("message", data, isBinary);
3252
- }
3253
- function receiverOnPing(data) {
3254
- const websocket = this[kWebSocket];
3255
- if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
3256
- websocket.emit("ping", data);
3257
- }
3258
- function receiverOnPong(data) {
3259
- this[kWebSocket].emit("pong", data);
3260
- }
3261
- function resume(stream) {
3262
- stream.resume();
3263
- }
3264
- function senderOnError(err) {
3265
- const websocket = this[kWebSocket];
3266
- if (websocket.readyState === WebSocket4.CLOSED) return;
3267
- if (websocket.readyState === WebSocket4.OPEN) {
3268
- websocket._readyState = WebSocket4.CLOSING;
3269
- setCloseTimer(websocket);
3270
- }
3271
- this._socket.end();
3272
- if (!websocket._errorEmitted) {
3273
- websocket._errorEmitted = true;
3274
- websocket.emit("error", err);
3275
- }
3276
- }
3277
- function setCloseTimer(websocket) {
3278
- websocket._closeTimer = setTimeout(
3279
- websocket._socket.destroy.bind(websocket._socket),
3280
- closeTimeout
3281
- );
3282
- }
3283
- function socketOnClose() {
3284
- const websocket = this[kWebSocket];
3285
- this.removeListener("close", socketOnClose);
3286
- this.removeListener("data", socketOnData);
3287
- this.removeListener("end", socketOnEnd);
3288
- websocket._readyState = WebSocket4.CLOSING;
3289
- let chunk;
3290
- if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) {
3291
- websocket._receiver.write(chunk);
3292
- }
3293
- websocket._receiver.end();
3294
- this[kWebSocket] = void 0;
3295
- clearTimeout(websocket._closeTimer);
3296
- if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
3297
- websocket.emitClose();
3298
- } else {
3299
- websocket._receiver.on("error", receiverOnFinish);
3300
- websocket._receiver.on("finish", receiverOnFinish);
3301
- }
3302
- }
3303
- function socketOnData(chunk) {
3304
- if (!this[kWebSocket]._receiver.write(chunk)) {
3305
- this.pause();
3306
- }
3307
- }
3308
- function socketOnEnd() {
3309
- const websocket = this[kWebSocket];
3310
- websocket._readyState = WebSocket4.CLOSING;
3311
- websocket._receiver.end();
3312
- this.end();
3313
- }
3314
- function socketOnError() {
3315
- const websocket = this[kWebSocket];
3316
- this.removeListener("error", socketOnError);
3317
- this.on("error", NOOP);
3318
- if (websocket) {
3319
- websocket._readyState = WebSocket4.CLOSING;
3320
- this.destroy();
3321
- }
3322
- }
3323
- }
3324
- });
3325
-
3326
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/stream.js
3327
- var require_stream = __commonJS({
3328
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/stream.js"(exports$1, module) {
3329
- require_websocket();
3330
- var { Duplex } = __require("stream");
3331
- function emitClose(stream) {
3332
- stream.emit("close");
3333
- }
3334
- function duplexOnEnd() {
3335
- if (!this.destroyed && this._writableState.finished) {
3336
- this.destroy();
3337
- }
3338
- }
3339
- function duplexOnError(err) {
3340
- this.removeListener("error", duplexOnError);
3341
- this.destroy();
3342
- if (this.listenerCount("error") === 0) {
3343
- this.emit("error", err);
3344
- }
3345
- }
3346
- function createWebSocketStream2(ws, options) {
3347
- let terminateOnDestroy = true;
3348
- const duplex = new Duplex({
3349
- ...options,
3350
- autoDestroy: false,
3351
- emitClose: false,
3352
- objectMode: false,
3353
- writableObjectMode: false
3354
- });
3355
- ws.on("message", function message(msg, isBinary) {
3356
- const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
3357
- if (!duplex.push(data)) ws.pause();
3358
- });
3359
- ws.once("error", function error(err) {
3360
- if (duplex.destroyed) return;
3361
- terminateOnDestroy = false;
3362
- duplex.destroy(err);
3363
- });
3364
- ws.once("close", function close() {
3365
- if (duplex.destroyed) return;
3366
- duplex.push(null);
3367
- });
3368
- duplex._destroy = function(err, callback) {
3369
- if (ws.readyState === ws.CLOSED) {
3370
- callback(err);
3371
- process.nextTick(emitClose, duplex);
3372
- return;
3373
- }
3374
- let called = false;
3375
- ws.once("error", function error(err2) {
3376
- called = true;
3377
- callback(err2);
3378
- });
3379
- ws.once("close", function close() {
3380
- if (!called) callback(err);
3381
- process.nextTick(emitClose, duplex);
3382
- });
3383
- if (terminateOnDestroy) ws.terminate();
3384
- };
3385
- duplex._final = function(callback) {
3386
- if (ws.readyState === ws.CONNECTING) {
3387
- ws.once("open", function open() {
3388
- duplex._final(callback);
3389
- });
3390
- return;
3391
- }
3392
- if (ws._socket === null) return;
3393
- if (ws._socket._writableState.finished) {
3394
- callback();
3395
- if (duplex._readableState.endEmitted) duplex.destroy();
3396
- } else {
3397
- ws._socket.once("finish", function finish() {
3398
- callback();
3399
- });
3400
- ws.close();
3401
- }
3402
- };
3403
- duplex._read = function() {
3404
- if (ws.isPaused) ws.resume();
3405
- };
3406
- duplex._write = function(chunk, encoding, callback) {
3407
- if (ws.readyState === ws.CONNECTING) {
3408
- ws.once("open", function open() {
3409
- duplex._write(chunk, encoding, callback);
3410
- });
3411
- return;
3412
- }
3413
- ws.send(chunk, callback);
3414
- };
3415
- duplex.on("end", duplexOnEnd);
3416
- duplex.on("error", duplexOnError);
3417
- return duplex;
3418
- }
3419
- module.exports = createWebSocketStream2;
3420
- }
3421
- });
3422
-
3423
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/subprotocol.js
3424
- var require_subprotocol = __commonJS({
3425
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/subprotocol.js"(exports$1, module) {
3426
- var { tokenChars } = require_validation();
3427
- function parse(header) {
3428
- const protocols = /* @__PURE__ */ new Set();
3429
- let start = -1;
3430
- let end = -1;
3431
- let i = 0;
3432
- for (i; i < header.length; i++) {
3433
- const code = header.charCodeAt(i);
3434
- if (end === -1 && tokenChars[code] === 1) {
3435
- if (start === -1) start = i;
3436
- } else if (i !== 0 && (code === 32 || code === 9)) {
3437
- if (end === -1 && start !== -1) end = i;
3438
- } else if (code === 44) {
3439
- if (start === -1) {
3440
- throw new SyntaxError(`Unexpected character at index ${i}`);
3441
- }
3442
- if (end === -1) end = i;
3443
- const protocol2 = header.slice(start, end);
3444
- if (protocols.has(protocol2)) {
3445
- throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
3446
- }
3447
- protocols.add(protocol2);
3448
- start = end = -1;
3449
- } else {
3450
- throw new SyntaxError(`Unexpected character at index ${i}`);
3451
- }
3452
- }
3453
- if (start === -1 || end !== -1) {
3454
- throw new SyntaxError("Unexpected end of input");
3455
- }
3456
- const protocol = header.slice(start, i);
3457
- if (protocols.has(protocol)) {
3458
- throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
3459
- }
3460
- protocols.add(protocol);
3461
- return protocols;
3462
- }
3463
- module.exports = { parse };
3464
- }
3465
- });
3466
-
3467
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/websocket-server.js
3468
- var require_websocket_server = __commonJS({
3469
- "../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/websocket-server.js"(exports$1, module) {
3470
- var EventEmitter = __require("events");
3471
- var http = __require("http");
3472
- var { Duplex } = __require("stream");
3473
- var { createHash } = __require("crypto");
3474
- var extension = require_extension();
3475
- var PerMessageDeflate = require_permessage_deflate();
3476
- var subprotocol = require_subprotocol();
3477
- var WebSocket4 = require_websocket();
3478
- var { GUID, kWebSocket } = require_constants();
3479
- var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
3480
- var RUNNING = 0;
3481
- var CLOSING = 1;
3482
- var CLOSED = 2;
3483
- var WebSocketServer2 = class extends EventEmitter {
3484
- /**
3485
- * Create a `WebSocketServer` instance.
3486
- *
3487
- * @param {Object} options Configuration options
3488
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
3489
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
3490
- * multiple times in the same tick
3491
- * @param {Boolean} [options.autoPong=true] Specifies whether or not to
3492
- * automatically send a pong in response to a ping
3493
- * @param {Number} [options.backlog=511] The maximum length of the queue of
3494
- * pending connections
3495
- * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
3496
- * track clients
3497
- * @param {Function} [options.handleProtocols] A hook to handle protocols
3498
- * @param {String} [options.host] The hostname where to bind the server
3499
- * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3500
- * size
3501
- * @param {Boolean} [options.noServer=false] Enable no server mode
3502
- * @param {String} [options.path] Accept only connections matching this path
3503
- * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
3504
- * permessage-deflate
3505
- * @param {Number} [options.port] The port where to bind the server
3506
- * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
3507
- * server to use
3508
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
3509
- * not to skip UTF-8 validation for text and close messages
3510
- * @param {Function} [options.verifyClient] A hook to reject connections
3511
- * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
3512
- * class to use. It must be the `WebSocket` class or class that extends it
3513
- * @param {Function} [callback] A listener for the `listening` event
3514
- */
3515
- constructor(options, callback) {
3516
- super();
3517
- options = {
3518
- allowSynchronousEvents: true,
3519
- autoPong: true,
3520
- maxPayload: 100 * 1024 * 1024,
3521
- skipUTF8Validation: false,
3522
- perMessageDeflate: false,
3523
- handleProtocols: null,
3524
- clientTracking: true,
3525
- verifyClient: null,
3526
- noServer: false,
3527
- backlog: null,
3528
- // use default (511 as implemented in net.js)
3529
- server: null,
3530
- host: null,
3531
- path: null,
3532
- port: null,
3533
- WebSocket: WebSocket4,
3534
- ...options
3535
- };
3536
- if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
3537
- throw new TypeError(
3538
- 'One and only one of the "port", "server", or "noServer" options must be specified'
3539
- );
3540
- }
3541
- if (options.port != null) {
3542
- this._server = http.createServer((req, res) => {
3543
- const body = http.STATUS_CODES[426];
3544
- res.writeHead(426, {
3545
- "Content-Length": body.length,
3546
- "Content-Type": "text/plain"
3547
- });
3548
- res.end(body);
3549
- });
3550
- this._server.listen(
3551
- options.port,
3552
- options.host,
3553
- options.backlog,
3554
- callback
3555
- );
3556
- } else if (options.server) {
3557
- this._server = options.server;
3558
- }
3559
- if (this._server) {
3560
- const emitConnection = this.emit.bind(this, "connection");
3561
- this._removeListeners = addListeners(this._server, {
3562
- listening: this.emit.bind(this, "listening"),
3563
- error: this.emit.bind(this, "error"),
3564
- upgrade: (req, socket, head) => {
3565
- this.handleUpgrade(req, socket, head, emitConnection);
3566
- }
3567
- });
3568
- }
3569
- if (options.perMessageDeflate === true) options.perMessageDeflate = {};
3570
- if (options.clientTracking) {
3571
- this.clients = /* @__PURE__ */ new Set();
3572
- this._shouldEmitClose = false;
3573
- }
3574
- this.options = options;
3575
- this._state = RUNNING;
3576
- }
3577
- /**
3578
- * Returns the bound address, the address family name, and port of the server
3579
- * as reported by the operating system if listening on an IP socket.
3580
- * If the server is listening on a pipe or UNIX domain socket, the name is
3581
- * returned as a string.
3582
- *
3583
- * @return {(Object|String|null)} The address of the server
3584
- * @public
3585
- */
3586
- address() {
3587
- if (this.options.noServer) {
3588
- throw new Error('The server is operating in "noServer" mode');
3589
- }
3590
- if (!this._server) return null;
3591
- return this._server.address();
3592
- }
3593
- /**
3594
- * Stop the server from accepting new connections and emit the `'close'` event
3595
- * when all existing connections are closed.
3596
- *
3597
- * @param {Function} [cb] A one-time listener for the `'close'` event
3598
- * @public
3599
- */
3600
- close(cb) {
3601
- if (this._state === CLOSED) {
3602
- if (cb) {
3603
- this.once("close", () => {
3604
- cb(new Error("The server is not running"));
3605
- });
3606
- }
3607
- process.nextTick(emitClose, this);
3608
- return;
3609
- }
3610
- if (cb) this.once("close", cb);
3611
- if (this._state === CLOSING) return;
3612
- this._state = CLOSING;
3613
- if (this.options.noServer || this.options.server) {
3614
- if (this._server) {
3615
- this._removeListeners();
3616
- this._removeListeners = this._server = null;
3617
- }
3618
- if (this.clients) {
3619
- if (!this.clients.size) {
3620
- process.nextTick(emitClose, this);
3621
- } else {
3622
- this._shouldEmitClose = true;
3623
- }
3624
- } else {
3625
- process.nextTick(emitClose, this);
3626
- }
3627
- } else {
3628
- const server = this._server;
3629
- this._removeListeners();
3630
- this._removeListeners = this._server = null;
3631
- server.close(() => {
3632
- emitClose(this);
3633
- });
3634
- }
3635
- }
3636
- /**
3637
- * See if a given request should be handled by this server instance.
3638
- *
3639
- * @param {http.IncomingMessage} req Request object to inspect
3640
- * @return {Boolean} `true` if the request is valid, else `false`
3641
- * @public
3642
- */
3643
- shouldHandle(req) {
3644
- if (this.options.path) {
3645
- const index = req.url.indexOf("?");
3646
- const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
3647
- if (pathname !== this.options.path) return false;
3648
- }
3649
- return true;
3650
- }
3651
- /**
3652
- * Handle a HTTP Upgrade request.
3653
- *
3654
- * @param {http.IncomingMessage} req The request object
3655
- * @param {Duplex} socket The network socket between the server and client
3656
- * @param {Buffer} head The first packet of the upgraded stream
3657
- * @param {Function} cb Callback
3658
- * @public
3659
- */
3660
- handleUpgrade(req, socket, head, cb) {
3661
- socket.on("error", socketOnError);
3662
- const key = req.headers["sec-websocket-key"];
3663
- const upgrade = req.headers.upgrade;
3664
- const version = +req.headers["sec-websocket-version"];
3665
- if (req.method !== "GET") {
3666
- const message = "Invalid HTTP method";
3667
- abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
3668
- return;
3669
- }
3670
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
3671
- const message = "Invalid Upgrade header";
3672
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3673
- return;
3674
- }
3675
- if (key === void 0 || !keyRegex.test(key)) {
3676
- const message = "Missing or invalid Sec-WebSocket-Key header";
3677
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3678
- return;
3679
- }
3680
- if (version !== 13 && version !== 8) {
3681
- const message = "Missing or invalid Sec-WebSocket-Version header";
3682
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
3683
- "Sec-WebSocket-Version": "13, 8"
3684
- });
3685
- return;
3686
- }
3687
- if (!this.shouldHandle(req)) {
3688
- abortHandshake(socket, 400);
3689
- return;
3690
- }
3691
- const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
3692
- let protocols = /* @__PURE__ */ new Set();
3693
- if (secWebSocketProtocol !== void 0) {
3694
- try {
3695
- protocols = subprotocol.parse(secWebSocketProtocol);
3696
- } catch (err) {
3697
- const message = "Invalid Sec-WebSocket-Protocol header";
3698
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3699
- return;
3700
- }
3701
- }
3702
- const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
3703
- const extensions = {};
3704
- if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
3705
- const perMessageDeflate = new PerMessageDeflate(
3706
- this.options.perMessageDeflate,
3707
- true,
3708
- this.options.maxPayload
3709
- );
3710
- try {
3711
- const offers = extension.parse(secWebSocketExtensions);
3712
- if (offers[PerMessageDeflate.extensionName]) {
3713
- perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
3714
- extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
3715
- }
3716
- } catch (err) {
3717
- const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
3718
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3719
- return;
3720
- }
3721
- }
3722
- if (this.options.verifyClient) {
3723
- const info = {
3724
- origin: req.headers[`${version === 8 ? "sec-websocket-origin" : "origin"}`],
3725
- secure: !!(req.socket.authorized || req.socket.encrypted),
3726
- req
3727
- };
3728
- if (this.options.verifyClient.length === 2) {
3729
- this.options.verifyClient(info, (verified, code, message, headers) => {
3730
- if (!verified) {
3731
- return abortHandshake(socket, code || 401, message, headers);
3732
- }
3733
- this.completeUpgrade(
3734
- extensions,
3735
- key,
3736
- protocols,
3737
- req,
3738
- socket,
3739
- head,
3740
- cb
3741
- );
3742
- });
3743
- return;
3744
- }
3745
- if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
3746
- }
3747
- this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
3748
- }
3749
- /**
3750
- * Upgrade the connection to WebSocket.
3751
- *
3752
- * @param {Object} extensions The accepted extensions
3753
- * @param {String} key The value of the `Sec-WebSocket-Key` header
3754
- * @param {Set} protocols The subprotocols
3755
- * @param {http.IncomingMessage} req The request object
3756
- * @param {Duplex} socket The network socket between the server and client
3757
- * @param {Buffer} head The first packet of the upgraded stream
3758
- * @param {Function} cb Callback
3759
- * @throws {Error} If called more than once with the same socket
3760
- * @private
3761
- */
3762
- completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
3763
- if (!socket.readable || !socket.writable) return socket.destroy();
3764
- if (socket[kWebSocket]) {
3765
- throw new Error(
3766
- "server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
3767
- );
3768
- }
3769
- if (this._state > RUNNING) return abortHandshake(socket, 503);
3770
- const digest = createHash("sha1").update(key + GUID).digest("base64");
3771
- const headers = [
3772
- "HTTP/1.1 101 Switching Protocols",
3773
- "Upgrade: websocket",
3774
- "Connection: Upgrade",
3775
- `Sec-WebSocket-Accept: ${digest}`
3776
- ];
3777
- const ws = new this.options.WebSocket(null, void 0, this.options);
3778
- if (protocols.size) {
3779
- const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
3780
- if (protocol) {
3781
- headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
3782
- ws._protocol = protocol;
3783
- }
3784
- }
3785
- if (extensions[PerMessageDeflate.extensionName]) {
3786
- const params = extensions[PerMessageDeflate.extensionName].params;
3787
- const value = extension.format({
3788
- [PerMessageDeflate.extensionName]: [params]
3789
- });
3790
- headers.push(`Sec-WebSocket-Extensions: ${value}`);
3791
- ws._extensions = extensions;
3792
- }
3793
- this.emit("headers", headers, req);
3794
- socket.write(headers.concat("\r\n").join("\r\n"));
3795
- socket.removeListener("error", socketOnError);
3796
- ws.setSocket(socket, head, {
3797
- allowSynchronousEvents: this.options.allowSynchronousEvents,
3798
- maxPayload: this.options.maxPayload,
3799
- skipUTF8Validation: this.options.skipUTF8Validation
3800
- });
3801
- if (this.clients) {
3802
- this.clients.add(ws);
3803
- ws.on("close", () => {
3804
- this.clients.delete(ws);
3805
- if (this._shouldEmitClose && !this.clients.size) {
3806
- process.nextTick(emitClose, this);
3807
- }
3808
- });
3809
- }
3810
- cb(ws, req);
3811
- }
3812
- };
3813
- module.exports = WebSocketServer2;
3814
- function addListeners(server, map) {
3815
- for (const event of Object.keys(map)) server.on(event, map[event]);
3816
- return function removeListeners() {
3817
- for (const event of Object.keys(map)) {
3818
- server.removeListener(event, map[event]);
3819
- }
3820
- };
3821
- }
3822
- function emitClose(server) {
3823
- server._state = CLOSED;
3824
- server.emit("close");
3825
- }
3826
- function socketOnError() {
3827
- this.destroy();
3828
- }
3829
- function abortHandshake(socket, code, message, headers) {
3830
- message = message || http.STATUS_CODES[code];
3831
- headers = {
3832
- Connection: "close",
3833
- "Content-Type": "text/html",
3834
- "Content-Length": Buffer.byteLength(message),
3835
- ...headers
3836
- };
3837
- socket.once("finish", socket.destroy);
3838
- socket.end(
3839
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
3840
- ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
3841
- );
3842
- }
3843
- function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
3844
- if (server.listenerCount("wsClientError")) {
3845
- const err = new Error(message);
3846
- Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
3847
- server.emit("wsClientError", err, socket, req);
3848
- } else {
3849
- abortHandshake(socket, code, message, headers);
3850
- }
3851
- }
3852
- }
3853
- });
3854
-
3855
- // ../../node_modules/.pnpm/ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/wrapper.mjs
3856
- var wrapper_exports = {};
3857
- __export(wrapper_exports, {
3858
- Receiver: () => import_receiver.default,
3859
- Sender: () => import_sender.default,
3860
- WebSocket: () => import_websocket.default,
3861
- WebSocketServer: () => import_websocket_server.default,
3862
- createWebSocketStream: () => import_stream.default,
3863
- default: () => wrapper_default
3864
- });
3865
- var import_stream = __toESM(require_stream(), 1);
3866
- var import_receiver = __toESM(require_receiver(), 1);
3867
- var import_sender = __toESM(require_sender(), 1);
3868
- var import_websocket = __toESM(require_websocket(), 1);
3869
- var import_websocket_server = __toESM(require_websocket_server(), 1);
3870
- var wrapper_default = import_websocket.default;
3871
-
3872
- // ../../node_modules/.pnpm/isows@1.0.7_ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6_/node_modules/isows/_esm/utils.js
3873
- function getNativeWebSocket() {
3874
- if (typeof WebSocket !== "undefined")
3875
- return WebSocket;
3876
- if (typeof global.WebSocket !== "undefined")
3877
- return global.WebSocket;
3878
- if (typeof window.WebSocket !== "undefined")
3879
- return window.WebSocket;
3880
- if (typeof self.WebSocket !== "undefined")
3881
- return self.WebSocket;
3882
- throw new Error("`WebSocket` is not supported in this environment");
3883
- }
3884
-
3885
- // ../../node_modules/.pnpm/isows@1.0.7_ws@8.18.3_bufferutil@4.1.0_utf-8-validate@6.0.6_/node_modules/isows/_esm/index.js
3886
- var WebSocket3 = (() => {
3887
- try {
3888
- return getNativeWebSocket();
3889
- } catch {
3890
- if (import_websocket.default)
3891
- return import_websocket.default;
3892
- return wrapper_exports;
3893
- }
3894
- })();
3895
-
3896
- export { WebSocket3 as WebSocket };
3897
- //# sourceMappingURL=_esm-QP3LOJYU.js.map
3898
- //# sourceMappingURL=_esm-QP3LOJYU.js.map