@pi-chamber/web 1.0.5-rc.4 → 1.0.6-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DiagramView-CiAfS52a.js → DiagramView-DUxXEKjQ.js} +1 -1
- package/dist/assets/DiffView-DEd3rdnu.js +18 -0
- package/dist/assets/FileSaveConflictDialog-C6o4fYIn.js +3 -0
- package/dist/assets/{FilesView-DAEtByHZ.js → FilesView-Ccl4CxjR.js} +3 -3
- package/dist/assets/{GitHubDetailScaffold-CtFeWl_3.js → GitHubDetailScaffold-DlgVm5uD.js} +3 -3
- package/dist/assets/{GitHubLinkPicker-BEB6WkNO.js → GitHubLinkPicker-BgDZR-3K.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-BilsEUSt.js → GitHubListPrimitives-BTeI3B3C.js} +1 -1
- package/dist/assets/{GitView-C19-aC7A.js → GitView-BkrH0HFQ.js} +4 -4
- package/dist/assets/{IssuesSurface-zvICpciG.js → IssuesSurface-CD1m8BHP.js} +3 -3
- package/dist/assets/{JsonTreeView-D99tzKTq.js → JsonTreeView-RLgBKik9.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CRfobHRu.js → MarkdownRendererImpl-BkfhE9NN.js} +2 -2
- package/dist/assets/{PatchDiff-Fbf3Mt_o.js → PatchDiff-BLNLrGYa.js} +1 -1
- package/dist/assets/{PierreDiffViewer-C2nEOax_.js → PierreDiffViewer-iLnLAFeL.js} +3 -3
- package/dist/assets/PullRequestsSurface-_kgJMFTh.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DByH7H41.js → SessionSwitcherContent-BCOUKRch.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CA64t2xd.js +2 -0
- package/dist/assets/SessionUnreadDot-BZy2DM6H.js +1 -0
- package/dist/assets/SettingsView-TwUy1kXV.js +6 -0
- package/dist/assets/{SettingsWindow-B1_mMQyb.js → SettingsWindow-BXE4JP-T.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-BMITjK4e.js → StickyHorizontalScrollbar-p7EbL2-E.js} +2 -2
- package/dist/assets/{ToolOutputDialog-BO3d88qF.js → ToolOutputDialog-tiXT-Xts.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-BgbLfmmd.js → ToolPartDiffPreview-CylbiIKd.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-D7kxYBDG.js → VirtualizedFileDiff-Cccy1L8L.js} +4 -4
- package/dist/assets/{Virtualizer-DP6HbEeC.js → Virtualizer-DNJrJKVb.js} +1 -1
- package/dist/assets/{appThemeRegistry-gegrE2dq.js → appThemeRegistry-Ca8eGRB9.js} +1 -1
- package/dist/assets/{collapsible-9MJx4VhA.js → collapsible-0yfy07W2.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-8pZIB8G2.js → computeVirtualFileMetrics-ydVGT2RY.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-BNtzRA7B.js → contextFileOpenGuard--7BLkncT.js} +1 -1
- package/dist/assets/{document-attachments-BslE4Ns7.js → document-attachments-CZl9rK1z.js} +5 -5
- package/dist/assets/{gitStatusPredicates-B7adeDSu.js → gitStatusPredicates-BzR54iPh.js} +1 -1
- package/dist/assets/{githubLink-DVRaj2ms.js → githubLink-WO5BkC0U.js} +5 -5
- package/dist/assets/{index-D4n3TVp2.js → index-C2ISrmRR.js} +10 -10
- package/dist/assets/index-DgwThEwf.css +1 -0
- package/dist/assets/index-nOAE6UDy.js +1 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-B4UP1bOp.js +2 -0
- package/dist/assets/main-DxYfmK5D.js +137 -0
- package/dist/assets/{markdown-shiki.worker-DnvH1S1x.js → markdown-shiki.worker-BVA5NZBT.js} +5 -5
- package/dist/assets/markdownCore-DIn2dwA6.js +2 -0
- package/dist/assets/miniChat-CMGH4R_p.js +2 -0
- package/dist/assets/mobile-BJz0lBjK.js +2 -0
- package/dist/assets/{nativeFileSave-BJsGPh58.js → nativeFileSave-Bhafll_7.js} +1 -1
- package/dist/assets/nsis-LY0VT_u5.js +1 -0
- package/dist/assets/permissionStore-zIpxq9Pq.js +1 -0
- package/dist/assets/pi-session-focus-preference-D6vrJGbH.js +9 -0
- package/dist/assets/{registerCustomTheme-DmolaWWZ.js → registerCustomTheme-C-h6lsYW.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-BamhejwM.js → renderDiffWithHighlighter-JwKOWdBN.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-DYdkuv5N.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CFlqKZg7.js → renderFileWithHighlighter-RJTrDxFH.js} +1 -1
- package/dist/assets/renderMobileApp-x1P9U65-.js +11 -0
- package/dist/assets/ruby-BK5aLJev.js +1 -0
- package/dist/assets/runtimeEndpointReset-OqTh3bbO.js +62 -0
- package/dist/assets/runtimeSurface-CJN1oo_1.js +1 -0
- package/dist/assets/themeResolver-DrfmQi8i.js +1 -0
- package/dist/assets/useAppFontEffects-CHnpTOtc.js +215 -0
- package/dist/assets/useFilesViewSearch-DeVixiGZ.js +7 -0
- package/dist/assets/{useGitHubRemoteSearch-BoCzq4zs.js → useGitHubRemoteSearch-GjQca1iD.js} +1 -1
- package/dist/assets/{useSwitcherItems-C8IKoSTL.js → useSwitcherItems-DYtnl0T2.js} +1 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js +1 -0
- package/dist/assets/vendor-base-ui-C7vVMZTg.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-DApbjBp2.js → vendor-beautiful-mermaid-b48gT2g0.js} +1 -1
- package/dist/assets/vendor-boot-CoTxysn6.js +65 -0
- package/dist/assets/{vendor-capacitor-app-BaupizkW.js → vendor-capacitor-app-NX6DULfp.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-9BVxykO7.js → vendor-capacitor-keyboard-DJD81I9f.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-BsrUwiaA.js → vendor-capacitor-status-bar-DV24OoQV.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-qsuH4Dh-.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-ZHWyBf7j.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-pCTOmv-k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-2bFuyM70.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-Crwca_X7.js → vendor-codemirror-lang-go-DrG_c7D7.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-BV8lrR8v.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-DrsvH6T2.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-Dkzl3s07.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-8Nn3bnoP.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-CsdmtHhi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-DJuZ4cZe.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-D2RO-Pzr.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-C0Zu3b3n.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-CuDtt2Zj.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-Cv2exx_M.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-C4TxJ6Rg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BmtPz8kf.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-B0f-qCZo.js → vendor-codemirror-lang-sql-BF1ZaXqJ.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-DZgXrP2k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-DsnaGtL_.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-D8DzzFat.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-D5hBv7m6.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-CqU7kHmg.js → vendor-codemirror-language-data-vn2RyN9T.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BVCYIV0D.js +2 -0
- package/dist/assets/vendor-dompurify-BGCr_sdL.js +3 -0
- package/dist/assets/vendor-elkjs-D1S1RCAO.js +24 -0
- package/dist/assets/vendor-fuse.js-t_7AcMTv.js +1 -0
- package/dist/assets/{vendor-hast-util-to-html-BKBhbTDb.js → vendor-hast-util-to-html-O3stl53j.js} +1 -1
- package/dist/assets/{vendor-heic2any-pq-UTQQR.js → vendor-heic2any-sztndhZI.js} +1 -1
- package/dist/assets/vendor-lezer-cpp-vqXSn3lv.js +1 -0
- package/dist/assets/vendor-lezer-css-JnEzSyZR.js +1 -0
- package/dist/assets/{vendor-lezer-go-CHIhCNY6.js → vendor-lezer-go-dD2gQMIL.js} +1 -1
- package/dist/assets/{vendor-lezer-html-B3h0MOrG.js → vendor-lezer-html-Cr3U-1pu.js} +1 -1
- package/dist/assets/vendor-lezer-java-CRM0IMCo.js +1 -0
- package/dist/assets/vendor-lezer-javascript-B3s21DIS.js +1 -0
- package/dist/assets/{vendor-lezer-json-BP_UAzLL.js → vendor-lezer-json-DPFM6EBV.js} +1 -1
- package/dist/assets/vendor-lezer-lr-Bllrq8hY.js +1 -0
- package/dist/assets/vendor-lezer-markdown-6-3PLvXG.js +6 -0
- package/dist/assets/vendor-lezer-php-DOyzfHRl.js +1 -0
- package/dist/assets/{vendor-lezer-python-EJ4Im4y2.js → vendor-lezer-python-CdHdN5qt.js} +1 -1
- package/dist/assets/vendor-lezer-rust-CqnW8EMH.js +1 -0
- package/dist/assets/{vendor-lezer-sass-CMi6zfXI.js → vendor-lezer-sass-BbcF4y6A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-0MHMeZDp.js → vendor-lezer-xml-C31AyWoo.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BE2EFjpA.js → vendor-lezer-yaml-Cv908yC2.js} +1 -1
- package/dist/assets/{vendor-lru_map-DOPmc7GU.js → vendor-lru_map-BbiDqlyL.js} +1 -1
- package/dist/assets/vendor-marked-Be78pDn1.js +59 -0
- package/dist/assets/{vendor-oniguruma-parser-C0D4_9rT.js → vendor-oniguruma-parser-BrbMHgHx.js} +1 -1
- package/dist/assets/vendor-oniguruma-to-es-DgwFOwdE.js +94 -0
- package/dist/assets/{vendor-pierre-theming-Dgp7B_O4.js → vendor-pierre-theming-BO6EPniU.js} +1 -1
- package/dist/assets/vendor-property-information-C40bX6nM.js +1 -0
- package/dist/assets/{vendor-qrcode-Dv4uniC1.js → vendor-qrcode-gzL9QFkg.js} +5 -5
- package/dist/assets/vendor-react-Bz1tRBxM.js +1 -0
- package/dist/assets/{vendor-react-drawio-Duu5LgQA.js → vendor-react-drawio-IYnLUY5N.js} +1 -1
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/vendor-replit-codemirror-vim-Cwhyn_5f.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-shiki-BEwTOAFg.js +1 -0
- package/dist/assets/{vendor-shikijs-core-CGM_jqPK.js → vendor-shikijs-core-Ck_OPM_T.js} +1 -1
- package/dist/assets/{vendor-shikijs-engine-javascript-Cme4830A.js → vendor-shikijs-engine-javascript-DL394yyj.js} +1 -1
- package/dist/assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js +3 -0
- package/dist/assets/vendor-tailwind-merge-BKkUfl9q.js +1 -0
- package/dist/assets/vendor-workbox-window-BBnX5xw4.js +2 -0
- package/dist/assets/vendor-zumer-snapdom-SJzqoCHV.js +8 -0
- package/dist/assets/vendor-zustand-CXhN0IMY.js +6 -0
- package/dist/assets/{web-components-DTteDmIQ.js → web-components-CIPJC1JE.js} +1 -1
- package/dist/assets/worker-CKCfxIfO.js +153 -0
- package/dist/assets/workerFactory-DlGfNFqf.js +1 -0
- package/dist/assets/zig-BB16gwVL.js +1 -0
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +7 -7
- package/package.json +54 -53
- package/server/index.js +18 -1
- package/server/lib/client-auth/live-revocation.test.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -0
- package/server/lib/fs/project-icon.js +243 -0
- package/server/lib/fs/project-icon.test.js +114 -0
- package/server/lib/fs/routes.js +35 -0
- package/server/lib/fs/routes.test.js +74 -0
- package/server/lib/git/DOCUMENTATION.md +2 -1
- package/server/lib/git/routes.js +11 -3
- package/server/lib/git/routes.test.js +80 -0
- package/server/lib/git/service.js +38 -3
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/open-url/DOCUMENTATION.md +35 -0
- package/server/lib/open-url/browser-env.js +199 -0
- package/server/lib/open-url/browser-env.test.js +147 -0
- package/server/lib/open-url/browser-handler.mjs +154 -0
- package/server/lib/open-url/browser-handler.test.js +69 -0
- package/server/lib/open-url/intake.js +187 -0
- package/server/lib/open-url/intake.test.js +75 -0
- package/server/lib/pi/extension-protocol.js +149 -0
- package/server/lib/pi/extension-protocol.test.js +20 -1
- package/server/lib/pi/routes.js +195 -1
- package/server/lib/pi/routes.test.js +129 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +38 -10
- package/server/lib/pi/session-daemon/builtin-extensions.js +14 -4
- package/server/lib/pi/session-daemon/daemon-process.js +13 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +6 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +40 -6
- package/server/lib/pi/session-daemon/extension-custom-host.js +1259 -0
- package/server/lib/pi/session-daemon/extension-custom-host.test.js +759 -0
- package/server/lib/pi/session-daemon/extension-keybindings.js +21 -0
- package/server/lib/pi/session-daemon/extension-keybindings.test.js +37 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +7 -4
- package/server/lib/pi/session-daemon/extension-message-render.test.js +14 -2
- package/server/lib/pi/session-daemon/extension-tool-render.js +7 -0
- package/server/lib/pi/session-daemon/extension-tool-render.test.js +26 -0
- package/server/lib/pi/session-daemon/open-request.js +60 -0
- package/server/lib/pi/session-daemon/open-request.test.js +54 -0
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +134 -0
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +21 -4
- package/server/lib/pi/session-daemon/session-daemon-bash.e2e.test.js +225 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.e2e.test.js +156 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.test.js +381 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +11 -2
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +30 -4
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +20 -0
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +16 -4
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +7 -2
- package/server/lib/pi/session-daemon/session-daemon.js +448 -49
- package/server/lib/pi/session-daemon/session-daemon.test.js +91 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +9 -3
- package/server/lib/pi/session-daemon/session-engine-router.test.js +12 -2
- package/server/lib/pi/session-daemon/session-engines.js +7 -2
- package/server/lib/pi/session-daemon/session-jsonl.js +170 -75
- package/server/lib/pi/session-daemon/session-jsonl.test.js +106 -2
- package/server/lib/pi/session-daemon/supervisor.js +4 -0
- package/server/lib/pi/session-daemon/user-bash.js +326 -0
- package/server/lib/pi/session-daemon/user-bash.test.js +371 -0
- package/server/lib/preview/proxy-runtime.js +140 -45
- package/server/lib/preview/proxy-runtime.test.js +174 -3
- package/server/lib/preview/proxy-runtime.websocket.test.js +89 -0
- package/server/lib/relay/tunnel-host.js +1 -0
- package/server/lib/security/request-security.js +37 -0
- package/server/lib/security/request-security.test.js +54 -0
- package/server/lib/security/server-network-host.js +107 -0
- package/server/lib/security/server-network-host.test.js +70 -0
- package/server/lib/server-browser/DOCUMENTATION.md +243 -0
- package/server/lib/server-browser/browser-tab.js +524 -0
- package/server/lib/server-browser/chrome-executable.js +138 -0
- package/server/lib/server-browser/chrome-launch.js +138 -0
- package/server/lib/server-browser/dev-servers.js +288 -0
- package/server/lib/server-browser/dev-servers.test.js +152 -0
- package/server/lib/server-browser/downloads.js +75 -0
- package/server/lib/server-browser/frame-policy.js +183 -0
- package/server/lib/server-browser/frame-policy.test.js +98 -0
- package/server/lib/server-browser/network-guard.js +235 -0
- package/server/lib/server-browser/page-scripts.js +209 -0
- package/server/lib/server-browser/runtime.integration.test.js +474 -0
- package/server/lib/server-browser/runtime.js +300 -0
- package/server/lib/server-browser/runtime.test.js +50 -0
- package/server/lib/server-browser/server-browser.js +431 -0
- package/server/lib/server-browser/server-browser.test.js +975 -0
- package/server/lib/server-browser/tab-input.js +241 -0
- package/server/lib/server-browser/tab-prompts.js +125 -0
- package/server/lib/server-browser/tab-stream.js +252 -0
- package/server/lib/server-browser/uploads.js +98 -0
- package/server/lib/stt/runtime.js +4 -1
- package/server/lib/stt/runtime.test.js +43 -0
- package/server/lib/terminal/runtime.js +4 -1
- package/server/lib/terminal/runtime.test.js +41 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +29 -1
- package/server/lib/ui-auth/ui-auth.js +1 -0
- package/server/lib/ui-auth/ui-auth.test.js +9 -1
- package/server/lib/workspace/host.js +20 -3
- package/dist/assets/DiffView-CEAAlJ4b.js +0 -18
- package/dist/assets/FileSaveConflictDialog-yvhJRLj7.js +0 -3
- package/dist/assets/PullRequestsSurface-DMWgrwmP.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-D-kE5IJ_.js +0 -2
- package/dist/assets/SessionUnreadDot-DNbvtMOd.js +0 -1
- package/dist/assets/SettingsView-BhXkRsZT.js +0 -6
- package/dist/assets/abap-BdImnpbu.js +0 -1
- package/dist/assets/actionscript-3-CoDkCxhg.js +0 -1
- package/dist/assets/ada-bCR0ucgS.js +0 -1
- package/dist/assets/angular-html-CU67Zn6k.js +0 -1
- package/dist/assets/angular-ts-BwZT4LLn.js +0 -1
- package/dist/assets/apache-Pmp26Uib.js +0 -1
- package/dist/assets/apex-D8_7TLub.js +0 -1
- package/dist/assets/apl-dKokRX4l.js +0 -1
- package/dist/assets/applescript-Co6uUVPk.js +0 -1
- package/dist/assets/ara-BRHolxvo.js +0 -1
- package/dist/assets/asciidoc-Ve4PFQV2.js +0 -1
- package/dist/assets/asm-D_Q5rh1f.js +0 -1
- package/dist/assets/astro-CbQHKStN.js +0 -1
- package/dist/assets/awk-DMzUqQB5.js +0 -1
- package/dist/assets/ballerina-BFfxhgS-.js +0 -1
- package/dist/assets/bat-BkioyH1T.js +0 -1
- package/dist/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/assets/berry-uYugtg8r.js +0 -1
- package/dist/assets/bibtex-CHM0blh-.js +0 -1
- package/dist/assets/bicep-Bmn6On1c.js +0 -1
- package/dist/assets/bird2-DPOp833l.js +0 -1
- package/dist/assets/blade-D4QpJJKB.js +0 -1
- package/dist/assets/bsl-BO_Y6i37.js +0 -1
- package/dist/assets/c-BIGW1oBm.js +0 -1
- package/dist/assets/c3-eo99z4R2.js +0 -1
- package/dist/assets/cadence-Bv_4Rxtq.js +0 -1
- package/dist/assets/cairo-KRGpt6FW.js +0 -1
- package/dist/assets/clarity-D53aC0YG.js +0 -1
- package/dist/assets/clojure-P80f7IUj.js +0 -1
- package/dist/assets/cmake-D1j8_8rp.js +0 -1
- package/dist/assets/cobol-nwyudZeR.js +0 -1
- package/dist/assets/codeowners-Bp6g37R7.js +0 -1
- package/dist/assets/codeql-DsOJ9woJ.js +0 -1
- package/dist/assets/coffee-Ch7k5sss.js +0 -1
- package/dist/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/dist/assets/coq-DkFqJrB1.js +0 -1
- package/dist/assets/cpp-CofmeUqb.js +0 -1
- package/dist/assets/crystal-tKQVLTB8.js +0 -1
- package/dist/assets/csharp-COcwbKMJ.js +0 -1
- package/dist/assets/css-DPfMkruS.js +0 -1
- package/dist/assets/csv-fuZLfV_i.js +0 -1
- package/dist/assets/cue-D82EKSYY.js +0 -1
- package/dist/assets/cypher-COkxafJQ.js +0 -1
- package/dist/assets/d-85-TOEBH.js +0 -1
- package/dist/assets/dart-CF10PKvl.js +0 -1
- package/dist/assets/dax-CEL-wOlO.js +0 -1
- package/dist/assets/desktop-BmXAJ9_W.js +0 -1
- package/dist/assets/diff-D97Zzqfu.js +0 -1
- package/dist/assets/docker-BcOcwvcX.js +0 -1
- package/dist/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/assets/dream-maker-BtqSS_iP.js +0 -1
- package/dist/assets/edge-BkV0erSs.js +0 -1
- package/dist/assets/elixir-CDX3lj18.js +0 -1
- package/dist/assets/elm-DbKCFpqz.js +0 -1
- package/dist/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/dist/assets/erb-B12qg9BL.js +0 -1
- package/dist/assets/erlang-DsQrWhSR.js +0 -1
- package/dist/assets/fennel-BYunw83y.js +0 -1
- package/dist/assets/fish-BvzEVeQv.js +0 -1
- package/dist/assets/fluent-C4IJs8-o.js +0 -1
- package/dist/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/dist/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/dist/assets/fsharp-CXgrBDvD.js +0 -1
- package/dist/assets/gdresource-BOOCDP_w.js +0 -1
- package/dist/assets/gdscript-C5YyOfLZ.js +0 -1
- package/dist/assets/gdshader-DkwncUOv.js +0 -1
- package/dist/assets/genie-D0YGMca9.js +0 -1
- package/dist/assets/gherkin-DyxjwDmM.js +0 -1
- package/dist/assets/git-commit-F4YmCXRG.js +0 -1
- package/dist/assets/git-rebase-r7XF79zn.js +0 -1
- package/dist/assets/gleam-BspZqrRM.js +0 -1
- package/dist/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/dist/assets/glimmer-ts-U6CK756n.js +0 -1
- package/dist/assets/glsl-DplSGwfg.js +0 -1
- package/dist/assets/gn-n2N0HUVH.js +0 -1
- package/dist/assets/gnuplot-DdkO51Og.js +0 -1
- package/dist/assets/go-CxLEBnE3.js +0 -1
- package/dist/assets/graphql-ChdNCCLP.js +0 -1
- package/dist/assets/groovy-gcz8RCvz.js +0 -1
- package/dist/assets/hack-CaT9iCJl.js +0 -1
- package/dist/assets/haml-B8DHNrY2.js +0 -1
- package/dist/assets/handlebars-BL8al0AC.js +0 -1
- package/dist/assets/haskell-Df6bDoY_.js +0 -1
- package/dist/assets/haxe-CzTSHFRz.js +0 -1
- package/dist/assets/hcl-BWvSN4gD.js +0 -1
- package/dist/assets/hjson-D5-asLiD.js +0 -1
- package/dist/assets/hlsl-D3lLCCz7.js +0 -1
- package/dist/assets/html-GMplVEZG.js +0 -1
- package/dist/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/dist/assets/http-jrhK8wxY.js +0 -1
- package/dist/assets/hurl-irOxFIW8.js +0 -1
- package/dist/assets/hxml-Bvhsp5Yf.js +0 -1
- package/dist/assets/hy-DFXneXwc.js +0 -1
- package/dist/assets/imba-DGztddWO.js +0 -1
- package/dist/assets/index-B7HgGIB0.js +0 -1
- package/dist/assets/index-BwoW_-vk.css +0 -1
- package/dist/assets/ini-BEwlwnbL.js +0 -1
- package/dist/assets/java-CylS5w8V.js +0 -1
- package/dist/assets/javascript-wDzz0qaB.js +0 -1
- package/dist/assets/jinja-4LBKfQ-Z.js +0 -1
- package/dist/assets/jison-wvAkD_A8.js +0 -1
- package/dist/assets/json-Cp-IABpG.js +0 -1
- package/dist/assets/json5-C9tS-k6U.js +0 -1
- package/dist/assets/jsonc-Des-eS-w.js +0 -1
- package/dist/assets/jsonl-DcaNXYhu.js +0 -1
- package/dist/assets/jsonnet-DFQXde-d.js +0 -1
- package/dist/assets/jssm-C2t-YnRu.js +0 -1
- package/dist/assets/jsx-g9-lgVsj.js +0 -1
- package/dist/assets/julia-CxzCAyBv.js +0 -1
- package/dist/assets/just-Cw27pwNe.js +0 -1
- package/dist/assets/kdl-DV7GczEv.js +0 -1
- package/dist/assets/kotlin-BdnUsdx6.js +0 -1
- package/dist/assets/kusto-DZf3V79B.js +0 -1
- package/dist/assets/latex-CWtU0Tv5.js +0 -1
- package/dist/assets/lean-BZvkOJ9d.js +0 -1
- package/dist/assets/less-B1dDrJ26.js +0 -1
- package/dist/assets/liquid-DYVedYrR.js +0 -1
- package/dist/assets/llvm-DjAJT7YJ.js +0 -1
- package/dist/assets/log-2UxHyX5q.js +0 -1
- package/dist/assets/logo-BtOb2qkB.js +0 -1
- package/dist/assets/lua-BaeVxFsk.js +0 -1
- package/dist/assets/luau-C-HG3fhB.js +0 -1
- package/dist/assets/main-BWWBkkNK.js +0 -136
- package/dist/assets/main-C-nlfc4f.js +0 -2
- package/dist/assets/make-CHLpvVh8.js +0 -1
- package/dist/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/assets/markdownCore-B6YzRefV.js +0 -2
- package/dist/assets/marko-CnJfTvn9.js +0 -1
- package/dist/assets/matlab-D7o27uSR.js +0 -1
- package/dist/assets/mdc-BMNejdWA.js +0 -1
- package/dist/assets/mdx-Cmh6b_Ma.js +0 -1
- package/dist/assets/mermaid-mWjccvbQ.js +0 -1
- package/dist/assets/miniChat-b8DbqBHL.js +0 -2
- package/dist/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/assets/mobile-BDDUPrDt.js +0 -2
- package/dist/assets/mojo-rZm6bMo-.js +0 -1
- package/dist/assets/moonbit-_H4v1dQx.js +0 -1
- package/dist/assets/move-IF9eRakj.js +0 -1
- package/dist/assets/narrat-DRg8JJMk.js +0 -1
- package/dist/assets/nextflow-Zz6hmt5N.js +0 -1
- package/dist/assets/nextflow-groovy-BeH2EWoN.js +0 -1
- package/dist/assets/nginx-BpAMiNFr.js +0 -1
- package/dist/assets/nim-CVrawwO9.js +0 -1
- package/dist/assets/nix-CwoSXNpI.js +0 -1
- package/dist/assets/nsis-LdVXkNf5.js +0 -1
- package/dist/assets/nushell-Cz2AlsmD.js +0 -1
- package/dist/assets/objective-c-DXmwc3jG.js +0 -1
- package/dist/assets/objective-cpp-CLxacb5B.js +0 -1
- package/dist/assets/ocaml-C0hk2d4L.js +0 -1
- package/dist/assets/odin-BBf5iR-q.js +0 -1
- package/dist/assets/openscad-C4EeE6gA.js +0 -1
- package/dist/assets/pascal-D93ZcfNL.js +0 -1
- package/dist/assets/perl-C0TMdlhV.js +0 -1
- package/dist/assets/permissionStore-B9Hkrqny.js +0 -1
- package/dist/assets/php-Dhbhpdrm.js +0 -1
- package/dist/assets/pi-session-focus-preference-gLalTsQo.js +0 -9
- package/dist/assets/pkl-u5AG7uiY.js +0 -1
- package/dist/assets/plsql-ChMvpjG-.js +0 -1
- package/dist/assets/po-BTJTHyun.js +0 -1
- package/dist/assets/polar-C0HS_06l.js +0 -1
- package/dist/assets/postcss-CXtECtnM.js +0 -1
- package/dist/assets/powerquery-CEu0bR-o.js +0 -1
- package/dist/assets/powershell-Dpen1YoG.js +0 -1
- package/dist/assets/prisma-Dd19v3D-.js +0 -1
- package/dist/assets/prolog-CbFg5uaA.js +0 -1
- package/dist/assets/proto-C7zT0LnQ.js +0 -1
- package/dist/assets/pug-CGlum2m_.js +0 -1
- package/dist/assets/puppet-BMWR74SV.js +0 -1
- package/dist/assets/purescript-CklMAg4u.js +0 -1
- package/dist/assets/python-B6aJPvgy.js +0 -1
- package/dist/assets/qml-3beO22l8.js +0 -1
- package/dist/assets/qmldir-C8lEn-DE.js +0 -1
- package/dist/assets/qss-IeuSbFQv.js +0 -1
- package/dist/assets/r-Dspwwk_N.js +0 -1
- package/dist/assets/racket-BqYA7rlc.js +0 -1
- package/dist/assets/raku-DXvB9xmW.js +0 -1
- package/dist/assets/razor-Uh8Bk_45.js +0 -1
- package/dist/assets/reg-C-SQnVFl.js +0 -1
- package/dist/assets/regexp-CDVJQ6XC.js +0 -1
- package/dist/assets/rel-C3B-1QV4.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-CiWui-Wg.js +0 -2
- package/dist/assets/renderMobileApp-C27Xb0G7.js +0 -11
- package/dist/assets/riscv-BM1_JUlF.js +0 -1
- package/dist/assets/ron-D8l8udqQ.js +0 -1
- package/dist/assets/rosmsg-BJDFO7_C.js +0 -1
- package/dist/assets/rst-BrH8l1NY.js +0 -1
- package/dist/assets/ruby-B2Rjki9n.js +0 -1
- package/dist/assets/ruby-Dw2BHqvy.js +0 -1
- package/dist/assets/runtimeEndpointReset-O-OHpVl7.js +0 -62
- package/dist/assets/runtimeSurface-k1Eit61v.js +0 -1
- package/dist/assets/rust-B1yitclQ.js +0 -1
- package/dist/assets/sas-cz2c8ADy.js +0 -1
- package/dist/assets/sass-Cj5Yp3dK.js +0 -1
- package/dist/assets/scala-C151Ov-r.js +0 -1
- package/dist/assets/scheme-C98Dy4si.js +0 -1
- package/dist/assets/scss-OYdSNvt2.js +0 -1
- package/dist/assets/sdbl-DVxCFoDh.js +0 -1
- package/dist/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/dist/assets/shellscript-Yzrsuije.js +0 -1
- package/dist/assets/shellsession-BADoaaVG.js +0 -1
- package/dist/assets/smalltalk-BERRCDM3.js +0 -1
- package/dist/assets/solidity-rGO070M0.js +0 -1
- package/dist/assets/soy-Brmx7dQM.js +0 -1
- package/dist/assets/sparql-rVzFXLq3.js +0 -1
- package/dist/assets/splunk-BtCnVYZw.js +0 -1
- package/dist/assets/sql-BLtJtn59.js +0 -1
- package/dist/assets/ssh-config-_ykCGR6B.js +0 -1
- package/dist/assets/stata-BH5u7GGu.js +0 -1
- package/dist/assets/stylus-BEDo0Tqx.js +0 -1
- package/dist/assets/surrealql-Bq5Q-fJD.js +0 -1
- package/dist/assets/svelte-C_ipcX3V.js +0 -1
- package/dist/assets/swift-D82vCrfD.js +0 -1
- package/dist/assets/system-verilog-CnnmHF94.js +0 -1
- package/dist/assets/systemd-4A_iFExJ.js +0 -1
- package/dist/assets/talonscript-CkByrt1z.js +0 -1
- package/dist/assets/tasl-QIJgUcNo.js +0 -1
- package/dist/assets/tcl-dwOrl1Do.js +0 -1
- package/dist/assets/templ-P3uqSqPl.js +0 -1
- package/dist/assets/terraform-BETggiCN.js +0 -1
- package/dist/assets/tex-idrVyKtj.js +0 -1
- package/dist/assets/themeResolver-yJ9XpNMI.js +0 -1
- package/dist/assets/toml-vGWfd6FD.js +0 -1
- package/dist/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/dist/assets/tsv-B_m7g4N7.js +0 -1
- package/dist/assets/tsx-COt5Ahok.js +0 -1
- package/dist/assets/turtle-BsS91CYL.js +0 -1
- package/dist/assets/twig-DNn4PbVi.js +0 -1
- package/dist/assets/typescript-BPQ3VLAy.js +0 -1
- package/dist/assets/typespec-BGHnOYBU.js +0 -1
- package/dist/assets/typst-DHCkPAjA.js +0 -1
- package/dist/assets/useAppFontEffects-B6Bro-YP.js +0 -212
- package/dist/assets/useFilesViewSearch-jAAdikwo.js +0 -7
- package/dist/assets/v-BcVCzyr7.js +0 -1
- package/dist/assets/vala-CsfeWuGM.js +0 -1
- package/dist/assets/vb-D17OF-Vu.js +0 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js +0 -1
- package/dist/assets/vendor-base-ui-CKRUCG-f.js +0 -1
- package/dist/assets/vendor-boot-EC6IyLt1.js +0 -69
- package/dist/assets/vendor-codemirror-autocomplete-CGpAsPWp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-CDJoHJSY.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BmHofQls.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-RM2HqXZ0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-CHSHUpwq.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-lhQXgWu0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Dw4kFO4e.js +0 -13
- package/dist/assets/vendor-codemirror-lang-jinja-_pAC3UTN.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-B-b1vAv-.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-xIgOi1ze.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-CP49m5dB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BTht2ATe.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-BguZDhaO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-CH6_em9L.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-EG_DtGyi.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BknY5Qpo.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-CyGn9snv.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-CsFfSyyB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-Cdan_Jp1.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-COI5hck8.js +0 -1
- package/dist/assets/vendor-codemirror-search-DUfSCF9S.js +0 -2
- package/dist/assets/vendor-dompurify-r8glNMJW.js +0 -2
- package/dist/assets/vendor-elkjs-D27273Ms.js +0 -24
- package/dist/assets/vendor-fuse.js-Dw8P0qyA.js +0 -1
- package/dist/assets/vendor-lezer-cpp-DMZOJzBa.js +0 -1
- package/dist/assets/vendor-lezer-css-DUkkbMp7.js +0 -1
- package/dist/assets/vendor-lezer-java-tMazV_6X.js +0 -1
- package/dist/assets/vendor-lezer-javascript-ctwLWf4v.js +0 -1
- package/dist/assets/vendor-lezer-lr-B8TQctNw.js +0 -1
- package/dist/assets/vendor-lezer-markdown-aGLZf_3h.js +0 -6
- package/dist/assets/vendor-lezer-php-D5zCNzlt.js +0 -1
- package/dist/assets/vendor-lezer-rust-DO5c7OtA.js +0 -1
- package/dist/assets/vendor-marked-CX41MkDF.js +0 -59
- package/dist/assets/vendor-oniguruma-to-es-DLBnFDCE.js +0 -94
- package/dist/assets/vendor-property-information-rJCbAzvX.js +0 -1
- package/dist/assets/vendor-react-DASdDPIk.js +0 -1
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/vendor-replit-codemirror-vim-AnOuN8yJ.js +0 -39
- package/dist/assets/vendor-shiki-Bbf2GEcE.js +0 -2
- package/dist/assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js +0 -3
- package/dist/assets/vendor-tailwind-merge-CPcsbTWB.js +0 -1
- package/dist/assets/vendor-workbox-window-BIl4cyR9.js +0 -2
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
- package/dist/assets/vendor-zustand-CUi8eEds.js +0 -6
- package/dist/assets/verilog-BQ8w6xss.js +0 -1
- package/dist/assets/vhdl-CeAyd5Ju.js +0 -1
- package/dist/assets/viml-CJc9bBzg.js +0 -1
- package/dist/assets/vue-DN_0RTcg.js +0 -1
- package/dist/assets/vue-html-AaS7Mt5G.js +0 -1
- package/dist/assets/vue-vine-CQOfvN7w.js +0 -1
- package/dist/assets/vyper-CDx5xZoG.js +0 -1
- package/dist/assets/wasm-MzD3tlZU.js +0 -1
- package/dist/assets/wenyan-BV7otONQ.js +0 -1
- package/dist/assets/wgsl-Dx-B1_4e.js +0 -1
- package/dist/assets/wikitext-BhOHFoWU.js +0 -1
- package/dist/assets/wit-5i3qLPDT.js +0 -1
- package/dist/assets/wolfram-lXgVvXCa.js +0 -1
- package/dist/assets/worker-BBk7yuNN.js +0 -153
- package/dist/assets/workerFactory-tw7cIdmV.js +0 -1
- package/dist/assets/xml-sdJ4AIDG.js +0 -1
- package/dist/assets/xsl-CtQFsRM5.js +0 -1
- package/dist/assets/yaml-Buea-lGh.js +0 -1
- package/dist/assets/zenscript-DVFEvuxE.js +0 -1
- package/dist/assets/zig-VOosw3JB.js +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import dns from 'node:dns';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import https from 'node:https';
|
|
4
|
+
|
|
5
|
+
import { isServerNetworkHost } from '../security/server-network-host.js';
|
|
6
|
+
|
|
7
|
+
// Tells the "This device" browser, which shows pages in an iframe, whether a
|
|
8
|
+
// public site refuses to be shown inside another page (X-Frame-Options or a
|
|
9
|
+
// CSP frame-ancestors directive). An iframe cannot see why a page stayed
|
|
10
|
+
// blank, so the server asks the site. Only public addresses are checked:
|
|
11
|
+
// the server's own network is not reached, and a device's `localhost` is
|
|
12
|
+
// not the server's anyway.
|
|
13
|
+
|
|
14
|
+
const TIMEOUT_MS = 5_000;
|
|
15
|
+
const MAX_REDIRECTS = 5;
|
|
16
|
+
const CACHE_MS = 60_000;
|
|
17
|
+
const MAX_CACHE = 200;
|
|
18
|
+
const REDIRECTS = new Set([301, 302, 303, 307, 308]);
|
|
19
|
+
const USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36';
|
|
20
|
+
|
|
21
|
+
const DEFAULT_PORTS = { 'http:': '80', 'https:': '443' };
|
|
22
|
+
const portOf = (url) => url.port || DEFAULT_PORTS[url.protocol] || '';
|
|
23
|
+
|
|
24
|
+
const headerValues = (value) => {
|
|
25
|
+
if (Array.isArray(value)) return value.flatMap((entry) => String(entry).split(','));
|
|
26
|
+
return typeof value === 'string' ? value.split(',') : [];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The `frame-ancestors` source lists of every CSP policy that has one. */
|
|
30
|
+
export const parseFrameAncestors = (header) => {
|
|
31
|
+
const lists = [];
|
|
32
|
+
// Node joins repeated headers with ", ", which also separates policies.
|
|
33
|
+
for (const policy of headerValues(header)) {
|
|
34
|
+
for (const directive of policy.split(';')) {
|
|
35
|
+
const [name, ...sources] = directive.trim().split(/\s+/);
|
|
36
|
+
if (name?.toLowerCase() === 'frame-ancestors') {
|
|
37
|
+
lists.push(sources.filter(Boolean));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return lists;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const schemeAllows = (sourceScheme, ancestor) => (
|
|
46
|
+
sourceScheme === ancestor.protocol || (sourceScheme === 'http:' && ancestor.protocol === 'https:')
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/** Whether one CSP source expression matches the embedding page's origin. */
|
|
50
|
+
const sourceMatches = (source, ancestor, target) => {
|
|
51
|
+
const lower = source.toLowerCase();
|
|
52
|
+
if (lower === "'self'") return ancestor.origin === target.origin;
|
|
53
|
+
if (lower === '*') return ancestor.protocol === 'http:' || ancestor.protocol === 'https:';
|
|
54
|
+
if (/^[a-z][a-z0-9+.-]*:$/.test(lower)) return schemeAllows(lower, ancestor);
|
|
55
|
+
const match = /^(?:([a-z][a-z0-9+.-]*:)\/\/)?(\*\.)?([a-z0-9.-]+|\*)(?::(\d+|\*))?(?:\/.*)?$/.exec(lower);
|
|
56
|
+
if (!match) return false;
|
|
57
|
+
const [, scheme, wildcard, host, port] = match;
|
|
58
|
+
if (!schemeAllows(scheme || target.protocol, ancestor)) return false;
|
|
59
|
+
const ancestorHost = ancestor.hostname.toLowerCase();
|
|
60
|
+
if (host === '*') {
|
|
61
|
+
if (wildcard) return false;
|
|
62
|
+
} else if (wildcard) {
|
|
63
|
+
if (!ancestorHost.endsWith(`.${host}`)) return false;
|
|
64
|
+
} else if (ancestorHost !== host) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (port === '*') return true;
|
|
68
|
+
const expected = port || DEFAULT_PORTS[scheme || target.protocol] || '';
|
|
69
|
+
return portOf(ancestor) === expected;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether a response with these headers may be shown in an iframe on
|
|
74
|
+
* `ancestorOrigin`, following Chrome: frame-ancestors wins over
|
|
75
|
+
* X-Frame-Options. Returns `refused` only for an unambiguous refusal.
|
|
76
|
+
*/
|
|
77
|
+
export const frameVerdict = ({ headers, targetUrl, ancestorOrigin }) => {
|
|
78
|
+
const target = new URL(targetUrl);
|
|
79
|
+
const ancestor = new URL(ancestorOrigin);
|
|
80
|
+
const lists = parseFrameAncestors(headers['content-security-policy']);
|
|
81
|
+
if (lists.length > 0) {
|
|
82
|
+
const allowed = lists.every((list) => list.some((source) => sourceMatches(source, ancestor, target)));
|
|
83
|
+
return allowed ? { framing: 'allowed' } : { framing: 'refused', reason: 'frame-ancestors' };
|
|
84
|
+
}
|
|
85
|
+
const values = new Set(headerValues(headers['x-frame-options']).map((value) => value.trim().toLowerCase()).filter(Boolean));
|
|
86
|
+
if (values.size === 0) return { framing: 'allowed' };
|
|
87
|
+
const known = ['deny', 'sameorigin', 'allowall'];
|
|
88
|
+
if (values.size > 1) {
|
|
89
|
+
return [...values].some((value) => known.includes(value)) ? { framing: 'refused', reason: 'x-frame-options' } : { framing: 'allowed' };
|
|
90
|
+
}
|
|
91
|
+
const [value] = values;
|
|
92
|
+
if (value === 'deny') return { framing: 'refused', reason: 'x-frame-options' };
|
|
93
|
+
if (value === 'sameorigin') {
|
|
94
|
+
return ancestor.origin === target.origin ? { framing: 'allowed' } : { framing: 'refused', reason: 'x-frame-options' };
|
|
95
|
+
}
|
|
96
|
+
return { framing: 'allowed' };
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const isPublicUrl = (url) => (url.protocol === 'http:' || url.protocol === 'https:') && !isServerNetworkHost(url.hostname);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A DNS lookup that refuses names resolving to the server's own network, so
|
|
103
|
+
* a public-looking name cannot reach it (also on the connection itself).
|
|
104
|
+
*/
|
|
105
|
+
export const createPublicLookup = (lookup = dns.lookup) => (hostname, options, callback) => {
|
|
106
|
+
const opts = typeof options === 'object' && options ? options : { family: options };
|
|
107
|
+
lookup(hostname, { ...opts, all: true }, (error, addresses) => {
|
|
108
|
+
if (error) return callback(error);
|
|
109
|
+
const list = Array.isArray(addresses) ? addresses : [];
|
|
110
|
+
if (list.length === 0 || list.some((entry) => isServerNetworkHost(entry.address))) {
|
|
111
|
+
const blocked = new Error(`${hostname} resolves to the server's network`);
|
|
112
|
+
blocked.code = 'ESERVERNETWORK';
|
|
113
|
+
return callback(blocked);
|
|
114
|
+
}
|
|
115
|
+
if (opts.all) return callback(null, list);
|
|
116
|
+
return callback(null, list[0].address, list[0].family);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const defaultFetchHeaders = (lookup) => (url) => new Promise((resolve, reject) => {
|
|
121
|
+
const client = url.protocol === 'https:' ? https : http;
|
|
122
|
+
const request = client.request(url, {
|
|
123
|
+
method: 'GET',
|
|
124
|
+
agent: false,
|
|
125
|
+
lookup,
|
|
126
|
+
timeout: TIMEOUT_MS,
|
|
127
|
+
headers: { 'user-agent': USER_AGENT, accept: 'text/html,application/xhtml+xml', 'sec-fetch-dest': 'iframe' },
|
|
128
|
+
}, (response) => {
|
|
129
|
+
resolve({ status: response.statusCode || 0, headers: response.headers });
|
|
130
|
+
response.destroy();
|
|
131
|
+
});
|
|
132
|
+
request.on('timeout', () => request.destroy(new Error('timed out')));
|
|
133
|
+
request.on('error', reject);
|
|
134
|
+
request.end();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Checks sites for framing refusals, following redirects and caching
|
|
139
|
+
* answers for a minute. Anything it cannot check is `unknown`, never a
|
|
140
|
+
* refusal.
|
|
141
|
+
*/
|
|
142
|
+
export const createFramePolicyChecker = ({
|
|
143
|
+
fetchHeaders = defaultFetchHeaders(createPublicLookup()),
|
|
144
|
+
now = Date.now,
|
|
145
|
+
} = {}) => {
|
|
146
|
+
const cache = new Map();
|
|
147
|
+
|
|
148
|
+
const resolve = async (startUrl, ancestorOrigin) => {
|
|
149
|
+
let url = new URL(startUrl);
|
|
150
|
+
for (let hop = 0; hop <= MAX_REDIRECTS; hop += 1) {
|
|
151
|
+
if (!isPublicUrl(url)) return { framing: 'unknown' };
|
|
152
|
+
const { status, headers } = await fetchHeaders(url);
|
|
153
|
+
const location = typeof headers.location === 'string' ? headers.location : null;
|
|
154
|
+
if (REDIRECTS.has(status) && location) {
|
|
155
|
+
url = new URL(location, url);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
return frameVerdict({ headers, targetUrl: url.toString(), ancestorOrigin });
|
|
159
|
+
}
|
|
160
|
+
return { framing: 'unknown' };
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
async check(rawUrl, rawOrigin) {
|
|
165
|
+
let url;
|
|
166
|
+
let origin;
|
|
167
|
+
try {
|
|
168
|
+
url = new URL(rawUrl);
|
|
169
|
+
origin = new URL(rawOrigin).origin;
|
|
170
|
+
} catch {
|
|
171
|
+
return { framing: 'unknown' };
|
|
172
|
+
}
|
|
173
|
+
if (!isPublicUrl(url) || origin === 'null') return { framing: 'unknown' };
|
|
174
|
+
const key = `${url.toString()}\n${origin}`;
|
|
175
|
+
const cached = cache.get(key);
|
|
176
|
+
if (cached && now() - cached.at < CACHE_MS) return cached.result;
|
|
177
|
+
const result = await resolve(url.toString(), origin).catch(() => ({ framing: 'unknown' }));
|
|
178
|
+
cache.set(key, { at: now(), result });
|
|
179
|
+
if (cache.size > MAX_CACHE) cache.delete(cache.keys().next().value);
|
|
180
|
+
return result;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { createFramePolicyChecker, createPublicLookup, frameVerdict, parseFrameAncestors } from './frame-policy.js';
|
|
4
|
+
|
|
5
|
+
const ORIGIN = 'http://192.168.0.5:5180';
|
|
6
|
+
const verdict = (headers, targetUrl = 'https://www.example.com/watch') => frameVerdict({ headers, targetUrl, ancestorOrigin: ORIGIN });
|
|
7
|
+
|
|
8
|
+
describe('frameVerdict', () => {
|
|
9
|
+
it('reads X-Frame-Options', () => {
|
|
10
|
+
expect(verdict({ 'x-frame-options': 'SAMEORIGIN' })).toEqual({ framing: 'refused', reason: 'x-frame-options' });
|
|
11
|
+
expect(verdict({ 'x-frame-options': 'deny' })).toEqual({ framing: 'refused', reason: 'x-frame-options' });
|
|
12
|
+
expect(verdict({ 'x-frame-options': 'sameorigin' }, `${ORIGIN}/page`).framing).toBe('allowed');
|
|
13
|
+
expect(verdict({ 'x-frame-options': 'ALLOW-FROM https://a.example' }).framing).toBe('allowed');
|
|
14
|
+
expect(verdict({ 'x-frame-options': 'deny, sameorigin' }).framing).toBe('refused');
|
|
15
|
+
expect(verdict({}).framing).toBe('allowed');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('lets frame-ancestors override X-Frame-Options', () => {
|
|
19
|
+
expect(verdict({ 'x-frame-options': 'DENY', 'content-security-policy': 'frame-ancestors *' }).framing).toBe('allowed');
|
|
20
|
+
expect(verdict({ 'content-security-policy': "default-src 'self'; frame-ancestors 'none'" })).toEqual({ framing: 'refused', reason: 'frame-ancestors' });
|
|
21
|
+
expect(verdict({ 'content-security-policy': "frame-ancestors 'self' https://*.example.com" }).framing).toBe('refused');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('matches host, scheme, and port sources against the embedding origin', () => {
|
|
25
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors http://192.168.0.5:5180' }).framing).toBe('allowed');
|
|
26
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors http://192.168.0.5:*' }).framing).toBe('allowed');
|
|
27
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors http://192.168.0.5' }).framing).toBe('refused');
|
|
28
|
+
// Without a scheme a source takes the protected page's (https), which an http origin does not match.
|
|
29
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors 192.168.0.5:*' }).framing).toBe('refused');
|
|
30
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors 192.168.0.5:5180' }, 'http://site.example/').framing).toBe('allowed');
|
|
31
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors http:' }).framing).toBe('allowed');
|
|
32
|
+
expect(verdict({ 'content-security-policy': 'frame-ancestors https:' }).framing).toBe('refused');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('needs every policy with frame-ancestors to allow it', () => {
|
|
36
|
+
expect(parseFrameAncestors("frame-ancestors *, script-src 'self', frame-ancestors 'none'")).toEqual([['*'], ["'none'"]]);
|
|
37
|
+
expect(verdict({ 'content-security-policy': "frame-ancestors *, frame-ancestors 'none'" }).framing).toBe('refused');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('createPublicLookup', () => {
|
|
42
|
+
const lookupWith = (addresses) => createPublicLookup((_host, _options, callback) => callback(null, addresses));
|
|
43
|
+
|
|
44
|
+
it('passes public addresses and refuses the server network', async () => {
|
|
45
|
+
const run = (lookup, options) => new Promise((resolve) => lookup('site.example', options, (error, address) => resolve(error ? error.code : address)));
|
|
46
|
+
expect(await run(lookupWith([{ address: '93.184.216.34', family: 4 }]), {})).toBe('93.184.216.34');
|
|
47
|
+
expect(await run(lookupWith([{ address: '93.184.216.34', family: 4 }, { address: '10.0.0.2', family: 4 }]), {})).toBe('ESERVERNETWORK');
|
|
48
|
+
expect(await run(lookupWith([{ address: '::1', family: 6 }]), { all: true })).toBe('ESERVERNETWORK');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('createFramePolicyChecker', () => {
|
|
53
|
+
it('follows redirects to the page that loads', async () => {
|
|
54
|
+
const seen = [];
|
|
55
|
+
const checker = createFramePolicyChecker({
|
|
56
|
+
fetchHeaders: async (url) => {
|
|
57
|
+
seen.push(url.toString());
|
|
58
|
+
return url.hostname === 'youtube.com'
|
|
59
|
+
? { status: 301, headers: { location: 'https://www.youtube.com/' } }
|
|
60
|
+
: { status: 200, headers: { 'x-frame-options': 'SAMEORIGIN' } };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
expect(await checker.check('https://youtube.com/', ORIGIN)).toEqual({ framing: 'refused', reason: 'x-frame-options' });
|
|
64
|
+
expect(seen).toEqual(['https://youtube.com/', 'https://www.youtube.com/']);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('never checks the server network and reports failures as unknown', async () => {
|
|
68
|
+
let calls = 0;
|
|
69
|
+
const checker = createFramePolicyChecker({
|
|
70
|
+
fetchHeaders: async (url) => {
|
|
71
|
+
calls += 1;
|
|
72
|
+
if (url.hostname === 'down.example') throw new Error('ECONNREFUSED');
|
|
73
|
+
return { status: 302, headers: { location: 'http://127.0.0.1:8080/' } };
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
expect(await checker.check('http://localhost:5173/', ORIGIN)).toEqual({ framing: 'unknown' });
|
|
77
|
+
expect(await checker.check('http://10.1.2.3/', ORIGIN)).toEqual({ framing: 'unknown' });
|
|
78
|
+
expect(calls).toBe(0);
|
|
79
|
+
expect(await checker.check('https://redirects.example/', ORIGIN)).toEqual({ framing: 'unknown' });
|
|
80
|
+
expect(await checker.check('https://down.example/', ORIGIN)).toEqual({ framing: 'unknown' });
|
|
81
|
+
expect(await checker.check('not a url', ORIGIN)).toEqual({ framing: 'unknown' });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('caches answers for a minute', async () => {
|
|
85
|
+
let calls = 0;
|
|
86
|
+
let time = 0;
|
|
87
|
+
const checker = createFramePolicyChecker({
|
|
88
|
+
fetchHeaders: async () => { calls += 1; return { status: 200, headers: {} }; },
|
|
89
|
+
now: () => time,
|
|
90
|
+
});
|
|
91
|
+
await checker.check('https://a.example/', ORIGIN);
|
|
92
|
+
await checker.check('https://a.example/', ORIGIN);
|
|
93
|
+
expect(calls).toBe(1);
|
|
94
|
+
time = 61_000;
|
|
95
|
+
await checker.check('https://a.example/', ORIGIN);
|
|
96
|
+
expect(calls).toBe(2);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import dns from 'node:dns';
|
|
2
|
+
import net from 'node:net';
|
|
3
|
+
|
|
4
|
+
import { isServerNetworkHost, isServerNetworkSource } from '../security/server-network-host.js';
|
|
5
|
+
|
|
6
|
+
// A page's load waits this long for the server-network check of its name.
|
|
7
|
+
const NAME_CHECK_TIMEOUT_MS = 5_000;
|
|
8
|
+
// A request from a frame not yet linked to its page waits this long for the
|
|
9
|
+
// link (Chrome reports an out-of-process frame just after its first request).
|
|
10
|
+
const OWNER_WAIT_MS = 1_000;
|
|
11
|
+
const MAX_TRACKED = 4_096;
|
|
12
|
+
|
|
13
|
+
const hostOf = (value) => {
|
|
14
|
+
try {
|
|
15
|
+
const url = new URL(value);
|
|
16
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') return null;
|
|
17
|
+
return url.hostname;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Whether a page at `url` is a public page (not about:blank, data:, or the server's network). */
|
|
24
|
+
const isPublicPage = (url) => {
|
|
25
|
+
const host = typeof url === 'string' ? hostOf(url) : null;
|
|
26
|
+
return Boolean(host) && !isServerNetworkSource(host);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether a page load to `url` must be refused because it would reach the
|
|
31
|
+
* server's own network from a public page. `from` is the address that caused
|
|
32
|
+
* the load: the page showing, or the page that redirected. Loads the person
|
|
33
|
+
* asked for (typed, back, forward, reload) pass `from = null`.
|
|
34
|
+
*/
|
|
35
|
+
export const isBlockedServerNetworkLoad = ({ url, from }) => {
|
|
36
|
+
const host = hostOf(url);
|
|
37
|
+
if (!host || !isServerNetworkHost(host)) return false;
|
|
38
|
+
if (from === null) return false;
|
|
39
|
+
return isPublicPage(from);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const lookupAll = (host) => dns.promises.lookup(host, { all: true });
|
|
43
|
+
|
|
44
|
+
const remember = (map, key, value) => {
|
|
45
|
+
map.set(key, value);
|
|
46
|
+
if (map.size > MAX_TRACKED) map.delete(map.keys().next().value);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The server-network rule for every page in the browser, on one
|
|
51
|
+
* browser-level DevTools session: each document request (main frames,
|
|
52
|
+
* subframes, popups, redirects) pauses until it is checked. Playwright's
|
|
53
|
+
* request routing would turn off the HTTP cache and never shows redirects,
|
|
54
|
+
* so this uses Chrome's Fetch domain directly.
|
|
55
|
+
*
|
|
56
|
+
* Pages register an owner:
|
|
57
|
+
* - `sourceUrl()`: the address loads in the page come from;
|
|
58
|
+
* - `consumeUserLoad(url)`: whether a main-frame load is one the person asked for;
|
|
59
|
+
* - `blocked(url, { mainFrame })`: a load was refused;
|
|
60
|
+
* - optional `admit(url, { mainFrame })`: return false to cancel an allowed load.
|
|
61
|
+
*
|
|
62
|
+
* A request is linked to its page through its frame: the page's own target,
|
|
63
|
+
* or a chain of parent frames reported by the page (`frameAttached`) or by
|
|
64
|
+
* Chrome (out-of-process frames). A request whose page cannot be found is
|
|
65
|
+
* judged as coming from a public page.
|
|
66
|
+
*/
|
|
67
|
+
export const createNetworkGuard = ({ lookup = lookupAll, onPopupTarget = () => null, log = () => {} } = {}) => {
|
|
68
|
+
let session = null;
|
|
69
|
+
const owners = new Map();
|
|
70
|
+
const parents = new Map();
|
|
71
|
+
const requestUrls = new Map();
|
|
72
|
+
const waiters = new Set();
|
|
73
|
+
|
|
74
|
+
const notify = () => {
|
|
75
|
+
for (const waiter of [...waiters]) waiter();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const ownerOf = (frameId) => {
|
|
79
|
+
let id = frameId;
|
|
80
|
+
for (let depth = 0; depth < 32 && id; depth += 1) {
|
|
81
|
+
const owner = owners.get(id);
|
|
82
|
+
if (owner) return { owner, mainFrame: id === frameId };
|
|
83
|
+
id = parents.get(id);
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const waitForOwner = (frameId) => new Promise((resolve) => {
|
|
89
|
+
const check = () => {
|
|
90
|
+
const found = ownerOf(frameId);
|
|
91
|
+
if (!found) return;
|
|
92
|
+
finish(found);
|
|
93
|
+
};
|
|
94
|
+
const finish = (found) => {
|
|
95
|
+
waiters.delete(check);
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
resolve(found);
|
|
98
|
+
};
|
|
99
|
+
const timer = setTimeout(() => finish(null), OWNER_WAIT_MS);
|
|
100
|
+
timer.unref?.();
|
|
101
|
+
waiters.add(check);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const send = (method, params) => session?.send(method, params).catch(() => {});
|
|
105
|
+
|
|
106
|
+
const decide = async ({ url, from, unknownSource }) => {
|
|
107
|
+
if (from === null) return 'allow';
|
|
108
|
+
if (!unknownSource && !isPublicPage(from)) return 'allow';
|
|
109
|
+
const host = hostOf(url);
|
|
110
|
+
if (!host) return 'allow';
|
|
111
|
+
if (isServerNetworkHost(host)) return 'block';
|
|
112
|
+
if (net.isIP(host.replace(/^\[|\]$/g, ''))) return 'allow';
|
|
113
|
+
// A public name can resolve to the server's network (127.0.0.1.nip.io).
|
|
114
|
+
// Chrome resolves the name again itself, so a name that changes its
|
|
115
|
+
// answer in between (DNS rebinding) is not caught. A name that cannot be
|
|
116
|
+
// checked does not load: Chrome shows its own error page for it.
|
|
117
|
+
let timer;
|
|
118
|
+
const timedOut = new Promise((resolve) => {
|
|
119
|
+
timer = setTimeout(() => resolve('timeout'), NAME_CHECK_TIMEOUT_MS);
|
|
120
|
+
timer.unref?.();
|
|
121
|
+
});
|
|
122
|
+
try {
|
|
123
|
+
const addresses = await Promise.race([Promise.resolve().then(() => lookup(host)), timedOut]);
|
|
124
|
+
if (addresses === 'timeout') return 'TimedOut';
|
|
125
|
+
if (!Array.isArray(addresses) || addresses.length === 0) return 'NameNotResolved';
|
|
126
|
+
return addresses.some((entry) => isServerNetworkHost(entry.address)) ? 'block' : 'allow';
|
|
127
|
+
} catch {
|
|
128
|
+
return 'NameNotResolved';
|
|
129
|
+
} finally {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const onRequestPaused = async ({ requestId, request, frameId, redirectedRequestId }) => {
|
|
135
|
+
const url = request?.url || '';
|
|
136
|
+
remember(requestUrls, requestId, url);
|
|
137
|
+
const found = ownerOf(frameId) ?? await waitForOwner(frameId);
|
|
138
|
+
const mainFrame = found?.mainFrame === true;
|
|
139
|
+
let from;
|
|
140
|
+
if (redirectedRequestId && requestUrls.has(redirectedRequestId)) from = requestUrls.get(redirectedRequestId);
|
|
141
|
+
else if (mainFrame && found.owner.consumeUserLoad(url)) from = null;
|
|
142
|
+
else from = found ? found.owner.sourceUrl() : undefined;
|
|
143
|
+
const outcome = await decide({ url, from, unknownSource: !found && from === undefined });
|
|
144
|
+
if (outcome === 'block') {
|
|
145
|
+
// Cancel rather than fail: the current page stays, with no error page
|
|
146
|
+
// standing in for the blocked address that Reload would then load.
|
|
147
|
+
await send('Fetch.failRequest', { requestId, errorReason: 'Aborted' });
|
|
148
|
+
if (found) found.owner.blocked(url, { mainFrame });
|
|
149
|
+
else log(`[server-browser] blocked a frame of an unknown page from loading ${hostOf(url)}`);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (outcome !== 'allow') {
|
|
153
|
+
await send('Fetch.failRequest', { requestId, errorReason: outcome });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (found?.owner.admit && found.owner.admit(url, { mainFrame }) === false) {
|
|
157
|
+
await send('Fetch.failRequest', { requestId, errorReason: 'Aborted' });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
await send('Fetch.continueRequest', { requestId });
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
/** Starts checking requests in `context`'s browser. */
|
|
165
|
+
async attach(context) {
|
|
166
|
+
const browser = context.browser();
|
|
167
|
+
if (!browser) throw new Error('The browser connection is not available');
|
|
168
|
+
session = await browser.newBrowserCDPSession();
|
|
169
|
+
session.on('Fetch.requestPaused', (params) => {
|
|
170
|
+
void onRequestPaused(params).catch((error) => {
|
|
171
|
+
log(`[server-browser] request check failed: ${error?.message || error}`);
|
|
172
|
+
void send('Fetch.failRequest', { requestId: params.requestId, errorReason: 'Failed' });
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
session.on('Target.targetCreated', ({ targetInfo }) => {
|
|
176
|
+
if (targetInfo.type === 'iframe' && targetInfo.parentFrameId) {
|
|
177
|
+
remember(parents, targetInfo.targetId, targetInfo.parentFrameId);
|
|
178
|
+
notify();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
// A popup: its first request pauses after this.
|
|
182
|
+
if (targetInfo.type === 'page' && targetInfo.openerId && owners.has(targetInfo.openerId) && !owners.has(targetInfo.targetId)) {
|
|
183
|
+
const owner = onPopupTarget({ targetId: targetInfo.targetId, opener: owners.get(targetInfo.openerId) });
|
|
184
|
+
if (owner) {
|
|
185
|
+
owners.set(targetInfo.targetId, owner);
|
|
186
|
+
notify();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
session.on('Target.targetDestroyed', ({ targetId }) => {
|
|
191
|
+
parents.delete(targetId);
|
|
192
|
+
// A popup that closed before a tab claimed it.
|
|
193
|
+
owners.delete(targetId);
|
|
194
|
+
});
|
|
195
|
+
await session.send('Target.setDiscoverTargets', { discover: true });
|
|
196
|
+
await session.send('Fetch.enable', { patterns: [{ resourceType: 'Document', requestStage: 'Request' }] });
|
|
197
|
+
// Chrome's Local Network Access also keeps public pages' scripts and
|
|
198
|
+
// subresources off the server's network. Its permission name changed
|
|
199
|
+
// over versions; unknown names fail.
|
|
200
|
+
for (const name of ['local-network-access', 'local-network', 'loopback-network']) {
|
|
201
|
+
await session.send('Browser.setPermission', { permission: { name }, setting: 'denied' }).catch(() => {});
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
addPage(targetId, owner) {
|
|
206
|
+
owners.set(targetId, owner);
|
|
207
|
+
notify();
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
removePage(targetId, owner) {
|
|
211
|
+
if (!owner || owners.get(targetId) === owner) owners.delete(targetId);
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
/** A page reported a frame in its own process. */
|
|
215
|
+
frameAttached(frameId, parentFrameId) {
|
|
216
|
+
if (!parentFrameId) return;
|
|
217
|
+
remember(parents, frameId, parentFrameId);
|
|
218
|
+
notify();
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
closeTarget(targetId) {
|
|
222
|
+
return send('Target.closeTarget', { targetId });
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
detach() {
|
|
226
|
+
waiters.clear();
|
|
227
|
+
owners.clear();
|
|
228
|
+
parents.clear();
|
|
229
|
+
requestUrls.clear();
|
|
230
|
+
const current = session;
|
|
231
|
+
session = null;
|
|
232
|
+
return current?.detach().catch(() => {});
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
};
|