@walkhi/code-relax 0.1.0-beta.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 +83 -0
- package/dist/bin/codex-remote.mjs +262 -0
- package/dist/bin/self-relay-demo.mjs +33 -0
- package/dist/bin/self-relay-server.mjs +50 -0
- package/dist/get-lan-networks.ps1 +40 -0
- package/dist/get-shared-service-url.ps1 +6 -0
- package/dist/shared/app-server-events.cjs +266 -0
- package/dist/shared/p2p-diagnostics.cjs +28 -0
- package/dist/shared/server-requests.cjs +67 -0
- package/dist/shared/timeline-sync.cjs +67 -0
- package/dist/skills/code-relax/SKILL.md +17 -0
- package/dist/src/app-server-client.mjs +468 -0
- package/dist/src/app-server-tasks.mjs +355 -0
- package/dist/src/background-process.mjs +18 -0
- package/dist/src/debug-ui.mjs +131 -0
- package/dist/src/desktop-launcher.mjs +51 -0
- package/dist/src/execution-health.mjs +26 -0
- package/dist/src/lan-socket-server.mjs +103 -0
- package/dist/src/managed-app-server.mjs +207 -0
- package/dist/src/message-images.mjs +27 -0
- package/dist/src/onboarding.mjs +31 -0
- package/dist/src/platform/README.md +12 -0
- package/dist/src/platform/linux/README.md +3 -0
- package/dist/src/platform/macos/README.md +3 -0
- package/dist/src/platform/windows/IsolatedProcess.cs +75 -0
- package/dist/src/platform/windows/background-process.mjs +25 -0
- package/dist/src/platform/windows/credential-store.mjs +27 -0
- package/dist/src/platform/windows/credential-store.ps1 +49 -0
- package/dist/src/platform/windows/desktop-host.mjs +38 -0
- package/dist/src/platform/windows/desktop-info.ps1 +16 -0
- package/dist/src/platform/windows/desktop-monitor.mjs +34 -0
- package/dist/src/platform/windows/desktop-shortcut-run.ps1 +5 -0
- package/dist/src/platform/windows/desktop-shortcuts.ps1 +28 -0
- package/dist/src/platform/windows/desktop-tools.mjs +48 -0
- package/dist/src/platform/windows/launch-worker.ps1 +13 -0
- package/dist/src/platform/windows/network-info.mjs +34 -0
- package/dist/src/platform/windows/resident-start.ps1 +7 -0
- package/dist/src/platform/windows/resident-startup.ps1 +27 -0
- package/dist/src/platform/windows/resolve-state-root.ps1 +14 -0
- package/dist/src/platform/windows/runtime-paths.mjs +20 -0
- package/dist/src/platform/windows/service-host.mjs +43 -0
- package/dist/src/platform/windows/start-hidden-console.ps1 +39 -0
- package/dist/src/platform/windows/stop-desktop.ps1 +19 -0
- package/dist/src/platform/windows/user-environment.mjs +50 -0
- package/dist/src/platform/windows/user-environment.ps1 +41 -0
- package/dist/src/self-relay/client.mjs +59 -0
- package/dist/src/self-relay/connector.mjs +147 -0
- package/dist/src/self-relay/debug-allowlist.mjs +33 -0
- package/dist/src/self-relay/demo.mjs +38 -0
- package/dist/src/self-relay/device-store.mjs +84 -0
- package/dist/src/self-relay/lan-authorizations.mjs +29 -0
- package/dist/src/self-relay/lifecycle.mjs +281 -0
- package/dist/src/self-relay/p2p-probe.mjs +83 -0
- package/dist/src/self-relay/server.mjs +340 -0
- package/dist/src/self-relay/windows-route-helper.mjs +75 -0
- package/dist/src/self-relay/wire.mjs +36 -0
- package/dist/src/server.mjs +2086 -0
- package/dist/src/service-control.mjs +72 -0
- package/dist/src/service-doctor.mjs +63 -0
- package/dist/src/service-health.mjs +33 -0
- package/dist/src/service-install.mjs +91 -0
- package/dist/src/service-lifecycle.mjs +130 -0
- package/dist/src/service-restart.mjs +48 -0
- package/dist/src/shared-app-server.mjs +356 -0
- package/dist/src/shared-catalog.mjs +60 -0
- package/dist/src/shared-recovery.mjs +142 -0
- package/dist/src/shared-thread-stream.mjs +80 -0
- package/dist/src/skill-install.mjs +64 -0
- package/dist/src/thread-catalog.mjs +42 -0
- package/dist/src/thread-title-generation.mjs +150 -0
- package/dist/tools/find-desktop-pipe.mjs +10 -0
- package/dist/tools/rtc-route-helper.ps1 +99 -0
- package/dist/tools/start-rtc-route-helper.ps1 +15 -0
- package/dist/web/approval-ui.js +188 -0
- package/dist/web/capabilities.js +57 -0
- package/dist/web/chat-transport.js +196 -0
- package/dist/web/chat.css +736 -0
- package/dist/web/chat.js +5149 -0
- package/dist/web/client-platform.js +11 -0
- package/dist/web/harmony-platform.js +51 -0
- package/dist/web/highlight-powershell.min.js +39 -0
- package/dist/web/highlight.min.js +1262 -0
- package/dist/web/history-cache.js +146 -0
- package/dist/web/index.html +222 -0
- package/dist/web/lan-session.js +122 -0
- package/dist/web/p2p-diagnostics.js +28 -0
- package/dist/web/p2p-probe.js +83 -0
- package/dist/web/resources.json +1 -0
- package/dist/web/self-relay-session.js +119 -0
- package/dist/web/server-requests.js +67 -0
- package/dist/web/timeline-sync.js +67 -0
- package/dist/web/vendor/README.md +14 -0
- package/dist/web/vendor/highlight-powershell.min.js +39 -0
- package/dist/web/vendor/highlight.LICENSE.txt +29 -0
- package/dist/web/vendor/highlight.min.js +1262 -0
- package/dist/web/vendor/markdown-it.LICENSE.txt +22 -0
- package/dist/web/vendor/markdown-it.umd.min.js +14 -0
- package/node_modules/@img/colour/LICENSE.md +82 -0
- package/node_modules/@img/colour/README.md +15 -0
- package/node_modules/@img/colour/color.cjs +1596 -0
- package/node_modules/@img/colour/index.cjs +1 -0
- package/node_modules/@img/colour/index.d.ts +929 -0
- package/node_modules/@img/colour/package.json +58 -0
- package/node_modules/@img/sharp-win32-x64/LICENSE +191 -0
- package/node_modules/@img/sharp-win32-x64/README.md +59 -0
- package/node_modules/@img/sharp-win32-x64/index.cjs +1 -0
- package/node_modules/@img/sharp-win32-x64/lib/libvips-42.dll +0 -0
- package/node_modules/@img/sharp-win32-x64/lib/libvips-cpp-8.18.6.dll +0 -0
- package/node_modules/@img/sharp-win32-x64/lib/sharp-win32-x64-0.35.4.node +0 -0
- package/node_modules/@img/sharp-win32-x64/package.json +40 -0
- package/node_modules/@img/sharp-win32-x64/versions.json +30 -0
- package/node_modules/@node-datachannel/win32-x64-msvc/node_datachannel.node +0 -0
- package/node_modules/@node-datachannel/win32-x64-msvc/package.json +20 -0
- package/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/camelcase/index.d.ts +63 -0
- package/node_modules/camelcase/index.js +76 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +43 -0
- package/node_modules/camelcase/readme.md +99 -0
- package/node_modules/cliui/CHANGELOG.md +76 -0
- package/node_modules/cliui/LICENSE.txt +14 -0
- package/node_modules/cliui/README.md +115 -0
- package/node_modules/cliui/index.js +354 -0
- package/node_modules/cliui/package.json +65 -0
- package/node_modules/color-convert/CHANGELOG.md +54 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/decamelize/index.js +13 -0
- package/node_modules/decamelize/license +21 -0
- package/node_modules/decamelize/package.json +38 -0
- package/node_modules/decamelize/readme.md +48 -0
- package/node_modules/detect-libc/LICENSE +201 -0
- package/node_modules/detect-libc/README.md +163 -0
- package/node_modules/detect-libc/index.d.ts +14 -0
- package/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/node_modules/detect-libc/lib/elf.js +39 -0
- package/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/node_modules/detect-libc/lib/process.js +24 -0
- package/node_modules/detect-libc/package.json +44 -0
- package/node_modules/dijkstrajs/.travis.yml +4 -0
- package/node_modules/dijkstrajs/CONTRIBUTING.md +8 -0
- package/node_modules/dijkstrajs/LICENSE.md +19 -0
- package/node_modules/dijkstrajs/README.md +18 -0
- package/node_modules/dijkstrajs/dijkstra.js +165 -0
- package/node_modules/dijkstrajs/package.json +60 -0
- package/node_modules/dijkstrajs/test/dijkstra.test.js +96 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/find-up/index.d.ts +137 -0
- package/node_modules/find-up/index.js +89 -0
- package/node_modules/find-up/license +9 -0
- package/node_modules/find-up/package.json +53 -0
- package/node_modules/find-up/readme.md +156 -0
- package/node_modules/get-caller-file/LICENSE.md +6 -0
- package/node_modules/get-caller-file/README.md +41 -0
- package/node_modules/get-caller-file/index.d.ts +2 -0
- package/node_modules/get-caller-file/index.js +22 -0
- package/node_modules/get-caller-file/index.js.map +1 -0
- package/node_modules/get-caller-file/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/locate-path/index.d.ts +83 -0
- package/node_modules/locate-path/index.js +65 -0
- package/node_modules/locate-path/license +9 -0
- package/node_modules/locate-path/package.json +45 -0
- package/node_modules/locate-path/readme.md +122 -0
- package/node_modules/node-datachannel/.clang-format +17 -0
- package/node_modules/node-datachannel/.editorconfig +12 -0
- package/node_modules/node-datachannel/.eslintignore +8 -0
- package/node_modules/node-datachannel/.eslintrc.json +27 -0
- package/node_modules/node-datachannel/.gitmodules +3 -0
- package/node_modules/node-datachannel/.prettierignore +7 -0
- package/node_modules/node-datachannel/.prettierrc +13 -0
- package/node_modules/node-datachannel/API.md +247 -0
- package/node_modules/node-datachannel/BULDING.md +26 -0
- package/node_modules/node-datachannel/CMakeLists.txt +153 -0
- package/node_modules/node-datachannel/LICENSE +373 -0
- package/node_modules/node-datachannel/README.md +129 -0
- package/node_modules/node-datachannel/dist/cjs/index.cjs +11 -0
- package/node_modules/node-datachannel/dist/cjs/index.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/lib/datachannel-stream.cjs +101 -0
- package/node_modules/node-datachannel/dist/cjs/lib/datachannel-stream.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/lib/index.cjs +91 -0
- package/node_modules/node-datachannel/dist/cjs/lib/index.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/lib/node-datachannel.cjs +94 -0
- package/node_modules/node-datachannel/dist/cjs/lib/node-datachannel.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/lib/websocket-server.cjs +45 -0
- package/node_modules/node-datachannel/dist/cjs/lib/websocket-server.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/lib/websocket.cjs +8 -0
- package/node_modules/node-datachannel/dist/cjs/lib/websocket.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/Events.cjs +86 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/Events.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/Exception.cjs +34 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/Exception.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCCertificate.cjs +34 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCCertificate.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDataChannel.cjs +214 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDtlsTransport.cjs +53 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCError.cjs +83 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCError.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceCandidate.cjs +132 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceCandidate.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceTransport.cjs +94 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceTransport.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCPeerConnection.cjs +434 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSctpTransport.cjs +59 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSessionDescription.cjs +45 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSessionDescription.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/index.cjs +42 -0
- package/node_modules/node-datachannel/dist/cjs/polyfill/index.cjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/index.mjs +8 -0
- package/node_modules/node-datachannel/dist/esm/index.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/lib/datachannel-stream.mjs +78 -0
- package/node_modules/node-datachannel/dist/esm/lib/datachannel-stream.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/lib/index.mjs +64 -0
- package/node_modules/node-datachannel/dist/esm/lib/index.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/lib/node-datachannel.mjs +78 -0
- package/node_modules/node-datachannel/dist/esm/lib/node-datachannel.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/lib/websocket-server.mjs +43 -0
- package/node_modules/node-datachannel/dist/esm/lib/websocket-server.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/lib/websocket.mjs +6 -0
- package/node_modules/node-datachannel/dist/esm/lib/websocket.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/Events.mjs +82 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/Events.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/Exception.mjs +28 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/Exception.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCCertificate.mjs +30 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCCertificate.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCDataChannel.mjs +210 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCDtlsTransport.mjs +49 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCError.mjs +79 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCError.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceCandidate.mjs +128 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceCandidate.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceTransport.mjs +89 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceTransport.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCPeerConnection.mjs +430 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCSctpTransport.mjs +55 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCSessionDescription.mjs +41 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/RTCSessionDescription.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/index.mjs +27 -0
- package/node_modules/node-datachannel/dist/esm/polyfill/index.mjs.map +1 -0
- package/node_modules/node-datachannel/dist/types/lib/datachannel-stream.d.ts +24 -0
- package/node_modules/node-datachannel/dist/types/lib/index.d.ts +241 -0
- package/node_modules/node-datachannel/dist/types/lib/types.d.ts +119 -0
- package/node_modules/node-datachannel/dist/types/lib/websocket-server.d.ts +13 -0
- package/node_modules/node-datachannel/dist/types/lib/websocket.d.ts +25 -0
- package/node_modules/node-datachannel/dist/types/polyfill/Events.d.ts +15 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCCertificate.d.ts +9 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCDataChannel.d.ts +29 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCDtlsTransport.d.ts +15 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCError.d.ts +17 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCIceCandidate.d.ts +21 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCIceTransport.d.ts +30 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCPeerConnection.d.ts +64 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCSctpTransport.d.ts +15 -0
- package/node_modules/node-datachannel/dist/types/polyfill/RTCSessionDescription.d.ts +10 -0
- package/node_modules/node-datachannel/dist/types/polyfill/index.d.ts +26 -0
- package/node_modules/node-datachannel/jest.config.ts +14 -0
- package/node_modules/node-datachannel/package.json +133 -0
- package/node_modules/node-datachannel/rollup.config.mjs +67 -0
- package/node_modules/node-datachannel/src/cpp/data-channel-wrapper.cpp +530 -0
- package/node_modules/node-datachannel/src/cpp/data-channel-wrapper.h +63 -0
- package/node_modules/node-datachannel/src/cpp/ice-udp-mux-listener-wrapper.cpp +172 -0
- package/node_modules/node-datachannel/src/cpp/ice-udp-mux-listener-wrapper.h +43 -0
- package/node_modules/node-datachannel/src/cpp/main.cpp +58 -0
- package/node_modules/node-datachannel/src/cpp/media-audio-wrapper.cpp +457 -0
- package/node_modules/node-datachannel/src/cpp/media-audio-wrapper.h +52 -0
- package/node_modules/node-datachannel/src/cpp/media-av1packetization.cpp +24 -0
- package/node_modules/node-datachannel/src/cpp/media-av1packetization.h +11 -0
- package/node_modules/node-datachannel/src/cpp/media-av1rtppacketizer-wrapper.cpp +126 -0
- package/node_modules/node-datachannel/src/cpp/media-av1rtppacketizer-wrapper.h +29 -0
- package/node_modules/node-datachannel/src/cpp/media-direction.cpp +43 -0
- package/node_modules/node-datachannel/src/cpp/media-direction.h +10 -0
- package/node_modules/node-datachannel/src/cpp/media-h264rtppacketizer-wrapper.cpp +126 -0
- package/node_modules/node-datachannel/src/cpp/media-h264rtppacketizer-wrapper.h +30 -0
- package/node_modules/node-datachannel/src/cpp/media-h265rtppacketizer-wrapper.cpp +126 -0
- package/node_modules/node-datachannel/src/cpp/media-h265rtppacketizer-wrapper.h +30 -0
- package/node_modules/node-datachannel/src/cpp/media-h26xseparator.cpp +32 -0
- package/node_modules/node-datachannel/src/cpp/media-h26xseparator.h +11 -0
- package/node_modules/node-datachannel/src/cpp/media-mediahandler-helper.cpp +31 -0
- package/node_modules/node-datachannel/src/cpp/media-mediahandler-helper.h +11 -0
- package/node_modules/node-datachannel/src/cpp/media-pacinghandler-wrapper.cpp +79 -0
- package/node_modules/node-datachannel/src/cpp/media-pacinghandler-wrapper.h +28 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpnackresponder-wrapper.cpp +68 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpnackresponder-wrapper.h +28 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpreceivingsession-wrapper.cpp +57 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpreceivingsession-wrapper.h +28 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpsrreporter-wrapper.cpp +93 -0
- package/node_modules/node-datachannel/src/cpp/media-rtcpsrreporter-wrapper.h +30 -0
- package/node_modules/node-datachannel/src/cpp/media-rtppacketizationconfig-wrapper.cpp +167 -0
- package/node_modules/node-datachannel/src/cpp/media-rtppacketizationconfig-wrapper.h +35 -0
- package/node_modules/node-datachannel/src/cpp/media-rtppacketizer-wrapper.cpp +95 -0
- package/node_modules/node-datachannel/src/cpp/media-rtppacketizer-wrapper.h +30 -0
- package/node_modules/node-datachannel/src/cpp/media-track-wrapper.cpp +458 -0
- package/node_modules/node-datachannel/src/cpp/media-track-wrapper.h +61 -0
- package/node_modules/node-datachannel/src/cpp/media-video-wrapper.cpp +526 -0
- package/node_modules/node-datachannel/src/cpp/media-video-wrapper.h +56 -0
- package/node_modules/node-datachannel/src/cpp/peer-connection-wrapper.cpp +1298 -0
- package/node_modules/node-datachannel/src/cpp/peer-connection-wrapper.h +89 -0
- package/node_modules/node-datachannel/src/cpp/rtc-wrapper.cpp +205 -0
- package/node_modules/node-datachannel/src/cpp/rtc-wrapper.h +24 -0
- package/node_modules/node-datachannel/src/cpp/thread-safe-callback.cpp +57 -0
- package/node_modules/node-datachannel/src/cpp/thread-safe-callback.h +47 -0
- package/node_modules/node-datachannel/src/cpp/web-socket-server-wrapper.cpp +275 -0
- package/node_modules/node-datachannel/src/cpp/web-socket-server-wrapper.h +41 -0
- package/node_modules/node-datachannel/src/cpp/web-socket-wrapper.cpp +796 -0
- package/node_modules/node-datachannel/src/cpp/web-socket-wrapper.h +63 -0
- package/node_modules/node-datachannel/src/index.ts +9 -0
- package/node_modules/node-datachannel/src/lib/datachannel-stream.ts +100 -0
- package/node_modules/node-datachannel/src/lib/index.ts +290 -0
- package/node_modules/node-datachannel/src/lib/node-datachannel.ts +84 -0
- package/node_modules/node-datachannel/src/lib/types.ts +169 -0
- package/node_modules/node-datachannel/src/lib/websocket-server.ts +37 -0
- package/node_modules/node-datachannel/src/lib/websocket.ts +26 -0
- package/node_modules/node-datachannel/src/polyfill/Events.ts +82 -0
- package/node_modules/node-datachannel/src/polyfill/Exception.ts +37 -0
- package/node_modules/node-datachannel/src/polyfill/README.md +41 -0
- package/node_modules/node-datachannel/src/polyfill/RTCCertificate.ts +21 -0
- package/node_modules/node-datachannel/src/polyfill/RTCDataChannel.ts +225 -0
- package/node_modules/node-datachannel/src/polyfill/RTCDtlsTransport.ts +46 -0
- package/node_modules/node-datachannel/src/polyfill/RTCError.ts +78 -0
- package/node_modules/node-datachannel/src/polyfill/RTCIceCandidate.ts +128 -0
- package/node_modules/node-datachannel/src/polyfill/RTCIceTransport.ts +90 -0
- package/node_modules/node-datachannel/src/polyfill/RTCPeerConnection.ts +527 -0
- package/node_modules/node-datachannel/src/polyfill/RTCSctpTransport.ts +51 -0
- package/node_modules/node-datachannel/src/polyfill/RTCSessionDescription.ts +41 -0
- package/node_modules/node-datachannel/src/polyfill/index.ts +38 -0
- package/node_modules/node-datachannel/tsconfig.json +21 -0
- package/node_modules/p-limit/index.d.ts +38 -0
- package/node_modules/p-limit/index.js +57 -0
- package/node_modules/p-limit/license +9 -0
- package/node_modules/p-limit/package.json +52 -0
- package/node_modules/p-limit/readme.md +101 -0
- package/node_modules/p-locate/index.d.ts +64 -0
- package/node_modules/p-locate/index.js +52 -0
- package/node_modules/p-locate/license +9 -0
- package/node_modules/p-locate/package.json +53 -0
- package/node_modules/p-locate/readme.md +90 -0
- package/node_modules/p-try/index.d.ts +39 -0
- package/node_modules/p-try/index.js +9 -0
- package/node_modules/p-try/license +9 -0
- package/node_modules/p-try/package.json +42 -0
- package/node_modules/p-try/readme.md +58 -0
- package/node_modules/path-exists/index.d.ts +28 -0
- package/node_modules/path-exists/index.js +23 -0
- package/node_modules/path-exists/license +9 -0
- package/node_modules/path-exists/package.json +39 -0
- package/node_modules/path-exists/readme.md +52 -0
- package/node_modules/pngjs/.eslintignore +2 -0
- package/node_modules/pngjs/.eslintrc.json +19 -0
- package/node_modules/pngjs/.prettierignore +3 -0
- package/node_modules/pngjs/LICENSE +20 -0
- package/node_modules/pngjs/README.md +429 -0
- package/node_modules/pngjs/browser.js +16096 -0
- package/node_modules/pngjs/coverage/lcov-report/base.css +354 -0
- package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +881 -0
- package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +554 -0
- package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +77 -0
- package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +647 -0
- package/node_modules/pngjs/coverage/lcov-report/constants.js.html +176 -0
- package/node_modules/pngjs/coverage/lcov-report/crc.js.html +200 -0
- package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +593 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +152 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +143 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +611 -0
- package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +359 -0
- package/node_modules/pngjs/coverage/lcov-report/index.html +426 -0
- package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +365 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +230 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +248 -0
- package/node_modules/pngjs/coverage/lcov-report/packer.js.html +467 -0
- package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +128 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +575 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +404 -0
- package/node_modules/pngjs/coverage/lcov-report/parser.js.html +950 -0
- package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +116 -0
- package/node_modules/pngjs/coverage/lcov-report/png.js.html +662 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.css +101 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.js +1007 -0
- package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/sorter.js +169 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +584 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +215 -0
- package/node_modules/pngjs/coverage/lcov.info +2177 -0
- package/node_modules/pngjs/lib/bitmapper.js +267 -0
- package/node_modules/pngjs/lib/bitpacker.js +158 -0
- package/node_modules/pngjs/lib/chunkstream.js +189 -0
- package/node_modules/pngjs/lib/constants.js +32 -0
- package/node_modules/pngjs/lib/crc.js +40 -0
- package/node_modules/pngjs/lib/filter-pack.js +171 -0
- package/node_modules/pngjs/lib/filter-parse-async.js +24 -0
- package/node_modules/pngjs/lib/filter-parse-sync.js +21 -0
- package/node_modules/pngjs/lib/filter-parse.js +177 -0
- package/node_modules/pngjs/lib/format-normaliser.js +93 -0
- package/node_modules/pngjs/lib/interlace.js +95 -0
- package/node_modules/pngjs/lib/packer-async.js +50 -0
- package/node_modules/pngjs/lib/packer-sync.js +56 -0
- package/node_modules/pngjs/lib/packer.js +129 -0
- package/node_modules/pngjs/lib/paeth-predictor.js +16 -0
- package/node_modules/pngjs/lib/parser-async.js +165 -0
- package/node_modules/pngjs/lib/parser-sync.js +108 -0
- package/node_modules/pngjs/lib/parser.js +290 -0
- package/node_modules/pngjs/lib/png-sync.js +12 -0
- package/node_modules/pngjs/lib/png.js +194 -0
- package/node_modules/pngjs/lib/sync-inflate.js +168 -0
- package/node_modules/pngjs/lib/sync-reader.js +45 -0
- package/node_modules/pngjs/package.json +73 -0
- package/node_modules/qrcode/README.md +770 -0
- package/node_modules/qrcode/bin/qrcode +159 -0
- package/node_modules/qrcode/helper/to-sjis-browser.js +2 -0
- package/node_modules/qrcode/helper/to-sjis.js +105 -0
- package/node_modules/qrcode/lib/browser.js +76 -0
- package/node_modules/qrcode/lib/can-promise.js +7 -0
- package/node_modules/qrcode/lib/core/alignment-pattern.js +83 -0
- package/node_modules/qrcode/lib/core/alphanumeric-data.js +59 -0
- package/node_modules/qrcode/lib/core/bit-buffer.js +37 -0
- package/node_modules/qrcode/lib/core/bit-matrix.js +65 -0
- package/node_modules/qrcode/lib/core/byte-data.js +30 -0
- package/node_modules/qrcode/lib/core/error-correction-code.js +135 -0
- package/node_modules/qrcode/lib/core/error-correction-level.js +50 -0
- package/node_modules/qrcode/lib/core/finder-pattern.js +22 -0
- package/node_modules/qrcode/lib/core/format-info.js +29 -0
- package/node_modules/qrcode/lib/core/galois-field.js +69 -0
- package/node_modules/qrcode/lib/core/kanji-data.js +54 -0
- package/node_modules/qrcode/lib/core/mask-pattern.js +234 -0
- package/node_modules/qrcode/lib/core/mode.js +167 -0
- package/node_modules/qrcode/lib/core/numeric-data.js +43 -0
- package/node_modules/qrcode/lib/core/polynomial.js +62 -0
- package/node_modules/qrcode/lib/core/qrcode.js +495 -0
- package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +56 -0
- package/node_modules/qrcode/lib/core/regex.js +31 -0
- package/node_modules/qrcode/lib/core/segments.js +330 -0
- package/node_modules/qrcode/lib/core/utils.js +63 -0
- package/node_modules/qrcode/lib/core/version-check.js +9 -0
- package/node_modules/qrcode/lib/core/version.js +163 -0
- package/node_modules/qrcode/lib/index.js +12 -0
- package/node_modules/qrcode/lib/renderer/canvas.js +63 -0
- package/node_modules/qrcode/lib/renderer/png.js +78 -0
- package/node_modules/qrcode/lib/renderer/svg-tag.js +81 -0
- package/node_modules/qrcode/lib/renderer/svg.js +19 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +85 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal.js +49 -0
- package/node_modules/qrcode/lib/renderer/terminal.js +9 -0
- package/node_modules/qrcode/lib/renderer/utf8.js +71 -0
- package/node_modules/qrcode/lib/renderer/utils.js +99 -0
- package/node_modules/qrcode/lib/server.js +138 -0
- package/node_modules/qrcode/license +10 -0
- package/node_modules/qrcode/package.json +77 -0
- package/node_modules/require-directory/.jshintrc +67 -0
- package/node_modules/require-directory/.npmignore +1 -0
- package/node_modules/require-directory/.travis.yml +3 -0
- package/node_modules/require-directory/LICENSE +22 -0
- package/node_modules/require-directory/README.markdown +184 -0
- package/node_modules/require-directory/index.js +86 -0
- package/node_modules/require-directory/package.json +40 -0
- package/node_modules/require-main-filename/CHANGELOG.md +26 -0
- package/node_modules/require-main-filename/LICENSE.txt +14 -0
- package/node_modules/require-main-filename/README.md +26 -0
- package/node_modules/require-main-filename/index.js +18 -0
- package/node_modules/require-main-filename/package.json +35 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +680 -0
- package/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/semver/classes/index.js +7 -0
- package/node_modules/semver/classes/range.js +577 -0
- package/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/semver/functions/major.js +5 -0
- package/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/semver/index.js +93 -0
- package/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/semver/internal/re.js +223 -0
- package/node_modules/semver/package.json +78 -0
- package/node_modules/semver/preload.js +4 -0
- package/node_modules/semver/range.bnf +17 -0
- package/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/set-blocking/CHANGELOG.md +26 -0
- package/node_modules/set-blocking/LICENSE.txt +14 -0
- package/node_modules/set-blocking/README.md +31 -0
- package/node_modules/set-blocking/index.js +7 -0
- package/node_modules/set-blocking/package.json +42 -0
- package/node_modules/sharp/LICENSE +191 -0
- package/node_modules/sharp/README.md +112 -0
- package/node_modules/sharp/dist/channel.cjs +177 -0
- package/node_modules/sharp/dist/channel.mjs +177 -0
- package/node_modules/sharp/dist/colour.cjs +199 -0
- package/node_modules/sharp/dist/colour.mjs +199 -0
- package/node_modules/sharp/dist/composite.cjs +213 -0
- package/node_modules/sharp/dist/composite.mjs +213 -0
- package/node_modules/sharp/dist/constructor.cjs +511 -0
- package/node_modules/sharp/dist/constructor.mjs +511 -0
- package/node_modules/sharp/dist/index.cjs +25 -0
- package/node_modules/sharp/dist/index.d.cts +1999 -0
- package/node_modules/sharp/dist/index.d.mts +2046 -0
- package/node_modules/sharp/dist/index.mjs +25 -0
- package/node_modules/sharp/dist/input.cjs +819 -0
- package/node_modules/sharp/dist/input.mjs +819 -0
- package/node_modules/sharp/dist/is.cjs +143 -0
- package/node_modules/sharp/dist/is.mjs +143 -0
- package/node_modules/sharp/dist/libvips.cjs +212 -0
- package/node_modules/sharp/dist/libvips.mjs +212 -0
- package/node_modules/sharp/dist/operation.cjs +1002 -0
- package/node_modules/sharp/dist/operation.mjs +1002 -0
- package/node_modules/sharp/dist/output.cjs +1785 -0
- package/node_modules/sharp/dist/output.mjs +1785 -0
- package/node_modules/sharp/dist/resize.cjs +617 -0
- package/node_modules/sharp/dist/resize.mjs +617 -0
- package/node_modules/sharp/dist/sharp.cjs +174 -0
- package/node_modules/sharp/dist/sharp.mjs +174 -0
- package/node_modules/sharp/dist/utility.cjs +301 -0
- package/node_modules/sharp/dist/utility.mjs +301 -0
- package/node_modules/sharp/install/build.js +38 -0
- package/node_modules/sharp/lib/index.d.ts +1999 -0
- package/node_modules/sharp/package.json +227 -0
- package/node_modules/sharp/src/binding.gyp +303 -0
- package/node_modules/sharp/src/common.cc +1186 -0
- package/node_modules/sharp/src/common.h +421 -0
- package/node_modules/sharp/src/metadata.cc +404 -0
- package/node_modules/sharp/src/metadata.h +95 -0
- package/node_modules/sharp/src/operations.cc +516 -0
- package/node_modules/sharp/src/operations.h +137 -0
- package/node_modules/sharp/src/pipeline.cc +1948 -0
- package/node_modules/sharp/src/pipeline.h +422 -0
- package/node_modules/sharp/src/sharp.cc +43 -0
- package/node_modules/sharp/src/stats.cc +186 -0
- package/node_modules/sharp/src/stats.h +62 -0
- package/node_modules/sharp/src/utilities.cc +289 -0
- package/node_modules/sharp/src/utilities.h +22 -0
- package/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/string-width/index.js +47 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +56 -0
- package/node_modules/string-width/readme.md +50 -0
- package/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/which-module/LICENSE +13 -0
- package/node_modules/which-module/README.md +58 -0
- package/node_modules/which-module/index.js +9 -0
- package/node_modules/which-module/package.json +41 -0
- package/node_modules/wrap-ansi/index.js +186 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +61 -0
- package/node_modules/wrap-ansi/readme.md +97 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1407 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/node_modules/y18n/CHANGELOG.md +35 -0
- package/node_modules/y18n/LICENSE +13 -0
- package/node_modules/y18n/README.md +109 -0
- package/node_modules/y18n/index.js +188 -0
- package/node_modules/y18n/package.json +39 -0
- package/node_modules/yargs/CHANGELOG.md +420 -0
- package/node_modules/yargs/LICENSE +21 -0
- package/node_modules/yargs/README.md +140 -0
- package/node_modules/yargs/build/lib/apply-extends.d.ts +2 -0
- package/node_modules/yargs/build/lib/apply-extends.js +65 -0
- package/node_modules/yargs/build/lib/argsert.d.ts +2 -0
- package/node_modules/yargs/build/lib/argsert.js +65 -0
- package/node_modules/yargs/build/lib/command.d.ts +64 -0
- package/node_modules/yargs/build/lib/command.js +416 -0
- package/node_modules/yargs/build/lib/common-types.d.ts +36 -0
- package/node_modules/yargs/build/lib/common-types.js +25 -0
- package/node_modules/yargs/build/lib/completion-templates.d.ts +2 -0
- package/node_modules/yargs/build/lib/completion-templates.js +50 -0
- package/node_modules/yargs/build/lib/completion.d.ts +21 -0
- package/node_modules/yargs/build/lib/completion.js +135 -0
- package/node_modules/yargs/build/lib/is-promise.d.ts +1 -0
- package/node_modules/yargs/build/lib/is-promise.js +9 -0
- package/node_modules/yargs/build/lib/levenshtein.d.ts +1 -0
- package/node_modules/yargs/build/lib/levenshtein.js +58 -0
- package/node_modules/yargs/build/lib/middleware.d.ts +10 -0
- package/node_modules/yargs/build/lib/middleware.js +57 -0
- package/node_modules/yargs/build/lib/obj-filter.d.ts +1 -0
- package/node_modules/yargs/build/lib/obj-filter.js +14 -0
- package/node_modules/yargs/build/lib/parse-command.d.ts +11 -0
- package/node_modules/yargs/build/lib/parse-command.js +36 -0
- package/node_modules/yargs/build/lib/process-argv.d.ts +2 -0
- package/node_modules/yargs/build/lib/process-argv.js +31 -0
- package/node_modules/yargs/build/lib/usage.d.ts +49 -0
- package/node_modules/yargs/build/lib/usage.js +540 -0
- package/node_modules/yargs/build/lib/validation.d.ts +34 -0
- package/node_modules/yargs/build/lib/validation.js +330 -0
- package/node_modules/yargs/build/lib/yargs.d.ts +274 -0
- package/node_modules/yargs/build/lib/yargs.js +1190 -0
- package/node_modules/yargs/build/lib/yerror.d.ts +4 -0
- package/node_modules/yargs/build/lib/yerror.js +11 -0
- package/node_modules/yargs/index.js +40 -0
- package/node_modules/yargs/locales/be.json +46 -0
- package/node_modules/yargs/locales/de.json +46 -0
- package/node_modules/yargs/locales/en.json +51 -0
- package/node_modules/yargs/locales/es.json +46 -0
- package/node_modules/yargs/locales/fi.json +49 -0
- package/node_modules/yargs/locales/fr.json +53 -0
- package/node_modules/yargs/locales/hi.json +49 -0
- package/node_modules/yargs/locales/hu.json +46 -0
- package/node_modules/yargs/locales/id.json +50 -0
- package/node_modules/yargs/locales/it.json +46 -0
- package/node_modules/yargs/locales/ja.json +51 -0
- package/node_modules/yargs/locales/ko.json +49 -0
- package/node_modules/yargs/locales/nb.json +44 -0
- package/node_modules/yargs/locales/nl.json +49 -0
- package/node_modules/yargs/locales/nn.json +44 -0
- package/node_modules/yargs/locales/pirate.json +13 -0
- package/node_modules/yargs/locales/pl.json +49 -0
- package/node_modules/yargs/locales/pt.json +45 -0
- package/node_modules/yargs/locales/pt_BR.json +48 -0
- package/node_modules/yargs/locales/ru.json +46 -0
- package/node_modules/yargs/locales/th.json +46 -0
- package/node_modules/yargs/locales/tr.json +48 -0
- package/node_modules/yargs/locales/zh_CN.json +48 -0
- package/node_modules/yargs/locales/zh_TW.json +47 -0
- package/node_modules/yargs/package.json +92 -0
- package/node_modules/yargs/yargs.js +14 -0
- package/node_modules/yargs-parser/CHANGELOG.md +601 -0
- package/node_modules/yargs-parser/LICENSE.txt +14 -0
- package/node_modules/yargs-parser/README.md +449 -0
- package/node_modules/yargs-parser/index.js +1032 -0
- package/node_modules/yargs-parser/lib/tokenize-arg-string.js +40 -0
- package/node_modules/yargs-parser/package.json +46 -0
- package/package.json +50 -0
- package/tools/postinstall.mjs +9 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const EventEmitter = require('events');
|
|
6
|
+
const http = require('http');
|
|
7
|
+
const { Duplex } = require('stream');
|
|
8
|
+
const { createHash } = require('crypto');
|
|
9
|
+
|
|
10
|
+
const extension = require('./extension');
|
|
11
|
+
const PerMessageDeflate = require('./permessage-deflate');
|
|
12
|
+
const subprotocol = require('./subprotocol');
|
|
13
|
+
const WebSocket = require('./websocket');
|
|
14
|
+
const { CLOSE_TIMEOUT, GUID, kWebSocket } = require('./constants');
|
|
15
|
+
|
|
16
|
+
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
17
|
+
|
|
18
|
+
const RUNNING = 0;
|
|
19
|
+
const CLOSING = 1;
|
|
20
|
+
const CLOSED = 2;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Class representing a WebSocket server.
|
|
24
|
+
*
|
|
25
|
+
* @extends EventEmitter
|
|
26
|
+
*/
|
|
27
|
+
class WebSocketServer extends EventEmitter {
|
|
28
|
+
/**
|
|
29
|
+
* Create a `WebSocketServer` instance.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} options Configuration options
|
|
32
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
33
|
+
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
34
|
+
* multiple times in the same tick
|
|
35
|
+
* @param {Boolean} [options.autoPong=true] Specifies whether or not to
|
|
36
|
+
* automatically send a pong in response to a ping
|
|
37
|
+
* @param {Number} [options.backlog=511] The maximum length of the queue of
|
|
38
|
+
* pending connections
|
|
39
|
+
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
|
40
|
+
* track clients
|
|
41
|
+
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
|
|
42
|
+
* wait for the closing handshake to finish after `websocket.close()` is
|
|
43
|
+
* called
|
|
44
|
+
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
45
|
+
* @param {String} [options.host] The hostname where to bind the server
|
|
46
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
47
|
+
* buffered data chunks
|
|
48
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
49
|
+
* fragments
|
|
50
|
+
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
51
|
+
* size
|
|
52
|
+
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
53
|
+
* @param {String} [options.path] Accept only connections matching this path
|
|
54
|
+
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
|
55
|
+
* permessage-deflate
|
|
56
|
+
* @param {Number} [options.port] The port where to bind the server
|
|
57
|
+
* @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
|
|
58
|
+
* server to use
|
|
59
|
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
60
|
+
* not to skip UTF-8 validation for text and close messages
|
|
61
|
+
* @param {Function} [options.verifyClient] A hook to reject connections
|
|
62
|
+
* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
|
|
63
|
+
* class to use. It must be the `WebSocket` class or class that extends it
|
|
64
|
+
* @param {Function} [callback] A listener for the `listening` event
|
|
65
|
+
*/
|
|
66
|
+
constructor(options, callback) {
|
|
67
|
+
super();
|
|
68
|
+
|
|
69
|
+
options = {
|
|
70
|
+
allowSynchronousEvents: true,
|
|
71
|
+
autoPong: true,
|
|
72
|
+
maxBufferedChunks: 256 * 1024,
|
|
73
|
+
maxFragments: 16 * 1024,
|
|
74
|
+
maxPayload: 100 * 1024 * 1024,
|
|
75
|
+
skipUTF8Validation: false,
|
|
76
|
+
perMessageDeflate: false,
|
|
77
|
+
handleProtocols: null,
|
|
78
|
+
clientTracking: true,
|
|
79
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
80
|
+
verifyClient: null,
|
|
81
|
+
noServer: false,
|
|
82
|
+
backlog: null, // use default (511 as implemented in net.js)
|
|
83
|
+
server: null,
|
|
84
|
+
host: null,
|
|
85
|
+
path: null,
|
|
86
|
+
port: null,
|
|
87
|
+
WebSocket,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
(options.port == null && !options.server && !options.noServer) ||
|
|
93
|
+
(options.port != null && (options.server || options.noServer)) ||
|
|
94
|
+
(options.server && options.noServer)
|
|
95
|
+
) {
|
|
96
|
+
throw new TypeError(
|
|
97
|
+
'One and only one of the "port", "server", or "noServer" options ' +
|
|
98
|
+
'must be specified'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (options.port != null) {
|
|
103
|
+
this._server = http.createServer((req, res) => {
|
|
104
|
+
const body = http.STATUS_CODES[426];
|
|
105
|
+
|
|
106
|
+
res.writeHead(426, {
|
|
107
|
+
'Content-Length': body.length,
|
|
108
|
+
'Content-Type': 'text/plain'
|
|
109
|
+
});
|
|
110
|
+
res.end(body);
|
|
111
|
+
});
|
|
112
|
+
this._server.listen(
|
|
113
|
+
options.port,
|
|
114
|
+
options.host,
|
|
115
|
+
options.backlog,
|
|
116
|
+
callback
|
|
117
|
+
);
|
|
118
|
+
} else if (options.server) {
|
|
119
|
+
this._server = options.server;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this._server) {
|
|
123
|
+
const emitConnection = this.emit.bind(this, 'connection');
|
|
124
|
+
|
|
125
|
+
this._removeListeners = addListeners(this._server, {
|
|
126
|
+
listening: this.emit.bind(this, 'listening'),
|
|
127
|
+
error: this.emit.bind(this, 'error'),
|
|
128
|
+
upgrade: (req, socket, head) => {
|
|
129
|
+
this.handleUpgrade(req, socket, head, emitConnection);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (options.perMessageDeflate === true) options.perMessageDeflate = {};
|
|
135
|
+
if (options.clientTracking) {
|
|
136
|
+
this.clients = new Set();
|
|
137
|
+
this._shouldEmitClose = false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.options = options;
|
|
141
|
+
this._state = RUNNING;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns the bound address, the address family name, and port of the server
|
|
146
|
+
* as reported by the operating system if listening on an IP socket.
|
|
147
|
+
* If the server is listening on a pipe or UNIX domain socket, the name is
|
|
148
|
+
* returned as a string.
|
|
149
|
+
*
|
|
150
|
+
* @return {(Object|String|null)} The address of the server
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
address() {
|
|
154
|
+
if (this.options.noServer) {
|
|
155
|
+
throw new Error('The server is operating in "noServer" mode');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!this._server) return null;
|
|
159
|
+
return this._server.address();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Stop the server from accepting new connections and emit the `'close'` event
|
|
164
|
+
* when all existing connections are closed.
|
|
165
|
+
*
|
|
166
|
+
* @param {Function} [cb] A one-time listener for the `'close'` event
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
close(cb) {
|
|
170
|
+
if (this._state === CLOSED) {
|
|
171
|
+
if (cb) {
|
|
172
|
+
this.once('close', () => {
|
|
173
|
+
cb(new Error('The server is not running'));
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
process.nextTick(emitClose, this);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (cb) this.once('close', cb);
|
|
182
|
+
|
|
183
|
+
if (this._state === CLOSING) return;
|
|
184
|
+
this._state = CLOSING;
|
|
185
|
+
|
|
186
|
+
if (this.options.noServer || this.options.server) {
|
|
187
|
+
if (this._server) {
|
|
188
|
+
this._removeListeners();
|
|
189
|
+
this._removeListeners = this._server = null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.clients) {
|
|
193
|
+
if (!this.clients.size) {
|
|
194
|
+
process.nextTick(emitClose, this);
|
|
195
|
+
} else {
|
|
196
|
+
this._shouldEmitClose = true;
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
process.nextTick(emitClose, this);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const server = this._server;
|
|
203
|
+
|
|
204
|
+
this._removeListeners();
|
|
205
|
+
this._removeListeners = this._server = null;
|
|
206
|
+
|
|
207
|
+
//
|
|
208
|
+
// The HTTP/S server was created internally. Close it, and rely on its
|
|
209
|
+
// `'close'` event.
|
|
210
|
+
//
|
|
211
|
+
server.close(() => {
|
|
212
|
+
emitClose(this);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* See if a given request should be handled by this server instance.
|
|
219
|
+
*
|
|
220
|
+
* @param {http.IncomingMessage} req Request object to inspect
|
|
221
|
+
* @return {Boolean} `true` if the request is valid, else `false`
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
shouldHandle(req) {
|
|
225
|
+
if (this.options.path) {
|
|
226
|
+
const index = req.url.indexOf('?');
|
|
227
|
+
const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
|
|
228
|
+
|
|
229
|
+
if (pathname !== this.options.path) return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Handle a HTTP Upgrade request.
|
|
237
|
+
*
|
|
238
|
+
* @param {http.IncomingMessage} req The request object
|
|
239
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
240
|
+
* @param {Buffer} head The first packet of the upgraded stream
|
|
241
|
+
* @param {Function} cb Callback
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
handleUpgrade(req, socket, head, cb) {
|
|
245
|
+
socket.on('error', socketOnError);
|
|
246
|
+
|
|
247
|
+
const key = req.headers['sec-websocket-key'];
|
|
248
|
+
const upgrade = req.headers.upgrade;
|
|
249
|
+
const version = +req.headers['sec-websocket-version'];
|
|
250
|
+
|
|
251
|
+
if (req.method !== 'GET') {
|
|
252
|
+
const message = 'Invalid HTTP method';
|
|
253
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (upgrade === undefined || upgrade.toLowerCase() !== 'websocket') {
|
|
258
|
+
const message = 'Invalid Upgrade header';
|
|
259
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (key === undefined || !keyRegex.test(key)) {
|
|
264
|
+
const message = 'Missing or invalid Sec-WebSocket-Key header';
|
|
265
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (version !== 13 && version !== 8) {
|
|
270
|
+
const message = 'Missing or invalid Sec-WebSocket-Version header';
|
|
271
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
272
|
+
'Sec-WebSocket-Version': '13, 8'
|
|
273
|
+
});
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!this.shouldHandle(req)) {
|
|
278
|
+
abortHandshake(socket, 400);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const secWebSocketProtocol = req.headers['sec-websocket-protocol'];
|
|
283
|
+
let protocols = new Set();
|
|
284
|
+
|
|
285
|
+
if (secWebSocketProtocol !== undefined) {
|
|
286
|
+
try {
|
|
287
|
+
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
const message = 'Invalid Sec-WebSocket-Protocol header';
|
|
290
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const secWebSocketExtensions = req.headers['sec-websocket-extensions'];
|
|
296
|
+
const extensions = {};
|
|
297
|
+
|
|
298
|
+
if (
|
|
299
|
+
this.options.perMessageDeflate &&
|
|
300
|
+
secWebSocketExtensions !== undefined
|
|
301
|
+
) {
|
|
302
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
303
|
+
...this.options.perMessageDeflate,
|
|
304
|
+
isServer: true,
|
|
305
|
+
maxPayload: this.options.maxPayload
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
const offers = extension.parse(secWebSocketExtensions);
|
|
310
|
+
|
|
311
|
+
if (offers[PerMessageDeflate.extensionName]) {
|
|
312
|
+
perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
|
|
313
|
+
extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
314
|
+
}
|
|
315
|
+
} catch (err) {
|
|
316
|
+
const message =
|
|
317
|
+
'Invalid or unacceptable Sec-WebSocket-Extensions header';
|
|
318
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
//
|
|
324
|
+
// Optionally call external client verification handler.
|
|
325
|
+
//
|
|
326
|
+
if (this.options.verifyClient) {
|
|
327
|
+
const info = {
|
|
328
|
+
origin:
|
|
329
|
+
req.headers[`${version === 8 ? 'sec-websocket-origin' : 'origin'}`],
|
|
330
|
+
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
331
|
+
req
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
if (this.options.verifyClient.length === 2) {
|
|
335
|
+
this.options.verifyClient(info, (verified, code, message, headers) => {
|
|
336
|
+
if (!verified) {
|
|
337
|
+
return abortHandshake(socket, code || 401, message, headers);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
this.completeUpgrade(
|
|
341
|
+
extensions,
|
|
342
|
+
key,
|
|
343
|
+
protocols,
|
|
344
|
+
req,
|
|
345
|
+
socket,
|
|
346
|
+
head,
|
|
347
|
+
cb
|
|
348
|
+
);
|
|
349
|
+
});
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Upgrade the connection to WebSocket.
|
|
361
|
+
*
|
|
362
|
+
* @param {Object} extensions The accepted extensions
|
|
363
|
+
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
|
364
|
+
* @param {Set} protocols The subprotocols
|
|
365
|
+
* @param {http.IncomingMessage} req The request object
|
|
366
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
367
|
+
* @param {Buffer} head The first packet of the upgraded stream
|
|
368
|
+
* @param {Function} cb Callback
|
|
369
|
+
* @throws {Error} If called more than once with the same socket
|
|
370
|
+
* @private
|
|
371
|
+
*/
|
|
372
|
+
completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
|
|
373
|
+
//
|
|
374
|
+
// Destroy the socket if the client has already sent a FIN packet.
|
|
375
|
+
//
|
|
376
|
+
if (!socket.readable || !socket.writable) return socket.destroy();
|
|
377
|
+
|
|
378
|
+
if (socket[kWebSocket]) {
|
|
379
|
+
throw new Error(
|
|
380
|
+
'server.handleUpgrade() was called more than once with the same ' +
|
|
381
|
+
'socket, possibly due to a misconfiguration'
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
386
|
+
|
|
387
|
+
const digest = createHash('sha1')
|
|
388
|
+
.update(key + GUID)
|
|
389
|
+
.digest('base64');
|
|
390
|
+
|
|
391
|
+
const headers = [
|
|
392
|
+
'HTTP/1.1 101 Switching Protocols',
|
|
393
|
+
'Upgrade: websocket',
|
|
394
|
+
'Connection: Upgrade',
|
|
395
|
+
`Sec-WebSocket-Accept: ${digest}`
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
const ws = new this.options.WebSocket(null, undefined, this.options);
|
|
399
|
+
|
|
400
|
+
if (protocols.size) {
|
|
401
|
+
//
|
|
402
|
+
// Optionally call external protocol selection handler.
|
|
403
|
+
//
|
|
404
|
+
const protocol = this.options.handleProtocols
|
|
405
|
+
? this.options.handleProtocols(protocols, req)
|
|
406
|
+
: protocols.values().next().value;
|
|
407
|
+
|
|
408
|
+
if (protocol) {
|
|
409
|
+
headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
|
|
410
|
+
ws._protocol = protocol;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (extensions[PerMessageDeflate.extensionName]) {
|
|
415
|
+
const params = extensions[PerMessageDeflate.extensionName].params;
|
|
416
|
+
const value = extension.format({
|
|
417
|
+
[PerMessageDeflate.extensionName]: [params]
|
|
418
|
+
});
|
|
419
|
+
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
420
|
+
ws._extensions = extensions;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
//
|
|
424
|
+
// Allow external modification/inspection of handshake headers.
|
|
425
|
+
//
|
|
426
|
+
this.emit('headers', headers, req);
|
|
427
|
+
|
|
428
|
+
socket.write(headers.concat('\r\n').join('\r\n'));
|
|
429
|
+
socket.removeListener('error', socketOnError);
|
|
430
|
+
|
|
431
|
+
ws.setSocket(socket, head, {
|
|
432
|
+
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
433
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
434
|
+
maxFragments: this.options.maxFragments,
|
|
435
|
+
maxPayload: this.options.maxPayload,
|
|
436
|
+
skipUTF8Validation: this.options.skipUTF8Validation
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
if (this.clients) {
|
|
440
|
+
this.clients.add(ws);
|
|
441
|
+
ws.on('close', () => {
|
|
442
|
+
this.clients.delete(ws);
|
|
443
|
+
|
|
444
|
+
if (this._shouldEmitClose && !this.clients.size) {
|
|
445
|
+
process.nextTick(emitClose, this);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
cb(ws, req);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
module.exports = WebSocketServer;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Add event listeners on an `EventEmitter` using a map of <event, listener>
|
|
458
|
+
* pairs.
|
|
459
|
+
*
|
|
460
|
+
* @param {EventEmitter} server The event emitter
|
|
461
|
+
* @param {Object.<String, Function>} map The listeners to add
|
|
462
|
+
* @return {Function} A function that will remove the added listeners when
|
|
463
|
+
* called
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
function addListeners(server, map) {
|
|
467
|
+
for (const event of Object.keys(map)) server.on(event, map[event]);
|
|
468
|
+
|
|
469
|
+
return function removeListeners() {
|
|
470
|
+
for (const event of Object.keys(map)) {
|
|
471
|
+
server.removeListener(event, map[event]);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Emit a `'close'` event on an `EventEmitter`.
|
|
478
|
+
*
|
|
479
|
+
* @param {EventEmitter} server The event emitter
|
|
480
|
+
* @private
|
|
481
|
+
*/
|
|
482
|
+
function emitClose(server) {
|
|
483
|
+
server._state = CLOSED;
|
|
484
|
+
server.emit('close');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Handle socket errors.
|
|
489
|
+
*
|
|
490
|
+
* @private
|
|
491
|
+
*/
|
|
492
|
+
function socketOnError() {
|
|
493
|
+
this.destroy();
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Close the connection when preconditions are not fulfilled.
|
|
498
|
+
*
|
|
499
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
500
|
+
* @param {Number} code The HTTP response status code
|
|
501
|
+
* @param {String} [message] The HTTP response body
|
|
502
|
+
* @param {Object} [headers] Additional HTTP response headers
|
|
503
|
+
* @private
|
|
504
|
+
*/
|
|
505
|
+
function abortHandshake(socket, code, message, headers) {
|
|
506
|
+
//
|
|
507
|
+
// The socket is writable unless the user destroyed or ended it before calling
|
|
508
|
+
// `server.handleUpgrade()` or in the `verifyClient` function, which is a user
|
|
509
|
+
// error. Handling this does not make much sense as the worst that can happen
|
|
510
|
+
// is that some of the data written by the user might be discarded due to the
|
|
511
|
+
// call to `socket.end()` below, which triggers an `'error'` event that in
|
|
512
|
+
// turn causes the socket to be destroyed.
|
|
513
|
+
//
|
|
514
|
+
message = message || http.STATUS_CODES[code];
|
|
515
|
+
headers = {
|
|
516
|
+
Connection: 'close',
|
|
517
|
+
'Content-Type': 'text/html',
|
|
518
|
+
'Content-Length': Buffer.byteLength(message),
|
|
519
|
+
...headers
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
socket.once('finish', socket.destroy);
|
|
523
|
+
|
|
524
|
+
socket.end(
|
|
525
|
+
`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` +
|
|
526
|
+
Object.keys(headers)
|
|
527
|
+
.map((h) => `${h}: ${headers[h]}`)
|
|
528
|
+
.join('\r\n') +
|
|
529
|
+
'\r\n\r\n' +
|
|
530
|
+
message
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
|
|
536
|
+
* one listener for it, otherwise call `abortHandshake()`.
|
|
537
|
+
*
|
|
538
|
+
* @param {WebSocketServer} server The WebSocket server
|
|
539
|
+
* @param {http.IncomingMessage} req The request object
|
|
540
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
541
|
+
* @param {Number} code The HTTP response status code
|
|
542
|
+
* @param {String} message The HTTP response body
|
|
543
|
+
* @param {Object} [headers] The HTTP response headers
|
|
544
|
+
* @private
|
|
545
|
+
*/
|
|
546
|
+
function abortHandshakeOrEmitwsClientError(
|
|
547
|
+
server,
|
|
548
|
+
req,
|
|
549
|
+
socket,
|
|
550
|
+
code,
|
|
551
|
+
message,
|
|
552
|
+
headers
|
|
553
|
+
) {
|
|
554
|
+
if (server.listenerCount('wsClientError')) {
|
|
555
|
+
const err = new Error(message);
|
|
556
|
+
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
557
|
+
|
|
558
|
+
server.emit('wsClientError', err, socket, req);
|
|
559
|
+
} else {
|
|
560
|
+
abortHandshake(socket, code, message, headers);
|
|
561
|
+
}
|
|
562
|
+
}
|