@pllla/openclaw-plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/dist/accounts.js +66 -0
  2. package/dist/bridges.js +110 -0
  3. package/dist/index.js +215 -0
  4. package/dist/lane.js +158 -0
  5. package/dist/pairing.js +36 -0
  6. package/dist/stateStore.js +88 -0
  7. package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
  8. package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
  9. package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
  10. package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
  11. package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
  12. package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
  13. package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
  14. package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
  15. package/node_modules/@socket.io/component-emitter/package.json +28 -0
  16. package/node_modules/debug/LICENSE +20 -0
  17. package/node_modules/debug/README.md +481 -0
  18. package/node_modules/debug/package.json +64 -0
  19. package/node_modules/debug/src/browser.js +272 -0
  20. package/node_modules/debug/src/common.js +292 -0
  21. package/node_modules/debug/src/index.js +10 -0
  22. package/node_modules/debug/src/node.js +263 -0
  23. package/node_modules/engine.io-client/LICENSE +22 -0
  24. package/node_modules/engine.io-client/README.md +331 -0
  25. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
  26. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
  27. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
  28. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
  29. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
  30. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
  31. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
  32. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
  33. package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
  34. package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
  35. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
  36. package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
  37. package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
  38. package/node_modules/engine.io-client/build/cjs/index.js +32 -0
  39. package/node_modules/engine.io-client/build/cjs/package.json +10 -0
  40. package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
  41. package/node_modules/engine.io-client/build/cjs/socket.js +766 -0
  42. package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
  43. package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
  44. package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
  45. package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
  46. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
  47. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
  48. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
  49. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
  50. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
  51. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
  52. package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
  53. package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
  54. package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
  55. package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
  56. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
  57. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
  58. package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
  59. package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
  60. package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
  61. package/node_modules/engine.io-client/build/cjs/util.js +65 -0
  62. package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
  63. package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
  64. package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
  65. package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
  66. package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
  67. package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
  68. package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
  69. package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
  70. package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
  71. package/node_modules/engine.io-client/build/esm/globals.js +22 -0
  72. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
  73. package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
  74. package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
  75. package/node_modules/engine.io-client/build/esm/index.js +15 -0
  76. package/node_modules/engine.io-client/build/esm/package.json +10 -0
  77. package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
  78. package/node_modules/engine.io-client/build/esm/socket.js +728 -0
  79. package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
  80. package/node_modules/engine.io-client/build/esm/transport.js +142 -0
  81. package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
  82. package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
  83. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
  84. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
  85. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
  86. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
  87. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
  88. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
  89. package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
  90. package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
  91. package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
  92. package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
  93. package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
  94. package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
  95. package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
  96. package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
  97. package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
  98. package/node_modules/engine.io-client/build/esm/util.js +59 -0
  99. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
  100. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  101. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
  102. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
  103. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
  104. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
  105. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
  106. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
  107. package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
  108. package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
  109. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
  110. package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
  111. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
  112. package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
  113. package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
  114. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
  115. package/node_modules/engine.io-client/build/esm-debug/socket.js +757 -0
  116. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
  117. package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
  118. package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
  119. package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
  120. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
  121. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
  122. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
  123. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
  124. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
  125. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
  126. package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
  127. package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
  128. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
  129. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
  130. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
  131. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
  132. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
  133. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
  134. package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
  135. package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
  136. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
  137. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
  138. package/node_modules/engine.io-client/dist/engine.io.js +3094 -0
  139. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
  140. package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
  141. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
  142. package/node_modules/engine.io-client/package.json +95 -0
  143. package/node_modules/engine.io-parser/LICENSE +22 -0
  144. package/node_modules/engine.io-parser/Readme.md +158 -0
  145. package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
  146. package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
  147. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
  148. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
  149. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
  150. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
  151. package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
  152. package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
  153. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
  154. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
  155. package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
  156. package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
  157. package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
  158. package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
  159. package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
  160. package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
  161. package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
  162. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
  163. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
  164. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
  165. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
  166. package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
  167. package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
  168. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
  169. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
  170. package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
  171. package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
  172. package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
  173. package/node_modules/engine.io-parser/build/esm/index.js +156 -0
  174. package/node_modules/engine.io-parser/build/esm/package.json +8 -0
  175. package/node_modules/engine.io-parser/package.json +46 -0
  176. package/node_modules/ms/index.js +162 -0
  177. package/node_modules/ms/license.md +21 -0
  178. package/node_modules/ms/package.json +38 -0
  179. package/node_modules/ms/readme.md +59 -0
  180. package/node_modules/socket.io-client/LICENSE +21 -0
  181. package/node_modules/socket.io-client/README.md +29 -0
  182. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
  183. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
  184. package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
  185. package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
  186. package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
  187. package/node_modules/socket.io-client/build/cjs/index.js +76 -0
  188. package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
  189. package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
  190. package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
  191. package/node_modules/socket.io-client/build/cjs/on.js +9 -0
  192. package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
  193. package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
  194. package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
  195. package/node_modules/socket.io-client/build/cjs/url.js +69 -0
  196. package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
  197. package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
  198. package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
  199. package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
  200. package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
  201. package/node_modules/socket.io-client/build/esm/index.js +58 -0
  202. package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
  203. package/node_modules/socket.io-client/build/esm/manager.js +367 -0
  204. package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
  205. package/node_modules/socket.io-client/build/esm/on.js +6 -0
  206. package/node_modules/socket.io-client/build/esm/package.json +5 -0
  207. package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
  208. package/node_modules/socket.io-client/build/esm/socket.js +880 -0
  209. package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
  210. package/node_modules/socket.io-client/build/esm/url.js +59 -0
  211. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
  212. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  213. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
  214. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
  215. package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
  216. package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
  217. package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
  218. package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
  219. package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
  220. package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
  221. package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
  222. package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
  223. package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
  224. package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
  225. package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
  226. package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
  227. package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
  228. package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
  229. package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
  230. package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
  231. package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
  232. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
  233. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
  234. package/node_modules/socket.io-client/package.json +101 -0
  235. package/node_modules/socket.io-parser/LICENSE +20 -0
  236. package/node_modules/socket.io-parser/Readme.md +81 -0
  237. package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
  238. package/node_modules/socket.io-parser/build/cjs/binary.js +90 -0
  239. package/node_modules/socket.io-parser/build/cjs/index.d.ts +101 -0
  240. package/node_modules/socket.io-parser/build/cjs/index.js +366 -0
  241. package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
  242. package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
  243. package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
  244. package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
  245. package/node_modules/socket.io-parser/build/esm/binary.js +86 -0
  246. package/node_modules/socket.io-parser/build/esm/index.d.ts +101 -0
  247. package/node_modules/socket.io-parser/build/esm/index.js +352 -0
  248. package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
  249. package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
  250. package/node_modules/socket.io-parser/build/esm/package.json +3 -0
  251. package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
  252. package/node_modules/socket.io-parser/build/esm-debug/binary.js +86 -0
  253. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +101 -0
  254. package/node_modules/socket.io-parser/build/esm-debug/index.js +357 -0
  255. package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
  256. package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
  257. package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
  258. package/node_modules/socket.io-parser/package.json +44 -0
  259. package/node_modules/ws/LICENSE +20 -0
  260. package/node_modules/ws/README.md +548 -0
  261. package/node_modules/ws/browser.js +8 -0
  262. package/node_modules/ws/index.js +22 -0
  263. package/node_modules/ws/lib/buffer-util.js +131 -0
  264. package/node_modules/ws/lib/constants.js +19 -0
  265. package/node_modules/ws/lib/event-target.js +292 -0
  266. package/node_modules/ws/lib/extension.js +203 -0
  267. package/node_modules/ws/lib/limiter.js +55 -0
  268. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  269. package/node_modules/ws/lib/receiver.js +743 -0
  270. package/node_modules/ws/lib/sender.js +607 -0
  271. package/node_modules/ws/lib/stream.js +161 -0
  272. package/node_modules/ws/lib/subprotocol.js +62 -0
  273. package/node_modules/ws/lib/validation.js +152 -0
  274. package/node_modules/ws/lib/websocket-server.js +562 -0
  275. package/node_modules/ws/lib/websocket.js +1407 -0
  276. package/node_modules/ws/package.json +74 -0
  277. package/node_modules/ws/wrapper.mjs +21 -0
  278. package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
  279. package/node_modules/xmlhttprequest-ssl/README.md +67 -0
  280. package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
  281. package/node_modules/xmlhttprequest-ssl/package.json +40 -0
  282. package/openclaw.plugin.json +60 -0
  283. package/package.json +48 -0
