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