@jingyi0605/codingns4dsh 0.2.1-beta.12 → 0.2.1-beta.14
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.en.md +5 -5
- package/README.md +6 -9
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +1 -1
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts.map +1 -1
- package/data/build/dist/bootstrap/index.d.ts +1 -1
- package/data/build/dist/bootstrap/index.d.ts.map +1 -1
- package/data/build/dist/client/account-bar.d.ts.map +1 -1
- package/data/build/dist/client/account-bar.js +24 -70
- package/data/build/dist/client/account-bar.js.map +1 -1
- package/data/build/dist/client/adapter-catalog-watch.d.ts +1 -1
- package/data/build/dist/client/adapter-catalog-watch.d.ts.map +1 -1
- package/data/build/dist/client/adapter-catalog-watch.js +2 -2
- package/data/build/dist/client/adapter-catalog-watch.js.map +1 -1
- package/data/build/dist/client/bundle.js +40225 -25580
- package/data/build/dist/client/bundle.js.map +1 -1
- package/data/build/dist/client/cli-management-dialog.d.ts +21 -0
- package/data/build/dist/client/cli-management-dialog.d.ts.map +1 -0
- package/data/build/dist/client/cli-management-dialog.js +215 -0
- package/data/build/dist/client/cli-management-dialog.js.map +1 -0
- package/data/build/dist/client/cli-management-terminal.d.ts +9 -0
- package/data/build/dist/client/cli-management-terminal.d.ts.map +1 -0
- package/data/build/dist/client/cli-management-terminal.js +30 -0
- package/data/build/dist/client/cli-management-terminal.js.map +1 -0
- package/data/build/dist/client/cli-settings-dialog.d.ts +9 -0
- package/data/build/dist/client/cli-settings-dialog.d.ts.map +1 -0
- package/data/build/dist/client/cli-settings-dialog.js +45 -0
- package/data/build/dist/client/cli-settings-dialog.js.map +1 -0
- package/data/build/dist/client/cli-settings-rpc.js +1 -1
- package/data/build/dist/client/cli-settings-rpc.js.map +1 -1
- package/data/build/dist/client/cli-slots.d.ts +4 -0
- package/data/build/dist/client/cli-slots.d.ts.map +1 -1
- package/data/build/dist/client/cli-slots.js +26 -10
- package/data/build/dist/client/cli-slots.js.map +1 -1
- package/data/build/dist/client/client.editor-engine.js +4 -1
- package/data/build/dist/client/client.editor-engine.js.map +1 -1
- package/data/build/dist/client/client.model-catalog-cache.js +9 -1
- package/data/build/dist/client/client.model-catalog-cache.js.map +1 -1
- package/data/build/dist/client/client.native-workspace-store.js +9 -15
- package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
- package/data/build/dist/client/client.primitives-adapter.js +53 -0
- package/data/build/dist/client/client.primitives-adapter.js.map +1 -1
- package/data/build/dist/client/client.session-translation.js +16 -0
- package/data/build/dist/client/client.session-translation.js.map +1 -1
- package/data/build/dist/client/client.transport.js +487 -44
- package/data/build/dist/client/client.transport.js.map +1 -1
- package/data/build/dist/client/conversation-translation-settings.d.ts +2 -1
- package/data/build/dist/client/conversation-translation-settings.d.ts.map +1 -1
- package/data/build/dist/client/conversation-translation-settings.js +7 -5
- package/data/build/dist/client/conversation-translation-settings.js.map +1 -1
- package/data/build/dist/client/desktop-assistant.js +595 -152
- package/data/build/dist/client/editor-engine.d.ts +1 -1
- package/data/build/dist/client/editor-engine.d.ts.map +1 -1
- package/data/build/dist/client/editor-engine.js +4 -1
- package/data/build/dist/client/editor-engine.js.map +1 -1
- package/data/build/dist/client/features/cli-adapters.d.ts +3 -1
- package/data/build/dist/client/features/cli-adapters.d.ts.map +1 -1
- package/data/build/dist/client/features/cli-adapters.js +183 -105
- package/data/build/dist/client/features/cli-adapters.js.map +1 -1
- package/data/build/dist/client/features/file-management.d.ts.map +1 -1
- package/data/build/dist/client/features/file-management.js +2 -0
- package/data/build/dist/client/features/file-management.js.map +1 -1
- package/data/build/dist/client/features/index.d.ts.map +1 -1
- package/data/build/dist/client/features/index.js +2 -0
- package/data/build/dist/client/features/index.js.map +1 -1
- package/data/build/dist/client/features/mobile-access.d.ts.map +1 -1
- package/data/build/dist/client/features/mobile-access.js +7 -0
- package/data/build/dist/client/features/mobile-access.js.map +1 -1
- package/data/build/dist/client/features/peer-host.d.ts.map +1 -1
- package/data/build/dist/client/features/peer-host.js +3 -0
- package/data/build/dist/client/features/peer-host.js.map +1 -1
- package/data/build/dist/client/features/quick-apps.d.ts +3 -0
- package/data/build/dist/client/features/quick-apps.d.ts.map +1 -0
- package/data/build/dist/client/features/quick-apps.js +14 -0
- package/data/build/dist/client/features/quick-apps.js.map +1 -0
- package/data/build/dist/client/features/workspace-session-enhancement.d.ts.map +1 -1
- package/data/build/dist/client/features/workspace-session-enhancement.js +6 -0
- package/data/build/dist/client/features/workspace-session-enhancement.js.map +1 -1
- package/data/build/dist/client/git-management.d.ts.map +1 -1
- package/data/build/dist/client/git-management.js +11 -30
- package/data/build/dist/client/git-management.js.map +1 -1
- package/data/build/dist/client/git-panel-styles.d.ts +4 -0
- package/data/build/dist/client/git-panel-styles.d.ts.map +1 -1
- package/data/build/dist/client/git-panel-styles.js +14 -0
- package/data/build/dist/client/git-panel-styles.js.map +1 -1
- package/data/build/dist/client/html-workspace-files.d.ts +4 -0
- package/data/build/dist/client/html-workspace-files.d.ts.map +1 -0
- package/data/build/dist/client/html-workspace-files.js +114 -0
- package/data/build/dist/client/html-workspace-files.js.map +1 -0
- package/data/build/dist/client/locale.d.ts.map +1 -1
- package/data/build/dist/client/locale.js +14 -0
- package/data/build/dist/client/locale.js.map +1 -1
- package/data/build/dist/client/locales/cliManagement.d.ts +3 -0
- package/data/build/dist/client/locales/cliManagement.d.ts.map +1 -0
- package/data/build/dist/client/locales/cliManagement.js +155 -0
- package/data/build/dist/client/locales/cliManagement.js.map +1 -0
- package/data/build/dist/client/locales/fileWorkspace.d.ts.map +1 -1
- package/data/build/dist/client/locales/fileWorkspace.js +4 -0
- package/data/build/dist/client/locales/fileWorkspace.js.map +1 -1
- package/data/build/dist/client/locales/panels.js +2 -2
- package/data/build/dist/client/locales/panels.js.map +1 -1
- package/data/build/dist/client/locales/quickApps.d.ts +132 -0
- package/data/build/dist/client/locales/quickApps.d.ts.map +1 -0
- package/data/build/dist/client/locales/quickApps.js +154 -0
- package/data/build/dist/client/locales/quickApps.js.map +1 -0
- package/data/build/dist/client/mobile-team-panel-dom.d.ts +14 -0
- package/data/build/dist/client/mobile-team-panel-dom.d.ts.map +1 -0
- package/data/build/dist/client/mobile-team-panel-dom.js +164 -0
- package/data/build/dist/client/mobile-team-panel-dom.js.map +1 -0
- package/data/build/dist/client/native-model-translation-menu.d.ts.map +1 -1
- package/data/build/dist/client/native-model-translation-menu.js +3 -1
- package/data/build/dist/client/native-model-translation-menu.js.map +1 -1
- package/data/build/dist/client/provider-icons.d.ts.map +1 -1
- package/data/build/dist/client/provider-icons.js +3 -1
- package/data/build/dist/client/provider-icons.js.map +1 -1
- package/data/build/dist/client/quick-apps/browser-storage.d.ts +24 -0
- package/data/build/dist/client/quick-apps/browser-storage.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/browser-storage.js +114 -0
- package/data/build/dist/client/quick-apps/browser-storage.js.map +1 -0
- package/data/build/dist/client/quick-apps/client.d.ts +31 -0
- package/data/build/dist/client/quick-apps/client.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/client.js +68 -0
- package/data/build/dist/client/quick-apps/client.js.map +1 -0
- package/data/build/dist/client/quick-apps/document.d.ts +26 -0
- package/data/build/dist/client/quick-apps/document.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/document.js +110 -0
- package/data/build/dist/client/quick-apps/document.js.map +1 -0
- package/data/build/dist/client/quick-apps/file-picker.d.ts +14 -0
- package/data/build/dist/client/quick-apps/file-picker.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/file-picker.js +51 -0
- package/data/build/dist/client/quick-apps/file-picker.js.map +1 -0
- package/data/build/dist/client/quick-apps/launcher.d.ts +7 -0
- package/data/build/dist/client/quick-apps/launcher.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/launcher.js +252 -0
- package/data/build/dist/client/quick-apps/launcher.js.map +1 -0
- package/data/build/dist/client/quick-apps/presentation.d.ts +16 -0
- package/data/build/dist/client/quick-apps/presentation.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/presentation.js +31 -0
- package/data/build/dist/client/quick-apps/presentation.js.map +1 -0
- package/data/build/dist/client/quick-apps/reorder-animation.d.ts +6 -0
- package/data/build/dist/client/quick-apps/reorder-animation.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/reorder-animation.js +50 -0
- package/data/build/dist/client/quick-apps/reorder-animation.js.map +1 -0
- package/data/build/dist/client/quick-apps/reorder.d.ts +26 -0
- package/data/build/dist/client/quick-apps/reorder.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/reorder.js +128 -0
- package/data/build/dist/client/quick-apps/reorder.js.map +1 -0
- package/data/build/dist/client/quick-apps/styles.d.ts +3 -0
- package/data/build/dist/client/quick-apps/styles.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/styles.js +143 -0
- package/data/build/dist/client/quick-apps/styles.js.map +1 -0
- package/data/build/dist/client/quick-apps/ui.d.ts +20 -0
- package/data/build/dist/client/quick-apps/ui.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/ui.js +21 -0
- package/data/build/dist/client/quick-apps/ui.js.map +1 -0
- package/data/build/dist/client/quick-apps/viewer.d.ts +16 -0
- package/data/build/dist/client/quick-apps/viewer.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/viewer.js +165 -0
- package/data/build/dist/client/quick-apps/viewer.js.map +1 -0
- package/data/build/dist/client/quick-apps/workspace-picker.d.ts +19 -0
- package/data/build/dist/client/quick-apps/workspace-picker.d.ts.map +1 -0
- package/data/build/dist/client/quick-apps/workspace-picker.js +30 -0
- package/data/build/dist/client/quick-apps/workspace-picker.js.map +1 -0
- package/data/build/dist/client/session-translation-chat.d.ts +1 -1
- package/data/build/dist/client/session-translation-chat.d.ts.map +1 -1
- package/data/build/dist/client/session-translation-chat.js +26 -22
- package/data/build/dist/client/session-translation-chat.js.map +1 -1
- package/data/build/dist/client/sidebar-footer-style.d.ts +13 -0
- package/data/build/dist/client/sidebar-footer-style.d.ts.map +1 -0
- package/data/build/dist/client/sidebar-footer-style.js +54 -0
- package/data/build/dist/client/sidebar-footer-style.js.map +1 -0
- package/data/build/dist/client/style.css +219 -219
- package/data/build/dist/client/terminal/model.d.ts.map +1 -1
- package/data/build/dist/client/terminal/model.js +2 -1
- package/data/build/dist/client/terminal/model.js.map +1 -1
- package/data/build/dist/client/workspace-session-rightbar-dom.d.ts.map +1 -1
- package/data/build/dist/client/workspace-session-rightbar-dom.js +12 -21
- package/data/build/dist/client/workspace-session-rightbar-dom.js.map +1 -1
- package/data/build/dist/client/workspace-session-visibility-dom.d.ts +3 -0
- package/data/build/dist/client/workspace-session-visibility-dom.d.ts.map +1 -1
- package/data/build/dist/client/workspace-session-visibility-dom.js +5 -4
- package/data/build/dist/client/workspace-session-visibility-dom.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts +4 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js +8 -0
- package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +18 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js +21 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts +18 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js +11 -0
- package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts +8 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js +100 -0
- package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts +3 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js +22 -0
- package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts +52 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js +109 -0
- package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts +11 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js +97 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts +36 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js +164 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts +44 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js +240 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts +37 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js +35 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts +13 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js +30 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts +21 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js +132 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts +10 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.js +33 -0
- package/data/build/dist/dsh-capabilities/host/quick-app-transport.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts +7 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js +18 -0
- package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts +13 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js +24 -0
- package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/matrix.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/matrix.js +16 -8
- package/data/build/dist/dsh-capabilities/matrix.js.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.d.ts +1 -0
- package/data/build/dist/dsh-capabilities/routes.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.js +27 -6
- package/data/build/dist/dsh-capabilities/routes.js.map +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/types.js.map +1 -1
- package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/acp-cli-driver.js +6 -3
- package/data/build/dist/host/cli-adapters/acp-cli-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/binary-detection.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/binary-detection.js +7 -3
- package/data/build/dist/host/cli-adapters/binary-detection.js.map +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts +1 -0
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.js +183 -20
- package/data/build/dist/host/cli-adapters/claude-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts +18 -0
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-driver.js +110 -11
- package/data/build/dist/host/cli-adapters/codex-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts +91 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.js +8 -0
- package/data/build/dist/host/cli-adapters/codex-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance.d.ts +16 -0
- package/data/build/dist/host/cli-adapters/codex-performance.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/codex-performance.js +81 -0
- package/data/build/dist/host/cli-adapters/codex-performance.js.map +1 -0
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.js +11 -1
- package/data/build/dist/host/cli-adapters/command-code-acp-loader.js.map +1 -1
- package/data/build/dist/host/cli-adapters/command-code-driver.js +3 -2
- package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts +3 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.js +41 -4
- package/data/build/dist/host/cli-adapters/desktop-app-runtime.js.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js +19 -5
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js +3 -2
- package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.js +164 -34
- package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js +4 -2
- package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +6 -0
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.js +327 -30
- package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts +123 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.js +48 -0
- package/data/build/dist/host/cli-adapters/grok-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-usage.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/grok-usage.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/grok-usage.js +197 -0
- package/data/build/dist/host/cli-adapters/grok-usage.js.map +1 -0
- package/data/build/dist/host/cli-adapters/legacy-session-adapter.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/legacy-session-adapter.js +20 -3
- package/data/build/dist/host/cli-adapters/legacy-session-adapter.js.map +1 -1
- package/data/build/dist/host/cli-adapters/management-installation.d.ts +5 -0
- package/data/build/dist/host/cli-adapters/management-installation.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-installation.js +131 -0
- package/data/build/dist/host/cli-adapters/management-installation.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management-methods.d.ts +37 -0
- package/data/build/dist/host/cli-adapters/management-methods.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-methods.js +144 -0
- package/data/build/dist/host/cli-adapters/management-methods.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management-process.d.ts +7 -0
- package/data/build/dist/host/cli-adapters/management-process.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management-process.js +62 -0
- package/data/build/dist/host/cli-adapters/management-process.js.map +1 -0
- package/data/build/dist/host/cli-adapters/management.d.ts +32 -0
- package/data/build/dist/host/cli-adapters/management.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/management.js +177 -0
- package/data/build/dist/host/cli-adapters/management.js.map +1 -0
- package/data/build/dist/host/cli-adapters/mcode-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/mcode-driver.js +11 -4
- package/data/build/dist/host/cli-adapters/mcode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts +1 -0
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/model-catalog.js +62 -0
- package/data/build/dist/host/cli-adapters/model-catalog.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js +11 -3
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts +7 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.js +4 -2
- package/data/build/dist/host/cli-adapters/native-team-subagent.js.map +1 -1
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/opencode-driver.js +105 -17
- package/data/build/dist/host/cli-adapters/opencode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/process-utils.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.js +16 -11
- package/data/build/dist/host/cli-adapters/process-utils.js.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.d.ts +7 -1
- package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.js +98 -30
- package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts +74 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.js +83 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.js.map +1 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js +4 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +3 -1
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/stream-normalizer.js +2 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.js.map +1 -1
- package/data/build/dist/host/cli-adapters/subagent-tool.js +1 -1
- package/data/build/dist/host/cli-adapters/subagent-tool.js.map +1 -1
- package/data/build/dist/host/cli-adapters/team-input.d.ts +17 -0
- package/data/build/dist/host/cli-adapters/team-input.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/team-input.js +67 -0
- package/data/build/dist/host/cli-adapters/team-input.js.map +1 -0
- package/data/build/dist/host/cli-adapters/update-check.d.ts +34 -0
- package/data/build/dist/host/cli-adapters/update-check.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/update-check.js +263 -0
- package/data/build/dist/host/cli-adapters/update-check.js.map +1 -0
- package/data/build/dist/host/cli-adapters/zcode-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js +6 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/zcode-update.d.ts +8 -0
- package/data/build/dist/host/cli-adapters/zcode-update.d.ts.map +1 -0
- package/data/build/dist/host/cli-adapters/zcode-update.js +149 -0
- package/data/build/dist/host/cli-adapters/zcode-update.js.map +1 -0
- package/data/build/dist/host/cli-bridge/bridge-holder.d.ts +14 -0
- package/data/build/dist/host/cli-bridge/bridge-holder.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-holder.js +53 -6
- package/data/build/dist/host/cli-bridge/bridge-holder.js.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-server.d.ts +4 -0
- package/data/build/dist/host/cli-bridge/bridge-server.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/bridge-server.js +34 -6
- package/data/build/dist/host/cli-bridge/bridge-server.js.map +1 -1
- package/data/build/dist/host/cli-bridge/command-code-mod.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/command-code-mod.js +43 -0
- package/data/build/dist/host/cli-bridge/command-code-mod.js.map +1 -1
- package/data/build/dist/host/cli-bridge/dispatch.js +1 -1
- package/data/build/dist/host/cli-bridge/dispatch.js.map +1 -1
- package/data/build/dist/host/cli-bridge/injections.d.ts +3 -0
- package/data/build/dist/host/cli-bridge/injections.d.ts.map +1 -1
- package/data/build/dist/host/cli-bridge/injections.js +23 -7
- package/data/build/dist/host/cli-bridge/injections.js.map +1 -1
- package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js +22 -3
- package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js.map +1 -1
- package/data/build/dist/host/cli-bridge/team-adapters.d.ts +11 -0
- package/data/build/dist/host/cli-bridge/team-adapters.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-adapters.js +22 -0
- package/data/build/dist/host/cli-bridge/team-adapters.js.map +1 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.d.ts +28 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.js +208 -0
- package/data/build/dist/host/cli-bridge/team-dispatch.js.map +1 -0
- package/data/build/dist/host/cli-bridge/team-tool.d.ts +3 -0
- package/data/build/dist/host/cli-bridge/team-tool.d.ts.map +1 -0
- package/data/build/dist/host/cli-bridge/team-tool.js +18 -0
- package/data/build/dist/host/cli-bridge/team-tool.js.map +1 -0
- package/data/build/dist/host/features/file-management.d.ts.map +1 -1
- package/data/build/dist/host/features/file-management.js +8 -0
- package/data/build/dist/host/features/file-management.js.map +1 -1
- package/data/build/dist/host/features/index.d.ts.map +1 -1
- package/data/build/dist/host/features/index.js +2 -0
- package/data/build/dist/host/features/index.js.map +1 -1
- package/data/build/dist/host/features/lan-access-dsh.js +1 -1
- package/data/build/dist/host/features/lan-access-dsh.js.map +1 -1
- package/data/build/dist/host/features/peer-host.d.ts.map +1 -1
- package/data/build/dist/host/features/peer-host.js +7 -0
- package/data/build/dist/host/features/peer-host.js.map +1 -1
- package/data/build/dist/host/features/quick-apps.d.ts +4 -0
- package/data/build/dist/host/features/quick-apps.d.ts.map +1 -0
- package/data/build/dist/host/features/quick-apps.js +158 -0
- package/data/build/dist/host/features/quick-apps.js.map +1 -0
- package/data/build/dist/host/features/session-prompt-translation.d.ts +1 -1
- package/data/build/dist/host/features/session-prompt-translation.d.ts.map +1 -1
- package/data/build/dist/host/features/session-prompt-translation.js +13 -4
- package/data/build/dist/host/features/session-prompt-translation.js.map +1 -1
- package/data/build/dist/host/features/session-translation-protection.d.ts +6 -0
- package/data/build/dist/host/features/session-translation-protection.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-protection.js +21 -0
- package/data/build/dist/host/features/session-translation-protection.js.map +1 -1
- package/data/build/dist/host/features/session-translation-recovery.d.ts +3 -2
- package/data/build/dist/host/features/session-translation-recovery.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-recovery.js +6 -3
- package/data/build/dist/host/features/session-translation-recovery.js.map +1 -1
- package/data/build/dist/host/features/session-translation-service.d.ts +3 -0
- package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-service.js +14 -8
- package/data/build/dist/host/features/session-translation-service.js.map +1 -1
- package/data/build/dist/host/features/types.d.ts +10 -0
- package/data/build/dist/host/features/types.d.ts.map +1 -1
- package/data/build/dist/host/html-workspace-files.d.ts +3 -0
- package/data/build/dist/host/html-workspace-files.d.ts.map +1 -0
- package/data/build/dist/host/html-workspace-files.js +135 -0
- package/data/build/dist/host/html-workspace-files.js.map +1 -0
- package/data/build/dist/host/index.d.ts.map +1 -1
- package/data/build/dist/host/index.js +27 -2
- package/data/build/dist/host/index.js.map +1 -1
- package/data/build/dist/host/lan-access-dsh.d.ts +5 -1
- package/data/build/dist/host/lan-access-dsh.d.ts.map +1 -1
- package/data/build/dist/host/lan-access-dsh.js +43 -2
- package/data/build/dist/host/lan-access-dsh.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts +5 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts.map +1 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.js +27 -0
- package/data/build/dist/host/modules/peer-host/quick-app-gateway.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/browse.d.ts +5 -0
- package/data/build/dist/host/modules/quick-apps/browse.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/browse.js +37 -0
- package/data/build/dist/host/modules/quick-apps/browse.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.d.ts +4 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.js +39 -0
- package/data/build/dist/host/modules/quick-apps/code-revision.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/documents.d.ts +14 -0
- package/data/build/dist/host/modules/quick-apps/documents.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/documents.js +87 -0
- package/data/build/dist/host/modules/quick-apps/documents.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/errors.d.ts +8 -0
- package/data/build/dist/host/modules/quick-apps/errors.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/errors.js +15 -0
- package/data/build/dist/host/modules/quick-apps/errors.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/file-api.d.ts +30 -0
- package/data/build/dist/host/modules/quick-apps/file-api.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/file-api.js +149 -0
- package/data/build/dist/host/modules/quick-apps/file-api.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/launches.d.ts +35 -0
- package/data/build/dist/host/modules/quick-apps/launches.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/launches.js +80 -0
- package/data/build/dist/host/modules/quick-apps/launches.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/paths.d.ts +14 -0
- package/data/build/dist/host/modules/quick-apps/paths.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/paths.js +72 -0
- package/data/build/dist/host/modules/quick-apps/paths.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/registry.d.ts +30 -0
- package/data/build/dist/host/modules/quick-apps/registry.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/registry.js +186 -0
- package/data/build/dist/host/modules/quick-apps/registry.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/remote.d.ts +38 -0
- package/data/build/dist/host/modules/quick-apps/remote.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/remote.js +238 -0
- package/data/build/dist/host/modules/quick-apps/remote.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/service.d.ts +27 -0
- package/data/build/dist/host/modules/quick-apps/service.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/service.js +174 -0
- package/data/build/dist/host/modules/quick-apps/service.js.map +1 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.d.ts +8 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.d.ts.map +1 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.js +190 -0
- package/data/build/dist/host/modules/quick-apps/static-handler.js.map +1 -0
- package/data/build/dist/host/native-session-bridge.d.ts +5 -0
- package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
- package/data/build/dist/host/native-session-bridge.js +3 -0
- package/data/build/dist/host/native-session-bridge.js.map +1 -1
- package/data/build/dist/host/rpc.d.ts.map +1 -1
- package/data/build/dist/host/rpc.js +8 -3
- package/data/build/dist/host/rpc.js.map +1 -1
- package/data/build/dist/host/session-migration-repair.js +48 -35
- package/data/build/dist/host/session-migration-repair.js.map +1 -1
- package/data/build/dist/host/settings.d.ts.map +1 -1
- package/data/build/dist/host/settings.js +13 -0
- package/data/build/dist/host/settings.js.map +1 -1
- package/data/build/dist/host/workspace-file-mutations.d.ts +2 -0
- package/data/build/dist/host/workspace-file-mutations.d.ts.map +1 -0
- package/data/build/dist/host/workspace-file-mutations.js +15 -0
- package/data/build/dist/host/workspace-file-mutations.js.map +1 -0
- package/data/build/dist/shared/cli-provider-route.d.ts +7 -0
- package/data/build/dist/shared/cli-provider-route.d.ts.map +1 -0
- package/data/build/dist/shared/cli-provider-route.js +13 -0
- package/data/build/dist/shared/cli-provider-route.js.map +1 -0
- package/data/build/dist/shared/codex-performance.d.ts +3 -0
- package/data/build/dist/shared/codex-performance.d.ts.map +1 -0
- package/data/build/dist/shared/codex-performance.js +2 -0
- package/data/build/dist/shared/codex-performance.js.map +1 -0
- package/data/build/dist/shared/contracts/agent-team.d.ts +14 -0
- package/data/build/dist/shared/contracts/agent-team.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/agent-team.js +48 -0
- package/data/build/dist/shared/contracts/agent-team.js.map +1 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +35 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/cli-management.d.ts +29 -0
- package/data/build/dist/shared/contracts/cli-management.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/cli-management.js +2 -0
- package/data/build/dist/shared/contracts/cli-management.js.map +1 -0
- package/data/build/dist/shared/contracts/config.d.ts +2 -0
- package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/config.js.map +1 -1
- package/data/build/dist/shared/contracts/errors.d.ts +2 -2
- package/data/build/dist/shared/contracts/errors.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/quick-apps.d.ts +68 -0
- package/data/build/dist/shared/contracts/quick-apps.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/quick-apps.js +4 -0
- package/data/build/dist/shared/contracts/quick-apps.js.map +1 -0
- package/data/build/dist/shared/contracts/session-translation.d.ts +8 -3
- package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/session-translation.js +14 -0
- package/data/build/dist/shared/contracts/session-translation.js.map +1 -1
- package/data/build/dist/shared/contracts/version.d.ts +9 -15
- package/data/build/dist/shared/contracts/version.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/version.js +8 -14
- package/data/build/dist/shared/contracts/version.js.map +1 -1
- package/data/build/dist/shared/peer-host-http-routes.d.ts +4 -0
- package/data/build/dist/shared/peer-host-http-routes.d.ts.map +1 -1
- package/data/build/dist/shared/peer-host-http-routes.js +4 -0
- package/data/build/dist/shared/peer-host-http-routes.js.map +1 -1
- package/data/build/dist/shared/quick-app-browser-storage.d.ts +33 -0
- package/data/build/dist/shared/quick-app-browser-storage.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-browser-storage.js +33 -0
- package/data/build/dist/shared/quick-app-browser-storage.js.map +1 -0
- package/data/build/dist/shared/quick-app-proxy-path.d.ts +6 -0
- package/data/build/dist/shared/quick-app-proxy-path.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-proxy-path.js +18 -0
- package/data/build/dist/shared/quick-app-proxy-path.js.map +1 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.d.ts +9 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.d.ts.map +1 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.js +186 -0
- package/data/build/dist/shared/quick-app-storage-bootstrap.js.map +1 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts +7 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts.map +1 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.js +10 -0
- package/data/build/dist/shared/quick-apps-bootstrap-locale.js.map +1 -0
- package/data/build/dist/shared/request-performance.d.ts +15 -0
- package/data/build/dist/shared/request-performance.d.ts.map +1 -0
- package/data/build/dist/shared/request-performance.js +3 -0
- package/data/build/dist/shared/request-performance.js.map +1 -0
- package/package.json +32 -32
- package/profile/README.md +2 -2
- package/profile/package.json +3 -3
- package/profile/version.json +3 -3
- package/version.json +3 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { QUICK_APP_LIMITS } from '../../shared/contracts/quick-apps.js';
|
|
3
|
+
import { quickAppBootstrapEn, quickAppBootstrapZh } from '../../shared/quick-apps-bootstrap-locale.js';
|
|
4
|
+
const bootstrapPath = '/__quickapp/bootstrap';
|
|
5
|
+
const exchangePath = '/__quickapp/exchange';
|
|
6
|
+
const readyPath = '/__quickapp/ready';
|
|
7
|
+
const hash = (value) => createHash('sha256').update(value).digest();
|
|
8
|
+
/** Shared credential landing page; application files are never rewritten. */
|
|
9
|
+
export function quickAppCredentials(origin, uiOrigin, cookieName) {
|
|
10
|
+
let active = true;
|
|
11
|
+
let activation;
|
|
12
|
+
let credentialDigest;
|
|
13
|
+
return {
|
|
14
|
+
async handle(request, response) {
|
|
15
|
+
const path = request.url;
|
|
16
|
+
if (path !== bootstrapPath && path !== exchangePath && path !== readyPath)
|
|
17
|
+
return false;
|
|
18
|
+
if (!active) {
|
|
19
|
+
endQuickAppResponse(response, 410);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (path === bootstrapPath && request.method === 'GET') {
|
|
23
|
+
if (!activation || activation.expires <= Date.now()) {
|
|
24
|
+
activation = undefined;
|
|
25
|
+
endQuickAppResponse(response, 410);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const nonce = randomBytes(18).toString('base64url');
|
|
29
|
+
const copy = /^zh(?:\b|-)/iu.test(request.headers['accept-language'] ?? '') ? quickAppBootstrapZh : quickAppBootstrapEn;
|
|
30
|
+
response.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
31
|
+
response.setHeader('Content-Security-Policy', `default-src 'none'; script-src 'nonce-${nonce}'; connect-src 'self'; frame-ancestors ${uiOrigin}; base-uri 'none'; form-action 'none'`);
|
|
32
|
+
response.end(`<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1"><p id="status">${copy['quickApps.opening']}</p><script nonce="${nonce}">(async()=>{const ticket=location.hash.slice(1);history.replaceState(null,'',location.pathname);try{const r=await fetch('${exchangePath}',{method:'POST',headers:{'Content-Type':'text/plain'},body:ticket,credentials:'include'});if(!r.ok)throw 0;const next=await r.text();const ready=await fetch('${readyPath}',{credentials:'include'});if(!ready.ok)throw 0;location.replace(next)}catch{document.querySelector('#status').textContent=${JSON.stringify(copy['quickApps.bootstrapFailed'])}}})()</script>`);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (path === exchangePath) {
|
|
36
|
+
if (request.method !== 'POST' || request.headers.origin !== origin || request.headers['content-type'] !== 'text/plain'
|
|
37
|
+
|| !activation || activation.expires <= Date.now()) {
|
|
38
|
+
endQuickAppResponse(response, 403);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const ticket = await readTicket(request);
|
|
42
|
+
if (!ticket || !active || !activation || !timingSafeEqual(activation.digest, hash(ticket))) {
|
|
43
|
+
endQuickAppResponse(response, 403);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
const grant = activation;
|
|
47
|
+
activation = undefined;
|
|
48
|
+
credentialDigest = hash(grant.credential);
|
|
49
|
+
response.setHeader('Set-Cookie', `${cookieName}=${grant.credential}; Path=/; Secure; HttpOnly; SameSite=None; Partitioned; Max-Age=${QUICK_APP_LIMITS.lifetimeMs / 1000}`);
|
|
50
|
+
response.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
51
|
+
response.end(grant.entryPath);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (path === readyPath) {
|
|
55
|
+
const cookies = request.headers.cookie?.split(';').map(value => value.trim()).filter(value => value.startsWith(`${cookieName}=`)) ?? [];
|
|
56
|
+
const supplied = cookies.length === 1 ? cookies[0].slice(cookieName.length + 1) : '';
|
|
57
|
+
endQuickAppResponse(response, request.method === 'GET' && credentialDigest && timingSafeEqual(credentialDigest, hash(supplied)) ? 204 : 401);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
endQuickAppResponse(response, 405);
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
async activate(credential, entryPath) {
|
|
64
|
+
if (!active || activation || credentialDigest || !/^\/(?!\/)/u.test(entryPath) || /[\r\n#?]/u.test(entryPath))
|
|
65
|
+
throw new Error('Invalid app activation.');
|
|
66
|
+
const ticket = randomBytes(32).toString('base64url');
|
|
67
|
+
activation = { digest: hash(ticket), credential, entryPath, expires: Date.now() + 60_000 };
|
|
68
|
+
return { url: `${origin}${bootstrapPath}#${ticket}` };
|
|
69
|
+
},
|
|
70
|
+
dispose() { active = false; activation = undefined; credentialDigest = undefined; },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function endQuickAppResponse(response, status) {
|
|
74
|
+
if (response.headersSent) {
|
|
75
|
+
response.destroy();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
response.setHeader('Cache-Control', 'no-store');
|
|
79
|
+
response.writeHead(status);
|
|
80
|
+
response.end();
|
|
81
|
+
}
|
|
82
|
+
async function readTicket(request) {
|
|
83
|
+
if (Number(request.headers['content-length'] ?? 0) > 128) {
|
|
84
|
+
request.resume();
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
let body = '';
|
|
88
|
+
for await (const chunk of request.iterator({ destroyOnReturn: false })) {
|
|
89
|
+
body += String(chunk);
|
|
90
|
+
if (body.length > 128) {
|
|
91
|
+
request.resume();
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return /^[A-Za-z0-9_-]{43}$/u.test(body) ? body : undefined;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=quick-app-credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-app-credentials.js","sourceRoot":"","sources":["../../../../../src/dsh-capabilities/host/quick-app-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAEtG,MAAM,aAAa,GAAG,uBAAu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OAAO,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACvE,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;QACrB,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAAC,OAAO,SAAS,CAAA;QAAC,CAAC;IAC/D,CAAC;IACD,OAAO,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7D,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { QuickAppOriginLease, QuickAppOriginProvider } from './quick-app-origin-adapter.js';
|
|
3
|
+
/** Operator-owned configuration, never settings mirrored to browsers or an RPC argument. */
|
|
4
|
+
export interface QuickAppHttpsConfig {
|
|
5
|
+
readonly appDomain: string;
|
|
6
|
+
readonly uiOrigins: readonly string[];
|
|
7
|
+
readonly listenHost: string;
|
|
8
|
+
readonly listenPort: number;
|
|
9
|
+
readonly publicPort: number;
|
|
10
|
+
readonly certFile: string;
|
|
11
|
+
readonly keyFile: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseQuickAppHttpsConfig(value: unknown): QuickAppHttpsConfig;
|
|
14
|
+
/** No listener is started until an authenticated user opens an HTML app. */
|
|
15
|
+
export declare function configuredQuickAppHttpsProvider(configPath?: string | undefined): Promise<QuickAppHttpsProvider | undefined>;
|
|
16
|
+
export declare function boundedFile(path: string, limit: number): Promise<string>;
|
|
17
|
+
/** Dedicated TLS virtual-host listener. It never serves or proxies privileged DSH routes. */
|
|
18
|
+
export declare class QuickAppHttpsProvider implements QuickAppOriginProvider {
|
|
19
|
+
private readonly config;
|
|
20
|
+
private readonly tls;
|
|
21
|
+
private readonly routes;
|
|
22
|
+
private server;
|
|
23
|
+
private pending;
|
|
24
|
+
private stopped;
|
|
25
|
+
constructor(config: QuickAppHttpsConfig, tls: {
|
|
26
|
+
cert: string;
|
|
27
|
+
key: string;
|
|
28
|
+
});
|
|
29
|
+
available(uiOrigin?: string): boolean;
|
|
30
|
+
open(handler: (request: IncomingMessage, response: ServerResponse) => void, uiOrigin?: string): Promise<QuickAppOriginLease>;
|
|
31
|
+
dispose(): Promise<void>;
|
|
32
|
+
private listen;
|
|
33
|
+
private closeListener;
|
|
34
|
+
private serialize;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=quick-app-https-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-app-https-provider.d.ts","sourceRoot":"","sources":["../../../../../src/dsh-capabilities/host/quick-app-https-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAIhG,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAKD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAqB5E;AAED,4EAA4E;AAC5E,wBAAsB,+BAA+B,CAAC,UAAU,qBAA+C,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAQ3J;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU9E;AAID,6FAA6F;AAC7F,qBAAa,qBAAsB,YAAW,sBAAsB;IAKtD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAuB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJ9E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,OAAO,CAAQ;gBACM,MAAM,EAAE,mBAAmB,EAAmB,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAS7G,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IACrC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwB5H,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIV,MAAM;YAsBN,aAAa;IAM3B,OAAO,CAAC,SAAS;CAKlB"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { randomBytes, X509Certificate } from 'node:crypto';
|
|
2
|
+
import { isAbsolute } from 'node:path';
|
|
3
|
+
import { isIP } from 'node:net';
|
|
4
|
+
import { createServer } from 'node:https';
|
|
5
|
+
import { QUICK_APP_LIMITS } from '../../shared/contracts/quick-apps.js';
|
|
6
|
+
import { endQuickAppResponse as end, quickAppCredentials } from './quick-app-credentials.js';
|
|
7
|
+
const cookieName = '__Host-quickapp';
|
|
8
|
+
const unavailable = () => Object.assign(new Error('Quick Apps HTTPS configuration is unavailable or invalid.'), { code: 'QUICK_APP_ORIGIN_UNAVAILABLE' });
|
|
9
|
+
export function parseQuickAppHttpsConfig(value) {
|
|
10
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
11
|
+
throw unavailable();
|
|
12
|
+
const config = value;
|
|
13
|
+
const keys = ['appDomain', 'uiOrigins', 'listenHost', 'listenPort', 'publicPort', 'certFile', 'keyFile'];
|
|
14
|
+
if (Object.keys(config).some(key => !keys.includes(key)) || typeof config.appDomain !== 'string'
|
|
15
|
+
|| config.appDomain.length > 190 || !/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/u.test(config.appDomain)
|
|
16
|
+
|| config.appDomain.split('.').some(label => label.length > 63)
|
|
17
|
+
|| config.appDomain === 'localhost' || config.appDomain.endsWith('.localhost') || isIP(config.appDomain)
|
|
18
|
+
|| !isIP(config.listenHost) || ![config.listenPort, config.publicPort].every(port => Number.isInteger(port) && port > 0 && port < 65536)
|
|
19
|
+
|| ![config.certFile, config.keyFile].every(path => typeof path === 'string' && isAbsolute(path))
|
|
20
|
+
|| !Array.isArray(config.uiOrigins) || config.uiOrigins.length < 1 || config.uiOrigins.length > 16)
|
|
21
|
+
throw unavailable();
|
|
22
|
+
for (const origin of config.uiOrigins) {
|
|
23
|
+
let ui;
|
|
24
|
+
try {
|
|
25
|
+
ui = new URL(origin);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw unavailable();
|
|
29
|
+
}
|
|
30
|
+
if (ui.origin !== origin || !['http:', 'https:'].includes(ui.protocol) || ui.username || ui.password
|
|
31
|
+
|| ui.hostname === config.appDomain || ui.hostname.endsWith(`.${config.appDomain}`)
|
|
32
|
+
// Conservatively reject even sibling sites under a multi-label public suffix.
|
|
33
|
+
// Different final two DNS labels ensure UI Domain cookies cannot reach app pages.
|
|
34
|
+
|| ui.hostname.split('.').slice(-2).join('.') === config.appDomain.split('.').slice(-2).join('.'))
|
|
35
|
+
throw unavailable();
|
|
36
|
+
}
|
|
37
|
+
return structuredClone(config);
|
|
38
|
+
}
|
|
39
|
+
/** No listener is started until an authenticated user opens an HTML app. */
|
|
40
|
+
export async function configuredQuickAppHttpsProvider(configPath = process.env.CODINGNS_QUICK_APPS_HTTPS_CONFIG) {
|
|
41
|
+
if (!configPath)
|
|
42
|
+
return undefined;
|
|
43
|
+
try {
|
|
44
|
+
if (!isAbsolute(configPath))
|
|
45
|
+
throw unavailable();
|
|
46
|
+
const config = parseQuickAppHttpsConfig(JSON.parse(await boundedFile(configPath, 32 * 1024)));
|
|
47
|
+
const [cert, key] = await Promise.all([boundedFile(config.certFile, 128 * 1024), boundedFile(config.keyFile, 64 * 1024)]);
|
|
48
|
+
return new QuickAppHttpsProvider(config, { cert, key });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw unavailable();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function boundedFile(path, limit) {
|
|
55
|
+
const { open } = await import('node:fs/promises');
|
|
56
|
+
const file = await open(path, 'r');
|
|
57
|
+
try {
|
|
58
|
+
if (!(await file.stat()).isFile())
|
|
59
|
+
throw unavailable();
|
|
60
|
+
const bytes = Buffer.alloc(limit + 1);
|
|
61
|
+
const { bytesRead } = await file.read(bytes, 0, bytes.length, 0);
|
|
62
|
+
if (bytesRead > limit)
|
|
63
|
+
throw unavailable();
|
|
64
|
+
return bytes.subarray(0, bytesRead).toString('utf8');
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
await file.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Dedicated TLS virtual-host listener. It never serves or proxies privileged DSH routes. */
|
|
71
|
+
export class QuickAppHttpsProvider {
|
|
72
|
+
config;
|
|
73
|
+
tls;
|
|
74
|
+
routes = new Map();
|
|
75
|
+
server;
|
|
76
|
+
pending = Promise.resolve();
|
|
77
|
+
stopped = false;
|
|
78
|
+
constructor(config, tls) {
|
|
79
|
+
this.config = config;
|
|
80
|
+
this.tls = tls;
|
|
81
|
+
parseQuickAppHttpsConfig(config);
|
|
82
|
+
const certificate = new X509Certificate(tls.cert);
|
|
83
|
+
if (!certificate.checkHost(`probe.${config.appDomain}`) || Date.parse(certificate.validTo) <= Date.now()
|
|
84
|
+
|| Date.parse(certificate.validFrom) > Date.now())
|
|
85
|
+
throw unavailable();
|
|
86
|
+
// Validate the key pair before reporting the configured transport as available.
|
|
87
|
+
const probe = createServer({ ...tls, minVersion: 'TLSv1.2' });
|
|
88
|
+
probe.close();
|
|
89
|
+
}
|
|
90
|
+
available(uiOrigin) { return !this.stopped && typeof uiOrigin === 'string' && this.config.uiOrigins.includes(uiOrigin); }
|
|
91
|
+
open(handler, uiOrigin) {
|
|
92
|
+
return this.serialize(async () => {
|
|
93
|
+
if (!this.available(uiOrigin) || this.routes.size >= QUICK_APP_LIMITS.launches)
|
|
94
|
+
throw unavailable();
|
|
95
|
+
await this.listen();
|
|
96
|
+
// Random names are never reused, including across Host/module restarts.
|
|
97
|
+
const hostname = `${randomBytes(24).toString('hex')}.${this.config.appDomain}`;
|
|
98
|
+
const origin = `https://${hostname}${this.config.publicPort === 443 ? '' : `:${this.config.publicPort}`}`;
|
|
99
|
+
const host = new URL(origin).host;
|
|
100
|
+
const credentials = quickAppCredentials(origin, uiOrigin, cookieName);
|
|
101
|
+
const route = { host, handle: async (request, response) => {
|
|
102
|
+
if (!await credentials.handle(request, response))
|
|
103
|
+
handler(request, response);
|
|
104
|
+
} };
|
|
105
|
+
this.routes.set(hostname, route);
|
|
106
|
+
return {
|
|
107
|
+
origin, uiOrigin: uiOrigin, ownerHostId: 'local', remote: true, cookieName,
|
|
108
|
+
activate: credentials.activate,
|
|
109
|
+
dispose: () => this.serialize(async () => {
|
|
110
|
+
credentials.dispose();
|
|
111
|
+
this.routes.delete(hostname);
|
|
112
|
+
if (this.routes.size === 0)
|
|
113
|
+
await this.closeListener();
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
dispose() {
|
|
119
|
+
this.stopped = true;
|
|
120
|
+
return this.serialize(async () => { this.routes.clear(); await this.closeListener(); });
|
|
121
|
+
}
|
|
122
|
+
async listen() {
|
|
123
|
+
if (this.server)
|
|
124
|
+
return;
|
|
125
|
+
const server = createServer({ ...this.tls, minVersion: 'TLSv1.2', handshakeTimeout: 10_000, maxHeaderSize: 16 * 1024 }, (request, response) => {
|
|
126
|
+
response.setHeader('Cache-Control', 'no-store');
|
|
127
|
+
response.setHeader('Referrer-Policy', 'no-referrer');
|
|
128
|
+
response.setHeader('X-Content-Type-Options', 'nosniff');
|
|
129
|
+
const sni = request.socket.servername;
|
|
130
|
+
const route = typeof sni === 'string' ? this.routes.get(sni) : undefined;
|
|
131
|
+
// Never trust forwarded Host/Origin headers; TLS terminates at this listener.
|
|
132
|
+
if (!route || request.headers.host !== route.host || request.rawHeaders.filter((_, i) => i % 2 === 0 && request.rawHeaders[i].toLowerCase() === 'host').length !== 1)
|
|
133
|
+
return end(response, 421);
|
|
134
|
+
void route.handle(request, response).catch(() => end(response, 400));
|
|
135
|
+
});
|
|
136
|
+
server.requestTimeout = 15_000;
|
|
137
|
+
server.headersTimeout = 10_000;
|
|
138
|
+
server.timeout = 30_000;
|
|
139
|
+
server.keepAliveTimeout = 5_000;
|
|
140
|
+
server.maxRequestsPerSocket = 100;
|
|
141
|
+
server.maxConnections = 256;
|
|
142
|
+
await new Promise((resolve, reject) => {
|
|
143
|
+
server.once('error', reject);
|
|
144
|
+
server.listen(this.config.listenPort, this.config.listenHost, () => { server.removeListener('error', reject); resolve(); });
|
|
145
|
+
}).catch(() => { server.close(); throw unavailable(); });
|
|
146
|
+
// Listener failures must not take down unrelated Host modules.
|
|
147
|
+
server.on('error', () => { void this.dispose(); });
|
|
148
|
+
this.server = server;
|
|
149
|
+
}
|
|
150
|
+
async closeListener() {
|
|
151
|
+
const server = this.server;
|
|
152
|
+
this.server = undefined;
|
|
153
|
+
if (!server)
|
|
154
|
+
return;
|
|
155
|
+
server.closeAllConnections();
|
|
156
|
+
await new Promise(resolve => server.close(() => resolve()));
|
|
157
|
+
}
|
|
158
|
+
serialize(operation) {
|
|
159
|
+
const result = this.pending.catch(() => undefined).then(operation);
|
|
160
|
+
this.pending = result.then(() => undefined, () => undefined);
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=quick-app-https-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-app-https-provider.js","sourceRoot":"","sources":["../../../../../src/dsh-capabilities/host/quick-app-https-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAe,MAAM,YAAY,CAAA;AAItD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AACvE,OAAO,EAAE,mBAAmB,IAAI,GAAG,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAa5F,MAAM,UAAU,GAAG,iBAAiB,CAAA;AACpC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2DAA2D,CAAC,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC,CAAA;AAEzJ,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,WAAW,EAAE,CAAA;IACpF,MAAM,MAAM,GAAG,KAA4B,CAAA;IAC3C,MAAM,IAAI,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;IACxG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IA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AC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;QACnD,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC5B,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC;IACO,SAAS,CAAI,SAA2B;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAClE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC5D,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { type QuickAppRuntimeReason } from '../../shared/contracts/quick-apps.js';
|
|
3
|
+
import type { QuickAppLanTransport, QuickAppOriginLease, QuickAppOriginProvider } from './quick-app-origin-adapter.js';
|
|
4
|
+
export interface QuickAppLanPortsConfig {
|
|
5
|
+
readonly transport: 'lan-ports';
|
|
6
|
+
readonly publicHost: string;
|
|
7
|
+
readonly uiOrigins: readonly string[];
|
|
8
|
+
readonly ports: readonly [number, number];
|
|
9
|
+
readonly stateDirectory: string;
|
|
10
|
+
readonly certFile: string;
|
|
11
|
+
readonly keyFile: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseQuickAppLanPortsConfig(value: unknown): QuickAppLanPortsConfig;
|
|
14
|
+
/** Browsers cannot forge these headers; they are an origin fence, never authentication. */
|
|
15
|
+
export declare function sameBrowserOrigin(headers: Record<string, string | string[] | undefined>, origin: string): boolean;
|
|
16
|
+
/** Dedicated app HTTPS ports on the existing LAN bind address; no DSH forwarding. */
|
|
17
|
+
export declare class QuickAppLanPortsProvider implements QuickAppOriginProvider, QuickAppLanTransport {
|
|
18
|
+
private readonly tls;
|
|
19
|
+
readonly isolation: "lan-port";
|
|
20
|
+
private listenHost;
|
|
21
|
+
private stopped;
|
|
22
|
+
private pending;
|
|
23
|
+
private readonly active;
|
|
24
|
+
private readonly reserved;
|
|
25
|
+
private allocationFailure;
|
|
26
|
+
private generation;
|
|
27
|
+
private readonly config;
|
|
28
|
+
constructor(config: QuickAppLanPortsConfig, tls: {
|
|
29
|
+
cert: string;
|
|
30
|
+
key: string;
|
|
31
|
+
});
|
|
32
|
+
/** Read persistent reservations before availability is advertised. Never delete this history. */
|
|
33
|
+
initialize(): Promise<void>;
|
|
34
|
+
started(listenHost: string): void;
|
|
35
|
+
stopping(): Promise<void>;
|
|
36
|
+
dispose(): Promise<void>;
|
|
37
|
+
available(uiOrigin?: string): boolean;
|
|
38
|
+
protects(uiOrigin?: string): boolean;
|
|
39
|
+
diagnostic(uiOrigin?: string): QuickAppRuntimeReason | undefined;
|
|
40
|
+
permits(headers: Record<string, string>, method: string, path: string): boolean;
|
|
41
|
+
open(handler: (request: IncomingMessage, response: ServerResponse) => void, uiOrigin?: string): Promise<QuickAppOriginLease>;
|
|
42
|
+
private allocate;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=quick-app-lan-ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-app-lan-ports.d.ts","sourceRoot":"","sources":["../../../../../src/dsh-capabilities/host/quick-app-lan-ports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EAAgD,KAAK,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC/H,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAGtH,MAAM,WAAW,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C,UAAU,EAAE,MAAM,GAAG,IAAI;IAC3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAC9B,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IACpC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAQhE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAe/E,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAM9G,QAAQ;CA2DvB"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { randomBytes, X509Certificate } from 'node:crypto';
|
|
2
|
+
import { mkdir, readdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { createServer } from 'node:https';
|
|
4
|
+
import { isIP } from 'node:net';
|
|
5
|
+
import { isAbsolute, join } from 'node:path';
|
|
6
|
+
import { QUICK_APP_LIMITS, quickAppTransportErrorCode } from '../../shared/contracts/quick-apps.js';
|
|
7
|
+
import { endQuickAppResponse, quickAppCredentials } from './quick-app-credentials.js';
|
|
8
|
+
export function parseQuickAppLanPortsConfig(value) {
|
|
9
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
10
|
+
throw unavailable('config-invalid');
|
|
11
|
+
const c = value;
|
|
12
|
+
if (Object.keys(c).some(key => !['transport', 'publicHost', 'uiOrigins', 'ports', 'stateDirectory', 'certFile', 'keyFile'].includes(key))
|
|
13
|
+
|| c.transport !== 'lan-ports' || typeof c.publicHost !== 'string' || c.publicHost.length > 253
|
|
14
|
+
|| !validHost(c.publicHost) || !Array.isArray(c.ports) || c.ports.length !== 2
|
|
15
|
+
|| !c.ports.every(port => Number.isInteger(port) && port >= 1024 && port <= 65535)
|
|
16
|
+
|| c.ports[0] > c.ports[1] || c.ports[1] - c.ports[0] >= 16384
|
|
17
|
+
|| ![c.stateDirectory, c.certFile, c.keyFile].every(path => typeof path === 'string' && isAbsolute(path))
|
|
18
|
+
|| !Array.isArray(c.uiOrigins) || c.uiOrigins.length < 1 || c.uiOrigins.length > 16)
|
|
19
|
+
throw unavailable('config-invalid');
|
|
20
|
+
for (const origin of c.uiOrigins) {
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(origin);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw unavailable('config-invalid');
|
|
27
|
+
}
|
|
28
|
+
if (url.origin !== origin || url.protocol !== 'https:' || url.username || url.password || !validHost(url.hostname)
|
|
29
|
+
|| url.hostname === c.publicHost && Number(url.port || 443) >= c.ports[0] && Number(url.port || 443) <= c.ports[1])
|
|
30
|
+
throw unavailable('config-invalid');
|
|
31
|
+
}
|
|
32
|
+
return structuredClone(c);
|
|
33
|
+
}
|
|
34
|
+
function validHost(host) {
|
|
35
|
+
try {
|
|
36
|
+
if (new URL(`https://${host}`).hostname !== host)
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const ip = host.replace(/^\[|\]$/gu, '');
|
|
43
|
+
if (isIP(ip))
|
|
44
|
+
return ip !== '0.0.0.0' && ip !== '::' && ip !== '::1' && !/^127\./u.test(ip) && !ip.startsWith('::ffff:');
|
|
45
|
+
return /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/u.test(host)
|
|
46
|
+
&& host.split('.').every(label => label.length <= 63) && !host.endsWith('.localhost');
|
|
47
|
+
}
|
|
48
|
+
/** Browsers cannot forge these headers; they are an origin fence, never authentication. */
|
|
49
|
+
export function sameBrowserOrigin(headers, origin) {
|
|
50
|
+
if (headers.origin !== undefined && headers.origin !== origin)
|
|
51
|
+
return false;
|
|
52
|
+
const site = headers['sec-fetch-site'];
|
|
53
|
+
if (site !== undefined && site !== 'same-origin')
|
|
54
|
+
return false;
|
|
55
|
+
if (headers.origin === origin || site === 'same-origin')
|
|
56
|
+
return true;
|
|
57
|
+
// A fallback for clients that omit Fetch Metadata. No-referrer clients fail closed.
|
|
58
|
+
try {
|
|
59
|
+
return typeof headers.referer === 'string' && new URL(headers.referer).origin === origin;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function unavailable(reason) {
|
|
66
|
+
return Object.assign(new Error(`Quick Apps transport unavailable: ${reason}.`), { code: quickAppTransportErrorCode(reason), reason });
|
|
67
|
+
}
|
|
68
|
+
/** Dedicated app HTTPS ports on the existing LAN bind address; no DSH forwarding. */
|
|
69
|
+
export class QuickAppLanPortsProvider {
|
|
70
|
+
tls;
|
|
71
|
+
isolation = 'lan-port';
|
|
72
|
+
listenHost;
|
|
73
|
+
stopped = false;
|
|
74
|
+
pending = Promise.resolve();
|
|
75
|
+
active = new Set();
|
|
76
|
+
reserved = new Set();
|
|
77
|
+
allocationFailure;
|
|
78
|
+
generation = 0;
|
|
79
|
+
config;
|
|
80
|
+
constructor(config, tls) {
|
|
81
|
+
this.tls = tls;
|
|
82
|
+
this.config = parseQuickAppLanPortsConfig(config);
|
|
83
|
+
const cert = new X509Certificate(tls.cert);
|
|
84
|
+
const ip = config.publicHost.replace(/^\[|\]$/gu, '');
|
|
85
|
+
if (!(isIP(ip) ? cert.checkIP(ip) : cert.checkHost(config.publicHost))
|
|
86
|
+
|| Date.parse(cert.validFrom) > Date.now() || Date.parse(cert.validTo) <= Date.now())
|
|
87
|
+
throw unavailable('config-invalid');
|
|
88
|
+
const probe = createServer({ ...tls, minVersion: 'TLSv1.2' });
|
|
89
|
+
probe.close();
|
|
90
|
+
}
|
|
91
|
+
/** Read persistent reservations before availability is advertised. Never delete this history. */
|
|
92
|
+
async initialize() {
|
|
93
|
+
await mkdir(this.config.stateDirectory, { recursive: true, mode: 0o700 });
|
|
94
|
+
for (const entry of await readdir(this.config.stateDirectory)) {
|
|
95
|
+
if (/^\d+\.json$/u.test(entry))
|
|
96
|
+
this.reserved.add(Number(entry.slice(0, -5)));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
started(listenHost) { this.listenHost = listenHost; this.generation++; this.allocationFailure = undefined; }
|
|
100
|
+
async stopping() {
|
|
101
|
+
this.listenHost = undefined;
|
|
102
|
+
this.generation++;
|
|
103
|
+
await this.pending.catch(() => undefined);
|
|
104
|
+
await Promise.all([...this.active].map(dispose => dispose()));
|
|
105
|
+
}
|
|
106
|
+
async dispose() { this.stopped = true; await this.stopping(); }
|
|
107
|
+
available(uiOrigin) { return this.diagnostic(uiOrigin) === undefined; }
|
|
108
|
+
protects(uiOrigin) { return !this.stopped && Boolean(this.listenHost) && Boolean(uiOrigin && this.config.uiOrigins.includes(uiOrigin)); }
|
|
109
|
+
diagnostic(uiOrigin) {
|
|
110
|
+
if (this.stopped || !this.listenHost)
|
|
111
|
+
return 'lan-stopped';
|
|
112
|
+
if (!uiOrigin || !this.config.uiOrigins.includes(uiOrigin))
|
|
113
|
+
return 'ui-not-allowed';
|
|
114
|
+
if (this.allocationFailure)
|
|
115
|
+
return this.allocationFailure;
|
|
116
|
+
for (let port = this.config.ports[0]; port <= this.config.ports[1]; port++)
|
|
117
|
+
if (!this.reserved.has(port))
|
|
118
|
+
return undefined;
|
|
119
|
+
return 'ports-exhausted';
|
|
120
|
+
}
|
|
121
|
+
permits(headers, method, path) {
|
|
122
|
+
if ((method === 'GET' || method === 'HEAD') && path === '/' && !headers.upgrade
|
|
123
|
+
&& headers['sec-fetch-mode'] === 'navigate' && headers['sec-fetch-dest'] === 'document')
|
|
124
|
+
return true;
|
|
125
|
+
// App configuration must not become an allowlist for ordinary DSH addresses.
|
|
126
|
+
// Block only origins owned by this app transport, including retired ports.
|
|
127
|
+
for (const value of [headers.origin, headers.referer]) {
|
|
128
|
+
if (value === undefined)
|
|
129
|
+
continue;
|
|
130
|
+
try {
|
|
131
|
+
const url = new URL(value);
|
|
132
|
+
if (url.hostname === this.config.publicHost && this.reserved.has(Number(url.port || 443)))
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
if (value === 'null')
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
open(handler, uiOrigin) {
|
|
143
|
+
const operation = this.pending.catch(() => undefined).then(() => this.allocate(handler, uiOrigin));
|
|
144
|
+
this.pending = operation.then(() => undefined, () => undefined);
|
|
145
|
+
return operation;
|
|
146
|
+
}
|
|
147
|
+
async allocate(handler, uiOrigin) {
|
|
148
|
+
const reason = this.diagnostic(uiOrigin);
|
|
149
|
+
if (reason)
|
|
150
|
+
throw unavailable(reason);
|
|
151
|
+
if (this.active.size >= QUICK_APP_LIMITS.launches)
|
|
152
|
+
throw unavailable('ports-busy');
|
|
153
|
+
const generation = this.generation;
|
|
154
|
+
let busy = false;
|
|
155
|
+
for (let port = this.config.ports[0]; port <= this.config.ports[1]; port++) {
|
|
156
|
+
if (this.reserved.has(port))
|
|
157
|
+
continue;
|
|
158
|
+
const origin = `https://${this.config.publicHost}:${port}`;
|
|
159
|
+
const cookieName = `__Host-quickapp-${randomBytes(16).toString('hex')}`;
|
|
160
|
+
const credentials = quickAppCredentials(origin, uiOrigin, cookieName);
|
|
161
|
+
let alive = true;
|
|
162
|
+
const server = createServer({ ...this.tls, minVersion: 'TLSv1.2', maxHeaderSize: 16 * 1024, handshakeTimeout: 10_000 }, (req, res) => {
|
|
163
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
164
|
+
res.setHeader('Referrer-Policy', 'same-origin');
|
|
165
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
166
|
+
const sni = req.socket.servername;
|
|
167
|
+
if (!alive || generation !== this.generation)
|
|
168
|
+
return endQuickAppResponse(res, 410);
|
|
169
|
+
if (req.headers.host !== new URL(origin).host || sni && sni !== this.config.publicHost
|
|
170
|
+
|| req.rawHeaders.filter((_, i) => i % 2 === 0 && req.rawHeaders[i].toLowerCase() === 'host').length !== 1)
|
|
171
|
+
return endQuickAppResponse(res, 421);
|
|
172
|
+
// Only the one-use landing page accepts cross-origin navigation from the DSH viewer.
|
|
173
|
+
if (req.url !== '/__quickapp/bootstrap' && !sameBrowserOrigin(req.headers, origin))
|
|
174
|
+
return endQuickAppResponse(res, 403);
|
|
175
|
+
// Browser cookies have no port scope. Strip every cookie except this launch's before
|
|
176
|
+
// passing the request to the application service; never forward general credentials.
|
|
177
|
+
const cookies = (req.headers.cookie ?? '').split(';').map(value => value.trim()).filter(value => value.startsWith(`${cookieName}=`));
|
|
178
|
+
req.headers.cookie = cookies.join('; ');
|
|
179
|
+
delete req.headers.authorization;
|
|
180
|
+
req.rawHeaders = req.rawHeaders.flatMap((value, i, headers) => i % 2 || ['cookie', 'authorization'].includes(value.toLowerCase()) ? [] : [value, headers[i + 1]]);
|
|
181
|
+
if (cookies.length)
|
|
182
|
+
req.rawHeaders.push('Cookie', cookies.join('; '));
|
|
183
|
+
void credentials.handle(req, res).then(handled => { if (!handled && alive)
|
|
184
|
+
handler(req, res); }).catch(() => endQuickAppResponse(res, 400));
|
|
185
|
+
});
|
|
186
|
+
server.requestTimeout = 15_000;
|
|
187
|
+
server.headersTimeout = 10_000;
|
|
188
|
+
server.timeout = 30_000;
|
|
189
|
+
server.keepAliveTimeout = 5_000;
|
|
190
|
+
server.maxConnections = 128;
|
|
191
|
+
server.maxRequestsPerSocket = 100;
|
|
192
|
+
const dispose = async () => {
|
|
193
|
+
if (!alive)
|
|
194
|
+
return;
|
|
195
|
+
alive = false;
|
|
196
|
+
credentials.dispose();
|
|
197
|
+
this.active.delete(dispose);
|
|
198
|
+
await close(server);
|
|
199
|
+
};
|
|
200
|
+
try {
|
|
201
|
+
await new Promise((resolve, reject) => {
|
|
202
|
+
server.once('error', reject);
|
|
203
|
+
server.listen(port, this.listenHost, () => { server.removeListener('error', reject); resolve(); });
|
|
204
|
+
});
|
|
205
|
+
server.on('error', () => { void dispose(); });
|
|
206
|
+
// Atomic create makes independent Host instances sharing this history race safely.
|
|
207
|
+
await writeFile(join(this.config.stateDirectory, `${port}.json`), JSON.stringify({ origin, allocatedAt: new Date().toISOString() }), { flag: 'wx', mode: 0o600 });
|
|
208
|
+
this.reserved.add(port);
|
|
209
|
+
if (this.stopped || generation !== this.generation) {
|
|
210
|
+
await dispose();
|
|
211
|
+
throw unavailable('lan-stopped');
|
|
212
|
+
}
|
|
213
|
+
this.active.add(dispose);
|
|
214
|
+
return { origin, uiOrigin: uiOrigin, ownerHostId: 'local', remote: true, cookieName, isolation: 'lan-port', activate: credentials.activate, dispose };
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
await dispose();
|
|
218
|
+
const code = error.code;
|
|
219
|
+
if (code === 'EEXIST') {
|
|
220
|
+
this.reserved.add(port);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (code === 'EADDRINUSE') {
|
|
224
|
+
busy = true;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!busy)
|
|
231
|
+
this.allocationFailure = 'ports-exhausted';
|
|
232
|
+
throw unavailable(busy ? 'ports-busy' : 'ports-exhausted');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async function close(server) {
|
|
236
|
+
server.closeAllConnections();
|
|
237
|
+
if (server.listening)
|
|
238
|
+
await new Promise(resolve => server.close(() => resolve()));
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=quick-app-lan-ports.js.map
|