@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,147 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import WebSocket from 'ws';
|
|
4
|
+
import { decode, loopbackUrl, relayAddress, send } from './wire.mjs';
|
|
5
|
+
import { createP2pProbe, validProbeSignal } from './p2p-probe.mjs';
|
|
6
|
+
import { createWindowsRouteHelper } from './windows-route-helper.mjs';
|
|
7
|
+
|
|
8
|
+
// Reuse the actual LAN dispatcher, including its normal/shared capability boundary.
|
|
9
|
+
// The LAN token never travels to the relay. No requests are replayed after a close.
|
|
10
|
+
export function connectBridgeRelay({ relayUrl, hostKey, bridgeUrl, bridgeToken, identity, bridgeConnection, hostName = 'Codex-PC', lanCandidates = [], p2pProbe = false, iceServers = [], p2pWindowsRouteHelper = false, p2pWindowsRouteHelperToken = '' }) {
|
|
11
|
+
relayAddress(relayUrl); loopbackUrl(bridgeUrl, '/api/socket');
|
|
12
|
+
if (!bridgeToken) throw new Error('Bridge token required');
|
|
13
|
+
const events = new EventEmitter();
|
|
14
|
+
const remote = new WebSocket(relayUrl, { maxPayload: 64 * 1024 * 1024, perMessageDeflate: {
|
|
15
|
+
serverNoContextTakeover: true, clientNoContextTakeover: true,
|
|
16
|
+
threshold: 1024, zlibDeflateOptions: { level: 3 },
|
|
17
|
+
} });
|
|
18
|
+
const locals = new Map();
|
|
19
|
+
let heartbeat, operation, lastClose;
|
|
20
|
+
const alive = () => { clearTimeout(heartbeat); heartbeat = setTimeout(() => remote.terminate(), 75000); };
|
|
21
|
+
remote.on('open', alive); remote.on('ping', alive); remote.on('message', alive);
|
|
22
|
+
function dropLocal(session) {
|
|
23
|
+
const current = locals.get(session);
|
|
24
|
+
if (!current) return;
|
|
25
|
+
locals.delete(session); clearTimeout(current.timer); current.socket?.terminate();
|
|
26
|
+
current.probe?.then(probe => probe.close());
|
|
27
|
+
}
|
|
28
|
+
function dropLocals() {
|
|
29
|
+
for (const session of [...locals.keys()]) dropLocal(session);
|
|
30
|
+
}
|
|
31
|
+
const ready = new Promise((resolve, reject) => {
|
|
32
|
+
let registered = false;
|
|
33
|
+
const timer = setTimeout(() => { reject(new Error('Relay registration timeout')); remote.terminate(); }, 5000);
|
|
34
|
+
remote.on('open', () => send(remote, { type: 'host', key: hostKey, hostName, lanCandidates, p2pProbe: p2pProbe ? 1 : 0, p2pProbeRepeat: true,
|
|
35
|
+
...(identity ? { deviceId: identity.id, deviceSecret: identity.secret } : {}) }));
|
|
36
|
+
remote.on('error', error => { reject(error); events.emit('diagnostic', error.message); });
|
|
37
|
+
remote.on('close', (code, reason) => {
|
|
38
|
+
clearTimeout(timer); clearTimeout(heartbeat); dropLocals();
|
|
39
|
+
const error = lastClose = Object.assign(new Error(`Relay closed (${code}): ${reason.toString()}`), { code });
|
|
40
|
+
if (!registered) reject(error);
|
|
41
|
+
if (operation) { clearTimeout(operation.timer); operation.reject(error); operation = undefined; }
|
|
42
|
+
events.emit('disconnected', { code, reason: reason.toString() });
|
|
43
|
+
});
|
|
44
|
+
remote.on('message', (bytes, binary) => {
|
|
45
|
+
try {
|
|
46
|
+
const message = decode(bytes, binary);
|
|
47
|
+
if (message.type === 'registered' && !registered) { registered = true; clearTimeout(timer); resolve(message); return; }
|
|
48
|
+
if (!registered) throw new Error('Relay not registered');
|
|
49
|
+
if (message.type === 'pair-code' || message.type === 'revoked' || message.type === 'status') {
|
|
50
|
+
if (operation && message.commandId === operation.id && message.type === operation.responseType) {
|
|
51
|
+
clearTimeout(operation.timer); const pending = operation; operation = undefined;
|
|
52
|
+
message.error ? pending.reject(new Error(message.error)) : pending.resolve(message);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (message.type === 'authorization-changed' && Array.isArray(message.clients) && Number.isSafeInteger(message.revision)) {
|
|
57
|
+
events.emit('authorization-changed', { clients: message.clients, revision: message.revision }); return;
|
|
58
|
+
}
|
|
59
|
+
if (message.type === 'attach') {
|
|
60
|
+
events.emit('attached', { session: message.session, clientId: message.clientId });
|
|
61
|
+
dropLocal(message.session);
|
|
62
|
+
const current = { socket: undefined, ready: false, timer: undefined, p2pProbe: p2pProbe && message.p2pProbe === 1 };
|
|
63
|
+
locals.set(message.session, current);
|
|
64
|
+
let connection;
|
|
65
|
+
try {
|
|
66
|
+
connection = bridgeConnection?.() || { url: bridgeUrl, token: bridgeToken };
|
|
67
|
+
loopbackUrl(connection.url, '/api/socket');
|
|
68
|
+
} catch {
|
|
69
|
+
send(remote, { type: 'detach', session: message.session }); dropLocal(message.session); events.emit('detached', { session: message.session });
|
|
70
|
+
events.emit('diagnostic', 'Local Bridge connection not ready'); return;
|
|
71
|
+
}
|
|
72
|
+
const socket = current.socket = new WebSocket(connection.url, { maxPayload: 64 * 1024 * 1024, perMessageDeflate: false });
|
|
73
|
+
current.timer = setTimeout(() => socket.terminate(), 5000);
|
|
74
|
+
socket.on('open', () => send(socket, { type: 'auth', token: connection.token }));
|
|
75
|
+
socket.on('error', error => events.emit('diagnostic', `Local Bridge: ${error.message}`));
|
|
76
|
+
socket.on('close', () => {
|
|
77
|
+
if (locals.get(message.session)?.socket !== socket) return;
|
|
78
|
+
send(remote, { type: 'detach', session: message.session }); dropLocal(message.session); events.emit('detached', { session: message.session });
|
|
79
|
+
});
|
|
80
|
+
socket.on('message', (data, isBinary) => {
|
|
81
|
+
if (locals.get(message.session)?.socket !== socket) return;
|
|
82
|
+
try {
|
|
83
|
+
const response = decode(data, isBinary);
|
|
84
|
+
if (!current.ready) {
|
|
85
|
+
if (response.type !== 'ready') throw new Error('Local Bridge authentication failed');
|
|
86
|
+
clearTimeout(current.timer); current.ready = true; send(remote, { type: 'ready', session: message.session });
|
|
87
|
+
} else send(remote, { type: 'data', session: message.session, payload: data.toString() });
|
|
88
|
+
} catch (error) { events.emit('diagnostic', error.message); socket.terminate(); }
|
|
89
|
+
});
|
|
90
|
+
} else if (message.type === 'p2p-probe' && locals.has(message.session)) {
|
|
91
|
+
const current = locals.get(message.session);
|
|
92
|
+
if (!current.ready || !current.p2pProbe || !validProbeSignal(message)) throw new Error('Invalid probe signal');
|
|
93
|
+
if (message.kind === 'start' && current.probeId !== message.probeId) {
|
|
94
|
+
void current.probe?.then(probe => probe.close());
|
|
95
|
+
current.probeId = message.probeId;
|
|
96
|
+
current.routeSignals = Promise.resolve();
|
|
97
|
+
const probeId = message.probeId;
|
|
98
|
+
current.routeHelper = createWindowsRouteHelper({ enabled: p2pWindowsRouteHelper, token: p2pWindowsRouteHelperToken, iceServers,
|
|
99
|
+
report: (event, details) => events.emit('diagnostic', `${event};count=${details.count}`) });
|
|
100
|
+
current.probe = current.routeHelper.prepare().then(() => createP2pProbe({ iceServers,
|
|
101
|
+
signal: signal => {
|
|
102
|
+
if (locals.get(message.session) === current && current.probeId === probeId) send(remote, { type: 'p2p-probe', session: message.session,
|
|
103
|
+
version: 1, probeId, ...signal });
|
|
104
|
+
}, report: (state, diagnostic) => events.emit('p2p-probe', { state, diagnostic })
|
|
105
|
+
})).catch(() => {
|
|
106
|
+
events.emit('diagnostic', p2pWindowsRouteHelper ? 'Windows RTC 路由辅助不可用' : 'WebRTC probe initialization failed');
|
|
107
|
+
return { receive() {}, close() {} };
|
|
108
|
+
});
|
|
109
|
+
} else if (current.probe && current.probeId === message.probeId) {
|
|
110
|
+
const pending = current.probe;
|
|
111
|
+
current.routeSignals ||= Promise.resolve();
|
|
112
|
+
current.routeSignals = current.routeSignals.then(async () => {
|
|
113
|
+
await current.routeHelper?.include(message);
|
|
114
|
+
const probe = await pending;
|
|
115
|
+
if (locals.get(message.session) === current && current.probeId === message.probeId) probe.receive(message);
|
|
116
|
+
});
|
|
117
|
+
void current.routeSignals
|
|
118
|
+
.catch(() => { events.emit('diagnostic', 'WebRTC probe negotiation failed'); void pending.then(probe => probe.close()); });
|
|
119
|
+
}
|
|
120
|
+
} else if (message.type === 'detach' && locals.has(message.session)) { dropLocal(message.session); events.emit('detached', { session: message.session }); }
|
|
121
|
+
else if (message.type === 'data' && locals.has(message.session)) {
|
|
122
|
+
const current = locals.get(message.session);
|
|
123
|
+
if (!current.ready) { send(remote, { type: 'detach', session: message.session }); dropLocal(message.session); return; }
|
|
124
|
+
const request = decode(message.payload, false);
|
|
125
|
+
if (!['request', 'subscribe', 'unsubscribe'].includes(request.type)) throw new Error('Unsupported LAN message');
|
|
126
|
+
send(current.socket, request);
|
|
127
|
+
}
|
|
128
|
+
} catch (error) { events.emit('diagnostic', error.message); remote.close(1008, 'Invalid relay message'); }
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return { ready, events,
|
|
132
|
+
assertConnected() { if (remote.readyState !== WebSocket.OPEN) throw lastClose || new Error('Relay disconnected during registration'); },
|
|
133
|
+
command(type, details = {}) {
|
|
134
|
+
if (operation) return Promise.reject(new Error('已有设备管理操作正在执行'));
|
|
135
|
+
return new Promise((resolve, reject) => {
|
|
136
|
+
const timer = setTimeout(() => { operation = undefined; reject(new Error('设备管理请求超时,结果未确认;未自动重发')); }, 7000);
|
|
137
|
+
const id = randomUUID();
|
|
138
|
+
operation = { resolve, reject, timer, id, responseType: type === 'revoke' ? 'revoked' : type };
|
|
139
|
+
if (!send(remote, { type, commandId: id, ...details })) { clearTimeout(timer); operation = undefined; reject(new Error('中继未连接')); }
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
updateLanCandidates(candidates) {
|
|
143
|
+
if (!send(remote, { type: 'lan-candidates', candidates })) throw new Error('中继未连接');
|
|
144
|
+
},
|
|
145
|
+
close() { clearTimeout(heartbeat); dropLocals(); remote.terminate(); }
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { validId } from './device-store.mjs';
|
|
5
|
+
|
|
6
|
+
export function readDebugAllowlist(file) {
|
|
7
|
+
if (!file || !fs.existsSync(file)) return { version: 1, devices: [] };
|
|
8
|
+
const value = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
9
|
+
if (value.version !== 1 || !Array.isArray(value.devices) || value.devices.some(entry => !validId(entry.deviceId))) {
|
|
10
|
+
throw new Error('Invalid debug allowlist');
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function debugAllowed(allowlist, deviceId, client) {
|
|
16
|
+
return Boolean(client && allowlist.devices.some(entry => entry.deviceId === deviceId));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Administrator-only file; never invoked by the relay wire protocol or Desktop CLI.
|
|
20
|
+
export function updateDebugAllowlist(file, deviceId, enabled) {
|
|
21
|
+
if (!validId(deviceId)) throw new Error('Invalid debug device');
|
|
22
|
+
const value = readDebugAllowlist(file);
|
|
23
|
+
const previous = fs.existsSync(file) ? fs.statSync(file) : null;
|
|
24
|
+
value.devices = value.devices.filter(entry => entry.deviceId !== deviceId);
|
|
25
|
+
if (enabled) value.devices.push({ deviceId });
|
|
26
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
27
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
28
|
+
try {
|
|
29
|
+
fs.writeFileSync(temporary, JSON.stringify(value, null, 2) + '\n', { mode: 0o640, flag: 'wx' });
|
|
30
|
+
if (previous && process.platform !== 'win32') fs.chownSync(temporary, previous.uid, previous.gid);
|
|
31
|
+
fs.renameSync(temporary, file);
|
|
32
|
+
} finally { fs.rmSync(temporary, { force: true }); }
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { attachLanSocket } from '../lan-socket-server.mjs';
|
|
4
|
+
import { startSelfRelay } from './server.mjs';
|
|
5
|
+
import { connectBridgeRelay } from './connector.mjs';
|
|
6
|
+
import { connectRelayClient } from './client.mjs';
|
|
7
|
+
import { secret } from './wire.mjs';
|
|
8
|
+
|
|
9
|
+
export async function startRelayDemo({ mode = 'lan-shared', pairingTtlMs, dispatch, remoteRelay, hostName = 'TEST-PC', lanCandidates = [] } = {}) {
|
|
10
|
+
if (!['lan-legacy', 'lan-shared'].includes(mode)) throw new Error('Invalid demo mode');
|
|
11
|
+
const token = secret(), calls = [];
|
|
12
|
+
const bridge = http.createServer((_request, response) => { response.writeHead(404); response.end(); });
|
|
13
|
+
const lan = attachLanSocket(bridge, { token, dispatch: async (request, reply) => {
|
|
14
|
+
calls.push(request);
|
|
15
|
+
if (dispatch) return dispatch(request, reply);
|
|
16
|
+
if (request.url === '/api/health') return reply.json(200, { ok: true, transportMode: mode, simulated: true });
|
|
17
|
+
if (request.url.split('?')[0] === '/api/threads/demo/events') {
|
|
18
|
+
reply.startEvents(); reply.event('update', { thread: { id: 'demo' }, simulated: true }); return;
|
|
19
|
+
}
|
|
20
|
+
if (request.url === '/api/demo/stop') return reply.json(mode === 'lan-shared' ? 200 : 409,
|
|
21
|
+
mode === 'lan-shared' ? { stopped: true, simulated: true } : { error: '基础控制不支持停止任务' });
|
|
22
|
+
reply.json(404, { error: '模拟 Bridge 不执行真实任务' });
|
|
23
|
+
} });
|
|
24
|
+
await new Promise(resolve => bridge.listen(0, '127.0.0.1', resolve));
|
|
25
|
+
const relay = remoteRelay ? { ...remoteRelay, async close() {} } : await startSelfRelay({ pairingTtlMs });
|
|
26
|
+
const bridgeUrl = `ws://127.0.0.1:${bridge.address().port}/api/socket`;
|
|
27
|
+
const identity = remoteRelay ? { id: randomUUID(), secret: secret() } : undefined;
|
|
28
|
+
const clientId = randomUUID(), credential = secret();
|
|
29
|
+
const connector = connectBridgeRelay({ identity, relayUrl: relay.url, hostKey: relay.hostKey, bridgeUrl, bridgeToken: token, hostName, lanCandidates });
|
|
30
|
+
let pairing;
|
|
31
|
+
try { pairing = await connector.ready; }
|
|
32
|
+
catch (error) { connector.close(); await relay.close(); lan.close(); await new Promise(resolve => bridge.close(resolve)); throw error; }
|
|
33
|
+
return {
|
|
34
|
+
relay, connector, pairing, bridgeUrl, calls,
|
|
35
|
+
connect(options = {}) { return connectRelayClient({ relayUrl: relay.url, room: pairing.room, code: pairing.code, ...(remoteRelay ? { clientId, credential } : {}), ...options }); },
|
|
36
|
+
async close() { if (remoteRelay) await connector.command('revoke'); connector.close(); await relay.close(); lan.close(); await new Promise(resolve => bridge.close(resolve)); },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
export const validId = value => typeof value === 'string' && /^[\w-]{16,128}$/.test(value);
|
|
6
|
+
const hash = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
7
|
+
export function deviceStore(file, { initialize = false } = {}) {
|
|
8
|
+
let devices = new Map();
|
|
9
|
+
function validate(record) {
|
|
10
|
+
if (!validId(record.id) || !hash(record.hostHash) || !['active', 'revoked'].includes(record.status) ||
|
|
11
|
+
!Number.isSafeInteger(record.revision) || record.revision < 0 ||
|
|
12
|
+
!Array.isArray(record.clients) || record.clients.length > 16 ||
|
|
13
|
+
record.clients.some(client => !validId(client.id) || !hash(client.hash) ||
|
|
14
|
+
!Number.isFinite(Date.parse(client.createdAt)) || !Number.isFinite(Date.parse(client.updatedAt))) ||
|
|
15
|
+
new Set(record.clients.map(client => client.id)).size !== record.clients.length ||
|
|
16
|
+
!Number.isFinite(Date.parse(record.createdAt)) || !Number.isFinite(Date.parse(record.updatedAt)) ||
|
|
17
|
+
!validOfficialComputer(record.officialComputer)) {
|
|
18
|
+
throw new Error('Invalid relay device record');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function write(next) {
|
|
22
|
+
if (!file) return;
|
|
23
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
24
|
+
let fd;
|
|
25
|
+
try {
|
|
26
|
+
fd = fs.openSync(temporary, 'wx', 0o600);
|
|
27
|
+
fs.writeFileSync(fd, JSON.stringify({ version: 4, devices: [...next.values()] }));
|
|
28
|
+
fs.fsyncSync(fd); fs.closeSync(fd); fd = undefined;
|
|
29
|
+
fs.renameSync(temporary, file);
|
|
30
|
+
if (process.platform !== 'win32') {
|
|
31
|
+
const directory = fs.openSync(path.dirname(file), 'r');
|
|
32
|
+
try { fs.fsyncSync(directory); } finally { fs.closeSync(directory); }
|
|
33
|
+
}
|
|
34
|
+
} finally {
|
|
35
|
+
if (fd !== undefined) fs.closeSync(fd);
|
|
36
|
+
fs.rmSync(temporary, { force: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (file) {
|
|
40
|
+
if (!fs.existsSync(file)) {
|
|
41
|
+
if (!initialize) throw new Error('Device store missing; explicit --init-state required for first installation');
|
|
42
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 }); write(devices);
|
|
43
|
+
} else {
|
|
44
|
+
if (initialize) throw new Error('Device store already exists; initialization refused');
|
|
45
|
+
const saved = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
46
|
+
if (![2, 3, 4].includes(saved.version) || !Array.isArray(saved.devices)) throw new Error('Invalid relay device store version');
|
|
47
|
+
for (const source of saved.devices) {
|
|
48
|
+
const record = saved.version === 2 ? {
|
|
49
|
+
...source,
|
|
50
|
+
clients: source.clientHash == null ? [] : [{
|
|
51
|
+
id: source.clientId,
|
|
52
|
+
hash: source.clientHash,
|
|
53
|
+
createdAt: source.updatedAt,
|
|
54
|
+
updatedAt: source.updatedAt,
|
|
55
|
+
}],
|
|
56
|
+
} : source;
|
|
57
|
+
delete record.clientHash; delete record.clientId;
|
|
58
|
+
validate(record);
|
|
59
|
+
if (devices.has(record.id)) throw new Error('Duplicate relay device identity');
|
|
60
|
+
devices.set(record.id, record);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
entries: () => [...devices.values()],
|
|
66
|
+
// Synchronous single-writer commit: publish only after durable replacement.
|
|
67
|
+
save(record) {
|
|
68
|
+
validate(record);
|
|
69
|
+
const next = new Map(devices); next.set(record.id, record); write(next); devices = next;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function validOfficialComputer(value) {
|
|
75
|
+
if (value === undefined) return true;
|
|
76
|
+
return value && typeof value === 'object' && plain(value.environmentId, 256, false) &&
|
|
77
|
+
plain(value.name, 80, true) && plain(value.hostname, 80, true) &&
|
|
78
|
+
Number.isFinite(Date.parse(value.updatedAt));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function plain(value, limit, empty) {
|
|
82
|
+
return typeof value === 'string' && (empty || value.trim().length > 0) &&
|
|
83
|
+
value.trim().length <= limit && !/[\u0000-\u001f\u007f]/.test(value);
|
|
84
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { digest, matches } from './wire.mjs';
|
|
5
|
+
import { validId } from './device-store.mjs';
|
|
6
|
+
|
|
7
|
+
const recordPath = stateRoot => path.join(stateRoot, 'lan-device-authorizations.json');
|
|
8
|
+
const validHash = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
9
|
+
|
|
10
|
+
export function saveLanAuthorizations(stateRoot, hostId, clients, revision) {
|
|
11
|
+
if (!validId(hostId) || !Array.isArray(clients) || clients.length > 16 ||
|
|
12
|
+
clients.some(client => !validId(client.id) || !validHash(client.hash)) ||
|
|
13
|
+
!Number.isSafeInteger(revision) || revision < 0) throw new Error('Invalid LAN device authorization state');
|
|
14
|
+
const file = recordPath(stateRoot), temporary = `${file}.${randomUUID()}.tmp`;
|
|
15
|
+
const record = { version: 1, hostId, revision, clients: clients.map(client => ({ id: client.id, hash: client.hash })) };
|
|
16
|
+
try {
|
|
17
|
+
fs.writeFileSync(temporary, JSON.stringify(record), { mode: 0o600, flag: 'wx' });
|
|
18
|
+
fs.renameSync(temporary, file);
|
|
19
|
+
} finally { fs.rmSync(temporary, { force: true }); }
|
|
20
|
+
}
|
|
21
|
+
export function authorizeLanDevice(stateRoot, clientId, credential) {
|
|
22
|
+
if (!validId(clientId)) return false;
|
|
23
|
+
let record;
|
|
24
|
+
try { record = JSON.parse(fs.readFileSync(recordPath(stateRoot), 'utf8')); }
|
|
25
|
+
catch (error) { if (error.code === 'ENOENT') return false; throw error; }
|
|
26
|
+
if (record?.version !== 1 || !validId(record.hostId) || !Array.isArray(record.clients)) return false;
|
|
27
|
+
const client = record.clients.find(item => item?.id === clientId && validHash(item.hash));
|
|
28
|
+
return Boolean(client && matches(credential, client.hash));
|
|
29
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
+
import { startBackground, processAlive } from '../background-process.mjs';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
import { randomBytes, randomUUID } from 'node:crypto';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { hostname } from 'node:os';
|
|
10
|
+
import QRCode from 'qrcode';
|
|
11
|
+
import { credentialStore } from '../platform/windows/credential-store.mjs';
|
|
12
|
+
import { readRecord, writeRecord } from '../service-lifecycle.mjs';
|
|
13
|
+
import { serviceHealth } from '../service-health.mjs';
|
|
14
|
+
import { openControl, controlRequest } from '../service-control.mjs';
|
|
15
|
+
import { connectBridgeRelay } from './connector.mjs';
|
|
16
|
+
import { validProbeIceServers } from './p2p-probe.mjs';
|
|
17
|
+
import { relayAddress, validSecret } from './wire.mjs';
|
|
18
|
+
import { saveLanAuthorizations } from './lan-authorizations.mjs';
|
|
19
|
+
import { lanNetworks } from '../platform/windows/network-info.mjs';
|
|
20
|
+
|
|
21
|
+
const exec = promisify(execFile);
|
|
22
|
+
const script = fileURLToPath(import.meta.url);
|
|
23
|
+
const recordPath = root => path.join(root, 'self-relay-session.json');
|
|
24
|
+
|
|
25
|
+
async function loadConfig(stateRoot) {
|
|
26
|
+
const config = readRecord(path.join(stateRoot, 'self-relay-config.json')) || {};
|
|
27
|
+
if (config.p2pIceServers !== undefined && !validProbeIceServers(config.p2pIceServers)) throw new Error('p2pIceServers 只接受最多 4 个 stun:主机:端口地址');
|
|
28
|
+
if (config.p2pWindowsRouteHelper !== undefined && typeof config.p2pWindowsRouteHelper !== 'boolean') throw new Error('p2pWindowsRouteHelper 必须是布尔值');
|
|
29
|
+
if (config.p2pWindowsRouteHelper && !/^[A-Za-z0-9_-]{32,128}$/.test(config.p2pWindowsRouteHelperToken || '')) throw new Error('p2pWindowsRouteHelperToken 无效');
|
|
30
|
+
const url = process.env.RELAY_URL || config.url;
|
|
31
|
+
if (!url) throw new Error('请先配置 self-relay-config.json 的 url 和 hostKeyFile(或 sshHost、sshKeyPath),详见自建中继文档。');
|
|
32
|
+
relayAddress(url);
|
|
33
|
+
const resolved = relayAddress(url);
|
|
34
|
+
const pairingUrl = config.pairingUrl || `${resolved.startsWith('wss:') ? 'https:' : 'http:'}//${new URL(resolved).host}/pair`;
|
|
35
|
+
const pairing = new URL(pairingUrl);
|
|
36
|
+
if (!['https:', 'http:'].includes(pairing.protocol) || pairing.pathname !== '/pair' || pairing.search || pairing.hash || pairing.username || pairing.password ||
|
|
37
|
+
(pairing.protocol === 'http:' && pairing.hostname !== '127.0.0.1')) throw new Error('self-relay-config.json 的 pairingUrl 必须是 HTTPS /pair 地址。');
|
|
38
|
+
return { ...config, url: resolved, pairingUrl: pairing.href };
|
|
39
|
+
}
|
|
40
|
+
async function registrationKey(config) {
|
|
41
|
+
const hostKeyFile = process.env.RELAY_HOST_KEY_FILE || config.hostKeyFile;
|
|
42
|
+
let hostKey;
|
|
43
|
+
if (hostKeyFile) hostKey = fs.readFileSync(hostKeyFile, 'utf8').trim();
|
|
44
|
+
else {
|
|
45
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(config.sshHost || '') ||
|
|
46
|
+
!/^\/[a-zA-Z0-9/_.-]+$/.test(config.sshKeyPath || '')) throw new Error('中继注册凭据配置不完整或无效。');
|
|
47
|
+
try {
|
|
48
|
+
const result = await exec('ssh', ['-o', 'BatchMode=yes', '-o', 'ConnectTimeout=10', config.sshHost,
|
|
49
|
+
`sudo -n cat ${config.sshKeyPath}`], { encoding: 'utf8', timeout: 15000, windowsHide: true });
|
|
50
|
+
hostKey = result.stdout.trim();
|
|
51
|
+
} catch { throw new Error('无法通过已配置 SSH 读取中继注册凭据。'); }
|
|
52
|
+
}
|
|
53
|
+
if (!validSecret(hostKey)) throw new Error('中继注册凭据格式无效。');
|
|
54
|
+
return hostKey;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function selfRelay(command, stateRoot, requiredMode = '') {
|
|
58
|
+
const previous = readRecord(recordPath(stateRoot));
|
|
59
|
+
let current;
|
|
60
|
+
if (previous) {
|
|
61
|
+
try { current = await controlRequest(previous); }
|
|
62
|
+
catch (error) { if (error.code !== 'ECONNREFUSED') throw error; }
|
|
63
|
+
}
|
|
64
|
+
if (command === 'relay-status' && current) return controlRequest(previous, 'POST', 'inspect');
|
|
65
|
+
if (command === 'relay-status') return current || { running: false, displayText: '私有中继连接器未运行。' };
|
|
66
|
+
if (command === 'relay-stop') {
|
|
67
|
+
if (current) await controlRequest(previous, 'POST');
|
|
68
|
+
const deadline = Date.now() + 10000;
|
|
69
|
+
while (current && processAlive(previous.pid)) {
|
|
70
|
+
if (Date.now() >= deadline) throw new Error('私有中继未在 10 秒内退出,未继续恢复服务。');
|
|
71
|
+
await delay(100);
|
|
72
|
+
}
|
|
73
|
+
return { stopped: true, displayText: '私有中继连接器已停止;Bridge 和 Codex 保持运行。' };
|
|
74
|
+
}
|
|
75
|
+
if (current) {
|
|
76
|
+
if (requiredMode) {
|
|
77
|
+
const bridge = await serviceHealth(readRecord(path.join(stateRoot, 'bridge-session.json')));
|
|
78
|
+
if (bridge?.transportMode !== requiredMode) throw new Error('当前 Bridge 未启用完整控制;请先执行 shared-start。');
|
|
79
|
+
}
|
|
80
|
+
if (command === 'relay-revoke') return controlRequest(previous, 'POST', 'revoke');
|
|
81
|
+
if (command === 'relay-pair' || (current.relayConnected && !current.paired && !current.qrPath)) return controlRequest(previous, 'POST', 'pair');
|
|
82
|
+
if (command === 'relay-start' && current.relayConnected) return controlRequest(previous, 'POST', 'refresh-lan');
|
|
83
|
+
return current;
|
|
84
|
+
}
|
|
85
|
+
if (command === 'relay-revoke') throw new Error('请先启动连接器,再撤销手机授权。');
|
|
86
|
+
fs.mkdirSync(stateRoot, { recursive: true });
|
|
87
|
+
const instanceId = randomUUID();
|
|
88
|
+
const log = path.join(stateRoot, 'self-relay.log');
|
|
89
|
+
const readyPath = path.join(stateRoot, `relay-ready-${instanceId}.json`);
|
|
90
|
+
const pid = await startBackground(process.execPath, [script, '--worker', stateRoot, instanceId,
|
|
91
|
+
command === 'relay-pair' ? 'pair' : '', requiredMode], process.env, [log, log]);
|
|
92
|
+
try {
|
|
93
|
+
const deadline = Date.now() + 25000;
|
|
94
|
+
while (true) {
|
|
95
|
+
const result = readRecord(readyPath);
|
|
96
|
+
if (result) {
|
|
97
|
+
if (result.pid !== pid || result.instanceId !== instanceId) throw new Error('私有中继启动实例不匹配。');
|
|
98
|
+
if (result.error) throw new Error(result.error);
|
|
99
|
+
return result.status;
|
|
100
|
+
}
|
|
101
|
+
if (!processAlive(pid)) throw new Error('私有中继启动失败,请查看 self-relay.log。');
|
|
102
|
+
if (Date.now() >= deadline) throw new Error('私有中继启动超时。');
|
|
103
|
+
await delay(100);
|
|
104
|
+
}
|
|
105
|
+
} catch (error) { if (processAlive(pid)) process.kill(pid); throw error; }
|
|
106
|
+
finally { fs.rmSync(readyPath, { force: true }); }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function worker(stateRoot, instanceId, refresh = false, requiredMode = '') {
|
|
110
|
+
const config = await loadConfig(stateRoot);
|
|
111
|
+
const session = () => readRecord(path.join(stateRoot, 'bridge-session.json'));
|
|
112
|
+
let health = await serviceHealth(session());
|
|
113
|
+
if (health?.status !== 'ok') throw new Error('Bridge 尚未运行,请先执行 relax start --json。');
|
|
114
|
+
if (requiredMode && health.transportMode !== requiredMode) throw new Error('完整控制的 Code Relax 中继需要完整控制 Bridge,请先执行 relax shared-start --json。');
|
|
115
|
+
const legacyPath = path.join(stateRoot, 'self-relay-device.json');
|
|
116
|
+
const legacy = readRecord(legacyPath);
|
|
117
|
+
const stored = await credentialStore('load');
|
|
118
|
+
let identities = stored.record || legacy || { version: 1, servers: {} };
|
|
119
|
+
const validate = value => {
|
|
120
|
+
if (value?.version !== 1 || !value.servers || typeof value.servers !== 'object' || Array.isArray(value.servers)) throw new Error('本机设备身份损坏,未自动覆盖');
|
|
121
|
+
for (const [url, item] of Object.entries(value.servers)) {
|
|
122
|
+
relayAddress(url);
|
|
123
|
+
if (!validSecret(item.secret) || !/^[\w-]{16,128}$/.test(item.id)) throw new Error('本机设备身份损坏,未自动覆盖');
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
validate(identities);
|
|
127
|
+
if (legacy) {
|
|
128
|
+
validate(legacy);
|
|
129
|
+
if (stored.record && JSON.stringify(stored.record) !== JSON.stringify(legacy)) throw new Error('新旧设备身份冲突,未覆盖任何凭据');
|
|
130
|
+
if (!stored.record) {
|
|
131
|
+
const verified = await credentialStore('save', identities);
|
|
132
|
+
if (JSON.stringify(verified.record) !== JSON.stringify(identities)) throw new Error('凭据迁移校验失败');
|
|
133
|
+
}
|
|
134
|
+
fs.rmSync(legacyPath);
|
|
135
|
+
}
|
|
136
|
+
let identity = identities.servers[config.url];
|
|
137
|
+
if (!identity) {
|
|
138
|
+
identity = { id: randomUUID(), secret: randomBytes(32).toString('base64url'), registered: false };
|
|
139
|
+
identities.servers[config.url] = identity; await credentialStore('save', identities);
|
|
140
|
+
}
|
|
141
|
+
const hostKey = identity.registered ? undefined : await registrationKey(config);
|
|
142
|
+
let bridgeError = '';
|
|
143
|
+
async function refreshHealth() {
|
|
144
|
+
try { health = await serviceHealth(session()) || { transportMode: health.transportMode, status: 'offline', desktopConnected: false }; bridgeError = ''; }
|
|
145
|
+
catch (error) { bridgeError = error.message; health = { transportMode: health.transportMode, status: 'offline', desktopConnected: false }; }
|
|
146
|
+
}
|
|
147
|
+
const secret = randomBytes(32).toString('base64url');
|
|
148
|
+
let connector, control, qrPath, expiresAt = 0, paired = false, clientCount = 0, attachedCount = 0;
|
|
149
|
+
let closing = false, online = false, connecting = false, retryTimer, attempts = 0, lastError = '';
|
|
150
|
+
const audit = (event, details = {}) => console.log(JSON.stringify({ time: new Date().toISOString(), event, ...details }));
|
|
151
|
+
async function currentLanCandidates() {
|
|
152
|
+
try {
|
|
153
|
+
const bridge = session(), port = bridge?.port || 45831;
|
|
154
|
+
return (await lanNetworks()).map(network => ({ ...network, address: `http://${network.address}:${port}` }));
|
|
155
|
+
} catch (error) {
|
|
156
|
+
audit('lan-candidates-unavailable', { message: error.message }); return [];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const status = () => {
|
|
160
|
+
const available = online && !paired && qrPath && Date.now() < expiresAt;
|
|
161
|
+
const next = !online ? (lastError || '电脑连接器正在恢复中继连接,已保存授权。')
|
|
162
|
+
: paired ? '设备已授权,手机可直接重连;网络断开不需要重新扫码。'
|
|
163
|
+
: available ? '用要添加的移动设备在有效期内扫描统一配对二维码。连接器在后台运行。'
|
|
164
|
+
: '尚未完成设备授权;调用 relax pair --json 生成配对二维码。';
|
|
165
|
+
return { running: !closing, relayConnected: online, mode: 'self-relay', transportMode: health.transportMode,
|
|
166
|
+
relayUrl: config.url, deviceId: identity.id, paired, clientCount, authorization: online ? (paired ? 'authorized' : 'unpaired') : 'unverified', phoneConnected: attachedCount > 0,
|
|
167
|
+
bridgeReady: health.status === 'ok' && Boolean(health.sharedAppServerConnected || health.desktopConnected), bridgeError,
|
|
168
|
+
expiresAt: expiresAt ? new Date(expiresAt).toISOString() : null,
|
|
169
|
+
...(available ? { qrPath } : {}), mobileAccess: 'unverified', lastError,
|
|
170
|
+
displayText: `Code Relax 中继 · ${health.transportMode === 'lan-shared' ? '完整控制' : '基础控制'}\n${next}\n停止连接器保留授权:relax relay-stop --json。撤销全部移动设备:relax relay-revoke --json。` };
|
|
171
|
+
};
|
|
172
|
+
async function shutdown() {
|
|
173
|
+
if (closing) return;
|
|
174
|
+
closing = true; clearTimeout(retryTimer);
|
|
175
|
+
connector?.events.removeAllListeners(); connector?.close();
|
|
176
|
+
if (readRecord(recordPath(stateRoot))?.instanceId === instanceId) fs.rmSync(recordPath(stateRoot), { force: true });
|
|
177
|
+
await control?.close();
|
|
178
|
+
}
|
|
179
|
+
async function saveInvitation(message) {
|
|
180
|
+
if (!message.code) return;
|
|
181
|
+
expiresAt = message.expires;
|
|
182
|
+
const link = new URL(config.pairingUrl);
|
|
183
|
+
link.searchParams.set('invite', message.code);
|
|
184
|
+
// Keep previously displayed files intact even when their invitation expires.
|
|
185
|
+
qrPath = path.join(stateRoot, `self-relay-qr-${randomUUID()}.png`);
|
|
186
|
+
await QRCode.toFile(qrPath, link.href, { width: 640, margin: 3 });
|
|
187
|
+
}
|
|
188
|
+
function scheduleRetry() {
|
|
189
|
+
if (closing || retryTimer) return;
|
|
190
|
+
const delay = Math.min(1000 * 2 ** Math.min(attempts++, 5), 30000) * (0.8 + Math.random() * 0.2);
|
|
191
|
+
retryTimer = setTimeout(() => { retryTimer = undefined; void connect(); }, delay);
|
|
192
|
+
}
|
|
193
|
+
async function connect() {
|
|
194
|
+
if (closing || connecting) return;
|
|
195
|
+
connecting = true;
|
|
196
|
+
let retryAfterAttempt = false;
|
|
197
|
+
try {
|
|
198
|
+
const bridge = session();
|
|
199
|
+
await refreshHealth();
|
|
200
|
+
const lanCandidates = await currentLanCandidates();
|
|
201
|
+
connector?.events.removeAllListeners(); connector?.close();
|
|
202
|
+
const current = connector = connectBridgeRelay({ relayUrl: config.url, hostKey: identity.registered ? undefined : hostKey, identity,
|
|
203
|
+
bridgeUrl: `ws://127.0.0.1:${bridge?.port || 45831}/api/socket`, bridgeToken: bridge?.accessUrl ? new URL(bridge.accessUrl).searchParams.get('token') : 'unavailable',
|
|
204
|
+
bridgeConnection: () => { const latest = session(); return { url: `ws://127.0.0.1:${latest.port}/api/socket`, token: new URL(latest.accessUrl).searchParams.get('token') }; },
|
|
205
|
+
hostName: hostname(), lanCandidates, p2pProbe: config.p2pProbe === true, iceServers: config.p2pIceServers || [],
|
|
206
|
+
p2pWindowsRouteHelper: config.p2pWindowsRouteHelper === true, p2pWindowsRouteHelperToken: config.p2pWindowsRouteHelperToken || '' });
|
|
207
|
+
current.events.on('p2p-probe', result => audit('p2p-probe', result));
|
|
208
|
+
current.events.on('diagnostic', message => audit('transport-error', { message }));
|
|
209
|
+
current.events.on('attached', () => { paired = true; attachedCount++; audit('phone-attached', { attachedCount }); });
|
|
210
|
+
current.events.on('detached', () => { attachedCount = Math.max(0, attachedCount - 1); audit('phone-detached', { attachedCount }); });
|
|
211
|
+
current.events.on('authorization-changed', update => {
|
|
212
|
+
saveLanAuthorizations(stateRoot, identity.id, update.clients, update.revision);
|
|
213
|
+
paired = update.clients.length > 0; clientCount = update.clients.length;
|
|
214
|
+
audit('mobile-authorizations-updated', { clientCount, revision: update.revision });
|
|
215
|
+
});
|
|
216
|
+
current.events.once('disconnected', event => {
|
|
217
|
+
if (connector !== current || closing) return;
|
|
218
|
+
online = false; attachedCount = 0; lastError = `电脑与中继连接断开(${event.code}):${event.reason}`; audit('relay-disconnected', event);
|
|
219
|
+
if (![1008, 4401, 4406, 4409, 4429].includes(event.code)) scheduleRetry();
|
|
220
|
+
});
|
|
221
|
+
const registration = await current.ready;
|
|
222
|
+
if (registration.protocolVersion !== 3 || registration.room !== identity.id) {
|
|
223
|
+
current.events.removeAllListeners(); current.close(); throw Object.assign(new Error('中继服务器尚未升级设备授权协议,未使用临时配对降级。'), { code: 4401 });
|
|
224
|
+
}
|
|
225
|
+
if (!identity.registered) {
|
|
226
|
+
const registeredIdentity = { ...identity, registered: true };
|
|
227
|
+
identities.servers[config.url] = registeredIdentity;
|
|
228
|
+
await credentialStore('save', identities); identity = registeredIdentity;
|
|
229
|
+
}
|
|
230
|
+
current.assertConnected();
|
|
231
|
+
online = true; attempts = 0; paired = registration.paired; clientCount = registration.clientCount || 0; lastError = '';
|
|
232
|
+
saveLanAuthorizations(stateRoot, identity.id, registration.clients || [], registration.revision);
|
|
233
|
+
await saveInvitation(registration); audit('relay-connected', { paired });
|
|
234
|
+
} catch (error) {
|
|
235
|
+
online = false; lastError = error.message; audit('connect-failed', { message: error.message });
|
|
236
|
+
if (![1008, 4401, 4406, 4409, 4429].includes(error.code)) retryAfterAttempt = true;
|
|
237
|
+
else { clearTimeout(retryTimer); retryTimer = undefined; }
|
|
238
|
+
} finally { connecting = false; if (retryAfterAttempt) scheduleRetry(); }
|
|
239
|
+
}
|
|
240
|
+
async function pair() {
|
|
241
|
+
if (!online || closing) throw new Error('中继尚未连接,设备授权保持不变。');
|
|
242
|
+
await saveInvitation(await connector.command('pair-code'));
|
|
243
|
+
// Each invitation adds or refreshes one mobile identity without revoking other devices.
|
|
244
|
+
return { ...status(), qrPath, expiresAt: new Date(expiresAt).toISOString(),
|
|
245
|
+
displayText: '用要添加的移动设备扫描此码。每台设备只需配对一次;已有设备授权保持不变。' };
|
|
246
|
+
}
|
|
247
|
+
async function revoke() {
|
|
248
|
+
if (!online || closing) throw new Error('中继尚未连接,未撤销授权。');
|
|
249
|
+
await connector.command('revoke'); paired = false; clientCount = 0; attachedCount = 0; qrPath = undefined; expiresAt = 0;
|
|
250
|
+
return { ...status(), displayText: '全部移动设备授权已撤销;重新添加请调用 relax pair --json。' };
|
|
251
|
+
}
|
|
252
|
+
async function refreshLan() {
|
|
253
|
+
if (!online || closing) throw new Error('中继尚未连接,未更新局域网候选。');
|
|
254
|
+
await refreshHealth();
|
|
255
|
+
const candidates = await currentLanCandidates();
|
|
256
|
+
connector.updateLanCandidates(candidates);
|
|
257
|
+
audit('lan-candidates-updated', { count: candidates.length });
|
|
258
|
+
return { ...status(), lanCandidateCount: candidates.length };
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
const freshStatus = async () => {
|
|
262
|
+
if (online) {
|
|
263
|
+
const remote = await connector.command('status'); paired = remote.paired;
|
|
264
|
+
await refreshHealth();
|
|
265
|
+
}
|
|
266
|
+
return status();
|
|
267
|
+
};
|
|
268
|
+
control = await openControl({ instanceId, secret, shutdown, status, actions: { pair, revoke, inspect: freshStatus, 'refresh-lan': refreshLan } });
|
|
269
|
+
writeRecord(recordPath(stateRoot), { pid: process.pid, instanceId, controlSecret: secret, controlPort: control.port });
|
|
270
|
+
await connect();
|
|
271
|
+
const result = refresh && online ? await pair() : status();
|
|
272
|
+
writeRecord(path.join(stateRoot, `relay-ready-${instanceId}.json`), { instanceId, pid: process.pid, status: { ...result, pid: process.pid } });
|
|
273
|
+
} catch (error) { await shutdown(); throw error; }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === script && process.argv[2] === '--worker') {
|
|
277
|
+
worker(process.argv[3], process.argv[4], process.argv[5] === 'pair', process.argv[6]).catch(error => {
|
|
278
|
+
writeRecord(path.join(process.argv[3], `relay-ready-${process.argv[4]}.json`), { instanceId: process.argv[4], pid: process.pid, error: error.message });
|
|
279
|
+
console.error(error.message); process.exitCode = 1;
|
|
280
|
+
});
|
|
281
|
+
}
|