@@ -0,0 +1,366 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
7
+ exports.isPacketValid = isPacketValid;
8
+ const component_emitter_1 = require("@socket.io/component-emitter");
9
+ const binary_js_1 = require("./binary.js");
10
+ const is_binary_js_1 = require("./is-binary.js");
11
+ const debug_1 = __importDefault(require("debug")); // debug()
12
+ const debug = (0, debug_1.default)("socket.io-parser"); // debug()
13
+ /**
14
+ * These strings must not be used as event names, as they have a special meaning.
15
+ */
16
+ const RESERVED_EVENTS = [
17
+ "connect", // used on the client side
18
+ "connect_error", // used on the client side
19
+ "disconnect", // used on both sides
20
+ "disconnecting", // used on the server side
21
+ "newListener", // used by the Node.js EventEmitter
22
+ "removeListener", // used by the Node.js EventEmitter
23
+ ];
24
+ /**
25
+ * Protocol version.
26
+ *
27
+ * @public
28
+ */
29
+ exports.protocol = 5;
30
+ var PacketType;
31
+ (function (PacketType) {
32
+ PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
33
+ PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
34
+ PacketType[PacketType["EVENT"] = 2] = "EVENT";
35
+ PacketType[PacketType["ACK"] = 3] = "ACK";
36
+ PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
37
+ PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
38
+ PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
39
+ })(PacketType || (exports.PacketType = PacketType = {}));
40
+ /**
41
+ * A socket.io Encoder instance
42
+ */
43
+ class Encoder {
44
+ /**
45
+ * Encoder constructor
46
+ *
47
+ * @param {function} replacer - custom replacer to pass down to JSON.parse
48
+ */
49
+ constructor(replacer) {
50
+ this.replacer = replacer;
51
+ }
52
+ /**
53
+ * Encode a packet as a single string if non-binary, or as a
54
+ * buffer sequence, depending on packet type.
55
+ *
56
+ * @param {Object} obj - packet object
57
+ */
58
+ encode(obj) {
59
+ debug("encoding packet %j", obj);
60
+ if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
61
+ if ((0, is_binary_js_1.hasBinary)(obj)) {
62
+ return this.encodeAsBinary({
63
+ type: obj.type === PacketType.EVENT
64
+ ? PacketType.BINARY_EVENT
65
+ : PacketType.BINARY_ACK,
66
+ nsp: obj.nsp,
67
+ data: obj.data,
68
+ id: obj.id,
69
+ });
70
+ }
71
+ }
72
+ return [this.encodeAsString(obj)];
73
+ }
74
+ /**
75
+ * Encode packet as string.
76
+ */
77
+ encodeAsString(obj) {
78
+ // first is type
79
+ let str = "" + obj.type;
80
+ // attachments if we have them
81
+ if (obj.type === PacketType.BINARY_EVENT ||
82
+ obj.type === PacketType.BINARY_ACK) {
83
+ str += obj.attachments + "-";
84
+ }
85
+ // if we have a namespace other than `/`
86
+ // we append it followed by a comma `,`
87
+ if (obj.nsp && "/" !== obj.nsp) {
88
+ str += obj.nsp + ",";
89
+ }
90
+ // immediately followed by the id
91
+ if (null != obj.id) {
92
+ str += obj.id;
93
+ }
94
+ // json data
95
+ if (null != obj.data) {
96
+ str += JSON.stringify(obj.data, this.replacer);
97
+ }
98
+ debug("encoded %j as %s", obj, str);
99
+ return str;
100
+ }
101
+ /**
102
+ * Encode packet as 'buffer sequence' by removing blobs, and
103
+ * deconstructing packet into object with placeholders and
104
+ * a list of buffers.
105
+ */
106
+ encodeAsBinary(obj) {
107
+ const deconstruction = (0, binary_js_1.deconstructPacket)(obj);
108
+ const pack = this.encodeAsString(deconstruction.packet);
109
+ const buffers = deconstruction.buffers;
110
+ buffers.unshift(pack); // add packet info to beginning of data list
111
+ return buffers; // write all the buffers
112
+ }
113
+ }
114
+ exports.Encoder = Encoder;
115
+ /**
116
+ * A socket.io Decoder instance
117
+ *
118
+ * @return {Object} decoder
119
+ */
120
+ class Decoder extends component_emitter_1.Emitter {
121
+ /**
122
+ * Decoder constructor
123
+ */
124
+ constructor(opts) {
125
+ super();
126
+ this.opts = Object.assign({
127
+ reviver: undefined,
128
+ maxAttachments: 10,
129
+ }, typeof opts === "function" ? { reviver: opts } : opts);
130
+ }
131
+ /**
132
+ * Decodes an encoded packet string into packet JSON.
133
+ *
134
+ * @param {String} obj - encoded packet
135
+ */
136
+ add(obj) {
137
+ let packet;
138
+ if (typeof obj === "string") {
139
+ if (this.reconstructor) {
140
+ throw new Error("got plaintext data when reconstructing a packet");
141
+ }
142
+ packet = this.decodeString(obj);
143
+ const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
144
+ if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
145
+ packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
146
+ // binary packet's json
147
+ this.reconstructor = new BinaryReconstructor(packet);
148
+ }
149
+ else {
150
+ // non-binary full packet
151
+ super.emitReserved("decoded", packet);
152
+ }
153
+ }
154
+ else if ((0, is_binary_js_1.isBinary)(obj) || obj.base64) {
155
+ // raw binary data
156
+ if (!this.reconstructor) {
157
+ throw new Error("got binary data when not reconstructing a packet");
158
+ }
159
+ else {
160
+ packet = this.reconstructor.takeBinaryData(obj);
161
+ if (packet) {
162
+ // received final buffer
163
+ this.reconstructor = null;
164
+ super.emitReserved("decoded", packet);
165
+ }
166
+ }
167
+ }
168
+ else {
169
+ throw new Error("Unknown type: " + obj);
170
+ }
171
+ }
172
+ /**
173
+ * Decode a packet String (JSON data)
174
+ *
175
+ * @param {String} str
176
+ * @return {Object} packet
177
+ */
178
+ decodeString(str) {
179
+ let i = 0;
180
+ // look up type
181
+ const p = {
182
+ type: Number(str.charAt(0)),
183
+ };
184
+ if (PacketType[p.type] === undefined) {
185
+ throw new Error("unknown packet type " + p.type);
186
+ }
187
+ // look up attachments if type binary
188
+ if (p.type === PacketType.BINARY_EVENT ||
189
+ p.type === PacketType.BINARY_ACK) {
190
+ const start = i + 1;
191
+ while (str.charAt(++i) !== "-" && i != str.length) { }
192
+ const buf = str.substring(start, i);
193
+ if (buf != Number(buf) || str.charAt(i) !== "-") {
194
+ throw new Error("Illegal attachments");
195
+ }
196
+ const n = Number(buf);
197
+ if (!isInteger(n) || n < 1) {
198
+ throw new Error("Illegal attachments");
199
+ }
200
+ else if (n > this.opts.maxAttachments) {
201
+ throw new Error("too many attachments");
202
+ }
203
+ p.attachments = n;
204
+ }
205
+ // look up namespace (if any)
206
+ if ("/" === str.charAt(i + 1)) {
207
+ const start = i + 1;
208
+ while (++i) {
209
+ const c = str.charAt(i);
210
+ if ("," === c)
211
+ break;
212
+ if (i === str.length)
213
+ break;
214
+ }
215
+ p.nsp = str.substring(start, i);
216
+ }
217
+ else {
218
+ p.nsp = "/";
219
+ }
220
+ // look up id
221
+ const next = str.charAt(i + 1);
222
+ if ("" !== next && Number(next) == next) {
223
+ const start = i + 1;
224
+ while (++i) {
225
+ const c = str.charAt(i);
226
+ if (null == c || Number(c) != c) {
227
+ --i;
228
+ break;
229
+ }
230
+ if (i === str.length)
231
+ break;
232
+ }
233
+ p.id = Number(str.substring(start, i + 1));
234
+ }
235
+ // look up json data
236
+ if (str.charAt(++i)) {
237
+ const payload = this.tryParse(str.substr(i));
238
+ if (Decoder.isPayloadValid(p.type, payload)) {
239
+ p.data = payload;
240
+ }
241
+ else {
242
+ throw new Error("invalid payload");
243
+ }
244
+ }
245
+ debug("decoded %s as %j", str, p);
246
+ return p;
247
+ }
248
+ tryParse(str) {
249
+ try {
250
+ return JSON.parse(str, this.opts.reviver);
251
+ }
252
+ catch (e) {
253
+ return false;
254
+ }
255
+ }
256
+ static isPayloadValid(type, payload) {
257
+ switch (type) {
258
+ case PacketType.CONNECT:
259
+ return isObject(payload);
260
+ case PacketType.DISCONNECT:
261
+ return payload === undefined;
262
+ case PacketType.CONNECT_ERROR:
263
+ return typeof payload === "string" || isObject(payload);
264
+ case PacketType.EVENT:
265
+ case PacketType.BINARY_EVENT:
266
+ return (Array.isArray(payload) &&
267
+ (typeof payload[0] === "number" ||
268
+ (typeof payload[0] === "string" &&
269
+ RESERVED_EVENTS.indexOf(payload[0]) === -1)));
270
+ case PacketType.ACK:
271
+ case PacketType.BINARY_ACK:
272
+ return Array.isArray(payload);
273
+ }
274
+ }
275
+ /**
276
+ * Deallocates a parser's resources
277
+ */
278
+ destroy() {
279
+ if (this.reconstructor) {
280
+ this.reconstructor.finishedReconstruction();
281
+ this.reconstructor = null;
282
+ }
283
+ }
284
+ }
285
+ exports.Decoder = Decoder;
286
+ /**
287
+ * A manager of a binary event's 'buffer sequence'. Should
288
+ * be constructed whenever a packet of type BINARY_EVENT is
289
+ * decoded.
290
+ *
291
+ * @param {Object} packet
292
+ * @return {BinaryReconstructor} initialized reconstructor
293
+ */
294
+ class BinaryReconstructor {
295
+ constructor(packet) {
296
+ this.packet = packet;
297
+ this.buffers = [];
298
+ this.reconPack = packet;
299
+ }
300
+ /**
301
+ * Method to be called when binary data received from connection
302
+ * after a BINARY_EVENT packet.
303
+ *
304
+ * @param {Buffer | ArrayBuffer} binData - the raw binary data received
305
+ * @return {null | Object} returns null if more binary data is expected or
306
+ * a reconstructed packet object if all buffers have been received.
307
+ */
308
+ takeBinaryData(binData) {
309
+ this.buffers.push(binData);
310
+ if (this.buffers.length === this.reconPack.attachments) {
311
+ // done with buffer list
312
+ const packet = (0, binary_js_1.reconstructPacket)(this.reconPack, this.buffers);
313
+ this.finishedReconstruction();
314
+ return packet;
315
+ }
316
+ return null;
317
+ }
318
+ /**
319
+ * Cleans up binary packet reconstruction variables.
320
+ */
321
+ finishedReconstruction() {
322
+ this.reconPack = null;
323
+ this.buffers = [];
324
+ }
325
+ }
326
+ function isNamespaceValid(nsp) {
327
+ return typeof nsp === "string";
328
+ }
329
+ // see https://caniuse.com/mdn-javascript_builtins_number_isinteger
330
+ const isInteger = Number.isInteger ||
331
+ function (value) {
332
+ return (typeof value === "number" &&
333
+ isFinite(value) &&
334
+ Math.floor(value) === value);
335
+ };
336
+ function isAckIdValid(id) {
337
+ return id === undefined || isInteger(id);
338
+ }
339
+ // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
340
+ function isObject(value) {
341
+ return Object.prototype.toString.call(value) === "[object Object]";
342
+ }
343
+ function isDataValid(type, payload) {
344
+ switch (type) {
345
+ case PacketType.CONNECT:
346
+ return payload === undefined || isObject(payload);
347
+ case PacketType.DISCONNECT:
348
+ return payload === undefined;
349
+ case PacketType.EVENT:
350
+ return (Array.isArray(payload) &&
351
+ (typeof payload[0] === "number" ||
352
+ (typeof payload[0] === "string" &&
353
+ RESERVED_EVENTS.indexOf(payload[0]) === -1)));
354
+ case PacketType.ACK:
355
+ return Array.isArray(payload);
356
+ case PacketType.CONNECT_ERROR:
357
+ return typeof payload === "string" || isObject(payload);
358
+ default:
359
+ return false;
360
+ }
361
+ }
362
+ function isPacketValid(packet) {
363
+ return (isNamespaceValid(packet.nsp) &&
364
+ isAckIdValid(packet.id) &&
365
+ isDataValid(packet.type, packet.data));
366
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
3
+ *
4
+ * @private
5
+ */
6
+ export declare function isBinary(obj: any): boolean;
7
+ export declare function hasBinary(obj: any, toJSON?: boolean): boolean;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBinary = isBinary;
4
+ exports.hasBinary = hasBinary;
5
+ const withNativeArrayBuffer = typeof ArrayBuffer === "function";
6
+ const isView = (obj) => {
7
+ return typeof ArrayBuffer.isView === "function"
8
+ ? ArrayBuffer.isView(obj)
9
+ : obj.buffer instanceof ArrayBuffer;
10
+ };
11
+ const toString = Object.prototype.toString;
12
+ const withNativeBlob = typeof Blob === "function" ||
13
+ (typeof Blob !== "undefined" &&
14
+ toString.call(Blob) === "[object BlobConstructor]");
15
+ const withNativeFile = typeof File === "function" ||
16
+ (typeof File !== "undefined" &&
17
+ toString.call(File) === "[object FileConstructor]");
18
+ /**
19
+ * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
20
+ *
21
+ * @private
22
+ */
23
+ function isBinary(obj) {
24
+ return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
25
+ (withNativeBlob && obj instanceof Blob) ||
26
+ (withNativeFile && obj instanceof File));
27
+ }
28
+ function hasBinary(obj, toJSON) {
29
+ if (!obj || typeof obj !== "object") {
30
+ return false;
31
+ }
32
+ if (Array.isArray(obj)) {
33
+ for (let i = 0, l = obj.length; i < l; i++) {
34
+ if (hasBinary(obj[i])) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+ if (isBinary(obj)) {
41
+ return true;
42
+ }
43
+ if (obj.toJSON &&
44
+ typeof obj.toJSON === "function" &&
45
+ arguments.length === 1) {
46
+ return hasBinary(obj.toJSON(), true);
47
+ }
48
+ for (const key in obj) {
49
+ if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
50
+ return true;
51
+ }
52
+ }
53
+ return false;
54
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
3
+ *
4
+ * @param {Object} packet - socket.io event packet
5
+ * @return {Object} with deconstructed packet and list of buffers
6
+ * @public
7
+ */
8
+ export declare function deconstructPacket(packet: any): {
9
+ packet: any;
10
+ buffers: any[];
11
+ };
12
+ /**
13
+ * Reconstructs a binary packet from its placeholder packet and buffers
14
+ *
15
+ * @param {Object} packet - event packet with placeholders
16
+ * @param {Array} buffers - binary buffers to put in placeholder positions
17
+ * @return {Object} reconstructed packet
18
+ * @public
19
+ */
20
+ export declare function reconstructPacket(packet: any, buffers: any): any;
@@ -0,0 +1,86 @@
1
+ import { isBinary } from "./is-binary.js";
2
+ /**
3
+ * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
4
+ *
5
+ * @param {Object} packet - socket.io event packet
6
+ * @return {Object} with deconstructed packet and list of buffers
7
+ * @public
8
+ */
9
+ export function deconstructPacket(packet) {
10
+ const buffers = [];
11
+ const packetData = packet.data;
12
+ const pack = packet;
13
+ pack.data = _deconstructPacket(packetData, buffers);
14
+ pack.attachments = buffers.length; // number of binary 'attachments'
15
+ return { packet: pack, buffers: buffers };
16
+ }
17
+ function _deconstructPacket(data, buffers, toJSON) {
18
+ if (!data)
19
+ return data;
20
+ if (isBinary(data)) {
21
+ const placeholder = { _placeholder: true, num: buffers.length };
22
+ buffers.push(data);
23
+ return placeholder;
24
+ }
25
+ else if (Array.isArray(data)) {
26
+ const newData = new Array(data.length);
27
+ for (let i = 0; i < data.length; i++) {
28
+ newData[i] = _deconstructPacket(data[i], buffers);
29
+ }
30
+ return newData;
31
+ }
32
+ else if (typeof data === "object" && !(data instanceof Date)) {
33
+ if (data.toJSON && typeof data.toJSON === "function" && !toJSON) {
34
+ return _deconstructPacket(data.toJSON(), buffers, true);
35
+ }
36
+ const newData = {};
37
+ for (const key in data) {
38
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
39
+ newData[key] = _deconstructPacket(data[key], buffers);
40
+ }
41
+ }
42
+ return newData;
43
+ }
44
+ return data;
45
+ }
46
+ /**
47
+ * Reconstructs a binary packet from its placeholder packet and buffers
48
+ *
49
+ * @param {Object} packet - event packet with placeholders
50
+ * @param {Array} buffers - binary buffers to put in placeholder positions
51
+ * @return {Object} reconstructed packet
52
+ * @public
53
+ */
54
+ export function reconstructPacket(packet, buffers) {
55
+ packet.data = _reconstructPacket(packet.data, buffers);
56
+ delete packet.attachments; // no longer useful
57
+ return packet;
58
+ }
59
+ function _reconstructPacket(data, buffers) {
60
+ if (!data)
61
+ return data;
62
+ if (data && data._placeholder === true) {
63
+ const isIndexValid = typeof data.num === "number" &&
64
+ data.num >= 0 &&
65
+ data.num < buffers.length;
66
+ if (isIndexValid) {
67
+ return buffers[data.num]; // appropriate buffer (should be natural order anyway)
68
+ }
69
+ else {
70
+ throw new Error("illegal attachments");
71
+ }
72
+ }
73
+ else if (Array.isArray(data)) {
74
+ for (let i = 0; i < data.length; i++) {
75
+ data[i] = _reconstructPacket(data[i], buffers);
76
+ }
77
+ }
78
+ else if (typeof data === "object") {
79
+ for (const key in data) {
80
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
81
+ data[key] = _reconstructPacket(data[key], buffers);
82
+ }
83
+ }
84
+ }
85
+ return data;
86
+ }
@@ -0,0 +1,101 @@
1
+ import { Emitter } from "@socket.io/component-emitter";
2
+ /**
3
+ * Protocol version.
4
+ *
5
+ * @public
6
+ */
7
+ export declare const protocol: number;
8
+ export declare enum PacketType {
9
+ CONNECT = 0,
10
+ DISCONNECT = 1,
11
+ EVENT = 2,
12
+ ACK = 3,
13
+ CONNECT_ERROR = 4,
14
+ BINARY_EVENT = 5,
15
+ BINARY_ACK = 6
16
+ }
17
+ export interface Packet {
18
+ type: PacketType;
19
+ nsp: string;
20
+ data?: any;
21
+ id?: number;
22
+ attachments?: number;
23
+ }
24
+ /**
25
+ * A socket.io Encoder instance
26
+ */
27
+ export declare class Encoder {
28
+ private replacer?;
29
+ /**
30
+ * Encoder constructor
31
+ *
32
+ * @param {function} replacer - custom replacer to pass down to JSON.parse
33
+ */
34
+ constructor(replacer?: (this: any, key: string, value: any) => any);
35
+ /**
36
+ * Encode a packet as a single string if non-binary, or as a
37
+ * buffer sequence, depending on packet type.
38
+ *
39
+ * @param {Object} obj - packet object
40
+ */
41
+ encode(obj: Packet): any[];
42
+ /**
43
+ * Encode packet as string.
44
+ */
45
+ private encodeAsString;
46
+ /**
47
+ * Encode packet as 'buffer sequence' by removing blobs, and
48
+ * deconstructing packet into object with placeholders and
49
+ * a list of buffers.
50
+ */
51
+ private encodeAsBinary;
52
+ }
53
+ interface DecoderReservedEvents {
54
+ decoded: (packet: Packet) => void;
55
+ }
56
+ type JSONReviver = (this: any, key: string, value: any) => any;
57
+ export interface DecoderOptions {
58
+ /**
59
+ * Custom reviver to pass down to JSON.parse()
60
+ */
61
+ reviver?: JSONReviver;
62
+ /**
63
+ * Maximum number of binary attachments per packet
64
+ * @default 10
65
+ */
66
+ maxAttachments?: number;
67
+ }
68
+ /**
69
+ * A socket.io Decoder instance
70
+ *
71
+ * @return {Object} decoder
72
+ */
73
+ export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
74
+ private reconstructor;
75
+ private opts;
76
+ /**
77
+ * Decoder constructor
78
+ */
79
+ constructor(opts?: DecoderOptions | JSONReviver);
80
+ /**
81
+ * Decodes an encoded packet string into packet JSON.
82
+ *
83
+ * @param {String} obj - encoded packet
84
+ */
85
+ add(obj: any): void;
86
+ /**
87
+ * Decode a packet String (JSON data)
88
+ *
89
+ * @param {String} str
90
+ * @return {Object} packet
91
+ */
92
+ private decodeString;
93
+ private tryParse;
94
+ private static isPayloadValid;
95
+ /**
96
+ * Deallocates a parser's resources
97
+ */
98
+ destroy(): void;
99
+ }
100
+ export declare function isPacketValid(packet: Packet): boolean;
101
+ export {};