windows-development-sandbox 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/config.example.json +17 -1
- package/dist/cli/args.d.ts +13 -2
- package/dist/cli/args.js +95 -24
- package/dist/cli/commands/accounts.js +45 -17
- package/dist/cli/commands/context.d.ts +2 -0
- package/dist/cli/commands/context.js +9 -2
- package/dist/cli/commands/data/clean.js +32 -9
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/launch/add-root.d.ts +3 -2
- package/dist/cli/commands/launch/add-root.js +11 -10
- package/dist/cli/commands/launch/launch.js +57 -4
- package/dist/cli/commands/launch/prepare.js +3 -1
- package/dist/cli/commands/maintenance/audit.js +1 -1
- package/dist/cli/commands/maintenance/clean.d.ts +1 -1
- package/dist/cli/commands/maintenance/clean.js +17 -3
- package/dist/cli/commands/maintenance/config.d.ts +1 -1
- package/dist/cli/commands/maintenance/config.js +112 -10
- package/dist/cli/commands/maintenance/doctor.d.ts +1 -1
- package/dist/cli/commands/maintenance/doctor.js +2 -4
- package/dist/cli/commands/maintenance/migrate.d.ts +2 -1
- package/dist/cli/commands/maintenance/migrate.js +19 -4
- package/dist/cli/commands/maintenance/sync.js +2 -0
- package/dist/cli/commands/maintenance/update.d.ts +2 -0
- package/dist/cli/commands/maintenance/update.js +27 -4
- package/dist/cli/commands/projects/here.js +12 -7
- package/dist/cli/commands/projects/projects.js +26 -17
- package/dist/cli/commands/registry.js +7 -0
- package/dist/cli/commands/repair/checks/agents.d.ts +2 -0
- package/dist/cli/commands/repair/checks/agents.js +70 -0
- package/dist/cli/commands/repair/checks/common.d.ts +8 -0
- package/dist/cli/commands/repair/checks/common.js +22 -0
- package/dist/cli/commands/repair/checks/data.d.ts +2 -0
- package/dist/cli/commands/repair/checks/data.js +241 -0
- package/dist/cli/commands/repair/checks/index.d.ts +2 -0
- package/dist/cli/commands/repair/checks/index.js +20 -0
- package/dist/cli/commands/repair/checks/install.d.ts +5 -0
- package/dist/cli/commands/repair/checks/install.js +318 -0
- package/dist/cli/commands/repair/checks/machine.d.ts +2 -0
- package/dist/cli/commands/repair/checks/machine.js +232 -0
- package/dist/cli/commands/repair/checks/network.d.ts +6 -0
- package/dist/cli/commands/repair/checks/network.js +60 -0
- package/dist/cli/commands/repair/checks/pc.d.ts +4 -0
- package/dist/cli/commands/repair/checks/pc.js +55 -0
- package/dist/cli/commands/repair/checks/sandbox.d.ts +2 -0
- package/dist/cli/commands/repair/checks/sandbox.js +267 -0
- package/dist/cli/commands/repair/checks/settings.d.ts +2 -0
- package/dist/cli/commands/repair/checks/settings.js +169 -0
- package/dist/cli/commands/repair/checks/vpn.d.ts +2 -0
- package/dist/cli/commands/repair/checks/vpn.js +53 -0
- package/dist/cli/commands/repair/engine.d.ts +32 -0
- package/dist/cli/commands/repair/engine.js +127 -0
- package/dist/cli/commands/repair/env.d.ts +7 -0
- package/dist/cli/commands/repair/env.js +49 -0
- package/dist/cli/commands/repair/index.d.ts +1 -9
- package/dist/cli/commands/repair/index.js +2 -54
- package/dist/cli/commands/repair/log.d.ts +17 -0
- package/dist/cli/commands/repair/log.js +82 -0
- package/dist/cli/commands/repair/printer.d.ts +32 -0
- package/dist/cli/commands/repair/printer.js +132 -0
- package/dist/cli/commands/repair/run.d.ts +33 -0
- package/dist/cli/commands/repair/run.js +133 -0
- package/dist/cli/commands/repair/types.d.ts +97 -9
- package/dist/cli/commands/repair/types.js +11 -7
- package/dist/cli/commands/resume.js +2 -2
- package/dist/cli/commands/sessions/list.js +5 -2
- package/dist/cli/commands/sessions/status.d.ts +2 -0
- package/dist/cli/commands/sessions/status.js +27 -6
- package/dist/cli/commands/setup/index.d.ts +5 -0
- package/dist/cli/commands/setup/index.js +25 -1
- package/dist/cli/commands/storage/index.d.ts +2 -0
- package/dist/cli/commands/storage/index.js +2 -0
- package/dist/cli/commands/storage/offer.d.ts +3 -0
- package/dist/cli/commands/storage/offer.js +85 -0
- package/dist/cli/commands/storage/storage.d.ts +8 -0
- package/dist/cli/commands/storage/storage.js +171 -0
- package/dist/cli/commands/user-config.js +1 -1
- package/dist/cli/commands/vpn.d.ts +4 -0
- package/dist/cli/commands/vpn.js +75 -0
- package/dist/cli/commands/web.d.ts +4 -0
- package/dist/cli/commands/web.js +95 -0
- package/dist/cli/history.js +1 -1
- package/dist/cli/index.js +46 -3
- package/dist/cli/manifest.d.ts +303 -29
- package/dist/cli/manifest.js +173 -43
- package/dist/cli/menu/add-agent.d.ts +47 -0
- package/dist/cli/menu/add-agent.js +168 -0
- package/dist/cli/menu/apps.d.ts +31 -2
- package/dist/cli/menu/apps.js +44 -5
- package/dist/cli/menu/command-fields.d.ts +18 -0
- package/dist/cli/menu/command-fields.js +61 -0
- package/dist/cli/menu/command-form.d.ts +22 -0
- package/dist/cli/menu/command-form.js +169 -46
- package/dist/cli/menu/data-folder.d.ts +18 -0
- package/dist/cli/menu/data-folder.js +99 -0
- package/dist/cli/menu/menu.d.ts +1 -1
- package/dist/cli/menu/menu.js +11 -8
- package/dist/cli/menu/pages/accounts-page.js +55 -24
- package/dist/cli/menu/pages/agents-page.d.ts +66 -0
- package/dist/cli/menu/pages/agents-page.js +338 -0
- package/dist/cli/menu/pages/apps-page.js +1 -2
- package/dist/cli/menu/pages/list-page.d.ts +16 -3
- package/dist/cli/menu/pages/list-page.js +40 -8
- package/dist/cli/menu/pages/maintenance-page.d.ts +9 -0
- package/dist/cli/menu/pages/maintenance-page.js +161 -72
- package/dist/cli/menu/pages/sandbox-page.d.ts +3 -0
- package/dist/cli/menu/pages/sandbox-page.js +132 -43
- package/dist/cli/menu/pages/sessions-page.d.ts +4 -0
- package/dist/cli/menu/pages/sessions-page.js +41 -25
- package/dist/cli/menu/pages/settings-page.d.ts +8 -4
- package/dist/cli/menu/pages/settings-page.js +36 -13
- package/dist/cli/menu/settings/categories.d.ts +2 -0
- package/dist/cli/menu/settings/categories.js +19 -44
- package/dist/cli/menu/settings/collections/collection-editor.d.ts +7 -1
- package/dist/cli/menu/settings/collections/collection-editor.js +12 -8
- package/dist/cli/menu/settings/collections/map-editor.js +5 -1
- package/dist/cli/menu/settings/collections/object-list-editor.js +2 -2
- package/dist/cli/menu/settings/collections/object-map-editor.js +2 -2
- package/dist/cli/menu/settings/collections/string-list-editor.d.ts +11 -1
- package/dist/cli/menu/settings/collections/string-list-editor.js +23 -0
- package/dist/cli/menu/settings/index.d.ts +1 -1
- package/dist/cli/menu/settings/index.js +1 -1
- package/dist/cli/menu/settings/object-editor.d.ts +5 -1
- package/dist/cli/menu/settings/object-editor.js +15 -4
- package/dist/cli/menu/settings/path-kind.d.ts +20 -0
- package/dist/cli/menu/settings/path-kind.js +44 -0
- package/dist/cli/menu/settings/schema-node.d.ts +9 -0
- package/dist/cli/menu/settings/schema-node.js +26 -0
- package/dist/cli/menu/settings/value-editor.d.ts +5 -0
- package/dist/cli/menu/settings/value-editor.js +51 -18
- package/dist/cli/menu/several.js +7 -5
- package/dist/cli/menu/shell.d.ts +37 -10
- package/dist/cli/menu/shell.js +90 -10
- package/dist/cli/menu/vpn-login.d.ts +16 -0
- package/dist/cli/menu/vpn-login.js +66 -0
- package/dist/cli/output/print.d.ts +2 -0
- package/dist/cli/output/print.js +8 -1
- package/dist/cli/services/accounts-service.d.ts +2 -0
- package/dist/cli/services/accounts-service.js +2 -2
- package/dist/cli/services/health-service.d.ts +0 -6
- package/dist/cli/services/health-service.js +5 -42
- package/dist/cli/services/index.d.ts +3 -1
- package/dist/cli/services/index.js +3 -1
- package/dist/cli/services/migrate-service.js +1 -1
- package/dist/cli/services/update-service.d.ts +2 -0
- package/dist/cli/services/update-service.js +13 -6
- package/dist/cli/services/vpn-service.d.ts +28 -0
- package/dist/cli/services/vpn-service.js +46 -0
- package/dist/cli/services/web-service.d.ts +22 -0
- package/dist/cli/services/web-service.js +111 -0
- package/dist/cli/tui/app.d.ts +6 -3
- package/dist/cli/tui/app.js +12 -5
- package/dist/cli/tui/dialogs/path-listing.d.ts +43 -0
- package/dist/cli/tui/dialogs/path-listing.js +127 -0
- package/dist/cli/tui/dialogs/path-picker.d.ts +67 -0
- package/dist/cli/tui/dialogs/path-picker.js +423 -0
- package/dist/cli/tui/dialogs/text-screen.d.ts +6 -0
- package/dist/cli/tui/dialogs/text-screen.js +10 -3
- package/dist/cli/tui/frame.d.ts +7 -10
- package/dist/cli/tui/frame.js +19 -10
- package/dist/cli/tui/index.d.ts +4 -3
- package/dist/cli/tui/index.js +2 -1
- package/dist/cli/tui/list/list-screen.d.ts +14 -2
- package/dist/cli/tui/list/list-screen.js +68 -32
- package/dist/cli/tui/list/list-types.d.ts +8 -4
- package/dist/cli/tui/nav.d.ts +29 -0
- package/dist/cli/tui/nav.js +67 -0
- package/dist/cli/validate.d.ts +1 -1
- package/dist/cli/validate.js +3 -3
- package/dist/cli/version.d.ts +2 -0
- package/dist/cli/version.js +11 -0
- package/dist/core/config/defaults.js +5 -1
- package/dist/core/config/loader.js +12 -2
- package/dist/core/local-config/overrides.js +1 -0
- package/dist/core/prompt.d.ts +19 -0
- package/dist/core/prompt.js +43 -3
- package/dist/core/schema/common.d.ts +6 -0
- package/dist/core/schema/common.js +8 -0
- package/dist/core/schema/config.d.ts +23 -0
- package/dist/core/schema/config.js +10 -1
- package/dist/core/schema/harness.d.ts +1 -0
- package/dist/core/schema/harness.js +8 -2
- package/dist/core/schema/index.d.ts +3 -1
- package/dist/core/schema/index.js +3 -1
- package/dist/core/schema/profile.d.ts +1 -0
- package/dist/core/schema/profile.js +3 -0
- package/dist/core/schema/redact.d.ts +13 -0
- package/dist/core/schema/redact.js +75 -0
- package/dist/core/schema/sandbox.js +1 -0
- package/dist/core/schema/vpn.d.ts +17 -0
- package/dist/core/schema/vpn.js +22 -0
- package/dist/core/schema/web.d.ts +6 -0
- package/dist/core/schema/web.js +14 -0
- package/dist/core/types.d.ts +26 -0
- package/dist/guest/agents/agent-files.d.ts +49 -0
- package/dist/guest/agents/agent-files.js +63 -0
- package/dist/guest/agents/agent-installer.js +2 -9
- package/dist/guest/agents/local-state.d.ts +12 -0
- package/dist/guest/agents/local-state.js +198 -0
- package/dist/guest/agents/sbx-agent.d.ts +2 -0
- package/dist/guest/agents/sbx-agent.js +35 -0
- package/dist/guest/boot/boot.d.ts +4 -0
- package/dist/guest/boot/boot.js +50 -11
- package/dist/guest/daemon/daemon.js +4 -1
- package/dist/guest/daemon/exec.js +2 -1
- package/dist/guest/daemon/idle-shutdown.js +2 -0
- package/dist/guest/daemon/sessions.js +4 -1
- package/dist/guest/entries/agent.d.ts +1 -0
- package/dist/guest/entries/agent.js +10 -0
- package/dist/guest/entries/daemon.js +2 -0
- package/dist/guest/runtime/csc.d.ts +1 -0
- package/dist/guest/runtime/csc.js +1 -0
- package/dist/guest/runtime/secrets.d.ts +12 -0
- package/dist/guest/runtime/secrets.js +63 -0
- package/dist/guest/setup/claude-profile.d.ts +2 -1
- package/dist/guest/setup/claude-profile.js +12 -1
- package/dist/guest/setup/environment.d.ts +6 -0
- package/dist/guest/setup/environment.js +56 -6
- package/dist/guest/setup/path-plan.d.ts +32 -0
- package/dist/guest/setup/path-plan.js +67 -0
- package/dist/guest/setup/shell-path.d.ts +1 -0
- package/dist/guest/setup/shell-path.js +22 -0
- package/dist/guest/toolchains/languages/python.js +1 -1
- package/dist/guest/toolchains/runtimes.js +2 -2
- package/dist/guest/vpn/index.d.ts +1 -0
- package/dist/guest/vpn/index.js +1 -0
- package/dist/guest/vpn/openvpn.d.ts +9 -0
- package/dist/guest/vpn/openvpn.js +47 -0
- package/dist/guest/vpn/tunnel.d.ts +17 -0
- package/dist/guest/vpn/tunnel.js +78 -0
- package/dist/guest/vpn/vpn.d.ts +6 -0
- package/dist/guest/vpn/vpn.js +126 -0
- package/dist/host/channel/attach.d.ts +3 -1
- package/dist/host/channel/attach.js +1 -1
- package/dist/host/channel/channel.d.ts +7 -0
- package/dist/host/channel/channel.js +26 -2
- package/dist/host/health/acl-read.d.ts +17 -0
- package/dist/host/health/acl-read.js +45 -0
- package/dist/host/health/config-backup.d.ts +11 -0
- package/dist/host/health/config-backup.js +73 -0
- package/dist/host/health/index.d.ts +6 -0
- package/dist/host/health/index.js +7 -0
- package/dist/host/health/install-state.d.ts +33 -0
- package/dist/host/health/install-state.js +110 -0
- package/dist/host/health/path-copies.d.ts +32 -0
- package/dist/host/health/path-copies.js +82 -0
- package/dist/host/health/stale.d.ts +45 -0
- package/dist/host/health/stale.js +120 -0
- package/dist/host/health/system.d.ts +37 -0
- package/dist/host/health/system.js +87 -0
- package/dist/host/install/copies.d.ts +13 -0
- package/dist/host/install/copies.js +63 -0
- package/dist/host/install/index.d.ts +1 -0
- package/dist/host/install/index.js +1 -0
- package/dist/host/launch/generate.js +25 -1
- package/dist/host/launch/session-file.js +4 -1
- package/dist/host/launch/stage.js +1 -1
- package/dist/host/migrate/backup.js +3 -0
- package/dist/host/migrate/migrations/config-file.d.ts +2 -0
- package/dist/host/migrate/migrations/config-file.js +7 -0
- package/dist/host/migrate/migrations/follow-machine-storage.js +9 -1
- package/dist/host/migrate/migrations/pin-storage-root.d.ts +4 -0
- package/dist/host/migrate/migrations/pin-storage-root.js +46 -0
- package/dist/host/migrate/migrations/unpin-config-defaults.js +4 -1
- package/dist/host/migrate/registry.js +2 -1
- package/dist/host/profile/accounts.d.ts +25 -1
- package/dist/host/profile/accounts.js +96 -13
- package/dist/host/profile/agent-accounts.d.ts +5 -1
- package/dist/host/profile/agent-accounts.js +35 -5
- package/dist/host/profile/index.d.ts +2 -1
- package/dist/host/profile/index.js +1 -0
- package/dist/host/profile/plugin-share.d.ts +26 -0
- package/dist/host/profile/plugin-share.js +146 -0
- package/dist/host/projects/join.d.ts +7 -1
- package/dist/host/projects/join.js +21 -4
- package/dist/host/projects/registry.d.ts +16 -10
- package/dist/host/projects/registry.js +74 -6
- package/dist/host/sandbox/platform.d.ts +2 -0
- package/dist/host/sandbox/platform.js +21 -2
- package/dist/host/secrets/index.d.ts +2 -0
- package/dist/host/secrets/index.js +2 -0
- package/dist/host/secrets/launch-secrets.d.ts +17 -0
- package/dist/host/secrets/launch-secrets.js +93 -0
- package/dist/host/secrets/secret-store.d.ts +25 -0
- package/dist/host/secrets/secret-store.js +89 -0
- package/dist/host/sharing/acl.d.ts +16 -2
- package/dist/host/sharing/acl.js +35 -10
- package/dist/host/sharing/current.js +11 -2
- package/dist/host/sharing/doctor.d.ts +2 -0
- package/dist/host/sharing/doctor.js +44 -0
- package/dist/host/sharing/group-access.d.ts +6 -0
- package/dist/host/sharing/group-access.js +24 -0
- package/dist/host/sharing/index.d.ts +2 -1
- package/dist/host/sharing/index.js +2 -1
- package/dist/host/sharing/lifecycle.d.ts +8 -2
- package/dist/host/sharing/lifecycle.js +16 -7
- package/dist/host/storage/cleanup.d.ts +2 -0
- package/dist/host/storage/cleanup.js +2 -1
- package/dist/host/storage/history.d.ts +21 -0
- package/dist/host/storage/history.js +49 -0
- package/dist/host/storage/index.d.ts +4 -0
- package/dist/host/storage/index.js +4 -0
- package/dist/host/storage/move.d.ts +95 -0
- package/dist/host/storage/move.js +384 -0
- package/dist/host/storage/offer.d.ts +11 -0
- package/dist/host/storage/offer.js +36 -0
- package/dist/host/storage/root.d.ts +18 -0
- package/dist/host/storage/root.js +77 -0
- package/dist/host/tools/windows-terminal.d.ts +2 -0
- package/dist/host/tools/windows-terminal.js +23 -5
- package/dist/host/update/index.d.ts +1 -1
- package/dist/host/update/index.js +1 -1
- package/dist/host/update/notice.d.ts +2 -0
- package/dist/host/update/notice.js +13 -1
- package/dist/host/update/update-state.d.ts +6 -0
- package/dist/host/update/update-state.js +2 -0
- package/dist/host/update/updater.d.ts +19 -0
- package/dist/host/update/updater.js +88 -12
- package/dist/host/vpn/index.d.ts +4 -0
- package/dist/host/vpn/index.js +4 -0
- package/dist/host/vpn/login.d.ts +24 -0
- package/dist/host/vpn/login.js +79 -0
- package/dist/host/vpn/nordvpn.d.ts +21 -0
- package/dist/host/vpn/nordvpn.js +77 -0
- package/dist/host/vpn/prepare.d.ts +17 -0
- package/dist/host/vpn/prepare.js +77 -0
- package/dist/host/vpn/status.d.ts +12 -0
- package/dist/host/vpn/status.js +53 -0
- package/dist/host/web/auth.d.ts +38 -0
- package/dist/host/web/auth.js +96 -0
- package/dist/host/web/backend.d.ts +14 -0
- package/dist/host/web/backend.js +1 -0
- package/dist/host/web/bridge.d.ts +27 -0
- package/dist/host/web/bridge.js +144 -0
- package/dist/host/web/browser.d.ts +1 -0
- package/dist/host/web/browser.js +10 -0
- package/dist/host/web/control.d.ts +17 -0
- package/dist/host/web/control.js +67 -0
- package/dist/host/web/index.d.ts +9 -0
- package/dist/host/web/index.js +8 -0
- package/dist/host/web/runner.d.ts +14 -0
- package/dist/host/web/runner.js +45 -0
- package/dist/host/web/server.d.ts +40 -0
- package/dist/host/web/server.js +218 -0
- package/dist/host/web/state.d.ts +20 -0
- package/dist/host/web/state.js +41 -0
- package/dist/host/web/static-files.d.ts +13 -0
- package/dist/host/web/static-files.js +57 -0
- package/dist/runtime/agent.js +27614 -0
- package/dist/runtime/daemon.js +1012 -618
- package/dist/runtime/db.js +236 -106
- package/dist/runtime/main.js +1093 -250
- package/dist/runtime/netproxy.js +102 -3
- package/dist/runtime/view.js +102 -3
- package/dist/selftest/accounts.test.js +40 -0
- package/dist/selftest/agent-paths.test.d.ts +2 -0
- package/dist/selftest/agent-paths.test.js +115 -0
- package/dist/selftest/channel.test.js +5 -0
- package/dist/selftest/cli.test.js +34 -4
- package/dist/selftest/credentials.test.d.ts +2 -0
- package/dist/selftest/credentials.test.js +198 -0
- package/dist/selftest/generate.test.js +1 -1
- package/dist/selftest/health.test.d.ts +2 -0
- package/dist/selftest/health.test.js +470 -0
- package/dist/selftest/host-sim.test.js +2 -0
- package/dist/selftest/index.js +19 -0
- package/dist/selftest/layout.test.js +2 -0
- package/dist/selftest/menu-screens.d.ts +7 -0
- package/dist/selftest/menu-screens.js +65 -16
- package/dist/selftest/menu.test.js +574 -21
- package/dist/selftest/migrate.test.js +1 -1
- package/dist/selftest/personalization.test.js +3 -1
- package/dist/selftest/projects.test.js +39 -1
- package/dist/selftest/shared-use.test.js +64 -2
- package/dist/selftest/sharing.test.js +50 -1
- package/dist/selftest/storage.test.d.ts +2 -0
- package/dist/selftest/storage.test.js +363 -0
- package/dist/selftest/support/fixtures.d.ts +14 -0
- package/dist/selftest/support/releases.js +1 -1
- package/dist/selftest/toolchains.test.js +21 -0
- package/dist/selftest/update-service.test.js +87 -3
- package/dist/selftest/vpn.test.d.ts +2 -0
- package/dist/selftest/vpn.test.js +279 -0
- package/dist/selftest/web.test.d.ts +2 -0
- package/dist/selftest/web.test.js +304 -0
- package/dist/shared/apps/catalogue.js +31 -0
- package/dist/shared/channel/index.d.ts +1 -0
- package/dist/shared/channel/index.js +1 -0
- package/dist/shared/channel/run-dir.d.ts +6 -1
- package/dist/shared/channel/run-dir.js +12 -1
- package/dist/shared/channel/schema.d.ts +19 -0
- package/dist/shared/channel/schema.js +11 -0
- package/dist/shared/channel/secrets.d.ts +28 -0
- package/dist/shared/channel/secrets.js +44 -0
- package/dist/shared/vpn/download.d.ts +13 -0
- package/dist/shared/vpn/download.js +14 -0
- package/dist/shared/vpn/kill-switch.d.ts +18 -0
- package/dist/shared/vpn/kill-switch.js +81 -0
- package/dist/shared/vpn/ovpn.d.ts +23 -0
- package/dist/shared/vpn/ovpn.js +244 -0
- package/dist/shared/web/index.d.ts +1 -0
- package/dist/shared/web/index.js +1 -0
- package/dist/shared/web/protocol.d.ts +61 -0
- package/dist/shared/web/protocol.js +35 -0
- package/dist/sync/sync-cycle.js +5 -1
- package/dist/sync/sync-state.d.ts +1 -0
- package/dist/sync/sync-state.js +1 -0
- package/dist/sync/watcher.js +10 -0
- package/dist/web/index.html +13 -0
- package/dist/web/main-CXESL347.js +45 -0
- package/dist/web/main-VLR7DVQ4.css +1 -0
- package/native/csharp/FolderSecurity.cs +29 -0
- package/native/scripts/protect-data.ps1 +29 -0
- package/native/scripts/read-folder-sddl.ps1 +10 -0
- package/native/scripts/set-folder-access.ps1 +49 -7
- 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 +1421 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +15 -5
- package/sandbox/csharp/EnvBroadcast.cs +33 -0
- package/sandbox/csharp/PathSync.cs +90 -0
- package/sandbox/scripts/install-shell-path.ps1 +73 -0
- package/sandbox/scripts/set-machine-environment.ps1 +37 -4
- package/schemas/config.schema.json +79 -4
- package/schemas/sandbox-config.schema.json +14 -1
- package/dist/cli/commands/repair/checks.d.ts +0 -2
- package/dist/cli/commands/repair/checks.js +0 -246
- package/dist/cli/menu/pages/start-page.d.ts +0 -43
- package/dist/cli/menu/pages/start-page.js +0 -192
- package/dist/cli/tui/tab-bar.d.ts +0 -9
- package/dist/cli/tui/tab-bar.js +0 -33
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kDone = Symbol('kDone');
|
|
4
|
+
const kRun = Symbol('kRun');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A very simple job queue with adjustable concurrency. Adapted from
|
|
8
|
+
* https://github.com/STRML/async-limiter
|
|
9
|
+
*/
|
|
10
|
+
class Limiter {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new `Limiter`.
|
|
13
|
+
*
|
|
14
|
+
* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
|
|
15
|
+
* to run concurrently
|
|
16
|
+
*/
|
|
17
|
+
constructor(concurrency) {
|
|
18
|
+
this[kDone] = () => {
|
|
19
|
+
this.pending--;
|
|
20
|
+
this[kRun]();
|
|
21
|
+
};
|
|
22
|
+
this.concurrency = concurrency || Infinity;
|
|
23
|
+
this.jobs = [];
|
|
24
|
+
this.pending = 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds a job to the queue.
|
|
29
|
+
*
|
|
30
|
+
* @param {Function} job The job to run
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
add(job) {
|
|
34
|
+
this.jobs.push(job);
|
|
35
|
+
this[kRun]();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Removes a job from the queue and runs it if possible.
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
[kRun]() {
|
|
44
|
+
if (this.pending === this.concurrency) return;
|
|
45
|
+
|
|
46
|
+
if (this.jobs.length) {
|
|
47
|
+
const job = this.jobs.shift();
|
|
48
|
+
|
|
49
|
+
this.pending++;
|
|
50
|
+
job(this[kDone]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = Limiter;
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const zlib = require('zlib');
|
|
4
|
+
|
|
5
|
+
const bufferUtil = require('./buffer-util');
|
|
6
|
+
const Limiter = require('./limiter');
|
|
7
|
+
const { kStatusCode } = require('./constants');
|
|
8
|
+
|
|
9
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
10
|
+
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
11
|
+
const kPerMessageDeflate = Symbol('permessage-deflate');
|
|
12
|
+
const kTotalLength = Symbol('total-length');
|
|
13
|
+
const kCallback = Symbol('callback');
|
|
14
|
+
const kBuffers = Symbol('buffers');
|
|
15
|
+
const kError = Symbol('error');
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// We limit zlib concurrency, which prevents severe memory fragmentation
|
|
19
|
+
// as documented in https://github.com/nodejs/node/issues/8871#issuecomment-250915913
|
|
20
|
+
// and https://github.com/websockets/ws/issues/1202
|
|
21
|
+
//
|
|
22
|
+
// Intentionally global; it's the global thread pool that's an issue.
|
|
23
|
+
//
|
|
24
|
+
let zlibLimiter;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* permessage-deflate implementation.
|
|
28
|
+
*/
|
|
29
|
+
class PerMessageDeflate {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a PerMessageDeflate instance.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} [options] Configuration options
|
|
34
|
+
* @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
|
|
35
|
+
* for, or request, a custom client window size
|
|
36
|
+
* @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
|
|
37
|
+
* acknowledge disabling of client context takeover
|
|
38
|
+
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
39
|
+
* calls to zlib
|
|
40
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
41
|
+
* server or client mode
|
|
42
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
43
|
+
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
44
|
+
* use of a custom server window size
|
|
45
|
+
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
46
|
+
* disabling of server context takeover
|
|
47
|
+
* @param {Number} [options.threshold=1024] Size (in bytes) below which
|
|
48
|
+
* messages should not be compressed if context takeover is disabled
|
|
49
|
+
* @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
|
|
50
|
+
* deflate
|
|
51
|
+
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
52
|
+
* inflate
|
|
53
|
+
*/
|
|
54
|
+
constructor(options) {
|
|
55
|
+
this._options = options || {};
|
|
56
|
+
this._threshold =
|
|
57
|
+
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
58
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
59
|
+
this._isServer = !!this._options.isServer;
|
|
60
|
+
this._deflate = null;
|
|
61
|
+
this._inflate = null;
|
|
62
|
+
|
|
63
|
+
this.params = null;
|
|
64
|
+
|
|
65
|
+
if (!zlibLimiter) {
|
|
66
|
+
const concurrency =
|
|
67
|
+
this._options.concurrencyLimit !== undefined
|
|
68
|
+
? this._options.concurrencyLimit
|
|
69
|
+
: 10;
|
|
70
|
+
zlibLimiter = new Limiter(concurrency);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @type {String}
|
|
76
|
+
*/
|
|
77
|
+
static get extensionName() {
|
|
78
|
+
return 'permessage-deflate';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create an extension negotiation offer.
|
|
83
|
+
*
|
|
84
|
+
* @return {Object} Extension parameters
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
offer() {
|
|
88
|
+
const params = {};
|
|
89
|
+
|
|
90
|
+
if (this._options.serverNoContextTakeover) {
|
|
91
|
+
params.server_no_context_takeover = true;
|
|
92
|
+
}
|
|
93
|
+
if (this._options.clientNoContextTakeover) {
|
|
94
|
+
params.client_no_context_takeover = true;
|
|
95
|
+
}
|
|
96
|
+
if (this._options.serverMaxWindowBits) {
|
|
97
|
+
params.server_max_window_bits = this._options.serverMaxWindowBits;
|
|
98
|
+
}
|
|
99
|
+
if (this._options.clientMaxWindowBits) {
|
|
100
|
+
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
101
|
+
} else if (this._options.clientMaxWindowBits == null) {
|
|
102
|
+
params.client_max_window_bits = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return params;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Accept an extension negotiation offer/response.
|
|
110
|
+
*
|
|
111
|
+
* @param {Array} configurations The extension negotiation offers/reponse
|
|
112
|
+
* @return {Object} Accepted configuration
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
accept(configurations) {
|
|
116
|
+
configurations = this.normalizeParams(configurations);
|
|
117
|
+
|
|
118
|
+
this.params = this._isServer
|
|
119
|
+
? this.acceptAsServer(configurations)
|
|
120
|
+
: this.acceptAsClient(configurations);
|
|
121
|
+
|
|
122
|
+
return this.params;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Releases all resources used by the extension.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
cleanup() {
|
|
131
|
+
if (this._inflate) {
|
|
132
|
+
this._inflate.close();
|
|
133
|
+
this._inflate = null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (this._deflate) {
|
|
137
|
+
const callback = this._deflate[kCallback];
|
|
138
|
+
|
|
139
|
+
this._deflate.close();
|
|
140
|
+
this._deflate = null;
|
|
141
|
+
|
|
142
|
+
if (callback) {
|
|
143
|
+
callback(
|
|
144
|
+
new Error(
|
|
145
|
+
'The deflate stream was closed while data was being processed'
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Accept an extension negotiation offer.
|
|
154
|
+
*
|
|
155
|
+
* @param {Array} offers The extension negotiation offers
|
|
156
|
+
* @return {Object} Accepted configuration
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
acceptAsServer(offers) {
|
|
160
|
+
const opts = this._options;
|
|
161
|
+
const accepted = offers.find((params) => {
|
|
162
|
+
if (
|
|
163
|
+
(opts.serverNoContextTakeover === false &&
|
|
164
|
+
params.server_no_context_takeover) ||
|
|
165
|
+
(params.server_max_window_bits &&
|
|
166
|
+
(opts.serverMaxWindowBits === false ||
|
|
167
|
+
(typeof opts.serverMaxWindowBits === 'number' &&
|
|
168
|
+
opts.serverMaxWindowBits > params.server_max_window_bits))) ||
|
|
169
|
+
(typeof opts.clientMaxWindowBits === 'number' &&
|
|
170
|
+
(typeof params.client_max_window_bits === 'number'
|
|
171
|
+
? opts.clientMaxWindowBits > params.client_max_window_bits
|
|
172
|
+
: !params.client_max_window_bits))
|
|
173
|
+
) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return true;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (!accepted) {
|
|
181
|
+
throw new Error('None of the extension offers can be accepted');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (opts.serverNoContextTakeover) {
|
|
185
|
+
accepted.server_no_context_takeover = true;
|
|
186
|
+
}
|
|
187
|
+
if (opts.clientNoContextTakeover) {
|
|
188
|
+
accepted.client_no_context_takeover = true;
|
|
189
|
+
}
|
|
190
|
+
if (typeof opts.serverMaxWindowBits === 'number') {
|
|
191
|
+
accepted.server_max_window_bits = opts.serverMaxWindowBits;
|
|
192
|
+
}
|
|
193
|
+
if (typeof opts.clientMaxWindowBits === 'number') {
|
|
194
|
+
accepted.client_max_window_bits = opts.clientMaxWindowBits;
|
|
195
|
+
} else if (
|
|
196
|
+
accepted.client_max_window_bits === true ||
|
|
197
|
+
opts.clientMaxWindowBits === false
|
|
198
|
+
) {
|
|
199
|
+
delete accepted.client_max_window_bits;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return accepted;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Accept the extension negotiation response.
|
|
207
|
+
*
|
|
208
|
+
* @param {Array} response The extension negotiation response
|
|
209
|
+
* @return {Object} Accepted configuration
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
acceptAsClient(response) {
|
|
213
|
+
const params = response[0];
|
|
214
|
+
|
|
215
|
+
if (
|
|
216
|
+
this._options.clientNoContextTakeover === false &&
|
|
217
|
+
params.client_no_context_takeover
|
|
218
|
+
) {
|
|
219
|
+
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!params.client_max_window_bits) {
|
|
223
|
+
if (typeof this._options.clientMaxWindowBits === 'number') {
|
|
224
|
+
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
225
|
+
}
|
|
226
|
+
} else if (
|
|
227
|
+
this._options.clientMaxWindowBits === false ||
|
|
228
|
+
(typeof this._options.clientMaxWindowBits === 'number' &&
|
|
229
|
+
params.client_max_window_bits > this._options.clientMaxWindowBits)
|
|
230
|
+
) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
'Unexpected or invalid parameter "client_max_window_bits"'
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return params;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Normalize parameters.
|
|
241
|
+
*
|
|
242
|
+
* @param {Array} configurations The extension negotiation offers/reponse
|
|
243
|
+
* @return {Array} The offers/response with normalized parameters
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
normalizeParams(configurations) {
|
|
247
|
+
configurations.forEach((params) => {
|
|
248
|
+
Object.keys(params).forEach((key) => {
|
|
249
|
+
let value = params[key];
|
|
250
|
+
|
|
251
|
+
if (value.length > 1) {
|
|
252
|
+
throw new Error(`Parameter "${key}" must have only a single value`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
value = value[0];
|
|
256
|
+
|
|
257
|
+
if (key === 'client_max_window_bits') {
|
|
258
|
+
if (value !== true) {
|
|
259
|
+
const num = +value;
|
|
260
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
261
|
+
throw new TypeError(
|
|
262
|
+
`Invalid value for parameter "${key}": ${value}`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
value = num;
|
|
266
|
+
} else if (!this._isServer) {
|
|
267
|
+
throw new TypeError(
|
|
268
|
+
`Invalid value for parameter "${key}": ${value}`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
} else if (key === 'server_max_window_bits') {
|
|
272
|
+
const num = +value;
|
|
273
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
274
|
+
throw new TypeError(
|
|
275
|
+
`Invalid value for parameter "${key}": ${value}`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
value = num;
|
|
279
|
+
} else if (
|
|
280
|
+
key === 'client_no_context_takeover' ||
|
|
281
|
+
key === 'server_no_context_takeover'
|
|
282
|
+
) {
|
|
283
|
+
if (value !== true) {
|
|
284
|
+
throw new TypeError(
|
|
285
|
+
`Invalid value for parameter "${key}": ${value}`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
throw new Error(`Unknown parameter "${key}"`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
params[key] = value;
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
return configurations;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Decompress data. Concurrency limited.
|
|
301
|
+
*
|
|
302
|
+
* @param {Buffer} data Compressed data
|
|
303
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
304
|
+
* @param {Function} callback Callback
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
decompress(data, fin, callback) {
|
|
308
|
+
zlibLimiter.add((done) => {
|
|
309
|
+
this._decompress(data, fin, (err, result) => {
|
|
310
|
+
done();
|
|
311
|
+
callback(err, result);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Compress data. Concurrency limited.
|
|
318
|
+
*
|
|
319
|
+
* @param {(Buffer|String)} data Data to compress
|
|
320
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
321
|
+
* @param {Function} callback Callback
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
compress(data, fin, callback) {
|
|
325
|
+
zlibLimiter.add((done) => {
|
|
326
|
+
this._compress(data, fin, (err, result) => {
|
|
327
|
+
done();
|
|
328
|
+
callback(err, result);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Decompress data.
|
|
335
|
+
*
|
|
336
|
+
* @param {Buffer} data Compressed data
|
|
337
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
338
|
+
* @param {Function} callback Callback
|
|
339
|
+
* @private
|
|
340
|
+
*/
|
|
341
|
+
_decompress(data, fin, callback) {
|
|
342
|
+
const endpoint = this._isServer ? 'client' : 'server';
|
|
343
|
+
|
|
344
|
+
if (!this._inflate) {
|
|
345
|
+
const key = `${endpoint}_max_window_bits`;
|
|
346
|
+
const windowBits =
|
|
347
|
+
typeof this.params[key] !== 'number'
|
|
348
|
+
? zlib.Z_DEFAULT_WINDOWBITS
|
|
349
|
+
: this.params[key];
|
|
350
|
+
|
|
351
|
+
this._inflate = zlib.createInflateRaw({
|
|
352
|
+
...this._options.zlibInflateOptions,
|
|
353
|
+
windowBits
|
|
354
|
+
});
|
|
355
|
+
this._inflate[kPerMessageDeflate] = this;
|
|
356
|
+
this._inflate[kTotalLength] = 0;
|
|
357
|
+
this._inflate[kBuffers] = [];
|
|
358
|
+
this._inflate.on('error', inflateOnError);
|
|
359
|
+
this._inflate.on('data', inflateOnData);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
this._inflate[kCallback] = callback;
|
|
363
|
+
|
|
364
|
+
this._inflate.write(data);
|
|
365
|
+
if (fin) this._inflate.write(TRAILER);
|
|
366
|
+
|
|
367
|
+
this._inflate.flush(() => {
|
|
368
|
+
const err = this._inflate[kError];
|
|
369
|
+
|
|
370
|
+
if (err) {
|
|
371
|
+
this._inflate.close();
|
|
372
|
+
this._inflate = null;
|
|
373
|
+
callback(err);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const data = bufferUtil.concat(
|
|
378
|
+
this._inflate[kBuffers],
|
|
379
|
+
this._inflate[kTotalLength]
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
if (this._inflate._readableState.endEmitted) {
|
|
383
|
+
this._inflate.close();
|
|
384
|
+
this._inflate = null;
|
|
385
|
+
} else {
|
|
386
|
+
this._inflate[kTotalLength] = 0;
|
|
387
|
+
this._inflate[kBuffers] = [];
|
|
388
|
+
|
|
389
|
+
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
390
|
+
this._inflate.reset();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
callback(null, data);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Compress data.
|
|
400
|
+
*
|
|
401
|
+
* @param {(Buffer|String)} data Data to compress
|
|
402
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
403
|
+
* @param {Function} callback Callback
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
_compress(data, fin, callback) {
|
|
407
|
+
const endpoint = this._isServer ? 'server' : 'client';
|
|
408
|
+
|
|
409
|
+
if (!this._deflate) {
|
|
410
|
+
const key = `${endpoint}_max_window_bits`;
|
|
411
|
+
const windowBits =
|
|
412
|
+
typeof this.params[key] !== 'number'
|
|
413
|
+
? zlib.Z_DEFAULT_WINDOWBITS
|
|
414
|
+
: this.params[key];
|
|
415
|
+
|
|
416
|
+
this._deflate = zlib.createDeflateRaw({
|
|
417
|
+
...this._options.zlibDeflateOptions,
|
|
418
|
+
windowBits
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
this._deflate[kTotalLength] = 0;
|
|
422
|
+
this._deflate[kBuffers] = [];
|
|
423
|
+
|
|
424
|
+
this._deflate.on('data', deflateOnData);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
this._deflate[kCallback] = callback;
|
|
428
|
+
|
|
429
|
+
this._deflate.write(data);
|
|
430
|
+
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
431
|
+
if (!this._deflate) {
|
|
432
|
+
//
|
|
433
|
+
// The deflate stream was closed while data was being processed.
|
|
434
|
+
//
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let data = bufferUtil.concat(
|
|
439
|
+
this._deflate[kBuffers],
|
|
440
|
+
this._deflate[kTotalLength]
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
if (fin) {
|
|
444
|
+
data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
//
|
|
448
|
+
// Ensure that the callback will not be called again in
|
|
449
|
+
// `PerMessageDeflate#cleanup()`.
|
|
450
|
+
//
|
|
451
|
+
this._deflate[kCallback] = null;
|
|
452
|
+
|
|
453
|
+
this._deflate[kTotalLength] = 0;
|
|
454
|
+
this._deflate[kBuffers] = [];
|
|
455
|
+
|
|
456
|
+
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
457
|
+
this._deflate.reset();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
callback(null, data);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
module.exports = PerMessageDeflate;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* The listener of the `zlib.DeflateRaw` stream `'data'` event.
|
|
469
|
+
*
|
|
470
|
+
* @param {Buffer} chunk A chunk of data
|
|
471
|
+
* @private
|
|
472
|
+
*/
|
|
473
|
+
function deflateOnData(chunk) {
|
|
474
|
+
this[kBuffers].push(chunk);
|
|
475
|
+
this[kTotalLength] += chunk.length;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The listener of the `zlib.InflateRaw` stream `'data'` event.
|
|
480
|
+
*
|
|
481
|
+
* @param {Buffer} chunk A chunk of data
|
|
482
|
+
* @private
|
|
483
|
+
*/
|
|
484
|
+
function inflateOnData(chunk) {
|
|
485
|
+
this[kTotalLength] += chunk.length;
|
|
486
|
+
|
|
487
|
+
if (
|
|
488
|
+
this[kPerMessageDeflate]._maxPayload < 1 ||
|
|
489
|
+
this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload
|
|
490
|
+
) {
|
|
491
|
+
this[kBuffers].push(chunk);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
this[kError] = new RangeError('Max payload size exceeded');
|
|
496
|
+
this[kError].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH';
|
|
497
|
+
this[kError][kStatusCode] = 1009;
|
|
498
|
+
this.removeListener('data', inflateOnData);
|
|
499
|
+
|
|
500
|
+
//
|
|
501
|
+
// The choice to employ `zlib.reset()` over `zlib.close()` is dictated by the
|
|
502
|
+
// fact that in Node.js versions prior to 13.10.0, the callback for
|
|
503
|
+
// `zlib.flush()` is not called if `zlib.close()` is used. Utilizing
|
|
504
|
+
// `zlib.reset()` ensures that either the callback is invoked or an error is
|
|
505
|
+
// emitted.
|
|
506
|
+
//
|
|
507
|
+
this.reset();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* The listener of the `zlib.InflateRaw` stream `'error'` event.
|
|
512
|
+
*
|
|
513
|
+
* @param {Error} err The emitted error
|
|
514
|
+
* @private
|
|
515
|
+
*/
|
|
516
|
+
function inflateOnError(err) {
|
|
517
|
+
//
|
|
518
|
+
// There is no need to call `Zlib#close()` as the handle is automatically
|
|
519
|
+
// closed when an error is emitted.
|
|
520
|
+
//
|
|
521
|
+
this[kPerMessageDeflate]._inflate = null;
|
|
522
|
+
|
|
523
|
+
if (this[kError]) {
|
|
524
|
+
this[kCallback](this[kError]);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
err[kStatusCode] = 1007;
|
|
529
|
+
this[kCallback](err);
|
|
530
|
+
}
|