@amalgm/browser 0.1.2-preview.44182723491 → 0.1.2-preview.44182928298
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/CHANGELOG.md +3 -1
- package/PURPOSE.md +106 -153
- package/README.md +27 -16
- package/SECURITY.md +28 -10
- package/dist/native/automation/LICENSE +201 -0
- package/dist/native/automation/README.md +31 -0
- package/dist/native/automation/control-auth.patch +129 -0
- package/dist/native/automation/source.json +6 -0
- package/dist/native/automation.json +90 -0
- package/dist/native/darwin-universal/amalgm-browser-keychain +0 -0
- package/dist/native/encoder-notices/README.md +7 -0
- package/dist/native/encoder-notices/darwin-arm64.LICENSE +129 -0
- package/dist/native/encoder-notices/darwin-arm64.README +46 -0
- package/dist/native/encoder-notices/darwin-x64.LICENSE +127 -0
- package/dist/native/encoder-notices/darwin-x64.README +293 -0
- package/dist/native/encoder-notices/linux-arm64.LICENSE +674 -0
- package/dist/native/encoder-notices/linux-arm64.README +67 -0
- package/dist/native/encoder-notices/linux-x64.LICENSE +674 -0
- package/dist/native/encoder-notices/linux-x64.README +67 -0
- package/dist/native/encoder-notices/win32-x64.LICENSE +674 -0
- package/dist/native/encoder-notices/win32-x64.README +792 -0
- package/dist/native/encoder.json +90 -0
- package/dist/native/engine.json +5016 -0
- package/dist/src/adapters/http/desktop-link.d.ts +7 -0
- package/dist/src/adapters/http/desktop-link.js +29 -0
- package/dist/src/adapters/http/desktop-link.js.map +1 -0
- package/dist/src/adapters/http/internal-routes.js +0 -11
- package/dist/src/adapters/http/internal-routes.js.map +1 -1
- package/dist/src/adapters/http/openapi.js +8 -1
- package/dist/src/adapters/http/openapi.js.map +1 -1
- package/dist/src/adapters/http/server.js +17 -3
- package/dist/src/adapters/http/server.js.map +1 -1
- package/dist/src/adapters/http/session-routes.js +1 -0
- package/dist/src/adapters/http/session-routes.js.map +1 -1
- package/dist/src/adapters/http/stream.d.ts +3 -2
- package/dist/src/adapters/http/stream.js +36 -52
- package/dist/src/adapters/http/stream.js.map +1 -1
- package/dist/src/adapters/http/types.d.ts +5 -0
- package/dist/src/{electron/adblock → adblock}/cache.d.ts +1 -1
- package/dist/src/{electron/adblock → adblock}/cache.js +8 -2
- package/dist/src/adblock/cache.js.map +1 -0
- package/dist/src/adblock/cosmetics.d.ts +33 -0
- package/dist/src/adblock/cosmetics.js +122 -0
- package/dist/src/adblock/cosmetics.js.map +1 -0
- package/dist/src/adblock/monitor.d.ts +4 -0
- package/dist/src/adblock/monitor.js +51 -0
- package/dist/src/adblock/monitor.js.map +1 -0
- package/dist/src/adblock/network.d.ts +15 -0
- package/dist/src/adblock/network.js +20 -0
- package/dist/src/adblock/network.js.map +1 -0
- package/dist/src/adblock/policy.js.map +1 -0
- package/dist/src/adblock/runtime.d.ts +30 -0
- package/dist/src/adblock/runtime.js +221 -0
- package/dist/src/adblock/runtime.js.map +1 -0
- package/dist/src/adblock/settings.js.map +1 -0
- package/dist/src/auth/vault.d.ts +3 -2
- package/dist/src/auth/vault.js.map +1 -1
- package/dist/src/cdp/capability.d.ts +2 -0
- package/dist/src/cdp/capability.js +8 -0
- package/dist/src/cdp/capability.js.map +1 -0
- package/dist/src/cdp/capture-png.d.ts +2 -0
- package/dist/src/cdp/capture-png.js +40 -0
- package/dist/src/cdp/capture-png.js.map +1 -0
- package/dist/src/cdp/capture.js +12 -13
- package/dist/src/cdp/capture.js.map +1 -1
- package/dist/src/cdp/navigation.d.ts +5 -0
- package/dist/src/cdp/navigation.js +53 -1
- package/dist/src/cdp/navigation.js.map +1 -1
- package/dist/src/cdp/screencast.d.ts +0 -1
- package/dist/src/cdp/screencast.js +7 -18
- package/dist/src/cdp/screencast.js.map +1 -1
- package/dist/src/chrome/cookie-adapter.d.ts +3 -0
- package/dist/src/chrome/cookie-adapter.js +6 -32
- package/dist/src/chrome/cookie-adapter.js.map +1 -1
- package/dist/src/chrome/cookie-changes.d.ts +1 -1
- package/dist/src/chrome/cookie-format.d.ts +19 -0
- package/dist/src/chrome/cookie-format.js +31 -0
- package/dist/src/chrome/cookie-format.js.map +1 -0
- package/dist/src/cookies/coordinator.d.ts +2 -2
- package/dist/src/cookies/coordinator.js +58 -24
- package/dist/src/cookies/coordinator.js.map +1 -1
- package/dist/src/cookies/database.d.ts +0 -1
- package/dist/src/cookies/database.js +10 -6
- package/dist/src/cookies/database.js.map +1 -1
- package/dist/src/cookies/jar.d.ts +1 -2
- package/dist/src/cookies/jar.js +2 -22
- package/dist/src/cookies/jar.js.map +1 -1
- package/dist/src/cookies/secret-file.d.ts +4 -2
- package/dist/src/cookies/secret-file.js +8 -32
- package/dist/src/cookies/secret-file.js.map +1 -1
- package/dist/src/cookies/types.d.ts +7 -0
- package/dist/src/credentials/keyring-helper.js +30 -0
- package/dist/src/credentials/keyring-helper.js.map +1 -0
- package/dist/src/credentials/platform-key.d.ts +3 -0
- package/dist/src/credentials/platform-key.js +92 -0
- package/dist/src/credentials/platform-key.js.map +1 -0
- package/dist/src/defaults.d.ts +3 -0
- package/dist/src/defaults.js +12 -10
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/driver/attachment.d.ts +5 -0
- package/dist/src/driver/attachment.js +23 -0
- package/dist/src/driver/attachment.js.map +1 -0
- package/dist/src/driver/cli-policy.js +1 -1
- package/dist/src/driver/cli-policy.js.map +1 -1
- package/dist/src/driver/cli.d.ts +7 -0
- package/dist/src/driver/cli.js +21 -0
- package/dist/src/driver/cli.js.map +1 -0
- package/dist/src/driver/command.d.ts +5 -4
- package/dist/src/driver/command.js +86 -85
- package/dist/src/driver/command.js.map +1 -1
- package/dist/src/driver/cua.d.ts +8 -0
- package/dist/src/driver/cua.js +36 -0
- package/dist/src/driver/cua.js.map +1 -0
- package/dist/src/driver/daemon-start.d.ts +1 -0
- package/dist/src/driver/daemon-start.js +19 -0
- package/dist/src/driver/daemon-start.js.map +1 -0
- package/dist/src/driver/daemon.d.ts +28 -0
- package/dist/src/driver/daemon.js +125 -0
- package/dist/src/driver/daemon.js.map +1 -0
- package/dist/src/driver/driver.d.ts +9 -6
- package/dist/src/driver/driver.js +62 -63
- package/dist/src/driver/driver.js.map +1 -1
- package/dist/src/driver/response.d.ts +4 -0
- package/dist/src/driver/response.js +53 -0
- package/dist/src/driver/response.js.map +1 -0
- package/dist/src/electron/bounds.d.ts +4 -0
- package/dist/src/electron/bounds.js +11 -0
- package/dist/src/electron/bounds.js.map +1 -0
- package/dist/src/electron/contracts.d.ts +10 -1
- package/dist/src/electron/contracts.js +3 -0
- package/dist/src/electron/contracts.js.map +1 -1
- package/dist/src/electron/desktop-link.d.ts +25 -0
- package/dist/src/electron/desktop-link.js +153 -0
- package/dist/src/electron/desktop-link.js.map +1 -0
- package/dist/src/electron/native-context-menu.d.ts +18 -0
- package/dist/src/electron/native-context-menu.js +98 -0
- package/dist/src/electron/native-context-menu.js.map +1 -0
- package/dist/src/electron/native-downloads.d.ts +13 -0
- package/dist/src/electron/native-downloads.js +72 -0
- package/dist/src/electron/native-downloads.js.map +1 -0
- package/dist/src/electron/native-interactions.d.ts +21 -0
- package/dist/src/electron/native-interactions.js +101 -0
- package/dist/src/electron/native-interactions.js.map +1 -0
- package/dist/src/electron/native-popups.d.ts +19 -0
- package/dist/src/electron/native-popups.js +109 -0
- package/dist/src/electron/native-popups.js.map +1 -0
- package/dist/src/electron/native-presentation.d.ts +8 -0
- package/dist/src/electron/native-presentation.js +2 -0
- package/dist/src/electron/native-presentation.js.map +1 -0
- package/dist/src/electron/native-surfaces.d.ts +7 -0
- package/dist/src/electron/native-surfaces.js +214 -0
- package/dist/src/electron/native-surfaces.js.map +1 -0
- package/dist/src/electron/policy.d.ts +0 -4
- package/dist/src/electron/policy.js +0 -24
- package/dist/src/electron/policy.js.map +1 -1
- package/dist/src/electron/runtime-windows.d.ts +19 -0
- package/dist/src/electron/runtime-windows.js +115 -0
- package/dist/src/electron/runtime-windows.js.map +1 -0
- package/dist/src/electron/shell.d.ts +10 -2
- package/dist/src/electron/shell.js +22 -68
- package/dist/src/electron/shell.js.map +1 -1
- package/dist/src/electron.cjs +4551 -12940
- package/dist/src/electron.d.cts +4 -1
- package/dist/src/electron.d.ts +4 -1
- package/dist/src/electron.js +2 -1
- package/dist/src/electron.js.map +1 -1
- package/dist/src/host/desktop-protocol.d.ts +71 -0
- package/dist/src/host/desktop-protocol.js +13 -0
- package/dist/src/host/desktop-protocol.js.map +1 -0
- package/dist/src/host/desktop-windows.d.ts +6 -0
- package/dist/src/host/desktop-windows.js +34 -0
- package/dist/src/host/desktop-windows.js.map +1 -0
- package/dist/src/host/desktop.d.ts +5 -0
- package/dist/src/host/desktop.js +138 -0
- package/dist/src/host/desktop.js.map +1 -0
- package/dist/src/host/engine.d.ts +43 -0
- package/dist/src/host/engine.js +2 -0
- package/dist/src/host/engine.js.map +1 -0
- package/dist/src/host/host.d.ts +38 -0
- package/dist/src/host/host.js +213 -0
- package/dist/src/host/host.js.map +1 -0
- package/dist/src/host/live-stream.d.ts +20 -0
- package/dist/src/host/live-stream.js +115 -0
- package/dist/src/host/live-stream.js.map +1 -0
- package/dist/src/host/relay/editing.js.map +1 -0
- package/dist/src/host/relay/server.d.ts +30 -0
- package/dist/src/host/relay/server.js +219 -0
- package/dist/src/host/relay/server.js.map +1 -0
- package/dist/src/{chrome → host}/relay/view.d.ts +2 -1
- package/dist/src/{chrome → host}/relay/view.js +11 -5
- package/dist/src/host/relay/view.js.map +1 -0
- package/dist/src/host/sessions.d.ts +42 -0
- package/dist/src/host/sessions.js +158 -0
- package/dist/src/host/sessions.js.map +1 -0
- package/dist/src/host/stream-input.d.ts +4 -0
- package/dist/src/host/stream-input.js +46 -0
- package/dist/src/host/stream-input.js.map +1 -0
- package/dist/src/host/stream-viewport.d.ts +6 -0
- package/dist/src/host/stream-viewport.js +70 -0
- package/dist/src/host/stream-viewport.js.map +1 -0
- package/dist/src/host/window-protocol.d.ts +67 -0
- package/dist/src/host/window-protocol.js +2 -0
- package/dist/src/host/window-protocol.js.map +1 -0
- package/dist/src/native/artifact-archive.d.ts +4 -0
- package/dist/src/native/artifact-archive.js +110 -0
- package/dist/src/native/artifact-archive.js.map +1 -0
- package/dist/src/native/artifact-cache.d.ts +9 -0
- package/dist/src/native/artifact-cache.js +113 -0
- package/dist/src/native/artifact-cache.js.map +1 -0
- package/dist/src/native/artifact-manifest.d.ts +25 -0
- package/dist/src/native/artifact-manifest.js +60 -0
- package/dist/src/native/artifact-manifest.js.map +1 -0
- package/dist/src/native/artifact-zip.d.ts +3 -0
- package/dist/src/native/artifact-zip.js +59 -0
- package/dist/src/native/artifact-zip.js.map +1 -0
- package/dist/src/native/automation.d.ts +2 -0
- package/dist/src/native/automation.js +33 -0
- package/dist/src/native/automation.js.map +1 -0
- package/dist/src/native/cache-directory.d.ts +1 -0
- package/dist/src/native/cache-directory.js +11 -0
- package/dist/src/native/cache-directory.js.map +1 -0
- package/dist/src/native/cdp-bridge.d.ts +17 -0
- package/dist/src/native/cdp-bridge.js +240 -0
- package/dist/src/native/cdp-bridge.js.map +1 -0
- package/dist/src/native/cdp-dialogs.d.ts +19 -0
- package/dist/src/native/cdp-dialogs.js +54 -0
- package/dist/src/native/cdp-dialogs.js.map +1 -0
- package/dist/src/native/cdp-pipe.d.ts +19 -0
- package/dist/src/native/cdp-pipe.js +112 -0
- package/dist/src/native/cdp-pipe.js.map +1 -0
- package/dist/src/native/cdp.d.ts +4 -0
- package/dist/src/native/cdp.js +71 -0
- package/dist/src/native/cdp.js.map +1 -0
- package/dist/src/native/downloads.d.ts +16 -0
- package/dist/src/native/downloads.js +76 -0
- package/dist/src/native/downloads.js.map +1 -0
- package/dist/src/native/encoder.d.ts +3 -0
- package/dist/src/native/encoder.js +37 -0
- package/dist/src/native/encoder.js.map +1 -0
- package/dist/src/native/engine.d.ts +20 -0
- package/dist/src/native/engine.js +267 -0
- package/dist/src/native/engine.js.map +1 -0
- package/dist/src/native/executable.d.ts +1 -0
- package/dist/src/native/executable.js +23 -0
- package/dist/src/native/executable.js.map +1 -0
- package/dist/src/native/interactions.d.ts +30 -0
- package/dist/src/native/interactions.js +16 -0
- package/dist/src/native/interactions.js.map +1 -0
- package/dist/src/native/permissions.d.ts +10 -0
- package/dist/src/native/permissions.js +62 -0
- package/dist/src/native/permissions.js.map +1 -0
- package/dist/src/native/process.d.ts +32 -0
- package/dist/src/native/process.js +212 -0
- package/dist/src/native/process.js.map +1 -0
- package/dist/src/native/profile-cookies.d.ts +3 -0
- package/dist/src/native/profile-cookies.js +160 -0
- package/dist/src/native/profile-cookies.js.map +1 -0
- package/dist/src/persistence/session-pages.d.ts +10 -0
- package/dist/src/persistence/session-pages.js +31 -0
- package/dist/src/persistence/session-pages.js.map +1 -0
- package/dist/src/persistence/sqlite-registry.js +7 -1
- package/dist/src/persistence/sqlite-registry.js.map +1 -1
- package/dist/src/ports.d.ts +5 -1
- package/dist/src/ports.js.map +1 -1
- package/dist/src/recording/service.js +2 -1
- package/dist/src/recording/service.js.map +1 -1
- package/dist/src/registry.js +2 -0
- package/dist/src/registry.js.map +1 -1
- package/dist/src/runtime-electron/downloads.d.ts +11 -0
- package/dist/src/runtime-electron/downloads.js +60 -0
- package/dist/src/runtime-electron/downloads.js.map +1 -0
- package/dist/src/runtime-electron/engine.d.ts +4 -0
- package/dist/src/runtime-electron/engine.js +46 -0
- package/dist/src/runtime-electron/engine.js.map +1 -0
- package/dist/src/runtime-electron/interactions.d.ts +24 -0
- package/dist/src/runtime-electron/interactions.js +211 -0
- package/dist/src/runtime-electron/interactions.js.map +1 -0
- package/dist/src/runtime-electron/main.cjs +6312 -0
- package/dist/src/runtime-electron/main.d.ts +1 -0
- package/dist/src/runtime-electron/main.js +133 -0
- package/dist/src/runtime-electron/main.js.map +1 -0
- package/dist/src/runtime-electron/media-components.d.ts +3 -0
- package/dist/src/runtime-electron/media-components.js +18 -0
- package/dist/src/runtime-electron/media-components.js.map +1 -0
- package/dist/src/runtime-electron/native-frame.d.ts +5 -0
- package/dist/src/runtime-electron/native-frame.js +21 -0
- package/dist/src/runtime-electron/native-frame.js.map +1 -0
- package/dist/src/runtime-electron/network.d.ts +23 -0
- package/dist/src/runtime-electron/network.js +98 -0
- package/dist/src/runtime-electron/network.js.map +1 -0
- package/dist/src/runtime-electron/page-preload.cjs +13 -0
- package/dist/src/runtime-electron/page-preload.d.ts +1 -0
- package/dist/src/runtime-electron/page-preload.js +10 -0
- package/dist/src/runtime-electron/page-preload.js.map +1 -0
- package/dist/src/runtime-electron/page-rendering.d.ts +19 -0
- package/dist/src/runtime-electron/page-rendering.js +100 -0
- package/dist/src/runtime-electron/page-rendering.js.map +1 -0
- package/dist/src/runtime-electron/page-viewport.d.ts +14 -0
- package/dist/src/runtime-electron/page-viewport.js +39 -0
- package/dist/src/runtime-electron/page-viewport.js.map +1 -0
- package/dist/src/runtime-electron/page-views.d.ts +22 -0
- package/dist/src/runtime-electron/page-views.js +137 -0
- package/dist/src/runtime-electron/page-views.js.map +1 -0
- package/dist/src/runtime-electron/pages.d.ts +50 -0
- package/dist/src/runtime-electron/pages.js +213 -0
- package/dist/src/runtime-electron/pages.js.map +1 -0
- package/dist/src/runtime-electron/permission-scopes.d.ts +5 -0
- package/dist/src/runtime-electron/permission-scopes.js +12 -0
- package/dist/src/runtime-electron/permission-scopes.js.map +1 -0
- package/dist/src/runtime-electron/presentation.d.ts +22 -0
- package/dist/src/runtime-electron/presentation.js +143 -0
- package/dist/src/runtime-electron/presentation.js.map +1 -0
- package/dist/src/runtime-electron/profile-migration.d.ts +3 -0
- package/dist/src/runtime-electron/profile-migration.js +112 -0
- package/dist/src/runtime-electron/profile-migration.js.map +1 -0
- package/dist/src/runtime-electron/prompt-preload.cjs +24 -0
- package/dist/src/runtime-electron/prompt-preload.d.ts +1 -0
- package/dist/src/runtime-electron/prompt-preload.js +18 -0
- package/dist/src/runtime-electron/prompt-preload.js.map +1 -0
- package/dist/src/runtime-electron/prompt-window.d.ts +16 -0
- package/dist/src/runtime-electron/prompt-window.js +52 -0
- package/dist/src/runtime-electron/prompt-window.js.map +1 -0
- package/dist/src/runtime-electron/protocol.d.ts +8 -0
- package/dist/src/runtime-electron/protocol.js +43 -0
- package/dist/src/runtime-electron/protocol.js.map +1 -0
- package/dist/src/runtime-electron/ui-profile.d.ts +15 -0
- package/dist/src/runtime-electron/ui-profile.js +128 -0
- package/dist/src/runtime-electron/ui-profile.js.map +1 -0
- package/dist/src/runtime-electron/window-control.d.ts +4 -0
- package/dist/src/runtime-electron/window-control.js +40 -0
- package/dist/src/runtime-electron/window-control.js.map +1 -0
- package/dist/src/runtime-electron/windows.d.ts +28 -0
- package/dist/src/runtime-electron/windows.js +186 -0
- package/dist/src/runtime-electron/windows.js.map +1 -0
- package/dist/src/service-options.d.ts +2 -0
- package/dist/src/service.d.ts +3 -0
- package/dist/src/service.js +12 -40
- package/dist/src/service.js.map +1 -1
- package/dist/src/sessions/admission.d.ts +12 -0
- package/dist/src/sessions/admission.js +68 -0
- package/dist/src/sessions/admission.js.map +1 -0
- package/dist/src/testing.d.ts +2 -1
- package/dist/src/testing.js +5 -1
- package/dist/src/testing.js.map +1 -1
- package/dist/src/types.d.ts +0 -1
- package/dist/src/viewport.d.ts +7 -0
- package/dist/src/viewport.js +8 -0
- package/dist/src/viewport.js.map +1 -0
- package/docs/ARCHITECTURE.md +114 -58
- package/docs/AXIOMS.md +39 -17
- package/docs/CHROME.md +74 -155
- package/docs/COMPATIBILITY.md +11 -4
- package/docs/COOKIES.md +33 -19
- package/docs/ELECTRON_INTEGRATION.md +70 -100
- package/docs/ENGINE_DELIVERY.md +143 -0
- package/docs/ENGINE_RELEASE.md +72 -0
- package/docs/NATIVE_BROWSER.md +138 -0
- package/docs/OPERATIONS.md +28 -12
- package/docs/README.md +3 -1
- package/docs/REALTIME_BOUNDARY.md +3 -4
- package/docs/REST.md +13 -9
- package/docs/SDK.md +13 -8
- package/docs/SHELL_INTEGRATION.md +11 -8
- package/docs/TESTING.md +56 -62
- package/docs/TROUBLESHOOTING.md +24 -24
- package/package.json +36 -16
- package/skills/use-amalgm-browser/SKILL.md +4 -3
- package/dist/src/chrome/executable.d.ts +0 -1
- package/dist/src/chrome/executable.js +0 -55
- package/dist/src/chrome/executable.js.map +0 -1
- package/dist/src/chrome/flags.d.ts +0 -7
- package/dist/src/chrome/flags.js +0 -59
- package/dist/src/chrome/flags.js.map +0 -1
- package/dist/src/chrome/host.d.ts +0 -25
- package/dist/src/chrome/host.js +0 -135
- package/dist/src/chrome/host.js.map +0 -1
- package/dist/src/chrome/launch.d.ts +0 -11
- package/dist/src/chrome/launch.js +0 -121
- package/dist/src/chrome/launch.js.map +0 -1
- package/dist/src/chrome/relay/editing.js.map +0 -1
- package/dist/src/chrome/relay/server.d.ts +0 -18
- package/dist/src/chrome/relay/server.js +0 -120
- package/dist/src/chrome/relay/server.js.map +0 -1
- package/dist/src/chrome/relay/targets.d.ts +0 -11
- package/dist/src/chrome/relay/targets.js +0 -59
- package/dist/src/chrome/relay/targets.js.map +0 -1
- package/dist/src/chrome/relay/view.js.map +0 -1
- package/dist/src/driver/executable.d.ts +0 -8
- package/dist/src/driver/executable.js +0 -56
- package/dist/src/driver/executable.js.map +0 -1
- package/dist/src/driver/stream.d.ts +0 -1
- package/dist/src/driver/stream.js +0 -22
- package/dist/src/driver/stream.js.map +0 -1
- package/dist/src/electron/adblock/cache.js.map +0 -1
- package/dist/src/electron/adblock/cosmetics.d.ts +0 -11
- package/dist/src/electron/adblock/cosmetics.js +0 -45
- package/dist/src/electron/adblock/cosmetics.js.map +0 -1
- package/dist/src/electron/adblock/index.d.ts +0 -43
- package/dist/src/electron/adblock/index.js +0 -157
- package/dist/src/electron/adblock/index.js.map +0 -1
- package/dist/src/electron/adblock/policy.js.map +0 -1
- package/dist/src/electron/adblock/preload.js +0 -131
- package/dist/src/electron/adblock/preload.js.map +0 -1
- package/dist/src/electron/adblock/settings.js.map +0 -1
- package/dist/src/electron/cookie-adapter.d.ts +0 -17
- package/dist/src/electron/cookie-adapter.js +0 -72
- package/dist/src/electron/cookie-adapter.js.map +0 -1
- package/dist/src/electron/cookie-sync.d.ts +0 -6
- package/dist/src/electron/cookie-sync.js +0 -18
- package/dist/src/electron/cookie-sync.js.map +0 -1
- package/dist/src/electron/session.d.ts +0 -2
- package/dist/src/electron/session.js +0 -9
- package/dist/src/electron/session.js.map +0 -1
- package/dist/src/electron/shell/adblock-ipc.d.ts +0 -10
- package/dist/src/electron/shell/adblock-ipc.js +0 -44
- package/dist/src/electron/shell/adblock-ipc.js.map +0 -1
- package/dist/src/electron/shell/context-menu.d.ts +0 -11
- package/dist/src/electron/shell/context-menu.js +0 -129
- package/dist/src/electron/shell/context-menu.js.map +0 -1
- package/dist/src/electron/shell/downloads.d.ts +0 -11
- package/dist/src/electron/shell/downloads.js +0 -90
- package/dist/src/electron/shell/downloads.js.map +0 -1
- package/dist/src/electron/shell/helpers.d.ts +0 -5
- package/dist/src/electron/shell/helpers.js +0 -53
- package/dist/src/electron/shell/helpers.js.map +0 -1
- package/dist/src/electron/shell/permissions.d.ts +0 -16
- package/dist/src/electron/shell/permissions.js +0 -107
- package/dist/src/electron/shell/permissions.js.map +0 -1
- package/dist/src/electron/shell/sites.d.ts +0 -22
- package/dist/src/electron/shell/sites.js +0 -87
- package/dist/src/electron/shell/sites.js.map +0 -1
- package/dist/src/electron/shell/types.d.ts +0 -12
- package/dist/src/electron/shell/types.js +0 -2
- package/dist/src/electron/shell/types.js.map +0 -1
- package/dist/src/electron/surface/commands.d.ts +0 -4
- package/dist/src/electron/surface/commands.js +0 -49
- package/dist/src/electron/surface/commands.js.map +0 -1
- package/dist/src/electron/surface/create.d.ts +0 -4
- package/dist/src/electron/surface/create.js +0 -40
- package/dist/src/electron/surface/create.js.map +0 -1
- package/dist/src/electron/surface/events.d.ts +0 -3
- package/dist/src/electron/surface/events.js +0 -43
- package/dist/src/electron/surface/events.js.map +0 -1
- package/dist/src/electron/surface/presentation.d.ts +0 -8
- package/dist/src/electron/surface/presentation.js +0 -29
- package/dist/src/electron/surface/presentation.js.map +0 -1
- package/dist/src/electron/surface/state.d.ts +0 -12
- package/dist/src/electron/surface/state.js +0 -51
- package/dist/src/electron/surface/state.js.map +0 -1
- package/dist/src/electron/surface/types.d.ts +0 -33
- package/dist/src/electron/surface/types.js +0 -2
- package/dist/src/electron/surface/types.js.map +0 -1
- package/dist/src/electron/surface-controller.d.ts +0 -6
- package/dist/src/electron/surface-controller.js +0 -135
- package/dist/src/electron/surface-controller.js.map +0 -1
- package/dist/src/electron-preload.cjs +0 -113
- /package/dist/src/{electron/adblock → adblock}/policy.d.ts +0 -0
- /package/dist/src/{electron/adblock → adblock}/policy.js +0 -0
- /package/dist/src/{electron/adblock → adblock}/settings.d.ts +0 -0
- /package/dist/src/{electron/adblock → adblock}/settings.js +0 -0
- /package/dist/src/{electron/adblock/preload.d.ts → credentials/keyring-helper.d.ts} +0 -0
- /package/dist/src/{chrome → host}/relay/editing.d.ts +0 -0
- /package/dist/src/{chrome → host}/relay/editing.js +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { BrowserError } from '../errors.js';
|
|
5
|
+
import { adoptProfileCookies } from '../native/profile-cookies.js';
|
|
6
|
+
import { readLegacyCookies } from '../native/process.js';
|
|
7
|
+
const receiptName = 'amalgm-profile-adopted.json';
|
|
8
|
+
const disposable = new Set(['Cache', 'Code Cache', 'GPUCache', 'DawnCache', 'DawnGraphiteCache', 'DawnWebGPUCache',
|
|
9
|
+
'GrShaderCache', 'ShaderCache', 'Crashpad', 'Crash Reports', 'BrowserMetrics', 'SingletonLock', 'SingletonCookie', 'SingletonSocket']);
|
|
10
|
+
const failure = (message) => new BrowserError('PROCESS_FAILED', `Browser profile migration: ${message} Original storage has been preserved.`);
|
|
11
|
+
/** Called with both the account-root lease and the older chrome-profile lease held. */
|
|
12
|
+
export async function migrateElectronProfile(root, store, legacyExecutable) {
|
|
13
|
+
const source = path.join(root, 'chrome'), target = path.join(root, 'electron');
|
|
14
|
+
if (!fs.existsSync(source))
|
|
15
|
+
return;
|
|
16
|
+
if (!fs.lstatSync(source).isDirectory() || fs.realpathSync(source) !== source)
|
|
17
|
+
throw failure('The legacy profile is not a local directory.');
|
|
18
|
+
const marker = path.join(target, receiptName);
|
|
19
|
+
if (fs.existsSync(marker)) {
|
|
20
|
+
const receipt = JSON.parse(fs.readFileSync(marker, 'utf8'));
|
|
21
|
+
if (receipt.schema !== 1 || receipt.source !== 'chrome' || !receipt.files || typeof receipt.files !== 'object')
|
|
22
|
+
throw failure('The migration receipt is invalid.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const defaultProfile = path.join(source, 'Default');
|
|
26
|
+
const profile = fs.existsSync(defaultProfile) ? defaultProfile : source;
|
|
27
|
+
const before = inventory(profile);
|
|
28
|
+
const hasCookies = ['Cookies', 'Network/Cookies'].some(name => fs.existsSync(path.join(profile, name)));
|
|
29
|
+
if (!Object.keys(before).length && !hasCookies)
|
|
30
|
+
return;
|
|
31
|
+
if (fs.existsSync(target) && fs.readdirSync(target).length)
|
|
32
|
+
throw failure('Both old and new profiles contain data; automatic merging is unavailable.');
|
|
33
|
+
await adoptProfileCookies(source, store, async (shadow) => {
|
|
34
|
+
if (!legacyExecutable)
|
|
35
|
+
throw failure('Unknown legacy cookies require the previous engine to unlock them.');
|
|
36
|
+
return readLegacyCookies(legacyExecutable, shadow);
|
|
37
|
+
});
|
|
38
|
+
const staging = path.join(root, '.electron-profile-adoption');
|
|
39
|
+
if (fs.existsSync(staging))
|
|
40
|
+
fs.rmSync(staging, { recursive: true });
|
|
41
|
+
fs.mkdirSync(staging, { mode: 0o700 });
|
|
42
|
+
try {
|
|
43
|
+
const files = inventory(profile);
|
|
44
|
+
for (const name of Object.keys(files)) {
|
|
45
|
+
const destination = path.join(staging, name);
|
|
46
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true, mode: 0o700 });
|
|
47
|
+
fs.copyFileSync(path.join(profile, name), destination, fs.constants.COPYFILE_EXCL);
|
|
48
|
+
fs.chmodSync(destination, 0o600);
|
|
49
|
+
syncFile(destination);
|
|
50
|
+
}
|
|
51
|
+
if (JSON.stringify(inventory(staging)) !== JSON.stringify(files) || JSON.stringify(inventory(profile)) !== JSON.stringify(files)) {
|
|
52
|
+
throw failure('The source changed while its storage was copied.');
|
|
53
|
+
}
|
|
54
|
+
fs.writeFileSync(path.join(staging, receiptName), JSON.stringify({ schema: 1, source: 'chrome', files }) + '\n', { mode: 0o600, flag: 'wx' });
|
|
55
|
+
syncFile(path.join(staging, receiptName));
|
|
56
|
+
syncDirectories(staging);
|
|
57
|
+
if (fs.existsSync(target))
|
|
58
|
+
fs.rmdirSync(target);
|
|
59
|
+
fs.renameSync(staging, target);
|
|
60
|
+
syncDirectory(root);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (fs.existsSync(staging))
|
|
64
|
+
fs.rmSync(staging, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function inventory(root) {
|
|
68
|
+
const files = {};
|
|
69
|
+
const visit = (directory) => {
|
|
70
|
+
for (const name of fs.readdirSync(directory).sort()) {
|
|
71
|
+
if (disposable.has(name) || name === receiptName || name === 'Cookies' || /^Cookies-(wal|shm|journal)$/.test(name))
|
|
72
|
+
continue;
|
|
73
|
+
const file = path.join(directory, name), stat = fs.lstatSync(file);
|
|
74
|
+
if (stat.isDirectory())
|
|
75
|
+
visit(file);
|
|
76
|
+
else if (stat.isFile()) {
|
|
77
|
+
const hash = createHash('sha256'), fd = fs.openSync(file, 'r'), buffer = Buffer.alloc(64 * 1024);
|
|
78
|
+
try {
|
|
79
|
+
for (;;) {
|
|
80
|
+
const length = fs.readSync(fd, buffer);
|
|
81
|
+
if (!length)
|
|
82
|
+
break;
|
|
83
|
+
hash.update(buffer.subarray(0, length));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
fs.closeSync(fd);
|
|
88
|
+
}
|
|
89
|
+
files[path.relative(root, file)] = hash.digest('hex');
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
throw failure('A storage entry is not a regular file.');
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
visit(root);
|
|
96
|
+
return files;
|
|
97
|
+
}
|
|
98
|
+
function syncFile(file) { const fd = fs.openSync(file, 'r'); try {
|
|
99
|
+
fs.fsyncSync(fd);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
fs.closeSync(fd);
|
|
103
|
+
} }
|
|
104
|
+
function syncDirectory(directory) { if (process.platform !== 'win32')
|
|
105
|
+
syncFile(directory); }
|
|
106
|
+
function syncDirectories(root) {
|
|
107
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true }))
|
|
108
|
+
if (entry.isDirectory())
|
|
109
|
+
syncDirectories(path.join(root, entry.name));
|
|
110
|
+
syncDirectory(root);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=profile-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-migration.js","sourceRoot":"","sources":["../../../src/runtime-electron/profile-migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB;IAChH,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,E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
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/runtime-electron/prompt-preload.ts
|
|
4
|
+
var import_electron = require("electron");
|
|
5
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
6
|
+
void import_electron.ipcRenderer.invoke("amalgm:prompt-config").then((input) => {
|
|
7
|
+
document.getElementById("message").textContent = input.message;
|
|
8
|
+
document.getElementById("origin").textContent = input.origin;
|
|
9
|
+
const answer = document.getElementById("answer");
|
|
10
|
+
answer.value = input.initial;
|
|
11
|
+
answer.focus();
|
|
12
|
+
answer.select();
|
|
13
|
+
const respond = (allow) => import_electron.ipcRenderer.send("amalgm:prompt-answer", allow, answer.value);
|
|
14
|
+
document.querySelector("form").addEventListener("submit", (event) => {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
respond(true);
|
|
17
|
+
});
|
|
18
|
+
document.getElementById("cancel").addEventListener("click", () => respond(false));
|
|
19
|
+
document.addEventListener("keydown", (event) => {
|
|
20
|
+
if (event.key === "Escape") respond(false);
|
|
21
|
+
});
|
|
22
|
+
import_electron.ipcRenderer.send("amalgm:prompt-ready");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ipcRenderer } from 'electron';
|
|
2
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
3
|
+
void ipcRenderer.invoke('amalgm:prompt-config').then((input) => {
|
|
4
|
+
document.getElementById('message').textContent = input.message;
|
|
5
|
+
document.getElementById('origin').textContent = input.origin;
|
|
6
|
+
const answer = document.getElementById('answer');
|
|
7
|
+
answer.value = input.initial;
|
|
8
|
+
answer.focus();
|
|
9
|
+
answer.select();
|
|
10
|
+
const respond = (allow) => ipcRenderer.send('amalgm:prompt-answer', allow, answer.value);
|
|
11
|
+
document.querySelector('form').addEventListener('submit', event => { event.preventDefault(); respond(true); });
|
|
12
|
+
document.getElementById('cancel').addEventListener('click', () => respond(false));
|
|
13
|
+
document.addEventListener('keydown', event => { if (event.key === 'Escape')
|
|
14
|
+
respond(false); });
|
|
15
|
+
ipcRenderer.send('amalgm:prompt-ready');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=prompt-preload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-preload.js","sourceRoot":"","sources":["../../../src/runtime-electron/prompt-preload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC/C,KAAK,WAAW,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,CAAC,KAA2D,EAAE,EAAE;QACnH,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAE,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC;QAChE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAE,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;QAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAqB,CAAC;QACrE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;QAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9D,MAAM,OAAO,GAAG,CAAC,KAAc,EAAQ,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACxG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChH,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACnF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/F,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
interface Prompt {
|
|
3
|
+
message?: string;
|
|
4
|
+
defaultPrompt?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
interface Answer {
|
|
8
|
+
allow: boolean;
|
|
9
|
+
value?: string;
|
|
10
|
+
}
|
|
11
|
+
/** This isolated UI can answer only the request that created it. */
|
|
12
|
+
export declare function showPrompt(owner: BrowserWindow, input: Prompt): {
|
|
13
|
+
result: Promise<Answer>;
|
|
14
|
+
close(): void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const document = `<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'">
|
|
4
|
+
<title>Website prompt</title><style>body{font:14px system-ui;margin:24px;background:#fafaf9;color:#292524}p{overflow-wrap:anywhere;max-height:160px;overflow:auto}#origin{font-size:12px;color:#57534e}input{box-sizing:border-box;width:100%;padding:8px;font:inherit}footer{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}button{font:inherit;padding:6px 20px}</style>
|
|
5
|
+
<p id="origin"></p><p id="message"></p><form><label for="answer">Response</label><input id="answer" autocomplete="off"><footer><button id="cancel" type="button">Cancel</button><button type="submit">OK</button></footer></form>`;
|
|
6
|
+
/** This isolated UI can answer only the request that created it. */
|
|
7
|
+
export function showPrompt(owner, input) {
|
|
8
|
+
const window = new BrowserWindow({ parent: owner, modal: true, show: false, width: 460, height: 320,
|
|
9
|
+
resizable: false, minimizable: false, maximizable: false, title: 'Website prompt',
|
|
10
|
+
webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false,
|
|
11
|
+
partition: 'amalgm-dialogs', preload: path.join(import.meta.dirname, 'prompt-preload.cjs') } });
|
|
12
|
+
let finish;
|
|
13
|
+
const result = new Promise(resolve => { finish = resolve; });
|
|
14
|
+
const close = () => { if (!window.isDestroyed())
|
|
15
|
+
window.close(); };
|
|
16
|
+
const timer = setTimeout(close, 30_000);
|
|
17
|
+
window.once('closed', () => { clearTimeout(timer); finish({ allow: false }); });
|
|
18
|
+
window.webContents.ipc.handle('amalgm:prompt-config', event => {
|
|
19
|
+
if (window.isDestroyed() || event.senderFrame !== window.webContents.mainFrame)
|
|
20
|
+
throw new Error('Unknown prompt frame.');
|
|
21
|
+
let origin = '';
|
|
22
|
+
try {
|
|
23
|
+
origin = new URL(input.url || '').origin;
|
|
24
|
+
}
|
|
25
|
+
catch { /* Blank documents have no network origin. */ }
|
|
26
|
+
return { message: input.message || '', initial: input.defaultPrompt || '', origin };
|
|
27
|
+
});
|
|
28
|
+
window.webContents.ipc.once('amalgm:prompt-answer', (event, allow, value) => {
|
|
29
|
+
if (window.isDestroyed() || event.senderFrame !== window.webContents.mainFrame || typeof allow !== 'boolean'
|
|
30
|
+
|| typeof value !== 'string' || value.length > 64 * 1024)
|
|
31
|
+
return;
|
|
32
|
+
finish({ allow, ...(allow ? { value } : {}) });
|
|
33
|
+
close();
|
|
34
|
+
});
|
|
35
|
+
window.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
|
|
36
|
+
window.webContents.on('will-navigate', event => event.preventDefault());
|
|
37
|
+
let painted = false, configured = false;
|
|
38
|
+
const show = () => { if (painted && configured && !window.isDestroyed())
|
|
39
|
+
window.show(); };
|
|
40
|
+
window.once('ready-to-show', () => { painted = true; show(); });
|
|
41
|
+
// Both the first frame and the asynchronous input configuration must be
|
|
42
|
+
// ready before the dialog is exposed to native keyboard input.
|
|
43
|
+
window.webContents.ipc.once('amalgm:prompt-ready', event => {
|
|
44
|
+
if (!window.isDestroyed() && event.senderFrame === window.webContents.mainFrame) {
|
|
45
|
+
configured = true;
|
|
46
|
+
show();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
void window.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(document)}`).catch(close);
|
|
50
|
+
return { result, close };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=prompt-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-window.js","sourceRoot":"","sources":["../../../src/runtime-electron/prompt-window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,MAAM,QAAQ,GAAG;;kOAEiN,CAAC;AAEnO,oEAAoE;AACpE,MAAM,UAAU,UAAU,CAAC,KAAoB,EAAE,KAAa;IAC5D,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG;QACjG,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB;QACjF,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK;YAC7E,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,C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AC;YAAC,UAAU,GAAG,IAAI,CAAC;YAAC,IAAI,EAAE,CAAC;QAAC,CAAC;IACjH,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,CAAC,OAAO,CAAC,gCAAgC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NativeReport } from '../native/process.js';
|
|
2
|
+
export interface RuntimeRequest extends Record<string, unknown> {
|
|
3
|
+
id: number;
|
|
4
|
+
method: string;
|
|
5
|
+
}
|
|
6
|
+
export type Report = (report: NativeReport) => void;
|
|
7
|
+
/** Inherited control only: websites never receive this channel or its authority. */
|
|
8
|
+
export declare function runtimeProtocol(handle: (request: RuntimeRequest) => Promise<unknown>, end: () => void): Report;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
import { Socket } from 'node:net';
|
|
3
|
+
/** Inherited control only: websites never receive this channel or its authority. */
|
|
4
|
+
export function runtimeProtocol(handle, end) {
|
|
5
|
+
const report = value => {
|
|
6
|
+
if (process.stdout.writableLength > 4 * 1024 * 1024) {
|
|
7
|
+
end();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
11
|
+
};
|
|
12
|
+
let active = 0;
|
|
13
|
+
// Electron replaces process.stdin with an immediate EOF stream on Windows.
|
|
14
|
+
// Open the actual inherited descriptor directly on every platform.
|
|
15
|
+
const control = new Socket({ fd: 0, readable: true, writable: false });
|
|
16
|
+
const input = createInterface({ input: control, crlfDelay: Infinity });
|
|
17
|
+
input.on('line', line => {
|
|
18
|
+
if (Buffer.byteLength(line) > 1024 * 1024 || active >= 2048) {
|
|
19
|
+
end();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let request;
|
|
23
|
+
try {
|
|
24
|
+
request = JSON.parse(line);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
end();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!Number.isSafeInteger(request?.id) || typeof request.method !== 'string') {
|
|
31
|
+
end();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
active++;
|
|
35
|
+
void handle(request).then(result => report({ id: request.id, ...result }), error => report({ id: request.id, error: error instanceof Error ? error.message : 'Runtime operation failed.' }))
|
|
36
|
+
.finally(() => { active--; });
|
|
37
|
+
});
|
|
38
|
+
input.once('close', end);
|
|
39
|
+
control.once('error', end);
|
|
40
|
+
process.stdout.on('error', end);
|
|
41
|
+
return report;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/runtime-electron/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,MAAqD,EAAE,GAAe;IACpG,MAAM,MAAM,GAAW,KAAK,CAAC,EAAE;QAC7B,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;YAAC,GAAG,EAAE,CAAC;YAAC,OAAO;QAAC,CAAC;QACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,2EAA2E;IAC3E,mEAAmE;IACnE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,IAA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,EAAE,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Session, type WebContents } from 'electron';
|
|
2
|
+
import type { DesktopWindowOptions, DesktopWindowSnapshot } from '../host/window-protocol.js';
|
|
3
|
+
/** Only the desktop UI uses this partition; website cookies never enter it. */
|
|
4
|
+
export declare function uiProfile(input: DesktopWindowOptions, owner: string): {
|
|
5
|
+
store: Session;
|
|
6
|
+
marker?: string;
|
|
7
|
+
};
|
|
8
|
+
/** One profile has one initial adoption even when several windows open together. */
|
|
9
|
+
export declare function withUiProfile<T>(input: DesktopWindowOptions, owner: string, operation: (profile: {
|
|
10
|
+
store: Session;
|
|
11
|
+
marker?: string;
|
|
12
|
+
}) => Promise<T>): Promise<T>;
|
|
13
|
+
export declare function setUiCookies(store: Session, origin: string, cookies: NonNullable<DesktopWindowOptions['cookies']>, replace?: boolean): Promise<void>;
|
|
14
|
+
export declare function seedUiStorage(contents: WebContents, input: DesktopWindowOptions, marker: string | undefined): Promise<() => Promise<void>>;
|
|
15
|
+
export declare function uiSnapshot(contents: WebContents, origin: string): Promise<DesktopWindowSnapshot>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { app, session } from 'electron';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
/** Only the desktop UI uses this partition; website cookies never enter it. */
|
|
6
|
+
export function uiProfile(input, owner) {
|
|
7
|
+
if (!input.profile)
|
|
8
|
+
return { store: session.fromPartition(`amalgm-ui:${owner}`) };
|
|
9
|
+
if (!/^[a-f0-9]{64}$/.test(input.profile))
|
|
10
|
+
throw new Error('Invalid desktop profile identity.');
|
|
11
|
+
const directory = path.join(app.getPath('userData'), 'desktop-ui', input.profile);
|
|
12
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
13
|
+
return { store: session.fromPath(directory), marker: path.join(directory, 'amalgm-ui-adopted.json') };
|
|
14
|
+
}
|
|
15
|
+
const adoptions = new Map();
|
|
16
|
+
const handoffId = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
17
|
+
/** One profile has one initial adoption even when several windows open together. */
|
|
18
|
+
export async function withUiProfile(input, owner, operation) {
|
|
19
|
+
const profile = uiProfile(input, owner), key = profile.marker ?? owner;
|
|
20
|
+
const previous = adoptions.get(key) ?? Promise.resolve();
|
|
21
|
+
let release;
|
|
22
|
+
const waiting = new Promise(resolve => { release = resolve; });
|
|
23
|
+
adoptions.set(key, waiting);
|
|
24
|
+
await previous;
|
|
25
|
+
try {
|
|
26
|
+
const seed = !profile.marker || !fs.existsSync(profile.marker);
|
|
27
|
+
const origin = new URL(input.url).origin;
|
|
28
|
+
let receipt = { version: 1, origin };
|
|
29
|
+
if (!seed) {
|
|
30
|
+
receipt = JSON.parse(fs.readFileSync(profile.marker, 'utf8'));
|
|
31
|
+
if (receipt.version !== 1 || receipt.origin !== origin || receipt.cookieHandoffs !== undefined
|
|
32
|
+
&& (!Array.isArray(receipt.cookieHandoffs) || receipt.cookieHandoffs.some(id => typeof id !== 'string' || !handoffId.test(id)))) {
|
|
33
|
+
throw new Error('The desktop profile adoption receipt does not match this application.');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (input.cookieHandoff && (!handoffId.test(input.cookieHandoff) || !profile.marker || !input.cookies)) {
|
|
37
|
+
throw new Error('A cookie handoff requires a persistent application profile and cookie snapshot.');
|
|
38
|
+
}
|
|
39
|
+
const handoff = input.cookieHandoff && !receipt.cookieHandoffs?.includes(input.cookieHandoff);
|
|
40
|
+
if (input.cookies && (seed || handoff)) {
|
|
41
|
+
await setUiCookies(profile.store, origin, input.cookies, true);
|
|
42
|
+
if (!seed && handoff)
|
|
43
|
+
writeReceipt(profile.marker, { ...receipt,
|
|
44
|
+
cookieHandoffs: [...(receipt.cookieHandoffs ?? []), input.cookieHandoff] });
|
|
45
|
+
}
|
|
46
|
+
return await operation(profile);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
release();
|
|
50
|
+
if (adoptions.get(key) === waiting)
|
|
51
|
+
adoptions.delete(key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function setUiCookies(store, origin, cookies, replace = false) {
|
|
55
|
+
if (cookies.some(cookie => new URL(cookie.url).origin !== origin))
|
|
56
|
+
throw new Error('An application cookie belongs to another origin.');
|
|
57
|
+
if (replace)
|
|
58
|
+
await store.clearStorageData({ storages: ['cookies'] });
|
|
59
|
+
for (const cookie of cookies)
|
|
60
|
+
await store.cookies.set(cookie);
|
|
61
|
+
await store.cookies.flushStore();
|
|
62
|
+
}
|
|
63
|
+
export async function seedUiStorage(contents, input, marker) {
|
|
64
|
+
if (marker && fs.existsSync(marker))
|
|
65
|
+
return async () => { };
|
|
66
|
+
let script;
|
|
67
|
+
if (input.storage && Object.keys(input.storage).length) {
|
|
68
|
+
if (Object.values(input.storage).some(value => typeof value !== 'string'))
|
|
69
|
+
throw new Error('Invalid application storage.');
|
|
70
|
+
// Renderer-scoped CDP commands need a live initial document.
|
|
71
|
+
await contents.loadURL('about:blank');
|
|
72
|
+
contents.debugger.attach('1.3');
|
|
73
|
+
await contents.debugger.sendCommand('Page.enable');
|
|
74
|
+
const value = await contents.debugger.sendCommand('Page.addScriptToEvaluateOnNewDocument', {
|
|
75
|
+
source: `if(location.origin===${JSON.stringify(new URL(input.url).origin)}){for(const [k,v] of Object.entries(${JSON.stringify(input.storage)}))localStorage.setItem(k,v)}`,
|
|
76
|
+
});
|
|
77
|
+
script = value.identifier;
|
|
78
|
+
}
|
|
79
|
+
return async () => {
|
|
80
|
+
if (script && !contents.isDestroyed()) {
|
|
81
|
+
await contents.debugger.sendCommand('Page.removeScriptToEvaluateOnNewDocument', { identifier: script });
|
|
82
|
+
contents.debugger.detach();
|
|
83
|
+
}
|
|
84
|
+
contents.session.flushStorageData();
|
|
85
|
+
await contents.session.cookies.flushStore();
|
|
86
|
+
if (marker)
|
|
87
|
+
writeReceipt(marker, { version: 1, origin: new URL(input.url).origin,
|
|
88
|
+
...(input.cookieHandoff ? { cookieHandoffs: [input.cookieHandoff] } : {}) });
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function writeReceipt(marker, receipt) {
|
|
92
|
+
const temporary = `${marker}.${randomUUID()}.tmp`;
|
|
93
|
+
try {
|
|
94
|
+
const file = fs.openSync(temporary, 'wx', 0o600);
|
|
95
|
+
try {
|
|
96
|
+
fs.writeFileSync(file, JSON.stringify(receipt) + '\n');
|
|
97
|
+
fs.fsyncSync(file);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
fs.closeSync(file);
|
|
101
|
+
}
|
|
102
|
+
fs.renameSync(temporary, marker);
|
|
103
|
+
if (process.platform !== 'win32') {
|
|
104
|
+
const directory = fs.openSync(path.dirname(marker), 'r');
|
|
105
|
+
try {
|
|
106
|
+
fs.fsyncSync(directory);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
fs.closeSync(directory);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
fs.rmSync(temporary, { force: true });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export async function uiSnapshot(contents, origin) {
|
|
118
|
+
await contents.session.cookies.flushStore();
|
|
119
|
+
contents.session.flushStorageData();
|
|
120
|
+
const cookies = await contents.session.cookies.get({ url: origin });
|
|
121
|
+
return {
|
|
122
|
+
cookies: cookies.map(cookie => ({ url: origin + (cookie.path ?? '/'), name: cookie.name, value: cookie.value,
|
|
123
|
+
path: cookie.path ?? '/', httpOnly: cookie.httpOnly === true, secure: cookie.secure === true, sameSite: cookie.sameSite,
|
|
124
|
+
...(cookie.expirationDate ? { expirationDate: cookie.expirationDate } : {}) })),
|
|
125
|
+
storage: await contents.executeJavaScript('Object.fromEntries(Object.entries(localStorage))'),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=ui-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-profile.js","sourceRoot":"","sources":["../../../src/runtime-electron/ui-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAkC,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,+EAA+E;AAC/E,MAAM,UAAU,SAAS,CAAC,KAA2B,EAAE,KAAa;IAClE,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,EAAE,CAAC,EAAE,CAAC;IAClF,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAChG,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClF,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,EAAE,CAAC;AACxG,CAA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C,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK;YAC1G,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACvH,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACjF,OAAO,EAAE,MAAM,QAAQ,CAAC,iBAAiB,CAAC,kDAAkD,CAA2B;KACxH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NativeProcess } from '../native/process.js';
|
|
2
|
+
import type { RuntimeDesktopWindows } from '../host/window-protocol.js';
|
|
3
|
+
/** The authenticated connection supplies ownership, never a caller-controlled window id alone. */
|
|
4
|
+
export declare function electronWindowControl(process: NativeProcess): RuntimeDesktopWindows;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The authenticated connection supplies ownership, never a caller-controlled window id alone. */
|
|
2
|
+
export function electronWindowControl(process) {
|
|
3
|
+
return {
|
|
4
|
+
async request(owner, command) {
|
|
5
|
+
if (command.action === 'open') {
|
|
6
|
+
const address = new URL(command.link.url);
|
|
7
|
+
if (address.protocol !== 'ws:' || !['127.0.0.1', 'localhost', '[::1]'].includes(address.hostname))
|
|
8
|
+
throw new Error('Desktop windows require a local runtime connection.');
|
|
9
|
+
await process.request('window-setup', { accountId: command.accountId, isDev: command.isDev, link: command.link });
|
|
10
|
+
const reply = await process.request('window-open', { options: { ...command.options, owner, clientId: command.clientId } });
|
|
11
|
+
return reply.result;
|
|
12
|
+
}
|
|
13
|
+
if (command.action === 'control') {
|
|
14
|
+
await process.request('window-control', { owner, windowId: command.windowId, command: command.command, value: command.value });
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
if (command.action === 'reply') {
|
|
18
|
+
await process.request('window-reply', { owner, requestId: command.requestId, value: command.value, error: command.error });
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
if (command.action === 'snapshot' || command.action === 'cookies' || command.action === 'account') {
|
|
22
|
+
const reply = await process.request(`window-${command.action}`, { ...command, owner });
|
|
23
|
+
return reply.result;
|
|
24
|
+
}
|
|
25
|
+
throw new Error('Unknown desktop window operation.');
|
|
26
|
+
},
|
|
27
|
+
async release(owner) { await process.request('window-disconnect', { owner }).catch(() => undefined); },
|
|
28
|
+
subscribe(owner, changed) {
|
|
29
|
+
let active = true;
|
|
30
|
+
void process.exited.then(() => { if (active)
|
|
31
|
+
changed({ event: 'window', payload: { type: 'owner-lost' } }); });
|
|
32
|
+
const stop = process.onReport(report => {
|
|
33
|
+
if ((report.event === 'window' || report.event === 'window-ipc') && report.payload?.owner === owner)
|
|
34
|
+
changed(report);
|
|
35
|
+
});
|
|
36
|
+
return () => { active = false; stop(); };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=window-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-control.js","sourceRoot":"","sources":["../../../src/runtime-electron/window-control.ts"],"names":[],"mappings":"AAGA,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC1D,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;YAC1B,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC9B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC1C,IAAI,O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ron';
|
|
2
|
+
import type { Report } from './protocol.js';
|
|
3
|
+
import type { DesktopWindowOptions, DesktopWindowSnapshot } from '../host/window-protocol.js';
|
|
4
|
+
export interface RuntimeWindowOptions extends DesktopWindowOptions {
|
|
5
|
+
owner: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
}
|
|
8
|
+
/** UI renderers may disappear independently; the page registry never belongs to this class. */
|
|
9
|
+
export declare class ElectronWindows {
|
|
10
|
+
private readonly report;
|
|
11
|
+
private readonly detach;
|
|
12
|
+
private readonly windows;
|
|
13
|
+
private readonly requests;
|
|
14
|
+
private readonly channels;
|
|
15
|
+
private readonly events;
|
|
16
|
+
private readonly inactive;
|
|
17
|
+
constructor(report: Report, detach: (window: BrowserWindow) => void);
|
|
18
|
+
trusted(url: string, contentsId?: number): boolean;
|
|
19
|
+
open(input: RuntimeWindowOptions): Promise<number>;
|
|
20
|
+
setActive(owner: string, active: boolean): BrowserWindow[];
|
|
21
|
+
snapshot(owner: string, id: number): Promise<DesktopWindowSnapshot>;
|
|
22
|
+
cookies(owner: string, id: number, cookies: NonNullable<DesktopWindowOptions['cookies']>): Promise<void>;
|
|
23
|
+
private owned;
|
|
24
|
+
control(owner: string, id: number, command: string, value?: unknown): void;
|
|
25
|
+
reply(owner: string, id: string, value: unknown, error?: string): void;
|
|
26
|
+
close(owner?: string): void;
|
|
27
|
+
private register;
|
|
28
|
+
}
|