@celljs/ta-host 4.7.0 → 4.9.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.en.md +34 -4
- package/README.md +33 -3
- package/cell.schema.json +4 -0
- package/cell.yml +2 -0
- package/esm/node/auth-server-impl.d.ts +2 -0
- package/esm/node/auth-server-impl.js +7 -0
- package/esm/node/client-tool-broker.d.ts +11 -3
- package/esm/node/client-tool-broker.js +23 -3
- package/esm/node/extension-providers.d.ts +22 -0
- package/esm/node/extension-providers.js +52 -0
- package/esm/node/host-protocol.d.ts +22 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +6 -0
- package/esm/node/index.js +6 -0
- package/esm/node/live-run.d.ts +22 -0
- package/esm/node/live-run.js +58 -0
- package/esm/node/message-page.d.ts +17 -0
- package/esm/node/message-page.js +71 -0
- package/esm/node/package-host-extension.d.ts +4 -2
- package/esm/node/package-host-extension.js +4 -3
- package/esm/node/package-hosts.d.ts +2 -2
- package/esm/node/package-hosts.js +2 -0
- package/esm/node/package-server-impl.d.ts +9 -1
- package/esm/node/package-server-impl.js +16 -1
- package/esm/node/relay-bridge.d.ts +9 -1
- package/esm/node/relay-bridge.js +44 -4
- package/esm/node/remote-ui-context.d.ts +6 -1
- package/esm/node/remote-ui-context.js +31 -3
- package/esm/node/session-catalog.d.ts +69 -0
- package/esm/node/session-catalog.js +211 -0
- package/esm/node/session-files.d.ts +18 -0
- package/esm/node/session-files.js +32 -0
- package/esm/node/session-info-util.d.ts +4 -1
- package/esm/node/session-info-util.js +8 -3
- package/esm/node/settings-server-impl.d.ts +1 -0
- package/esm/node/settings-server-impl.js +8 -0
- package/esm/node/settings-store.d.ts +3 -1
- package/esm/node/settings-store.js +25 -3
- package/esm/node/sign-in/access-server-impl.d.ts +19 -0
- package/esm/node/sign-in/access-server-impl.js +82 -0
- package/esm/node/sign-in/access-store.d.ts +65 -0
- package/esm/node/sign-in/access-store.js +175 -0
- package/esm/node/sign-in/index.d.ts +7 -0
- package/esm/node/sign-in/index.js +8 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +58 -0
- package/esm/node/sign-in/sign-in-flow.js +104 -0
- package/esm/node/sign-in/sign-in-middleware.d.ts +10 -0
- package/esm/node/sign-in/sign-in-middleware.js +48 -0
- package/esm/node/sign-in/sign-in-pages.d.ts +31 -0
- package/esm/node/sign-in/sign-in-pages.js +118 -0
- package/esm/node/sign-in/sign-in-provider.d.ts +135 -0
- package/esm/node/sign-in/sign-in-provider.js +225 -0
- package/esm/node/sign-in/ta-sign-in.d.ts +10 -0
- package/esm/node/sign-in/ta-sign-in.js +32 -0
- package/esm/node/ta-access.d.ts +7 -0
- package/esm/node/ta-access.js +30 -1
- package/esm/node/ta-server-impl.d.ts +8 -3
- package/esm/node/ta-server-impl.js +25 -6
- package/esm/node/ta-session-factory.d.ts +4 -1
- package/esm/node/ta-session-factory.js +30 -7
- package/esm/node/ta-session-registry.d.ts +2 -0
- package/esm/node/ta-session-registry.js +23 -3
- package/esm/node/ta-session.d.ts +24 -2
- package/esm/node/ta-session.js +84 -6
- package/esm/node/temporary-packages.d.ts +46 -0
- package/esm/node/temporary-packages.js +114 -0
- package/esm/node/temporary-purge.d.ts +13 -0
- package/esm/node/temporary-purge.js +51 -0
- package/esm/node/terminal-service.d.ts +18 -2
- package/esm/node/terminal-service.js +45 -9
- package/esm/node/terminal-util.d.ts +14 -0
- package/esm/node/terminal-util.js +30 -1
- package/esm/node/web-extension-catalog.d.ts +28 -1
- package/esm/node/web-extension-catalog.js +173 -5
- package/esm/node/web-extension-util.d.ts +5 -1
- package/esm/node/web-extension-util.js +36 -5
- package/esm/node/workspace-protocol.d.ts +2 -0
- package/esm/node/workspace-server-impl.d.ts +2 -1
- package/esm/node/workspace-server-impl.js +13 -1
- package/esm/node/workspace-service.d.ts +1 -0
- package/esm/node/workspace-service.js +13 -1
- package/lib/node/auth-server-impl.d.ts +2 -0
- package/lib/node/auth-server-impl.js +7 -0
- package/lib/node/client-tool-broker.d.ts +11 -3
- package/lib/node/client-tool-broker.js +23 -3
- package/lib/node/extension-providers.d.ts +23 -0
- package/lib/node/extension-providers.js +55 -0
- package/lib/node/host-protocol.d.ts +22 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +6 -0
- package/lib/node/index.js +6 -0
- package/lib/node/live-run.d.ts +23 -0
- package/lib/node/live-run.js +62 -0
- package/lib/node/message-page.d.ts +18 -0
- package/lib/node/message-page.js +74 -0
- package/lib/node/package-host-extension.d.ts +4 -2
- package/lib/node/package-host-extension.js +4 -3
- package/lib/node/package-hosts.d.ts +2 -2
- package/lib/node/package-hosts.js +2 -0
- package/lib/node/package-server-impl.d.ts +9 -1
- package/lib/node/package-server-impl.js +15 -0
- package/lib/node/relay-bridge.d.ts +9 -1
- package/lib/node/relay-bridge.js +43 -3
- package/lib/node/remote-ui-context.d.ts +6 -1
- package/lib/node/remote-ui-context.js +31 -3
- package/lib/node/session-catalog.d.ts +70 -0
- package/lib/node/session-catalog.js +214 -0
- package/lib/node/session-files.d.ts +19 -0
- package/lib/node/session-files.js +36 -0
- package/lib/node/session-info-util.d.ts +4 -1
- package/lib/node/session-info-util.js +7 -2
- package/lib/node/settings-server-impl.d.ts +1 -0
- package/lib/node/settings-server-impl.js +8 -0
- package/lib/node/settings-store.d.ts +3 -1
- package/lib/node/settings-store.js +25 -3
- package/lib/node/sign-in/access-server-impl.d.ts +20 -0
- package/lib/node/sign-in/access-server-impl.js +85 -0
- package/lib/node/sign-in/access-store.d.ts +66 -0
- package/lib/node/sign-in/access-store.js +179 -0
- package/lib/node/sign-in/index.d.ts +8 -0
- package/lib/node/sign-in/index.js +24 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +59 -0
- package/lib/node/sign-in/sign-in-flow.js +108 -0
- package/lib/node/sign-in/sign-in-middleware.d.ts +11 -0
- package/lib/node/sign-in/sign-in-middleware.js +51 -0
- package/lib/node/sign-in/sign-in-pages.d.ts +32 -0
- package/lib/node/sign-in/sign-in-pages.js +121 -0
- package/lib/node/sign-in/sign-in-provider.d.ts +136 -0
- package/lib/node/sign-in/sign-in-provider.js +232 -0
- package/lib/node/sign-in/ta-sign-in.d.ts +11 -0
- package/lib/node/sign-in/ta-sign-in.js +35 -0
- package/lib/node/ta-access.d.ts +7 -0
- package/lib/node/ta-access.js +30 -1
- package/lib/node/ta-server-impl.d.ts +8 -3
- package/lib/node/ta-server-impl.js +24 -5
- package/lib/node/ta-session-factory.d.ts +4 -1
- package/lib/node/ta-session-factory.js +30 -7
- package/lib/node/ta-session-registry.d.ts +2 -0
- package/lib/node/ta-session-registry.js +23 -3
- package/lib/node/ta-session.d.ts +24 -2
- package/lib/node/ta-session.js +84 -6
- package/lib/node/temporary-packages.d.ts +47 -0
- package/lib/node/temporary-packages.js +118 -0
- package/lib/node/temporary-purge.d.ts +14 -0
- package/lib/node/temporary-purge.js +54 -0
- package/lib/node/terminal-service.d.ts +18 -2
- package/lib/node/terminal-service.js +44 -8
- package/lib/node/terminal-util.d.ts +14 -0
- package/lib/node/terminal-util.js +30 -1
- package/lib/node/web-extension-catalog.d.ts +28 -1
- package/lib/node/web-extension-catalog.js +172 -4
- package/lib/node/web-extension-util.d.ts +5 -1
- package/lib/node/web-extension-util.js +36 -5
- package/lib/node/workspace-protocol.d.ts +2 -0
- package/lib/node/workspace-server-impl.d.ts +2 -1
- package/lib/node/workspace-server-impl.js +12 -0
- package/lib/node/workspace-service.d.ts +1 -0
- package/lib/node/workspace-service.js +13 -1
- package/package.json +17 -12
- package/esm/node/auth-server-impl.js.map +0 -1
- package/esm/node/client-channel.js.map +0 -1
- package/esm/node/client-tool-broker.js.map +0 -1
- package/esm/node/event-log.js.map +0 -1
- package/esm/node/exec-environment-factory.js.map +0 -1
- package/esm/node/extension-data-notifier.js.map +0 -1
- package/esm/node/extension-data.js.map +0 -1
- package/esm/node/host-protocol.js.map +0 -1
- package/esm/node/index.js.map +0 -1
- package/esm/node/module.js.map +0 -1
- package/esm/node/package-host-extension.js.map +0 -1
- package/esm/node/package-hosts.js.map +0 -1
- package/esm/node/package-server-impl.js.map +0 -1
- package/esm/node/package-switch.js.map +0 -1
- package/esm/node/receipt-book.js.map +0 -1
- package/esm/node/relay-bridge.js.map +0 -1
- package/esm/node/remote/index.js.map +0 -1
- package/esm/node/remote/pi-directories.js.map +0 -1
- package/esm/node/remote/port-forwards.js.map +0 -1
- package/esm/node/remote/remote-hosts.js.map +0 -1
- package/esm/node/remote/remote-protocol.js.map +0 -1
- package/esm/node/remote/remote-server-impl.js.map +0 -1
- package/esm/node/remote-ui-context.js.map +0 -1
- package/esm/node/session-info-util.js.map +0 -1
- package/esm/node/session-storage/file-session-storage.js.map +0 -1
- package/esm/node/session-storage/index.js.map +0 -1
- package/esm/node/session-storage/session-storage-protocol.js.map +0 -1
- package/esm/node/session-storage/stored-session.js.map +0 -1
- package/esm/node/settings-server-impl.js.map +0 -1
- package/esm/node/settings-store.js.map +0 -1
- package/esm/node/ta-access.js.map +0 -1
- package/esm/node/ta-errors.js.map +0 -1
- package/esm/node/ta-event-util.js.map +0 -1
- package/esm/node/ta-server-impl.js.map +0 -1
- package/esm/node/ta-session-factory.js.map +0 -1
- package/esm/node/ta-session-registry.js.map +0 -1
- package/esm/node/ta-session.js.map +0 -1
- package/esm/node/terminal-protocol.js.map +0 -1
- package/esm/node/terminal-service.js.map +0 -1
- package/esm/node/terminal-util.js.map +0 -1
- package/esm/node/web-extension-catalog.js.map +0 -1
- package/esm/node/web-extension-util.js.map +0 -1
- package/esm/node/working-directory.js.map +0 -1
- package/esm/node/workspace-files.js.map +0 -1
- package/esm/node/workspace-protocol.js.map +0 -1
- package/esm/node/workspace-server-impl.js.map +0 -1
- package/esm/node/workspace-service.js.map +0 -1
- package/esm/node/workspace-util.js.map +0 -1
- package/lib/node/auth-server-impl.d.ts.map +0 -1
- package/lib/node/auth-server-impl.js.map +0 -1
- package/lib/node/auth-server-impl.spec.d.ts +0 -2
- package/lib/node/auth-server-impl.spec.d.ts.map +0 -1
- package/lib/node/auth-server-impl.spec.js +0 -47
- package/lib/node/auth-server-impl.spec.js.map +0 -1
- package/lib/node/client-channel.d.ts.map +0 -1
- package/lib/node/client-channel.js.map +0 -1
- package/lib/node/client-channel.spec.d.ts +0 -2
- package/lib/node/client-channel.spec.d.ts.map +0 -1
- package/lib/node/client-channel.spec.js +0 -106
- package/lib/node/client-channel.spec.js.map +0 -1
- package/lib/node/client-tool-broker.d.ts.map +0 -1
- package/lib/node/client-tool-broker.js.map +0 -1
- package/lib/node/client-tool-broker.spec.d.ts +0 -2
- package/lib/node/client-tool-broker.spec.d.ts.map +0 -1
- package/lib/node/client-tool-broker.spec.js +0 -49
- package/lib/node/client-tool-broker.spec.js.map +0 -1
- package/lib/node/event-log.d.ts.map +0 -1
- package/lib/node/event-log.js.map +0 -1
- package/lib/node/event-log.spec.d.ts +0 -2
- package/lib/node/event-log.spec.d.ts.map +0 -1
- package/lib/node/event-log.spec.js +0 -48
- package/lib/node/event-log.spec.js.map +0 -1
- package/lib/node/exec-environment-factory.d.ts.map +0 -1
- package/lib/node/exec-environment-factory.js.map +0 -1
- package/lib/node/extension-data-notifier.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.js.map +0 -1
- package/lib/node/extension-data-notifier.spec.d.ts +0 -2
- package/lib/node/extension-data-notifier.spec.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.spec.js +0 -35
- package/lib/node/extension-data-notifier.spec.js.map +0 -1
- package/lib/node/extension-data.d.ts.map +0 -1
- package/lib/node/extension-data.js.map +0 -1
- package/lib/node/extension-data.spec.d.ts +0 -2
- package/lib/node/extension-data.spec.d.ts.map +0 -1
- package/lib/node/extension-data.spec.js +0 -99
- package/lib/node/extension-data.spec.js.map +0 -1
- package/lib/node/host-protocol.d.ts.map +0 -1
- package/lib/node/host-protocol.js.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js.map +0 -1
- package/lib/node/module.d.ts.map +0 -1
- package/lib/node/module.js.map +0 -1
- package/lib/node/package-host-extension.d.ts.map +0 -1
- package/lib/node/package-host-extension.js.map +0 -1
- package/lib/node/package-hosts.d.ts.map +0 -1
- package/lib/node/package-hosts.js.map +0 -1
- package/lib/node/package-hosts.spec.d.ts +0 -2
- package/lib/node/package-hosts.spec.d.ts.map +0 -1
- package/lib/node/package-hosts.spec.js +0 -53
- package/lib/node/package-hosts.spec.js.map +0 -1
- package/lib/node/package-server-impl.d.ts.map +0 -1
- package/lib/node/package-server-impl.js.map +0 -1
- package/lib/node/package-switch.d.ts.map +0 -1
- package/lib/node/package-switch.js.map +0 -1
- package/lib/node/receipt-book.d.ts.map +0 -1
- package/lib/node/receipt-book.js.map +0 -1
- package/lib/node/receipt-book.spec.d.ts +0 -2
- package/lib/node/receipt-book.spec.d.ts.map +0 -1
- package/lib/node/receipt-book.spec.js +0 -39
- package/lib/node/receipt-book.spec.js.map +0 -1
- package/lib/node/relay-bridge.d.ts.map +0 -1
- package/lib/node/relay-bridge.js.map +0 -1
- package/lib/node/remote/index.d.ts.map +0 -1
- package/lib/node/remote/index.js.map +0 -1
- package/lib/node/remote/pi-directories.d.ts.map +0 -1
- package/lib/node/remote/pi-directories.js.map +0 -1
- package/lib/node/remote/port-forwards.d.ts.map +0 -1
- package/lib/node/remote/port-forwards.js.map +0 -1
- package/lib/node/remote/remote-hosts.d.ts.map +0 -1
- package/lib/node/remote/remote-hosts.js.map +0 -1
- package/lib/node/remote/remote-protocol.d.ts.map +0 -1
- package/lib/node/remote/remote-protocol.js.map +0 -1
- package/lib/node/remote/remote-server-impl.d.ts.map +0 -1
- package/lib/node/remote/remote-server-impl.js.map +0 -1
- package/lib/node/remote/remote.spec.d.ts +0 -2
- package/lib/node/remote/remote.spec.d.ts.map +0 -1
- package/lib/node/remote/remote.spec.js +0 -130
- package/lib/node/remote/remote.spec.js.map +0 -1
- package/lib/node/remote-ui-context.d.ts.map +0 -1
- package/lib/node/remote-ui-context.js.map +0 -1
- package/lib/node/remote-ui-context.spec.d.ts +0 -2
- package/lib/node/remote-ui-context.spec.d.ts.map +0 -1
- package/lib/node/remote-ui-context.spec.js +0 -62
- package/lib/node/remote-ui-context.spec.js.map +0 -1
- package/lib/node/session-info-util.d.ts.map +0 -1
- package/lib/node/session-info-util.js.map +0 -1
- package/lib/node/session-info-util.spec.d.ts +0 -2
- package/lib/node/session-info-util.spec.d.ts.map +0 -1
- package/lib/node/session-info-util.spec.js +0 -22
- package/lib/node/session-info-util.spec.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.d.ts +0 -2
- package/lib/node/session-storage/file-session-storage.spec.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.js +0 -70
- package/lib/node/session-storage/file-session-storage.spec.js.map +0 -1
- package/lib/node/session-storage/index.d.ts.map +0 -1
- package/lib/node/session-storage/index.js.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.d.ts.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.js.map +0 -1
- package/lib/node/session-storage/stored-session.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.js.map +0 -1
- package/lib/node/session-storage/stored-session.spec.d.ts +0 -2
- package/lib/node/session-storage/stored-session.spec.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.spec.js +0 -73
- package/lib/node/session-storage/stored-session.spec.js.map +0 -1
- package/lib/node/settings-server-impl.d.ts.map +0 -1
- package/lib/node/settings-server-impl.js.map +0 -1
- package/lib/node/settings-store.d.ts.map +0 -1
- package/lib/node/settings-store.js.map +0 -1
- package/lib/node/settings-store.spec.d.ts +0 -2
- package/lib/node/settings-store.spec.d.ts.map +0 -1
- package/lib/node/settings-store.spec.js +0 -146
- package/lib/node/settings-store.spec.js.map +0 -1
- package/lib/node/ta-access.d.ts.map +0 -1
- package/lib/node/ta-access.js.map +0 -1
- package/lib/node/ta-access.spec.d.ts +0 -2
- package/lib/node/ta-access.spec.d.ts.map +0 -1
- package/lib/node/ta-access.spec.js +0 -33
- package/lib/node/ta-access.spec.js.map +0 -1
- package/lib/node/ta-errors.d.ts.map +0 -1
- package/lib/node/ta-errors.js.map +0 -1
- package/lib/node/ta-errors.spec.d.ts +0 -2
- package/lib/node/ta-errors.spec.d.ts.map +0 -1
- package/lib/node/ta-errors.spec.js +0 -25
- package/lib/node/ta-errors.spec.js.map +0 -1
- package/lib/node/ta-event-util.d.ts.map +0 -1
- package/lib/node/ta-event-util.js.map +0 -1
- package/lib/node/ta-event-util.spec.d.ts +0 -2
- package/lib/node/ta-event-util.spec.d.ts.map +0 -1
- package/lib/node/ta-event-util.spec.js +0 -28
- package/lib/node/ta-event-util.spec.js.map +0 -1
- package/lib/node/ta-server-impl.d.ts.map +0 -1
- package/lib/node/ta-server-impl.js.map +0 -1
- package/lib/node/ta-session-factory.d.ts.map +0 -1
- package/lib/node/ta-session-factory.js.map +0 -1
- package/lib/node/ta-session-registry.d.ts.map +0 -1
- package/lib/node/ta-session-registry.js.map +0 -1
- package/lib/node/ta-session.d.ts.map +0 -1
- package/lib/node/ta-session.js.map +0 -1
- package/lib/node/terminal-protocol.d.ts.map +0 -1
- package/lib/node/terminal-protocol.js.map +0 -1
- package/lib/node/terminal-service.d.ts.map +0 -1
- package/lib/node/terminal-service.js.map +0 -1
- package/lib/node/terminal-service.spec.d.ts +0 -2
- package/lib/node/terminal-service.spec.d.ts.map +0 -1
- package/lib/node/terminal-service.spec.js +0 -79
- package/lib/node/terminal-service.spec.js.map +0 -1
- package/lib/node/terminal-util.d.ts.map +0 -1
- package/lib/node/terminal-util.js.map +0 -1
- package/lib/node/terminal-util.spec.d.ts +0 -2
- package/lib/node/terminal-util.spec.d.ts.map +0 -1
- package/lib/node/terminal-util.spec.js +0 -71
- package/lib/node/terminal-util.spec.js.map +0 -1
- package/lib/node/web-extension-catalog.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.js.map +0 -1
- package/lib/node/web-extension-catalog.spec.d.ts +0 -2
- package/lib/node/web-extension-catalog.spec.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.spec.js +0 -157
- package/lib/node/web-extension-catalog.spec.js.map +0 -1
- package/lib/node/web-extension-util.d.ts.map +0 -1
- package/lib/node/web-extension-util.js.map +0 -1
- package/lib/node/working-directory.d.ts.map +0 -1
- package/lib/node/working-directory.js.map +0 -1
- package/lib/node/workspace-files.d.ts.map +0 -1
- package/lib/node/workspace-files.js.map +0 -1
- package/lib/node/workspace-files.spec.d.ts +0 -2
- package/lib/node/workspace-files.spec.d.ts.map +0 -1
- package/lib/node/workspace-files.spec.js +0 -133
- package/lib/node/workspace-files.spec.js.map +0 -1
- package/lib/node/workspace-protocol.d.ts.map +0 -1
- package/lib/node/workspace-protocol.js.map +0 -1
- package/lib/node/workspace-server-impl.d.ts.map +0 -1
- package/lib/node/workspace-server-impl.js.map +0 -1
- package/lib/node/workspace-service.d.ts.map +0 -1
- package/lib/node/workspace-service.js.map +0 -1
- package/lib/node/workspace-service.spec.d.ts +0 -2
- package/lib/node/workspace-service.spec.d.ts.map +0 -1
- package/lib/node/workspace-service.spec.js +0 -104
- package/lib/node/workspace-service.spec.js.map +0 -1
- package/lib/node/workspace-util.d.ts.map +0 -1
- package/lib/node/workspace-util.js.map +0 -1
- package/lib/node/workspace-util.spec.d.ts +0 -2
- package/lib/node/workspace-util.spec.d.ts.map +0 -1
- package/lib/node/workspace-util.spec.js +0 -44
- package/lib/node/workspace-util.spec.js.map +0 -1
- package/src/node/auth-server-impl.spec.ts +0 -49
- package/src/node/auth-server-impl.ts +0 -252
- package/src/node/client-channel.spec.ts +0 -117
- package/src/node/client-channel.ts +0 -94
- package/src/node/client-tool-broker.spec.ts +0 -53
- package/src/node/client-tool-broker.ts +0 -106
- package/src/node/event-log.spec.ts +0 -52
- package/src/node/event-log.ts +0 -59
- package/src/node/exec-environment-factory.ts +0 -66
- package/src/node/extension-data-notifier.spec.ts +0 -34
- package/src/node/extension-data-notifier.ts +0 -124
- package/src/node/extension-data.spec.ts +0 -105
- package/src/node/extension-data.ts +0 -180
- package/src/node/host-protocol.ts +0 -62
- package/src/node/index.ts +0 -37
- package/src/node/module.ts +0 -4
- package/src/node/package-host-extension.ts +0 -20
- package/src/node/package-hosts.spec.ts +0 -54
- package/src/node/package-hosts.ts +0 -202
- package/src/node/package-server-impl.ts +0 -87
- package/src/node/package-switch.ts +0 -80
- package/src/node/receipt-book.spec.ts +0 -41
- package/src/node/receipt-book.ts +0 -40
- package/src/node/relay-bridge.ts +0 -94
- package/src/node/remote/index.ts +0 -5
- package/src/node/remote/pi-directories.ts +0 -49
- package/src/node/remote/port-forwards.ts +0 -148
- package/src/node/remote/remote-hosts.ts +0 -170
- package/src/node/remote/remote-protocol.ts +0 -57
- package/src/node/remote/remote-server-impl.ts +0 -60
- package/src/node/remote/remote.spec.ts +0 -142
- package/src/node/remote-ui-context.spec.ts +0 -68
- package/src/node/remote-ui-context.ts +0 -168
- package/src/node/session-info-util.spec.ts +0 -23
- package/src/node/session-info-util.ts +0 -55
- package/src/node/session-storage/file-session-storage.spec.ts +0 -72
- package/src/node/session-storage/file-session-storage.ts +0 -145
- package/src/node/session-storage/index.ts +0 -3
- package/src/node/session-storage/session-storage-protocol.ts +0 -81
- package/src/node/session-storage/stored-session.spec.ts +0 -80
- package/src/node/session-storage/stored-session.ts +0 -149
- package/src/node/settings-server-impl.ts +0 -33
- package/src/node/settings-store.spec.ts +0 -156
- package/src/node/settings-store.ts +0 -314
- package/src/node/ta-access.spec.ts +0 -36
- package/src/node/ta-access.ts +0 -156
- package/src/node/ta-errors.spec.ts +0 -25
- package/src/node/ta-errors.ts +0 -75
- package/src/node/ta-event-util.spec.ts +0 -29
- package/src/node/ta-event-util.ts +0 -23
- package/src/node/ta-server-impl.ts +0 -341
- package/src/node/ta-session-factory.ts +0 -203
- package/src/node/ta-session-registry.ts +0 -75
- package/src/node/ta-session.ts +0 -240
- package/src/node/terminal-protocol.ts +0 -18
- package/src/node/terminal-service.spec.ts +0 -84
- package/src/node/terminal-service.ts +0 -259
- package/src/node/terminal-util.spec.ts +0 -78
- package/src/node/terminal-util.ts +0 -166
- package/src/node/web-extension-catalog.spec.ts +0 -172
- package/src/node/web-extension-catalog.ts +0 -177
- package/src/node/web-extension-util.ts +0 -144
- package/src/node/working-directory.ts +0 -71
- package/src/node/workspace-files.spec.ts +0 -145
- package/src/node/workspace-files.ts +0 -256
- package/src/node/workspace-protocol.ts +0 -22
- package/src/node/workspace-server-impl.ts +0 -90
- package/src/node/workspace-service.spec.ts +0 -113
- package/src/node/workspace-service.ts +0 -223
- package/src/node/workspace-util.spec.ts +0 -47
- package/src/node/workspace-util.ts +0 -103
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { Component } from '@celljs/core';
|
|
4
|
-
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
5
|
-
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
6
|
-
|
|
7
|
-
export const TaWorkingDirectory = Symbol('TaWorkingDirectory');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The working directory the user chose for ta serve (TaServer.setWorkingDirectory), and the hosts of the
|
|
11
|
-
* remote directories opened lately (TaRemoteServer), kept across restarts.
|
|
12
|
-
*/
|
|
13
|
-
export interface TaWorkingDirectory {
|
|
14
|
-
get(): string | undefined;
|
|
15
|
-
set(cwd: string): void;
|
|
16
|
-
/** The latest first. */
|
|
17
|
-
recentHosts(): string[];
|
|
18
|
-
addRecentHost(host: string): void;
|
|
19
|
-
removeRecentHost(host: string): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Hosts kept in recentHosts. */
|
|
23
|
-
const RECENT_HOSTS = 10;
|
|
24
|
-
|
|
25
|
-
/** In ta.json of the agent directory, beside Ta's other settings of its own; the file keeps its other keys. */
|
|
26
|
-
@Component(TaWorkingDirectory)
|
|
27
|
-
export class TaWorkingDirectoryImpl implements TaWorkingDirectory {
|
|
28
|
-
protected readonly file = join(TaBrand.agentDir(), TaPackages.SETTINGS_FILE);
|
|
29
|
-
|
|
30
|
-
get(): string | undefined {
|
|
31
|
-
const { workingDirectory } = this.read();
|
|
32
|
-
return typeof workingDirectory === 'string' && workingDirectory ? workingDirectory : undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
set(cwd: string): void {
|
|
36
|
-
this.write({ workingDirectory: cwd });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
recentHosts(): string[] {
|
|
40
|
-
const { remoteHosts } = this.read();
|
|
41
|
-
return Array.isArray(remoteHosts) ? remoteHosts.filter((host): host is string => typeof host === 'string') : [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
addRecentHost(host: string): void {
|
|
45
|
-
const hosts = this.recentHosts();
|
|
46
|
-
if (hosts[0] !== host) {
|
|
47
|
-
this.write({ remoteHosts: [host, ...hosts.filter(other => other !== host)].slice(0, RECENT_HOSTS) });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
removeRecentHost(host: string): void {
|
|
52
|
-
const hosts = this.recentHosts();
|
|
53
|
-
if (hosts.includes(host)) {
|
|
54
|
-
this.write({ remoteHosts: hosts.filter(other => other !== host) });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected write(changes: Record<string, unknown>): void {
|
|
59
|
-
writeFileSync(`${this.file}.tmp`, `${JSON.stringify({ ...this.read(), ...changes }, null, 2)}\n`);
|
|
60
|
-
renameSync(`${this.file}.tmp`, this.file);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected read(): Record<string, unknown> {
|
|
64
|
-
try {
|
|
65
|
-
const data = JSON.parse(readFileSync(this.file, 'utf8'));
|
|
66
|
-
return data && typeof data === 'object' && !Array.isArray(data) ? data : {};
|
|
67
|
-
} catch {
|
|
68
|
-
return {};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
|
|
2
|
-
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { createServer, type Server } from 'node:http';
|
|
4
|
-
import type { AddressInfo } from 'node:net';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import { join } from 'node:path';
|
|
7
|
-
import { type ExecEnvironment, LocalExecEnvironment } from '@celljs/ta-exec';
|
|
8
|
-
import type { Context } from '@celljs/web/lib/node';
|
|
9
|
-
import { DefaultWorkspaceFiles, WorkspaceFilesUtil } from './workspace-files';
|
|
10
|
-
|
|
11
|
-
function write(file: string, content: string | Uint8Array) {
|
|
12
|
-
mkdirSync(join(file, '..'), { recursive: true });
|
|
13
|
-
writeFileSync(file, content);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** The middleware in a server of its own; what it passes on answers 418. */
|
|
17
|
-
function serve(files: DefaultWorkspaceFiles): Promise<Server> {
|
|
18
|
-
const server = createServer((request, response) => {
|
|
19
|
-
void files.handle({ request, response } as unknown as Context, async () => {
|
|
20
|
-
response.statusCode = 418;
|
|
21
|
-
response.end();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
return new Promise(resolve => server.listen(0, '127.0.0.1', () => resolve(server)));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function files(remote = false): DefaultWorkspaceFiles {
|
|
28
|
-
const created = new DefaultWorkspaceFiles();
|
|
29
|
-
// Another machine: the same files, read through the environment instead of node:fs.
|
|
30
|
-
const create = (cwd: string): ExecEnvironment => {
|
|
31
|
-
const local = new LocalExecEnvironment(cwd);
|
|
32
|
-
return remote ? Object.assign(Object.create(local), { local: false }) : local;
|
|
33
|
-
};
|
|
34
|
-
Object.assign(created, { environments: { create, defaultCwd: async () => process.cwd() }, host: '127.0.0.1' });
|
|
35
|
-
return created;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe('WorkspaceFilesUtil', () => {
|
|
39
|
-
it('reads the id and the path of a URL', () => {
|
|
40
|
-
expect(WorkspaceFilesUtil.parse('/api/files/abc/docs/a%20b.md?v=2')).toEqual({ id: 'abc', path: 'docs/a b.md' });
|
|
41
|
-
expect(WorkspaceFilesUtil.parse('/api/files/abc')).toEqual({ id: 'abc', path: '' });
|
|
42
|
-
expect(WorkspaceFilesUtil.parse('/api/files/abc/%E0%A4%A')).toBeUndefined();
|
|
43
|
-
expect(WorkspaceFilesUtil.parse('/api/ws')).toBeUndefined();
|
|
44
|
-
expect(WorkspaceFilesUtil.url('abc', 'docs/a b#1.md')).toBe('/api/files/abc/docs/a%20b%231.md');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('serves one range', () => {
|
|
48
|
-
expect(WorkspaceFilesUtil.range('bytes=0-9', 100)).toEqual({ start: 0, end: 9 });
|
|
49
|
-
expect(WorkspaceFilesUtil.range('bytes=90-', 100)).toEqual({ start: 90, end: 99 });
|
|
50
|
-
expect(WorkspaceFilesUtil.range('bytes=-10', 100)).toEqual({ start: 90, end: 99 });
|
|
51
|
-
expect(WorkspaceFilesUtil.range('bytes=50-500', 100)).toEqual({ start: 50, end: 99 });
|
|
52
|
-
expect(WorkspaceFilesUtil.range('bytes=100-', 100)).toBe(false);
|
|
53
|
-
expect(WorkspaceFilesUtil.range('bytes=0-1,5-6', 100)).toBeUndefined();
|
|
54
|
-
expect(WorkspaceFilesUtil.range(undefined, 100)).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('names the type of a file', () => {
|
|
58
|
-
expect(WorkspaceFilesUtil.contentType('/a/index.HTML')).toBe('text/html; charset=utf-8');
|
|
59
|
-
expect(WorkspaceFilesUtil.contentType('clip.mp4')).toBe('video/mp4');
|
|
60
|
-
expect(WorkspaceFilesUtil.contentType('Makefile')).toBe('application/octet-stream');
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('DefaultWorkspaceFiles', () => {
|
|
65
|
-
let root: string;
|
|
66
|
-
let workspace: string;
|
|
67
|
-
const servers: Server[] = [];
|
|
68
|
-
|
|
69
|
-
beforeAll(() => {
|
|
70
|
-
root = realpathSync(mkdtempSync(join(tmpdir(), 'ta-files-')));
|
|
71
|
-
workspace = join(root, 'workspace');
|
|
72
|
-
write(join(workspace, 'site/index.html'), '<h1>Hi</h1>');
|
|
73
|
-
write(join(workspace, 'site/app.js'), 'alert(1)');
|
|
74
|
-
write(join(workspace, 'clip.mp4'), new Uint8Array(Array.from({ length: 256 }, (_, i) => i)));
|
|
75
|
-
write(join(workspace, 'doc.pdf'), '%PDF-1.4');
|
|
76
|
-
write(join(root, 'secret.txt'), 'secret');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
afterAll(() => {
|
|
80
|
-
for (const server of servers) {
|
|
81
|
-
server.close();
|
|
82
|
-
}
|
|
83
|
-
rmSync(root, { recursive: true, force: true });
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
async function base(remote = false): Promise<{ origin: string; files: DefaultWorkspaceFiles }> {
|
|
87
|
-
const created = files(remote);
|
|
88
|
-
const server = await serve(created);
|
|
89
|
-
servers.push(server);
|
|
90
|
-
return { origin: `http://127.0.0.1:${(server.address() as AddressInfo).port}`, files: created };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
it('gives each directory one URL that stays inside it', async () => {
|
|
94
|
-
const { files } = await base();
|
|
95
|
-
const url = files.url(workspace, 'site/index.html');
|
|
96
|
-
expect(url).toMatch(/^\/api\/files\/[\w-]{22}\/site\/index\.html$/);
|
|
97
|
-
expect(files.url(workspace, 'clip.mp4').split('/')[3]).toBe(url.split('/')[3]);
|
|
98
|
-
expect(files.url(join(workspace, 'site'), 'app.js').split('/')[3]).not.toBe(url.split('/')[3]);
|
|
99
|
-
expect(() => files.url(workspace, '../secret.txt')).toThrow('outside');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('answers a page sandboxed, and the files beside it', async () => {
|
|
103
|
-
const { origin, files } = await base();
|
|
104
|
-
const page = await fetch(origin + files.url(workspace, 'site/index.html'));
|
|
105
|
-
expect(page.status).toBe(200);
|
|
106
|
-
expect(await page.text()).toBe('<h1>Hi</h1>');
|
|
107
|
-
expect(page.headers.get('content-type')).toBe('text/html; charset=utf-8');
|
|
108
|
-
expect(page.headers.get('content-security-policy')).toContain('sandbox allow-scripts');
|
|
109
|
-
expect(page.headers.get('referrer-policy')).toBe('no-referrer');
|
|
110
|
-
const script = await fetch(new URL('app.js', origin + files.url(workspace, 'site/index.html')));
|
|
111
|
-
expect(await script.text()).toBe('alert(1)');
|
|
112
|
-
// A directory answers its index.html.
|
|
113
|
-
expect(await (await fetch(origin + files.url(workspace, 'site'))).text()).toBe('<h1>Hi</h1>');
|
|
114
|
-
// Browsers show no PDF sandboxed.
|
|
115
|
-
expect((await fetch(origin + files.url(workspace, 'doc.pdf'))).headers.get('content-security-policy')).toBeNull();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('serves a range, and asks again only when the file changed', async () => {
|
|
119
|
-
for (const remote of [false, true]) {
|
|
120
|
-
const { origin, files } = await base(remote);
|
|
121
|
-
const url = origin + files.url(workspace, 'clip.mp4');
|
|
122
|
-
const part = await fetch(url, { headers: { range: 'bytes=10-13' } });
|
|
123
|
-
expect(part.status).toBe(206);
|
|
124
|
-
expect(part.headers.get('content-range')).toBe('bytes 10-13/256');
|
|
125
|
-
expect([...new Uint8Array(await part.arrayBuffer())]).toEqual([10, 11, 12, 13]);
|
|
126
|
-
const whole = await fetch(url);
|
|
127
|
-
expect((await whole.arrayBuffer()).byteLength).toBe(256);
|
|
128
|
-
expect((await fetch(url, { headers: { 'if-none-match': whole.headers.get('etag') ?? '' } })).status).toBe(304);
|
|
129
|
-
expect((await fetch(url, { headers: { range: 'bytes=300-' } })).status).toBe(416);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('answers nothing outside the directory, for an unknown id, or by another name', async () => {
|
|
134
|
-
const { origin, files } = await base();
|
|
135
|
-
const url = files.url(workspace, 'clip.mp4');
|
|
136
|
-
const id = url.split('/')[3];
|
|
137
|
-
expect((await fetch(`${origin}/api/files/${id}/..%2Fsecret.txt`)).status).toBe(404);
|
|
138
|
-
expect((await fetch(`${origin}/api/files/${id}/missing.txt`)).status).toBe(404);
|
|
139
|
-
expect((await fetch(`${origin}/api/files/unknown/clip.mp4`)).status).toBe(404);
|
|
140
|
-
expect((await fetch(origin + url, { method: 'POST' })).status).toBe(405);
|
|
141
|
-
expect((await fetch(origin + url, { headers: { host: 'evil.example' } })).status).toBe(404);
|
|
142
|
-
// Other requests go on to the rest of the server.
|
|
143
|
-
expect((await fetch(`${origin}/api/ws`)).status).toBe(418);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { createReadStream } from 'node:fs';
|
|
3
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
-
import { Autowired, Component, Value } from '@celljs/core';
|
|
5
|
-
import { type ExecEnvironment, ExecEnvironmentFactory, type FileStat } from '@celljs/ta-exec';
|
|
6
|
-
import { TA_FILES_PATH } from '@celljs/ta-protocol';
|
|
7
|
-
import { type Context, Middleware } from '@celljs/web/lib/node';
|
|
8
|
-
import { ACCESS_MIDDLEWARE_PRIORITY, TaAccessUtil } from './ta-access';
|
|
9
|
-
import { WorkspaceFiles } from './workspace-protocol';
|
|
10
|
-
import { WorkspaceUtil } from './workspace-util';
|
|
11
|
-
|
|
12
|
-
/** Types of the files the page shows as they are; anything else is `application/octet-stream`. */
|
|
13
|
-
const TYPES: Record<string, string> = {
|
|
14
|
-
html: 'text/html',
|
|
15
|
-
htm: 'text/html',
|
|
16
|
-
css: 'text/css',
|
|
17
|
-
txt: 'text/plain',
|
|
18
|
-
md: 'text/markdown',
|
|
19
|
-
csv: 'text/csv',
|
|
20
|
-
js: 'text/javascript',
|
|
21
|
-
mjs: 'text/javascript',
|
|
22
|
-
cjs: 'text/javascript',
|
|
23
|
-
json: 'application/json',
|
|
24
|
-
map: 'application/json',
|
|
25
|
-
xml: 'application/xml',
|
|
26
|
-
wasm: 'application/wasm',
|
|
27
|
-
pdf: 'application/pdf',
|
|
28
|
-
svg: 'image/svg+xml',
|
|
29
|
-
png: 'image/png',
|
|
30
|
-
jpg: 'image/jpeg',
|
|
31
|
-
jpeg: 'image/jpeg',
|
|
32
|
-
gif: 'image/gif',
|
|
33
|
-
webp: 'image/webp',
|
|
34
|
-
avif: 'image/avif',
|
|
35
|
-
bmp: 'image/bmp',
|
|
36
|
-
ico: 'image/x-icon',
|
|
37
|
-
woff: 'font/woff',
|
|
38
|
-
woff2: 'font/woff2',
|
|
39
|
-
ttf: 'font/ttf',
|
|
40
|
-
otf: 'font/otf',
|
|
41
|
-
mp4: 'video/mp4',
|
|
42
|
-
m4v: 'video/mp4',
|
|
43
|
-
webm: 'video/webm',
|
|
44
|
-
ogv: 'video/ogg',
|
|
45
|
-
mov: 'video/quicktime',
|
|
46
|
-
mp3: 'audio/mpeg',
|
|
47
|
-
m4a: 'audio/mp4',
|
|
48
|
-
aac: 'audio/aac',
|
|
49
|
-
wav: 'audio/wav',
|
|
50
|
-
ogg: 'audio/ogg',
|
|
51
|
-
oga: 'audio/ogg',
|
|
52
|
-
flac: 'audio/flac',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* What a page of the workspace may do: run its scripts, in an origin of its own, so that it cannot
|
|
57
|
-
* reach the page of ta or call ta serve. A PDF is left out: browsers do not show one sandboxed.
|
|
58
|
-
*/
|
|
59
|
-
const SANDBOX = 'sandbox allow-scripts allow-forms allow-popups allow-modals allow-downloads';
|
|
60
|
-
|
|
61
|
-
const ID_BYTES = 16;
|
|
62
|
-
/** Read whole from another machine: a part of a larger file is read with `tail` and `head`. */
|
|
63
|
-
const REMOTE_WHOLE_BYTES = 8 * 1024 * 1024;
|
|
64
|
-
|
|
65
|
-
export namespace WorkspaceFilesUtil {
|
|
66
|
-
export function contentType(path: string): string {
|
|
67
|
-
const type = TYPES[path.replace(/^.*[./]/, '').toLowerCase()] ?? 'application/octet-stream';
|
|
68
|
-
return /^text\/|^application\/(json|xml)$/.test(type) ? `${type}; charset=utf-8` : type;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** `/api/files/<id>/<path>`; undefined for other URLs or a path that does not decode. */
|
|
72
|
-
export function parse(url: string | undefined): { id: string; path: string } | undefined {
|
|
73
|
-
const pathname = (url ?? '').split(/[?#]/)[0];
|
|
74
|
-
if (!pathname.startsWith(`${TA_FILES_PATH}/`)) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const rest = pathname.slice(TA_FILES_PATH.length + 1);
|
|
78
|
-
const slash = rest.indexOf('/');
|
|
79
|
-
try {
|
|
80
|
-
return slash < 0 ? { id: rest, path: '' } : { id: rest.slice(0, slash), path: decodeURIComponent(rest.slice(slash + 1)) };
|
|
81
|
-
} catch {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function url(id: string, path: string): string {
|
|
87
|
-
return `${TA_FILES_PATH}/${id}/${path.split('/').map(encodeURIComponent).join('/')}`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The one range of `bytes=a-b`, `bytes=a-` or `bytes=-n` within `size` bytes; undefined for none or
|
|
92
|
-
* several (the whole file is answered), `false` when it lies outside the file.
|
|
93
|
-
*/
|
|
94
|
-
export function range(header: string | undefined, size: number): { start: number; end: number } | false | undefined {
|
|
95
|
-
const match = /^bytes=(\d*)-(\d*)$/.exec(header?.trim() ?? '');
|
|
96
|
-
if (!match || (!match[1] && !match[2])) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
const start = match[1] ? Number(match[1]) : Math.max(0, size - Number(match[2]));
|
|
100
|
-
const end = match[1] && match[2] ? Math.min(Number(match[2]), size - 1) : size - 1;
|
|
101
|
-
return start <= end && start < size ? { start, end } : false;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function etag(stat: FileStat): string {
|
|
105
|
-
return `"${stat.size.toString(36)}-${Math.floor(stat.mtimeMs).toString(36)}"`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Answers `GET /api/files/<id>/<path>` with the bytes of a file, without the token of ta serve: `<id>`
|
|
111
|
-
* stands for one directory, and only who has the token learns it (TaWorkspaceServer.fileUrl). Paths stay inside
|
|
112
|
-
* that directory; a directory answers its `index.html`. One range is served, so that videos seek.
|
|
113
|
-
*/
|
|
114
|
-
@Component([WorkspaceFiles, Middleware])
|
|
115
|
-
export class DefaultWorkspaceFiles implements WorkspaceFiles, Middleware {
|
|
116
|
-
/** Before TaAccess, which turns away `/api` requests without the token. */
|
|
117
|
-
readonly priority = ACCESS_MIDDLEWARE_PRIORITY + 1;
|
|
118
|
-
|
|
119
|
-
@Autowired(ExecEnvironmentFactory)
|
|
120
|
-
protected readonly environments: ExecEnvironmentFactory;
|
|
121
|
-
|
|
122
|
-
@Value('server.host')
|
|
123
|
-
protected readonly host?: string;
|
|
124
|
-
|
|
125
|
-
protected readonly directories = new Map<string, string>();
|
|
126
|
-
protected readonly ids = new Map<string, string>();
|
|
127
|
-
|
|
128
|
-
url(cwd: string, path: string): string {
|
|
129
|
-
const { relative } = WorkspaceUtil.inside(cwd, path);
|
|
130
|
-
let id = this.ids.get(cwd);
|
|
131
|
-
if (!id) {
|
|
132
|
-
id = randomBytes(ID_BYTES).toString('base64url');
|
|
133
|
-
this.ids.set(cwd, id);
|
|
134
|
-
this.directories.set(id, cwd);
|
|
135
|
-
}
|
|
136
|
-
return WorkspaceFilesUtil.url(id, relative);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async handle(ctx: Context, next: () => Promise<void>): Promise<void> {
|
|
140
|
-
const request = ctx.request as unknown as IncomingMessage;
|
|
141
|
-
const target = WorkspaceFilesUtil.parse(request.url);
|
|
142
|
-
if (!target) {
|
|
143
|
-
await next();
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const response = ctx.response as unknown as ServerResponse;
|
|
147
|
-
const cwd = this.directories.get(target.id);
|
|
148
|
-
if (!cwd || !this.acceptsHost(request)) {
|
|
149
|
-
this.fail(response, 404);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
153
|
-
response.setHeader('Allow', 'GET, HEAD');
|
|
154
|
-
this.fail(response, 405);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
await this.send(request, response, cwd, target.path);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
protected async send(request: IncomingMessage, response: ServerResponse, cwd: string, path: string): Promise<void> {
|
|
161
|
-
const env = this.environments.create(cwd);
|
|
162
|
-
const file = await this.find(env, path);
|
|
163
|
-
if (!file) {
|
|
164
|
-
this.fail(response, 404);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const { absolute, stat } = file;
|
|
168
|
-
const type = WorkspaceFilesUtil.contentType(absolute);
|
|
169
|
-
const etag = WorkspaceFilesUtil.etag(stat);
|
|
170
|
-
response.setHeader('Content-Type', type);
|
|
171
|
-
response.setHeader('ETag', etag);
|
|
172
|
-
response.setHeader('Cache-Control', 'no-cache');
|
|
173
|
-
response.setHeader('Accept-Ranges', 'bytes');
|
|
174
|
-
response.setHeader('X-Content-Type-Options', 'nosniff');
|
|
175
|
-
response.setHeader('Referrer-Policy', 'no-referrer');
|
|
176
|
-
// Pages run in an origin of their own: their module scripts and fetches come from `null`.
|
|
177
|
-
response.setHeader('Access-Control-Allow-Origin', '*');
|
|
178
|
-
if (!type.startsWith('application/pdf')) {
|
|
179
|
-
response.setHeader('Content-Security-Policy', SANDBOX);
|
|
180
|
-
}
|
|
181
|
-
if (request.headers['if-none-match'] === etag) {
|
|
182
|
-
response.statusCode = 304;
|
|
183
|
-
response.end();
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const range = WorkspaceFilesUtil.range(request.headers.range, stat.size);
|
|
187
|
-
if (range === false) {
|
|
188
|
-
response.setHeader('Content-Range', `bytes */${stat.size}`);
|
|
189
|
-
this.fail(response, 416);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const { start, end } = range ?? { start: 0, end: stat.size - 1 };
|
|
193
|
-
response.statusCode = range ? 206 : 200;
|
|
194
|
-
if (range) {
|
|
195
|
-
response.setHeader('Content-Range', `bytes ${start}-${end}/${stat.size}`);
|
|
196
|
-
}
|
|
197
|
-
response.setHeader('Content-Length', Math.max(0, end - start + 1));
|
|
198
|
-
if (request.method === 'HEAD' || stat.size === 0) {
|
|
199
|
-
response.end();
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (env.local) {
|
|
203
|
-
await this.stream(response, absolute, start, end);
|
|
204
|
-
} else {
|
|
205
|
-
response.end(await this.read(env, absolute, stat.size, start, end));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** The file at `path`, or the `index.html` of the directory there. */
|
|
210
|
-
protected async find(env: ExecEnvironment, path: string): Promise<{ absolute: string; stat: FileStat } | undefined> {
|
|
211
|
-
let absolute: string;
|
|
212
|
-
try {
|
|
213
|
-
absolute = WorkspaceUtil.inside(env.cwd, path).absolute;
|
|
214
|
-
} catch {
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
|
-
let stat = await env.stat(absolute);
|
|
218
|
-
if (stat?.isDirectory) {
|
|
219
|
-
absolute = WorkspaceUtil.join(absolute, 'index.html');
|
|
220
|
-
stat = await env.stat(absolute);
|
|
221
|
-
}
|
|
222
|
-
return stat && !stat.isDirectory ? { absolute, stat } : undefined;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
protected stream(response: ServerResponse, absolute: string, start: number, end: number): Promise<void> {
|
|
226
|
-
return new Promise(resolve => {
|
|
227
|
-
const stream = createReadStream(absolute, { start, end });
|
|
228
|
-
stream.on('error', () => response.destroy());
|
|
229
|
-
response.once('close', () => {
|
|
230
|
-
stream.destroy();
|
|
231
|
-
resolve();
|
|
232
|
-
});
|
|
233
|
-
stream.pipe(response);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
protected async read(env: ExecEnvironment, absolute: string, size: number, start: number, end: number): Promise<Uint8Array> {
|
|
238
|
-
if (size <= REMOTE_WHOLE_BYTES) {
|
|
239
|
-
return (await env.readFile(absolute)).subarray(start, end + 1);
|
|
240
|
-
}
|
|
241
|
-
const chunks: Uint8Array[] = [];
|
|
242
|
-
const child = env.spawn('/bin/sh', ['-c', 'tail -c +"$1" -- "$0" | head -c "$2"', absolute, String(start + 1), String(end - start + 1)]);
|
|
243
|
-
child.onStdout(data => chunks.push(data));
|
|
244
|
-
await new Promise(resolve => child.onExit(resolve));
|
|
245
|
-
return Buffer.concat(chunks);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
protected acceptsHost(request: IncomingMessage): boolean {
|
|
249
|
-
return !TaAccessUtil.isLoopbackHost(this.host) || TaAccessUtil.isLoopbackHost(request.headers.host);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
protected fail(response: ServerResponse, status: number): void {
|
|
253
|
-
response.statusCode = status;
|
|
254
|
-
response.end();
|
|
255
|
-
}
|
|
256
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { TaCommandOutput, TaDirEntry, TaFileContent, TaRunCommandOptions } from '@celljs/ta-protocol';
|
|
2
|
-
|
|
3
|
-
export const TaWorkspace = Symbol('TaWorkspace');
|
|
4
|
-
export const WorkspaceFiles = Symbol('WorkspaceFiles');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The files of a directory for the web client, and programs run there: the methods of TaServer of
|
|
8
|
-
* the same names, with `cwd` resolved. Paths are relative to `cwd` and may not leave it; the work
|
|
9
|
-
* runs in the execution environment of `cwd`, as the tools of a session do.
|
|
10
|
-
*/
|
|
11
|
-
export interface TaWorkspace {
|
|
12
|
-
listDirectory(cwd: string, path: string): Promise<TaDirEntry[]>;
|
|
13
|
-
readFile(cwd: string, path: string): Promise<TaFileContent>;
|
|
14
|
-
writeFile(cwd: string, path: string, text: string): Promise<void>;
|
|
15
|
-
findFiles(cwd: string, query: string, limit?: number): Promise<string[]>;
|
|
16
|
-
runCommand(cwd: string, command: string, args: string[], options?: TaRunCommandOptions): Promise<TaCommandOutput>;
|
|
17
|
-
}
|
|
18
|
-
/** The bytes of workspace files over plain HTTP, for the page to show them as they are (TaWorkspaceServer.fileUrl). */
|
|
19
|
-
export interface WorkspaceFiles {
|
|
20
|
-
/** The URL of `path` of `cwd`; throws when it leaves `cwd`. */
|
|
21
|
-
url(cwd: string, path: string): string;
|
|
22
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Autowired } from '@celljs/core';
|
|
2
|
-
import { Rpc } from '@celljs/rpc';
|
|
3
|
-
import { RpcContext } from '@celljs/rpc/lib/node';
|
|
4
|
-
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
5
|
-
import {
|
|
6
|
-
type TaCommandOutput,
|
|
7
|
-
type TaDirEntry,
|
|
8
|
-
type TaFileContent,
|
|
9
|
-
type TaOpenTerminalOptions,
|
|
10
|
-
type TaRunCommandOptions,
|
|
11
|
-
type TaTerminalInfo,
|
|
12
|
-
TaTerminalServer,
|
|
13
|
-
TaWorkspaceServer,
|
|
14
|
-
} from '@celljs/ta-protocol';
|
|
15
|
-
import { TaErrors } from './ta-errors';
|
|
16
|
-
import { TaTerminals } from './terminal-protocol';
|
|
17
|
-
import { TaWorkspace, WorkspaceFiles } from './workspace-protocol';
|
|
18
|
-
|
|
19
|
-
/** The files and programs of a directory, for the web client; `cwd` defaults to the server's directory. */
|
|
20
|
-
@Rpc(TaWorkspaceServer)
|
|
21
|
-
export class TaWorkspaceServerImpl implements TaWorkspaceServer {
|
|
22
|
-
@Autowired(ExecEnvironmentFactory)
|
|
23
|
-
protected readonly environments: ExecEnvironmentFactory;
|
|
24
|
-
|
|
25
|
-
@Autowired(TaWorkspace)
|
|
26
|
-
protected readonly workspace: TaWorkspace;
|
|
27
|
-
|
|
28
|
-
@Autowired(WorkspaceFiles)
|
|
29
|
-
protected readonly files: WorkspaceFiles;
|
|
30
|
-
|
|
31
|
-
listDirectory(path: string, cwd?: string): Promise<TaDirEntry[]> {
|
|
32
|
-
return TaErrors.guard(async () => this.workspace.listDirectory(await this.cwd(cwd), path));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
readFile(path: string, cwd?: string): Promise<TaFileContent> {
|
|
36
|
-
return TaErrors.guard(async () => this.workspace.readFile(await this.cwd(cwd), path));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
writeFile(path: string, text: string, cwd?: string): Promise<void> {
|
|
40
|
-
return TaErrors.guard(async () => this.workspace.writeFile(await this.cwd(cwd), path, text));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fileUrl(path: string, cwd?: string): Promise<string> {
|
|
44
|
-
return TaErrors.guard(async () => this.files.url(await this.cwd(cwd), path));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
findFiles(query: string, cwd?: string, limit?: number): Promise<string[]> {
|
|
48
|
-
return TaErrors.guard(async () => this.workspace.findFiles(await this.cwd(cwd), query, limit));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
runCommand(command: string, args: string[], options: TaRunCommandOptions = {}): Promise<TaCommandOutput> {
|
|
52
|
-
return TaErrors.guard(async () => this.workspace.runCommand(await this.cwd(options.cwd), command, args, options));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
protected async cwd(cwd?: string): Promise<string> {
|
|
56
|
-
return cwd || (await this.environments.defaultCwd());
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** The shells of the connection that calls. */
|
|
61
|
-
@Rpc(TaTerminalServer)
|
|
62
|
-
export class TaTerminalServerImpl implements TaTerminalServer {
|
|
63
|
-
@Autowired(ExecEnvironmentFactory)
|
|
64
|
-
protected readonly environments: ExecEnvironmentFactory;
|
|
65
|
-
|
|
66
|
-
@Autowired(TaTerminals)
|
|
67
|
-
protected readonly terminals: TaTerminals;
|
|
68
|
-
|
|
69
|
-
openTerminal(options: TaOpenTerminalOptions): Promise<TaTerminalInfo> {
|
|
70
|
-
return TaErrors.guard(async () =>
|
|
71
|
-
this.terminals.open(RpcContext.requireConnection(), { ...options, cwd: options.cwd || (await this.environments.defaultCwd()) }),
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
writeTerminal(terminalId: string, data: string): Promise<void> {
|
|
76
|
-
return TaErrors.guard(() => this.terminals.write(RpcContext.requireConnection(), terminalId, data));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
resizeTerminal(terminalId: string, cols: number, rows: number): Promise<void> {
|
|
80
|
-
return TaErrors.guard(() => this.terminals.resize(RpcContext.requireConnection(), terminalId, cols, rows));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
closeTerminal(terminalId: string): Promise<void> {
|
|
84
|
-
return TaErrors.guard(() => this.terminals.close(RpcContext.requireConnection(), terminalId));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
listTerminals(): Promise<TaTerminalInfo[]> {
|
|
88
|
-
return TaErrors.guard(() => this.terminals.list(RpcContext.requireConnection()));
|
|
89
|
-
}
|
|
90
|
-
}
|