@asterxsk/kiln 0.3.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -155
- package/agent/AGENTS.md +67 -67
- package/agent/README.md +5 -5
- package/agent/extensions/ask-user/index.ts +418 -418
- package/agent/extensions/ask-user/install.ps1 +27 -27
- package/agent/extensions/ask-user/install.sh +24 -24
- package/agent/extensions/ask-user/package-lock.json +769 -769
- package/agent/extensions/ask-user/package.json +19 -19
- package/agent/extensions/ask-user/prompt.ts +45 -45
- package/agent/extensions/ask-user/tsconfig.json +7 -7
- package/agent/extensions/background-terminals/docs/implementation-guide.md +942 -942
- package/agent/extensions/background-terminals/index.ts +627 -627
- package/agent/extensions/background-terminals/install.ps1 +27 -27
- package/agent/extensions/background-terminals/install.sh +24 -24
- package/agent/extensions/background-terminals/manager.test.ts +735 -735
- package/agent/extensions/background-terminals/output.test.ts +109 -109
- package/agent/extensions/background-terminals/package-lock.json +769 -769
- package/agent/extensions/background-terminals/package.json +17 -17
- package/agent/extensions/background-terminals/prompt.test.ts +125 -125
- package/agent/extensions/background-terminals/ps.test.ts +82 -82
- package/agent/extensions/background-terminals/result-delivery.test.ts +44 -44
- package/agent/extensions/background-terminals/src/domain.ts +87 -87
- package/agent/extensions/background-terminals/src/manager.ts +907 -907
- package/agent/extensions/background-terminals/src/output.ts +84 -84
- package/agent/extensions/background-terminals/src/prompt.ts +142 -142
- package/agent/extensions/background-terminals/src/result-delivery.ts +27 -27
- package/agent/extensions/background-terminals/src/runtime.ts +36 -36
- package/agent/extensions/background-terminals/src/ui/output-view.ts +79 -79
- package/agent/extensions/background-terminals/src/ui/ps.ts +621 -621
- package/agent/extensions/background-terminals/tsconfig.json +7 -7
- package/agent/extensions/destructive/README.md +31 -31
- package/agent/extensions/destructive/index.ts +88 -88
- package/agent/extensions/destructive/install.ps1 +27 -27
- package/agent/extensions/destructive/install.sh +24 -24
- package/agent/extensions/file-search/index.spec.ts +443 -443
- package/agent/extensions/file-search/index.ts +459 -459
- package/agent/extensions/file-search/install.ps1 +27 -27
- package/agent/extensions/file-search/install.sh +24 -24
- package/agent/extensions/file-search/package-lock.json +2253 -2253
- package/agent/extensions/file-search/package.json +23 -23
- package/agent/extensions/file-search/src/args.ts +122 -122
- package/agent/extensions/file-search/src/binaries.ts +422 -422
- package/agent/extensions/file-search/src/output.ts +126 -126
- package/agent/extensions/file-search/src/process.ts +146 -146
- package/agent/extensions/file-search/src/prompt.ts +52 -52
- package/agent/extensions/file-search/tsconfig.json +7 -7
- package/agent/extensions/goal/README.md +50 -50
- package/agent/extensions/goal/index.ts +155 -155
- package/agent/extensions/goal/install.ps1 +27 -27
- package/agent/extensions/goal/install.sh +24 -24
- package/agent/extensions/kiln-update/README.md +38 -25
- package/agent/extensions/kiln-update/index.ts +177 -99
- package/agent/extensions/modelconf/PLAN.md +915 -915
- package/agent/extensions/modelconf/README.md +66 -66
- package/agent/extensions/modelconf/index.ts +296 -296
- package/agent/extensions/modelconf/install.ps1 +27 -27
- package/agent/extensions/modelconf/install.sh +24 -24
- package/agent/extensions/modelconf/package-lock.json +1809 -1809
- package/agent/extensions/modelconf/package.json +13 -13
- package/agent/extensions/modelconf/src/fuzzy.ts +26 -26
- package/agent/extensions/modelconf/src/glob.ts +13 -13
- package/agent/extensions/modelconf/src/persistence.test.ts +46 -46
- package/agent/extensions/modelconf/src/persistence.ts +164 -164
- package/agent/extensions/modelconf/src/ui/ModelConfView.test.ts +75 -75
- package/agent/extensions/modelconf/src/ui/ModelConfView.ts +1101 -1101
- package/agent/extensions/modelconf/tsconfig.json +15 -15
- package/agent/extensions/pi-web-access/CHANGELOG.md +690 -690
- package/agent/extensions/pi-web-access/LICENSE +21 -21
- package/agent/extensions/pi-web-access/README.md +470 -470
- package/agent/extensions/pi-web-access/SECURITY.md +5 -5
- package/agent/extensions/pi-web-access/activity.ts +101 -101
- package/agent/extensions/pi-web-access/auth-fetch.ts +148 -148
- package/agent/extensions/pi-web-access/brightdata-unlocker.ts +272 -272
- package/agent/extensions/pi-web-access/chrome-cookies.ts +669 -669
- package/agent/extensions/pi-web-access/content-find.ts +139 -139
- package/agent/extensions/pi-web-access/credential-source.ts +191 -191
- package/agent/extensions/pi-web-access/data-uri-sanitize.ts +406 -406
- package/agent/extensions/pi-web-access/datalab-pdf-extract.ts +568 -568
- package/agent/extensions/pi-web-access/declared-web-links.ts +173 -173
- package/agent/extensions/pi-web-access/evidence/CONTRACT-EVIDENCE.md +496 -496
- package/agent/extensions/pi-web-access/evidence/contract-probe.mjs +140 -140
- package/agent/extensions/pi-web-access/exa.ts +526 -526
- package/agent/extensions/pi-web-access/extract.ts +1196 -1196
- package/agent/extensions/pi-web-access/feature-config.ts +29 -29
- package/agent/extensions/pi-web-access/fetch-params.ts +111 -111
- package/agent/extensions/pi-web-access/gemini-adc.ts +298 -298
- package/agent/extensions/pi-web-access/gemini-api.ts +353 -353
- package/agent/extensions/pi-web-access/gemini-pdf-extract.ts +108 -108
- package/agent/extensions/pi-web-access/gemini-search.ts +21 -21
- package/agent/extensions/pi-web-access/gemini-url-context.ts +128 -128
- package/agent/extensions/pi-web-access/gemini-web-config.ts +101 -101
- package/agent/extensions/pi-web-access/gemini-web.ts +487 -487
- package/agent/extensions/pi-web-access/github-api.ts +197 -197
- package/agent/extensions/pi-web-access/github-extract.ts +746 -746
- package/agent/extensions/pi-web-access/github-issue-pr.ts +700 -700
- package/agent/extensions/pi-web-access/index.ts +1737 -1737
- package/agent/extensions/pi-web-access/package-lock.json +5808 -5808
- package/agent/extensions/pi-web-access/package.json +64 -64
- package/agent/extensions/pi-web-access/page-query.ts +96 -96
- package/agent/extensions/pi-web-access/pdf-extract.ts +409 -409
- package/agent/extensions/pi-web-access/promise-try.d.ts +7 -7
- package/agent/extensions/pi-web-access/query-rewrite.ts +51 -51
- package/agent/extensions/pi-web-access/render-search-error.ts +170 -170
- package/agent/extensions/pi-web-access/rsc-extract.ts +338 -338
- package/agent/extensions/pi-web-access/search-types.ts +20 -20
- package/agent/extensions/pi-web-access/source-check.ts +282 -282
- package/agent/extensions/pi-web-access/ssrf-protection.ts +526 -526
- package/agent/extensions/pi-web-access/storage.ts +521 -521
- package/agent/extensions/pi-web-access/summary-model-scope.ts +125 -125
- package/agent/extensions/pi-web-access/test/auth-fetch.test.mjs +208 -208
- package/agent/extensions/pi-web-access/test/brightdata-unlocker.test.mjs +840 -840
- package/agent/extensions/pi-web-access/test/chrome-cookie-extraction.test.mjs +441 -441
- package/agent/extensions/pi-web-access/test/config-path.test.mjs +283 -283
- package/agent/extensions/pi-web-access/test/content-find.test.mjs +25 -25
- package/agent/extensions/pi-web-access/test/credential-source.test.mjs +118 -118
- package/agent/extensions/pi-web-access/test/data-uri-sanitize.test.mjs +210 -210
- package/agent/extensions/pi-web-access/test/datalab-pdf-extract.test.mjs +552 -552
- package/agent/extensions/pi-web-access/test/declared-web-links.test.mjs +212 -212
- package/agent/extensions/pi-web-access/test/fetch-answer-storage.test.mjs +40 -40
- package/agent/extensions/pi-web-access/test/fetch-cache-storage.test.mjs +334 -334
- package/agent/extensions/pi-web-access/test/fetch-content-domain-policy.test.mjs +95 -95
- package/agent/extensions/pi-web-access/test/fetch-modes.test.mjs +53 -53
- package/agent/extensions/pi-web-access/test/fetch-not-found-guidance.test.mjs +92 -92
- package/agent/extensions/pi-web-access/test/fetch-params.test.mjs +86 -86
- package/agent/extensions/pi-web-access/test/fetch-render-call.test.mjs +34 -34
- package/agent/extensions/pi-web-access/test/fetch-routing.test.mjs +173 -173
- package/agent/extensions/pi-web-access/test/gemini-adc-auth.test.mjs +257 -257
- package/agent/extensions/pi-web-access/test/gemini-api-transport.test.mjs +170 -170
- package/agent/extensions/pi-web-access/test/gemini-pdf-extract.test.mjs +133 -133
- package/agent/extensions/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +178 -178
- package/agent/extensions/pi-web-access/test/gemini-web-header-overflow.test.mjs +148 -148
- package/agent/extensions/pi-web-access/test/get-search-content.test.mjs +223 -223
- package/agent/extensions/pi-web-access/test/github-extract.test.mjs +378 -378
- package/agent/extensions/pi-web-access/test/github-issue-pr.test.mjs +565 -565
- package/agent/extensions/pi-web-access/test/inline-content-config.test.mjs +99 -99
- package/agent/extensions/pi-web-access/test/lazy-extract-load.test.mjs +118 -118
- package/agent/extensions/pi-web-access/test/local-video-oversize.test.mjs +52 -52
- package/agent/extensions/pi-web-access/test/package-typebox-dependency.test.mjs +50 -50
- package/agent/extensions/pi-web-access/test/page-query.test.mjs +51 -51
- package/agent/extensions/pi-web-access/test/pdf-config.test.mjs +140 -140
- package/agent/extensions/pi-web-access/test/pdf-extract.test.mjs +500 -500
- package/agent/extensions/pi-web-access/test/proxy-transport.test.mjs +286 -286
- package/agent/extensions/pi-web-access/test/query-rewrite.test.mjs +52 -52
- package/agent/extensions/pi-web-access/test/rsc-fallback.test.mjs +102 -102
- package/agent/extensions/pi-web-access/test/search-error-render.test.mjs +152 -152
- package/agent/extensions/pi-web-access/test/search-providers.test.mjs +274 -274
- package/agent/extensions/pi-web-access/test/source-check.test.mjs +179 -179
- package/agent/extensions/pi-web-access/test/ssrf-allow-ranges-config.test.mjs +205 -205
- package/agent/extensions/pi-web-access/test/ssrf-protection.test.mjs +456 -456
- package/agent/extensions/pi-web-access/test/summary-model-scope.test.mjs +106 -106
- package/agent/extensions/pi-web-access/test/tool-registration-config.test.mjs +182 -182
- package/agent/extensions/pi-web-access/test/web-search-answer-render.test.mjs +66 -66
- package/agent/extensions/pi-web-access/test/youtube-extract-errors.test.mjs +64 -64
- package/agent/extensions/pi-web-access/tsconfig.json +11 -11
- package/agent/extensions/pi-web-access/utils.ts +451 -451
- package/agent/extensions/pi-web-access/video-extract.ts +392 -392
- package/agent/extensions/pi-web-access/youtube-extract.ts +328 -328
- package/agent/extensions/shared/activity-status.ts +31 -31
- package/agent/extensions/shared/child-session.test.ts +270 -270
- package/agent/extensions/shared/child-session.ts +148 -148
- package/agent/extensions/shared/context-utilization.test.ts +48 -48
- package/agent/extensions/shared/context-utilization.ts +47 -47
- package/agent/extensions/shared/dashboard-state.ts +99 -99
- package/agent/extensions/shared/install.ps1 +27 -27
- package/agent/extensions/shared/install.sh +24 -24
- package/agent/extensions/shared/tool-call-timeout.test.ts +117 -117
- package/agent/extensions/shared/tool-call-timeout.ts +104 -104
- package/agent/extensions/skillsconf/README.md +74 -74
- package/agent/extensions/skillsconf/index.ts +92 -92
- package/agent/extensions/skillsconf/install.ps1 +27 -27
- package/agent/extensions/skillsconf/install.sh +24 -24
- package/agent/extensions/skillsconf/package-lock.json +1809 -1809
- package/agent/extensions/skillsconf/package.json +18 -18
- package/agent/extensions/skillsconf/src/delete-skill.test.ts +64 -64
- package/agent/extensions/skillsconf/src/delete-skill.ts +45 -45
- package/agent/extensions/skillsconf/src/filter.test.ts +80 -80
- package/agent/extensions/skillsconf/src/filter.ts +74 -74
- package/agent/extensions/skillsconf/src/fuzzy.ts +26 -26
- package/agent/extensions/skillsconf/src/persistence.test.ts +72 -72
- package/agent/extensions/skillsconf/src/persistence.ts +169 -169
- package/agent/extensions/skillsconf/src/ui/SkillConfView.test.ts +337 -337
- package/agent/extensions/skillsconf/src/ui/SkillConfView.ts +758 -758
- package/agent/extensions/skillsconf/src/ui/text-input.ts +91 -91
- package/agent/extensions/skillsconf/src/ui/tui-helpers.ts +144 -144
- package/agent/extensions/skillsconf/tsconfig.json +15 -15
- package/agent/extensions/statusline/index.ts +273 -282
- package/agent/extensions/statusline/install.ps1 +27 -27
- package/agent/extensions/statusline/install.sh +24 -24
- package/agent/extensions/subagents/by-the-way.test.ts +29 -29
- package/agent/extensions/subagents/claude.test.ts +119 -119
- package/agent/extensions/subagents/codex.test.ts +102 -102
- package/agent/extensions/subagents/context-usage.test.ts +107 -107
- package/agent/extensions/subagents/docs/design-plan.md +568 -568
- package/agent/extensions/subagents/docs/effect-v4-extension-guide.md +354 -354
- package/agent/extensions/subagents/docs/effect-v4-notes.md +571 -571
- package/agent/extensions/subagents/index.ts +779 -779
- package/agent/extensions/subagents/install.ps1 +27 -27
- package/agent/extensions/subagents/install.sh +24 -24
- package/agent/extensions/subagents/manager.test.ts +276 -276
- package/agent/extensions/subagents/package-lock.json +2244 -2244
- package/agent/extensions/subagents/package.json +19 -19
- package/agent/extensions/subagents/result-delivery.test.ts +27 -27
- package/agent/extensions/subagents/src/backend.ts +73 -73
- package/agent/extensions/subagents/src/backends/claude.ts +701 -701
- package/agent/extensions/subagents/src/backends/codex.ts +1060 -1060
- package/agent/extensions/subagents/src/backends/pi.ts +575 -575
- package/agent/extensions/subagents/src/backends/stub.ts +300 -300
- package/agent/extensions/subagents/src/by-the-way.ts +21 -21
- package/agent/extensions/subagents/src/domain.ts +253 -253
- package/agent/extensions/subagents/src/format.ts +74 -74
- package/agent/extensions/subagents/src/manager.ts +736 -736
- package/agent/extensions/subagents/src/prompt.ts +92 -92
- package/agent/extensions/subagents/src/result-delivery.ts +20 -20
- package/agent/extensions/subagents/src/runtime.ts +53 -53
- package/agent/extensions/subagents/src/ui/takeover.ts +583 -583
- package/agent/extensions/subagents/src/ui/transcript.ts +201 -201
- package/agent/extensions/subagents/takeover.test.ts +29 -29
- package/agent/extensions/subagents/tsconfig.json +7 -7
- package/agent/extensions/todo/AGENTS.md +38 -38
- package/agent/extensions/todo/LICENSE +21 -21
- package/agent/extensions/todo/config.ts +55 -55
- package/agent/extensions/todo/index.ts +151 -151
- package/agent/extensions/todo/install.ps1 +27 -27
- package/agent/extensions/todo/install.sh +24 -24
- package/agent/extensions/todo/locales/de.json +17 -17
- package/agent/extensions/todo/locales/en.json +15 -15
- package/agent/extensions/todo/locales/es.json +17 -17
- package/agent/extensions/todo/locales/fr.json +17 -17
- package/agent/extensions/todo/locales/pt-BR.json +17 -17
- package/agent/extensions/todo/locales/pt.json +17 -17
- package/agent/extensions/todo/locales/ru.json +17 -17
- package/agent/extensions/todo/locales/uk.json +17 -17
- package/agent/extensions/todo/locales/zh.json +17 -17
- package/agent/extensions/todo/package-lock.json +3358 -3358
- package/agent/extensions/todo/package.json +67 -67
- package/agent/extensions/todo/state/i18n-bridge.ts +64 -64
- package/agent/extensions/todo/state/invariants.ts +20 -20
- package/agent/extensions/todo/state/replay.ts +38 -38
- package/agent/extensions/todo/state/selectors.ts +107 -107
- package/agent/extensions/todo/state/state-reducer.ts +326 -326
- package/agent/extensions/todo/state/state.ts +18 -18
- package/agent/extensions/todo/state/store.ts +82 -82
- package/agent/extensions/todo/state/task-graph.ts +57 -57
- package/agent/extensions/todo/todo-overlay.ts +200 -200
- package/agent/extensions/todo/todo.ts +155 -155
- package/agent/extensions/todo/tool/response-envelope.ts +109 -109
- package/agent/extensions/todo/tool/types.ts +206 -206
- package/agent/extensions/todo/view/format.ts +177 -177
- package/agent/extensions/trim-context/README.md +54 -54
- package/agent/extensions/trim-context/index.ts +487 -487
- package/agent/extensions/trim-context/install.ps1 +27 -27
- package/agent/extensions/trim-context/install.sh +24 -24
- package/agent/keybindings.json +7 -7
- package/agent/version.txt +1 -1
- package/bin/kiln.js +30 -21
- package/package.json +1 -1
- package/agent/extensions/taste/index.ts +0 -443
- package/agent/extensions/taste/install.ps1 +0 -27
- package/agent/extensions/taste/install.sh +0 -24
- package/agent.bak.20260905-190020/AGENTS.md +0 -67
- package/agent.bak.20260905-190020/README.md +0 -5
- package/agent.bak.20260905-190020/extensions/ask-user/index.ts +0 -418
- package/agent.bak.20260905-190020/extensions/ask-user/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/ask-user/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/ask-user/package-lock.json +0 -769
- package/agent.bak.20260905-190020/extensions/ask-user/package.json +0 -19
- package/agent.bak.20260905-190020/extensions/ask-user/prompt.ts +0 -45
- package/agent.bak.20260905-190020/extensions/ask-user/tsconfig.json +0 -7
- package/agent.bak.20260905-190020/extensions/background-terminals/docs/implementation-guide.md +0 -942
- package/agent.bak.20260905-190020/extensions/background-terminals/index.ts +0 -629
- package/agent.bak.20260905-190020/extensions/background-terminals/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/background-terminals/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/background-terminals/package-lock.json +0 -769
- package/agent.bak.20260905-190020/extensions/background-terminals/package.json +0 -17
- package/agent.bak.20260905-190020/extensions/background-terminals/src/domain.ts +0 -87
- package/agent.bak.20260905-190020/extensions/background-terminals/src/manager.ts +0 -907
- package/agent.bak.20260905-190020/extensions/background-terminals/src/output.ts +0 -84
- package/agent.bak.20260905-190020/extensions/background-terminals/src/prompt.ts +0 -142
- package/agent.bak.20260905-190020/extensions/background-terminals/src/result-delivery.ts +0 -27
- package/agent.bak.20260905-190020/extensions/background-terminals/src/runtime.ts +0 -36
- package/agent.bak.20260905-190020/extensions/background-terminals/src/ui/output-view.ts +0 -79
- package/agent.bak.20260905-190020/extensions/background-terminals/src/ui/ps.ts +0 -621
- package/agent.bak.20260905-190020/extensions/background-terminals/src/widget-order.ts +0 -121
- package/agent.bak.20260905-190020/extensions/background-terminals/test/manager.test.ts +0 -735
- package/agent.bak.20260905-190020/extensions/background-terminals/test/output.test.ts +0 -109
- package/agent.bak.20260905-190020/extensions/background-terminals/test/prompt.test.ts +0 -125
- package/agent.bak.20260905-190020/extensions/background-terminals/test/ps.test.ts +0 -82
- package/agent.bak.20260905-190020/extensions/background-terminals/test/result-delivery.test.ts +0 -44
- package/agent.bak.20260905-190020/extensions/background-terminals/tsconfig.json +0 -7
- package/agent.bak.20260905-190020/extensions/destructive/README.md +0 -34
- package/agent.bak.20260905-190020/extensions/destructive/index.ts +0 -124
- package/agent.bak.20260905-190020/extensions/destructive/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/destructive/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/file-search/index.ts +0 -459
- package/agent.bak.20260905-190020/extensions/file-search/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/file-search/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/file-search/package-lock.json +0 -2253
- package/agent.bak.20260905-190020/extensions/file-search/package.json +0 -23
- package/agent.bak.20260905-190020/extensions/file-search/src/args.ts +0 -122
- package/agent.bak.20260905-190020/extensions/file-search/src/binaries.ts +0 -422
- package/agent.bak.20260905-190020/extensions/file-search/src/output.ts +0 -126
- package/agent.bak.20260905-190020/extensions/file-search/src/process.ts +0 -146
- package/agent.bak.20260905-190020/extensions/file-search/src/prompt.ts +0 -52
- package/agent.bak.20260905-190020/extensions/file-search/test/index.spec.ts +0 -443
- package/agent.bak.20260905-190020/extensions/file-search/tsconfig.json +0 -7
- package/agent.bak.20260905-190020/extensions/goal/README.md +0 -50
- package/agent.bak.20260905-190020/extensions/goal/index.ts +0 -155
- package/agent.bak.20260905-190020/extensions/goal/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/goal/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/kiln-update/README.md +0 -25
- package/agent.bak.20260905-190020/extensions/kiln-update/index.ts +0 -99
- package/agent.bak.20260905-190020/extensions/kiln-update/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/kiln-update/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/modelconf/PLAN.md +0 -915
- package/agent.bak.20260905-190020/extensions/modelconf/README.md +0 -66
- package/agent.bak.20260905-190020/extensions/modelconf/index.ts +0 -296
- package/agent.bak.20260905-190020/extensions/modelconf/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/modelconf/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/modelconf/package-lock.json +0 -1809
- package/agent.bak.20260905-190020/extensions/modelconf/package.json +0 -13
- package/agent.bak.20260905-190020/extensions/modelconf/src/fuzzy.ts +0 -26
- package/agent.bak.20260905-190020/extensions/modelconf/src/glob.ts +0 -13
- package/agent.bak.20260905-190020/extensions/modelconf/src/persistence.test.ts +0 -46
- package/agent.bak.20260905-190020/extensions/modelconf/src/persistence.ts +0 -164
- package/agent.bak.20260905-190020/extensions/modelconf/src/ui/ModelConfView.test.ts +0 -75
- package/agent.bak.20260905-190020/extensions/modelconf/src/ui/ModelConfView.ts +0 -1101
- package/agent.bak.20260905-190020/extensions/modelconf/tsconfig.json +0 -15
- package/agent.bak.20260905-190020/extensions/pi-web-access/CHANGELOG.md +0 -690
- package/agent.bak.20260905-190020/extensions/pi-web-access/LICENSE +0 -21
- package/agent.bak.20260905-190020/extensions/pi-web-access/README.md +0 -470
- package/agent.bak.20260905-190020/extensions/pi-web-access/SECURITY.md +0 -5
- package/agent.bak.20260905-190020/extensions/pi-web-access/activity.ts +0 -101
- package/agent.bak.20260905-190020/extensions/pi-web-access/auth-fetch.ts +0 -148
- package/agent.bak.20260905-190020/extensions/pi-web-access/banner.png +0 -0
- package/agent.bak.20260905-190020/extensions/pi-web-access/brightdata-unlocker.ts +0 -272
- package/agent.bak.20260905-190020/extensions/pi-web-access/chrome-cookies.ts +0 -669
- package/agent.bak.20260905-190020/extensions/pi-web-access/content-find.ts +0 -139
- package/agent.bak.20260905-190020/extensions/pi-web-access/credential-source.ts +0 -191
- package/agent.bak.20260905-190020/extensions/pi-web-access/data-uri-sanitize.ts +0 -406
- package/agent.bak.20260905-190020/extensions/pi-web-access/datalab-pdf-extract.ts +0 -568
- package/agent.bak.20260905-190020/extensions/pi-web-access/declared-web-links.ts +0 -173
- package/agent.bak.20260905-190020/extensions/pi-web-access/evidence/CONTRACT-EVIDENCE.md +0 -496
- package/agent.bak.20260905-190020/extensions/pi-web-access/evidence/contract-probe.mjs +0 -140
- package/agent.bak.20260905-190020/extensions/pi-web-access/exa.ts +0 -526
- package/agent.bak.20260905-190020/extensions/pi-web-access/extract.ts +0 -1196
- package/agent.bak.20260905-190020/extensions/pi-web-access/feature-config.ts +0 -29
- package/agent.bak.20260905-190020/extensions/pi-web-access/fetch-params.ts +0 -111
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-adc.ts +0 -298
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-api.ts +0 -353
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-pdf-extract.ts +0 -108
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-search.ts +0 -21
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-url-context.ts +0 -128
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-web-config.ts +0 -101
- package/agent.bak.20260905-190020/extensions/pi-web-access/gemini-web.ts +0 -487
- package/agent.bak.20260905-190020/extensions/pi-web-access/github-api.ts +0 -197
- package/agent.bak.20260905-190020/extensions/pi-web-access/github-extract.ts +0 -746
- package/agent.bak.20260905-190020/extensions/pi-web-access/github-issue-pr.ts +0 -700
- package/agent.bak.20260905-190020/extensions/pi-web-access/index.ts +0 -1737
- package/agent.bak.20260905-190020/extensions/pi-web-access/package-lock.json +0 -5808
- package/agent.bak.20260905-190020/extensions/pi-web-access/package.json +0 -64
- package/agent.bak.20260905-190020/extensions/pi-web-access/page-query.ts +0 -96
- package/agent.bak.20260905-190020/extensions/pi-web-access/pdf-extract.ts +0 -409
- package/agent.bak.20260905-190020/extensions/pi-web-access/pi-web-fetch-demo.mp4 +0 -0
- package/agent.bak.20260905-190020/extensions/pi-web-access/promise-try.d.ts +0 -7
- package/agent.bak.20260905-190020/extensions/pi-web-access/query-rewrite.ts +0 -51
- package/agent.bak.20260905-190020/extensions/pi-web-access/render-search-error.ts +0 -170
- package/agent.bak.20260905-190020/extensions/pi-web-access/rsc-extract.ts +0 -338
- package/agent.bak.20260905-190020/extensions/pi-web-access/search-types.ts +0 -20
- package/agent.bak.20260905-190020/extensions/pi-web-access/source-check.ts +0 -282
- package/agent.bak.20260905-190020/extensions/pi-web-access/ssrf-protection.ts +0 -526
- package/agent.bak.20260905-190020/extensions/pi-web-access/storage.ts +0 -521
- package/agent.bak.20260905-190020/extensions/pi-web-access/summary-model-scope.ts +0 -125
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/auth-fetch.test.mjs +0 -208
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/brightdata-unlocker.test.mjs +0 -840
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/chrome-cookie-extraction.test.mjs +0 -441
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/config-path.test.mjs +0 -283
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/content-find.test.mjs +0 -25
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/credential-source.test.mjs +0 -118
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/data-uri-sanitize.test.mjs +0 -210
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/datalab-pdf-extract.test.mjs +0 -552
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/declared-web-links.test.mjs +0 -212
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-answer-storage.test.mjs +0 -40
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-cache-storage.test.mjs +0 -334
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-content-domain-policy.test.mjs +0 -95
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-modes.test.mjs +0 -53
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-not-found-guidance.test.mjs +0 -92
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-params.test.mjs +0 -86
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-render-call.test.mjs +0 -34
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/fetch-routing.test.mjs +0 -173
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/gemini-adc-auth.test.mjs +0 -257
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/gemini-api-transport.test.mjs +0 -170
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/gemini-pdf-extract.test.mjs +0 -133
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +0 -178
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/gemini-web-header-overflow.test.mjs +0 -148
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/get-search-content.test.mjs +0 -223
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/github-extract.test.mjs +0 -378
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/github-issue-pr.test.mjs +0 -565
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/inline-content-config.test.mjs +0 -99
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/lazy-extract-load.test.mjs +0 -118
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/local-video-oversize.test.mjs +0 -52
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/package-typebox-dependency.test.mjs +0 -50
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/page-query.test.mjs +0 -51
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/pdf-config.test.mjs +0 -140
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/pdf-extract.test.mjs +0 -500
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/proxy-transport.test.mjs +0 -286
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/query-rewrite.test.mjs +0 -52
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/rsc-fallback.test.mjs +0 -102
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/search-error-render.test.mjs +0 -152
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/search-providers.test.mjs +0 -274
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/source-check.test.mjs +0 -179
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/ssrf-allow-ranges-config.test.mjs +0 -205
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/ssrf-protection.test.mjs +0 -456
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/summary-model-scope.test.mjs +0 -106
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/tool-registration-config.test.mjs +0 -182
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/web-search-answer-render.test.mjs +0 -66
- package/agent.bak.20260905-190020/extensions/pi-web-access/test/youtube-extract-errors.test.mjs +0 -64
- package/agent.bak.20260905-190020/extensions/pi-web-access/tsconfig.json +0 -11
- package/agent.bak.20260905-190020/extensions/pi-web-access/utils.ts +0 -451
- package/agent.bak.20260905-190020/extensions/pi-web-access/video-extract.ts +0 -392
- package/agent.bak.20260905-190020/extensions/pi-web-access/youtube-extract.ts +0 -328
- package/agent.bak.20260905-190020/extensions/shared/activity-status.ts +0 -31
- package/agent.bak.20260905-190020/extensions/shared/child-session.ts +0 -148
- package/agent.bak.20260905-190020/extensions/shared/context-utilization.ts +0 -47
- package/agent.bak.20260905-190020/extensions/shared/dashboard-state.ts +0 -99
- package/agent.bak.20260905-190020/extensions/shared/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/shared/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/shared/test/child-session.test.ts +0 -270
- package/agent.bak.20260905-190020/extensions/shared/test/context-utilization.test.ts +0 -48
- package/agent.bak.20260905-190020/extensions/shared/test/tool-call-timeout.test.ts +0 -117
- package/agent.bak.20260905-190020/extensions/shared/test/widget-order.test.ts +0 -167
- package/agent.bak.20260905-190020/extensions/shared/tool-call-timeout.ts +0 -104
- package/agent.bak.20260905-190020/extensions/skillsconf/README.md +0 -74
- package/agent.bak.20260905-190020/extensions/skillsconf/index.ts +0 -92
- package/agent.bak.20260905-190020/extensions/skillsconf/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/skillsconf/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/skillsconf/package-lock.json +0 -1809
- package/agent.bak.20260905-190020/extensions/skillsconf/package.json +0 -18
- package/agent.bak.20260905-190020/extensions/skillsconf/src/delete-skill.test.ts +0 -64
- package/agent.bak.20260905-190020/extensions/skillsconf/src/delete-skill.ts +0 -45
- package/agent.bak.20260905-190020/extensions/skillsconf/src/filter.test.ts +0 -80
- package/agent.bak.20260905-190020/extensions/skillsconf/src/filter.ts +0 -74
- package/agent.bak.20260905-190020/extensions/skillsconf/src/fuzzy.ts +0 -26
- package/agent.bak.20260905-190020/extensions/skillsconf/src/persistence.test.ts +0 -72
- package/agent.bak.20260905-190020/extensions/skillsconf/src/persistence.ts +0 -169
- package/agent.bak.20260905-190020/extensions/skillsconf/src/ui/SkillConfView.test.ts +0 -337
- package/agent.bak.20260905-190020/extensions/skillsconf/src/ui/SkillConfView.ts +0 -758
- package/agent.bak.20260905-190020/extensions/skillsconf/src/ui/text-input.ts +0 -91
- package/agent.bak.20260905-190020/extensions/skillsconf/src/ui/tui-helpers.ts +0 -144
- package/agent.bak.20260905-190020/extensions/skillsconf/tsconfig.json +0 -15
- package/agent.bak.20260905-190020/extensions/statusline/index.ts +0 -282
- package/agent.bak.20260905-190020/extensions/statusline/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/statusline/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/subagents/docs/design-plan.md +0 -568
- package/agent.bak.20260905-190020/extensions/subagents/docs/effect-v4-extension-guide.md +0 -354
- package/agent.bak.20260905-190020/extensions/subagents/docs/effect-v4-notes.md +0 -571
- package/agent.bak.20260905-190020/extensions/subagents/index.ts +0 -826
- package/agent.bak.20260905-190020/extensions/subagents/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/subagents/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/subagents/package-lock.json +0 -2244
- package/agent.bak.20260905-190020/extensions/subagents/package.json +0 -19
- package/agent.bak.20260905-190020/extensions/subagents/src/backend.ts +0 -73
- package/agent.bak.20260905-190020/extensions/subagents/src/backends/claude.ts +0 -701
- package/agent.bak.20260905-190020/extensions/subagents/src/backends/codex.ts +0 -1060
- package/agent.bak.20260905-190020/extensions/subagents/src/backends/pi.ts +0 -575
- package/agent.bak.20260905-190020/extensions/subagents/src/backends/stub.ts +0 -300
- package/agent.bak.20260905-190020/extensions/subagents/src/by-the-way.ts +0 -21
- package/agent.bak.20260905-190020/extensions/subagents/src/domain.ts +0 -253
- package/agent.bak.20260905-190020/extensions/subagents/src/format.ts +0 -74
- package/agent.bak.20260905-190020/extensions/subagents/src/manager.ts +0 -736
- package/agent.bak.20260905-190020/extensions/subagents/src/prompt.ts +0 -92
- package/agent.bak.20260905-190020/extensions/subagents/src/result-delivery.ts +0 -20
- package/agent.bak.20260905-190020/extensions/subagents/src/runtime.ts +0 -53
- package/agent.bak.20260905-190020/extensions/subagents/src/ui/takeover.ts +0 -583
- package/agent.bak.20260905-190020/extensions/subagents/src/ui/transcript.ts +0 -201
- package/agent.bak.20260905-190020/extensions/subagents/src/widget-order.ts +0 -121
- package/agent.bak.20260905-190020/extensions/subagents/test/by-the-way.test.ts +0 -29
- package/agent.bak.20260905-190020/extensions/subagents/test/claude.test.ts +0 -119
- package/agent.bak.20260905-190020/extensions/subagents/test/codex.test.ts +0 -102
- package/agent.bak.20260905-190020/extensions/subagents/test/context-usage.test.ts +0 -107
- package/agent.bak.20260905-190020/extensions/subagents/test/manager.test.ts +0 -276
- package/agent.bak.20260905-190020/extensions/subagents/test/result-delivery.test.ts +0 -27
- package/agent.bak.20260905-190020/extensions/subagents/test/takeover.test.ts +0 -29
- package/agent.bak.20260905-190020/extensions/subagents/tsconfig.json +0 -7
- package/agent.bak.20260905-190020/extensions/taste/index.ts +0 -443
- package/agent.bak.20260905-190020/extensions/taste/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/taste/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/todo/AGENTS.md +0 -38
- package/agent.bak.20260905-190020/extensions/todo/LICENSE +0 -21
- package/agent.bak.20260905-190020/extensions/todo/config.ts +0 -55
- package/agent.bak.20260905-190020/extensions/todo/index.ts +0 -151
- package/agent.bak.20260905-190020/extensions/todo/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/todo/install.sh +0 -21
- package/agent.bak.20260905-190020/extensions/todo/locales/de.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/en.json +0 -15
- package/agent.bak.20260905-190020/extensions/todo/locales/es.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/fr.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/pt-BR.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/pt.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/ru.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/uk.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/locales/zh.json +0 -17
- package/agent.bak.20260905-190020/extensions/todo/package-lock.json +0 -3358
- package/agent.bak.20260905-190020/extensions/todo/package.json +0 -67
- package/agent.bak.20260905-190020/extensions/todo/state/i18n-bridge.ts +0 -64
- package/agent.bak.20260905-190020/extensions/todo/state/invariants.ts +0 -20
- package/agent.bak.20260905-190020/extensions/todo/state/replay.ts +0 -38
- package/agent.bak.20260905-190020/extensions/todo/state/selectors.ts +0 -107
- package/agent.bak.20260905-190020/extensions/todo/state/state-reducer.ts +0 -326
- package/agent.bak.20260905-190020/extensions/todo/state/state.ts +0 -18
- package/agent.bak.20260905-190020/extensions/todo/state/store.ts +0 -82
- package/agent.bak.20260905-190020/extensions/todo/state/task-graph.ts +0 -57
- package/agent.bak.20260905-190020/extensions/todo/todo-overlay.ts +0 -204
- package/agent.bak.20260905-190020/extensions/todo/todo.ts +0 -155
- package/agent.bak.20260905-190020/extensions/todo/tool/response-envelope.ts +0 -109
- package/agent.bak.20260905-190020/extensions/todo/tool/types.ts +0 -206
- package/agent.bak.20260905-190020/extensions/todo/view/format.ts +0 -177
- package/agent.bak.20260905-190020/extensions/todo/widget-order.ts +0 -121
- package/agent.bak.20260905-190020/extensions/trim-context/README.md +0 -54
- package/agent.bak.20260905-190020/extensions/trim-context/index.ts +0 -487
- package/agent.bak.20260905-190020/extensions/trim-context/install.ps1 +0 -23
- package/agent.bak.20260905-190020/extensions/trim-context/install.sh +0 -21
- package/agent.bak.20260905-190020/keybindings.json +0 -7
|
@@ -1,441 +1,441 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
3
|
-
import { createCipheriv, createHash } from "node:crypto";
|
|
4
|
-
import { chmodSync, existsSync, mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, symlinkSync } from "node:fs";
|
|
5
|
-
import { homedir, tmpdir } from "node:os";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { test } from "node:test";
|
|
8
|
-
|
|
9
|
-
const moduleUrl = new URL("../chrome-cookies.ts", import.meta.url).href;
|
|
10
|
-
const python = process.platform === "win32" ? null : "python3";
|
|
11
|
-
|
|
12
|
-
function createFixture(home, profile, rows = [], options = {}) {
|
|
13
|
-
if (!python) return;
|
|
14
|
-
const { browser = "Chrome", targetPlatform = process.platform } = options;
|
|
15
|
-
const base = targetPlatform === "darwin"
|
|
16
|
-
? browser === "Brave"
|
|
17
|
-
? join(home, "Library", "Application Support", "BraveSoftware", "Brave-Browser")
|
|
18
|
-
: browser === "Helium"
|
|
19
|
-
? join(home, "Library", "Application Support", "net.imput.helium")
|
|
20
|
-
: browser === "Arc"
|
|
21
|
-
? join(home, "Library", "Application Support", "Arc", "User Data")
|
|
22
|
-
: join(home, "Library", "Application Support", "Google", "Chrome")
|
|
23
|
-
: targetPlatform === "win32"
|
|
24
|
-
? browser === "Edge"
|
|
25
|
-
? join(home, "AppData", "Local", "Microsoft", "Edge", "User Data")
|
|
26
|
-
: join(home, "AppData", "Local", "Google", "Chrome", "User Data")
|
|
27
|
-
: join(home, ".config", "google-chrome");
|
|
28
|
-
const dbPath = targetPlatform === "win32" ? join(base, profile, "Network", "Cookies") : join(base, profile, "Cookies");
|
|
29
|
-
mkdirSync(dirname(dbPath), { recursive: true });
|
|
30
|
-
execFileSync(python, ["-c", `
|
|
31
|
-
import json, sqlite3, sys
|
|
32
|
-
c = sqlite3.connect(sys.argv[1])
|
|
33
|
-
c.execute("create table meta (key text, value integer)")
|
|
34
|
-
c.execute("insert into meta values ('version', 24)")
|
|
35
|
-
c.execute("create table cookies (name text, value text, host_key text, encrypted_value blob, expires_utc integer)")
|
|
36
|
-
for row in json.loads(sys.argv[2]):
|
|
37
|
-
encrypted = bytes.fromhex(row[3][4:]) if isinstance(row[3], str) and row[3].startswith('hex:') else row[3]
|
|
38
|
-
c.execute("insert into cookies values (?, ?, ?, ?, ?)", [row[0], row[1], row[2], encrypted, row[4]])
|
|
39
|
-
c.commit()
|
|
40
|
-
c.close()
|
|
41
|
-
`, dbPath, JSON.stringify(rows)], { stdio: "ignore" });
|
|
42
|
-
if (options.windowsKey) {
|
|
43
|
-
writeFileSync(join(base, "Local State"), JSON.stringify({ os_crypt: { encrypted_key: Buffer.concat([Buffer.from("DPAPI"), Buffer.from("protected")]).toString("base64") } }));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function encryptWindowsCookie(value, key, version = "v10", hostKey) {
|
|
48
|
-
const nonce = Buffer.alloc(12, 7);
|
|
49
|
-
const cipher = createCipheriv("aes-256-gcm", key, nonce);
|
|
50
|
-
const plaintext = hostKey ? Buffer.concat([createHash("sha256").update(hostKey).digest(), Buffer.from(value)]) : Buffer.from(value);
|
|
51
|
-
return Buffer.concat([Buffer.from(version), nonce, cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]).toString("hex");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function writeWindowsDpapiCommand(bin, argsPath) {
|
|
55
|
-
const script = "#!/bin/sh\n[ -n \"$ARGS_FILE\" ] && printf '%s\\n' \"$@\" > \"$ARGS_FILE\"\nencoded=0\nfor arg do [ \"$arg\" = \"-EncodedCommand\" ] && encoded=1; [ \"$arg\" = \"$DPAPI_PROTECTED\" ] && exit 1; done\n[ \"$encoded\" = 1 ] || exit 1\n[ \"$PIWA_PROTECTED\" = \"$DPAPI_PROTECTED\" ] || exit 1\nprintf '%s' \"$DPAPI_KEY\"\n";
|
|
56
|
-
writeFileSync(join(bin, "powershell.exe"), script);
|
|
57
|
-
chmodSync(join(bin, "powershell.exe"), 0o755);
|
|
58
|
-
return argsPath ? { ARGS_FILE: argsPath } : {};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function makeEnvironment(home, bin, extra = {}) {
|
|
62
|
-
const env = {
|
|
63
|
-
...process.env,
|
|
64
|
-
HOME: home,
|
|
65
|
-
USERPROFILE: home,
|
|
66
|
-
PI_ALLOW_BROWSER_COOKIES: "1",
|
|
67
|
-
PATH: `${bin}:${process.env.PATH ?? ""}`,
|
|
68
|
-
...extra,
|
|
69
|
-
};
|
|
70
|
-
delete env.PI_CODING_AGENT_DIR;
|
|
71
|
-
delete env.XDG_CONFIG_HOME;
|
|
72
|
-
return env;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function writePasswordCommand(bin, countPath, targetPlatform = process.platform, argsPath) {
|
|
76
|
-
const command = targetPlatform === "darwin" ? "security" : "secret-tool";
|
|
77
|
-
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\n[ -n "$ARGS_FILE" ] && printf '%s\\n' "$@" > "$ARGS_FILE"\nprintf peanuts\n`;
|
|
78
|
-
writeFileSync(join(bin, command), script);
|
|
79
|
-
chmodSync(join(bin, command), 0o755);
|
|
80
|
-
return { COUNT_FILE: countPath, ...(argsPath ? { ARGS_FILE: argsPath } : {}) };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function writeFailThenSucceedPasswordCommand(bin, countPath) {
|
|
84
|
-
const command = process.platform === "darwin" ? "security" : "secret-tool";
|
|
85
|
-
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nn=$((n + 1))\nprintf '%s' $n > "$COUNT_FILE"\n[ "$n" = 1 ] && exit 1\nprintf peanuts\n`;
|
|
86
|
-
writeFileSync(join(bin, command), script);
|
|
87
|
-
chmodSync(join(bin, command), 0o755);
|
|
88
|
-
return { COUNT_FILE: countPath };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function writeFailPasswordCommand(bin, countPath, targetPlatform = process.platform) {
|
|
92
|
-
const command = targetPlatform === "darwin" ? "security" : "secret-tool";
|
|
93
|
-
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\nprintf 'sensitive stderr' >&2\nexit 1\n`;
|
|
94
|
-
writeFileSync(join(bin, command), script);
|
|
95
|
-
chmodSync(join(bin, command), 0o755);
|
|
96
|
-
return { COUNT_FILE: countPath };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function runCookies(home, env, options = "{ requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", platformOverride) {
|
|
100
|
-
return runCookieScript(env, `const r = await m.getGoogleCookies(${options}); console.log(JSON.stringify({ result: r, diagnostic: m.getLastGoogleCookieDiagnostic(), details: m.getLastGoogleCookieDiagnosticDetails() }));`, platformOverride);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function runCookieScript(env, body, platformOverride) {
|
|
104
|
-
const override = platformOverride
|
|
105
|
-
? `Object.defineProperty(process, "platform", { value: ${JSON.stringify(platformOverride)} }); `
|
|
106
|
-
: "";
|
|
107
|
-
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
108
|
-
encoding: "utf8",
|
|
109
|
-
env,
|
|
110
|
-
input: `${override}const m = await import(${JSON.stringify(moduleUrl)}); ${body}`,
|
|
111
|
-
});
|
|
112
|
-
assert.equal(child.status, 0, child.stderr);
|
|
113
|
-
return JSON.parse(child.stdout);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function skipWithoutPython(t) {
|
|
117
|
-
if (!python) t.skip("fixture creation requires Python on macOS/Linux");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
test("cookie extraction remains opt-in even when a browser database exists", (t) => {
|
|
121
|
-
skipWithoutPython(t);
|
|
122
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-opt-out-"));
|
|
123
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
124
|
-
createFixture(home, "Default", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
|
|
125
|
-
const env = makeEnvironment(home, bin);
|
|
126
|
-
delete env.PI_ALLOW_BROWSER_COOKIES;
|
|
127
|
-
const result = runCookies(home, env);
|
|
128
|
-
assert.equal(result.result, null);
|
|
129
|
-
assert.match(result.diagnostic, /disabled/);
|
|
130
|
-
rmSync(home, { recursive: true, force: true });
|
|
131
|
-
rmSync(bin, { recursive: true, force: true });
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test("auto-discovery finds a non-default Chromium profile", (t) => {
|
|
135
|
-
skipWithoutPython(t);
|
|
136
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-"));
|
|
137
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
138
|
-
createFixture(home, "Profile 2", [
|
|
139
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
140
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
141
|
-
]);
|
|
142
|
-
const env = makeEnvironment(home, bin);
|
|
143
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
144
|
-
const result = runCookies(home, env);
|
|
145
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
146
|
-
rmSync(home, { recursive: true, force: true });
|
|
147
|
-
rmSync(bin, { recursive: true, force: true });
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("auto-discovery finds a Brave profile on macOS", (t) => {
|
|
151
|
-
skipWithoutPython(t);
|
|
152
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-brave-profile-"));
|
|
153
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
154
|
-
createFixture(home, "Default", [
|
|
155
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
156
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
157
|
-
], { browser: "Brave", targetPlatform: "darwin" });
|
|
158
|
-
const env = makeEnvironment(home, bin);
|
|
159
|
-
const argsPath = join(home, "password-args");
|
|
160
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
|
|
161
|
-
const result = runCookies(home, env, undefined, "darwin");
|
|
162
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
163
|
-
assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
|
|
164
|
-
"find-generic-password", "-w", "-a", "Brave", "-s", "Brave Safe Storage",
|
|
165
|
-
]);
|
|
166
|
-
rmSync(home, { recursive: true, force: true });
|
|
167
|
-
rmSync(bin, { recursive: true, force: true });
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("browser selection checks only the requested preset", (t) => {
|
|
171
|
-
skipWithoutPython(t);
|
|
172
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-selected-browser-"));
|
|
173
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
174
|
-
createFixture(home, "Profile 1", [
|
|
175
|
-
["__Secure-1PSID", "helium-one", ".google.com", null, 1],
|
|
176
|
-
["__Secure-1PSIDTS", "helium-two", ".google.com", null, 2],
|
|
177
|
-
], { browser: "Helium", targetPlatform: "darwin" });
|
|
178
|
-
createFixture(home, "Profile 1", [
|
|
179
|
-
["__Secure-1PSID", "chrome-one", ".google.com", null, 1],
|
|
180
|
-
["__Secure-1PSIDTS", "chrome-two", ".google.com", null, 2],
|
|
181
|
-
], { browser: "Chrome", targetPlatform: "darwin" });
|
|
182
|
-
const env = makeEnvironment(home, bin);
|
|
183
|
-
const argsPath = join(home, "password-args");
|
|
184
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
|
|
185
|
-
const result = runCookies(home, env, "{ browser: 'helium', profile: 'Profile 1', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", "darwin");
|
|
186
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "helium-two", "__Secure-1PSID": "helium-one" });
|
|
187
|
-
assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
|
|
188
|
-
"find-generic-password", "-w", "-a", "Helium", "-s", "Helium Storage Key",
|
|
189
|
-
]);
|
|
190
|
-
rmSync(home, { recursive: true, force: true });
|
|
191
|
-
rmSync(bin, { recursive: true, force: true });
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
test("Windows Chrome profiles decrypt v10 cookies with DPAPI keys", (t) => {
|
|
195
|
-
skipWithoutPython(t);
|
|
196
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-"));
|
|
197
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
198
|
-
const argsPath = join(home, "powershell-args");
|
|
199
|
-
const key = Buffer.alloc(32, 3);
|
|
200
|
-
createFixture(home, "Default", [
|
|
201
|
-
["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v10", ".google.com")}`, 1],
|
|
202
|
-
["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v10", ".google.com")}`, 2],
|
|
203
|
-
], { targetPlatform: "win32", windowsKey: key });
|
|
204
|
-
const protectedValue = Buffer.from("protected").toString("base64");
|
|
205
|
-
const env = makeEnvironment(home, bin, { LOCALAPPDATA: join(home, "AppData", "Local"), DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: protectedValue, TEMP: tmpdir(), TMP: tmpdir(), ...writeWindowsDpapiCommand(bin, argsPath) });
|
|
206
|
-
const result = runCookies(home, env, undefined, "win32");
|
|
207
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
208
|
-
const args = readFileSync(argsPath, "utf8").trim().split("\n");
|
|
209
|
-
assert.equal(args.includes("-EncodedCommand"), true);
|
|
210
|
-
assert.equal(args.includes(protectedValue), false);
|
|
211
|
-
rmSync(home, { recursive: true, force: true });
|
|
212
|
-
rmSync(bin, { recursive: true, force: true });
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test("cookie queries keep high Chromium expiry values safe", (t) => {
|
|
216
|
-
skipWithoutPython(t);
|
|
217
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-high-expiry-"));
|
|
218
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
219
|
-
createFixture(home, "Profile 2", [
|
|
220
|
-
["__Secure-1PSID", "expired", ".google.com", null, 1],
|
|
221
|
-
["__Secure-1PSID", "future", ".google.com", null, "9223372036854775807"],
|
|
222
|
-
["__Secure-1PSIDTS", "session", ".google.com", null, 0],
|
|
223
|
-
]);
|
|
224
|
-
const env = makeEnvironment(home, bin);
|
|
225
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
226
|
-
const result = runCookieScript(env, "const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));");
|
|
227
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
|
|
228
|
-
rmSync(home, { recursive: true, force: true });
|
|
229
|
-
rmSync(bin, { recursive: true, force: true });
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test("cookie expiry filtering preserves same-second validity", (t) => {
|
|
233
|
-
skipWithoutPython(t);
|
|
234
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-subsecond-expiry-"));
|
|
235
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
236
|
-
const nowMs = 1_700_000_000_500;
|
|
237
|
-
const sameSecondFutureChromeMicros = (nowMs + 400 + 11644473600000) * 1000;
|
|
238
|
-
createFixture(home, "Profile 2", [
|
|
239
|
-
["__Secure-1PSID", "future", ".google.com", null, sameSecondFutureChromeMicros],
|
|
240
|
-
["__Secure-1PSIDTS", "session", ".google.com", null, 0],
|
|
241
|
-
]);
|
|
242
|
-
const env = makeEnvironment(home, bin);
|
|
243
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
244
|
-
const result = runCookieScript(env, `Date.now = () => ${nowMs}; const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));`);
|
|
245
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
|
|
246
|
-
rmSync(home, { recursive: true, force: true });
|
|
247
|
-
rmSync(bin, { recursive: true, force: true });
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
test("Windows Edge uses the USERPROFILE AppData fallback and reports unsupported v20 cookies", (t) => {
|
|
251
|
-
skipWithoutPython(t);
|
|
252
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-edge-"));
|
|
253
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
254
|
-
const key = Buffer.alloc(32, 4);
|
|
255
|
-
createFixture(home, "Default", [
|
|
256
|
-
["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v20")}`, 1],
|
|
257
|
-
["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v20")}`, 2],
|
|
258
|
-
], { browser: "Edge", targetPlatform: "win32", windowsKey: key });
|
|
259
|
-
const env = makeEnvironment(home, bin, { DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: Buffer.from("protected").toString("base64"), TEMP: tmpdir(), TMP: tmpdir() });
|
|
260
|
-
delete env.LOCALAPPDATA;
|
|
261
|
-
writeWindowsDpapiCommand(bin);
|
|
262
|
-
const result = runCookies(home, env, undefined, "win32");
|
|
263
|
-
assert.equal(result.result, null);
|
|
264
|
-
assert.match(result.diagnostic, /v20 app-bound cookies are not supported/);
|
|
265
|
-
rmSync(home, { recursive: true, force: true });
|
|
266
|
-
rmSync(bin, { recursive: true, force: true });
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test("required-cookie preflight avoids password invocation for unrelated profiles", (t) => {
|
|
270
|
-
skipWithoutPython(t);
|
|
271
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-preflight-"));
|
|
272
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
273
|
-
createFixture(home, "Profile 1", [["NID", "unrelated", ".google.com", null, 1]]);
|
|
274
|
-
const countPath = join(home, "password-count");
|
|
275
|
-
const env = makeEnvironment(home, bin);
|
|
276
|
-
Object.assign(env, writePasswordCommand(bin, countPath));
|
|
277
|
-
const result = runCookies(home, env);
|
|
278
|
-
assert.equal(result.result, null);
|
|
279
|
-
assert.equal(result.diagnostic.includes("required Gemini cookies"), true);
|
|
280
|
-
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 1" && attempt.status === "missing-required-cookies"), true);
|
|
281
|
-
assert.equal(existsSync(countPath), false);
|
|
282
|
-
rmSync(home, { recursive: true, force: true });
|
|
283
|
-
rmSync(bin, { recursive: true, force: true });
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test("diagnostics report browser profile when password-store access fails", (t) => {
|
|
287
|
-
skipWithoutPython(t);
|
|
288
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-keychain-failure-"));
|
|
289
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
290
|
-
createFixture(home, "Default", [
|
|
291
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
292
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
293
|
-
], { browser: "Helium", targetPlatform: "darwin" });
|
|
294
|
-
const env = makeEnvironment(home, bin);
|
|
295
|
-
Object.assign(env, writeFailPasswordCommand(bin, join(home, "password-count"), "darwin"));
|
|
296
|
-
const result = runCookies(home, env, undefined, "darwin");
|
|
297
|
-
assert.equal(result.result, null);
|
|
298
|
-
assert.equal(result.diagnostic, "Could not read Helium cookie encryption password");
|
|
299
|
-
assert.deepEqual(result.details.attempts[0], { browser: "Helium", profile: "Default", status: "password-read-failed" });
|
|
300
|
-
assert.doesNotMatch(JSON.stringify(result), /one|two|peanuts|sensitive stderr/);
|
|
301
|
-
rmSync(home, { recursive: true, force: true });
|
|
302
|
-
rmSync(bin, { recursive: true, force: true });
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test("diagnostics distinguish required cookie decryption failure", (t) => {
|
|
306
|
-
skipWithoutPython(t);
|
|
307
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-decrypt-failure-"));
|
|
308
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
309
|
-
const encrypted = `hex:${Buffer.from("v10bad-ciphertext").toString("hex")}`;
|
|
310
|
-
createFixture(home, "Profile 2", [
|
|
311
|
-
["__Secure-1PSID", "", ".google.com", encrypted, 1],
|
|
312
|
-
["__Secure-1PSIDTS", "", ".google.com", encrypted, 2],
|
|
313
|
-
]);
|
|
314
|
-
const env = makeEnvironment(home, bin);
|
|
315
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
316
|
-
const result = runCookies(home, env);
|
|
317
|
-
assert.equal(result.result, null);
|
|
318
|
-
assert.match(result.diagnostic, /could not be decrypted/);
|
|
319
|
-
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "decryption-failed"), true);
|
|
320
|
-
assert.doesNotMatch(JSON.stringify(result), /peanuts|bad-ciphertext/);
|
|
321
|
-
rmSync(home, { recursive: true, force: true });
|
|
322
|
-
rmSync(bin, { recursive: true, force: true });
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
test("browser encryption password is cached within a process", (t) => {
|
|
326
|
-
skipWithoutPython(t);
|
|
327
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-"));
|
|
328
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
329
|
-
createFixture(home, "Profile 2", [
|
|
330
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
331
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
332
|
-
]);
|
|
333
|
-
const countPath = join(home, "password-count");
|
|
334
|
-
const env = makeEnvironment(home, bin);
|
|
335
|
-
Object.assign(env, writePasswordCommand(bin, countPath));
|
|
336
|
-
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
337
|
-
encoding: "utf8",
|
|
338
|
-
env,
|
|
339
|
-
input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] });`,
|
|
340
|
-
});
|
|
341
|
-
assert.equal(child.status, 0, child.stderr);
|
|
342
|
-
assert.equal(readFileSync(countPath, "utf8"), "1");
|
|
343
|
-
rmSync(home, { recursive: true, force: true });
|
|
344
|
-
rmSync(bin, { recursive: true, force: true });
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
test("failed password lookups are retried instead of cached", (t) => {
|
|
348
|
-
skipWithoutPython(t);
|
|
349
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-failure-"));
|
|
350
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
351
|
-
createFixture(home, "Profile 2", [
|
|
352
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
353
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
354
|
-
]);
|
|
355
|
-
const countPath = join(home, "password-count");
|
|
356
|
-
const env = makeEnvironment(home, bin);
|
|
357
|
-
Object.assign(env, writeFailThenSucceedPasswordCommand(bin, countPath));
|
|
358
|
-
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
359
|
-
encoding: "utf8",
|
|
360
|
-
env,
|
|
361
|
-
input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); const options = { profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }; const first = await getGoogleCookies(options); const second = await getGoogleCookies(options); console.log(JSON.stringify({ first, second }));`,
|
|
362
|
-
});
|
|
363
|
-
assert.equal(child.status, 0, child.stderr);
|
|
364
|
-
const result = JSON.parse(child.stdout);
|
|
365
|
-
assert.equal(result.first, null);
|
|
366
|
-
assert.deepEqual(result.second.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
367
|
-
assert.equal(readFileSync(countPath, "utf8"), "2");
|
|
368
|
-
rmSync(home, { recursive: true, force: true });
|
|
369
|
-
rmSync(bin, { recursive: true, force: true });
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test("configured profile names cannot escape the browser profile root", (t) => {
|
|
373
|
-
skipWithoutPython(t);
|
|
374
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-traversal-"));
|
|
375
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
376
|
-
const env = makeEnvironment(home, bin);
|
|
377
|
-
const result = runCookies(home, env, "{ profile: '../Profile 2', requiredCookies: ['__Secure-1PSID'] }");
|
|
378
|
-
assert.equal(result.result, null);
|
|
379
|
-
assert.match(result.diagnostic, /profile directory name/);
|
|
380
|
-
rmSync(home, { recursive: true, force: true });
|
|
381
|
-
rmSync(bin, { recursive: true, force: true });
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test("explicit profile symlinks cannot escape the browser profile root", (t) => {
|
|
385
|
-
skipWithoutPython(t);
|
|
386
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-symlink-"));
|
|
387
|
-
const outsideHome = mkdtempSync(join(tmpdir(), "pi-cookie-outside-"));
|
|
388
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
389
|
-
createFixture(outsideHome, "Outside", [
|
|
390
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
391
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
392
|
-
]);
|
|
393
|
-
const browserRoot = process.platform === "darwin"
|
|
394
|
-
? join(home, "Library", "Application Support", "Google", "Chrome")
|
|
395
|
-
: join(home, ".config", "google-chrome");
|
|
396
|
-
const outsideProfile = process.platform === "darwin"
|
|
397
|
-
? join(outsideHome, "Library", "Application Support", "Google", "Chrome", "Outside")
|
|
398
|
-
: join(outsideHome, ".config", "google-chrome", "Outside");
|
|
399
|
-
mkdirSync(browserRoot, { recursive: true });
|
|
400
|
-
symlinkSync(outsideProfile, join(browserRoot, "link"), "dir");
|
|
401
|
-
const env = makeEnvironment(home, bin);
|
|
402
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
403
|
-
const result = runCookies(home, env, "{ profile: 'link', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }");
|
|
404
|
-
assert.equal(result.result, null);
|
|
405
|
-
assert.match(result.diagnostic, /inside the browser profile root/);
|
|
406
|
-
rmSync(home, { recursive: true, force: true });
|
|
407
|
-
rmSync(outsideHome, { recursive: true, force: true });
|
|
408
|
-
rmSync(bin, { recursive: true, force: true });
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
test("sqlite3 CLI fallback reads a copied database when node sqlite is unavailable", (t) => {
|
|
412
|
-
skipWithoutPython(t);
|
|
413
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-fallback-"));
|
|
414
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
415
|
-
createFixture(home, "Profile 2", [
|
|
416
|
-
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
417
|
-
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
418
|
-
]);
|
|
419
|
-
const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1" });
|
|
420
|
-
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
421
|
-
const result = runCookies(home, env);
|
|
422
|
-
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
423
|
-
rmSync(home, { recursive: true, force: true });
|
|
424
|
-
rmSync(bin, { recursive: true, force: true });
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
test("unavailable SQLite backends produce actionable sanitized diagnostics", (t) => {
|
|
428
|
-
skipWithoutPython(t);
|
|
429
|
-
const home = mkdtempSync(join(tmpdir(), "pi-cookie-diagnostic-"));
|
|
430
|
-
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
431
|
-
createFixture(home, "Profile 2", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
|
|
432
|
-
const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1", PATH: bin });
|
|
433
|
-
const result = runCookies(home, env);
|
|
434
|
-
assert.equal(result.result, null);
|
|
435
|
-
assert.match(result.diagnostic, /SQLite backend unavailable/);
|
|
436
|
-
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "sqlite-unavailable"), true);
|
|
437
|
-
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "missing-required-cookies"), false);
|
|
438
|
-
assert.doesNotMatch(result.diagnostic, /one|peanuts|stderr|password/i);
|
|
439
|
-
rmSync(home, { recursive: true, force: true });
|
|
440
|
-
rmSync(bin, { recursive: true, force: true });
|
|
441
|
-
});
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
3
|
+
import { createCipheriv, createHash } from "node:crypto";
|
|
4
|
+
import { chmodSync, existsSync, mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, symlinkSync } from "node:fs";
|
|
5
|
+
import { homedir, tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { test } from "node:test";
|
|
8
|
+
|
|
9
|
+
const moduleUrl = new URL("../chrome-cookies.ts", import.meta.url).href;
|
|
10
|
+
const python = process.platform === "win32" ? null : "python3";
|
|
11
|
+
|
|
12
|
+
function createFixture(home, profile, rows = [], options = {}) {
|
|
13
|
+
if (!python) return;
|
|
14
|
+
const { browser = "Chrome", targetPlatform = process.platform } = options;
|
|
15
|
+
const base = targetPlatform === "darwin"
|
|
16
|
+
? browser === "Brave"
|
|
17
|
+
? join(home, "Library", "Application Support", "BraveSoftware", "Brave-Browser")
|
|
18
|
+
: browser === "Helium"
|
|
19
|
+
? join(home, "Library", "Application Support", "net.imput.helium")
|
|
20
|
+
: browser === "Arc"
|
|
21
|
+
? join(home, "Library", "Application Support", "Arc", "User Data")
|
|
22
|
+
: join(home, "Library", "Application Support", "Google", "Chrome")
|
|
23
|
+
: targetPlatform === "win32"
|
|
24
|
+
? browser === "Edge"
|
|
25
|
+
? join(home, "AppData", "Local", "Microsoft", "Edge", "User Data")
|
|
26
|
+
: join(home, "AppData", "Local", "Google", "Chrome", "User Data")
|
|
27
|
+
: join(home, ".config", "google-chrome");
|
|
28
|
+
const dbPath = targetPlatform === "win32" ? join(base, profile, "Network", "Cookies") : join(base, profile, "Cookies");
|
|
29
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
30
|
+
execFileSync(python, ["-c", `
|
|
31
|
+
import json, sqlite3, sys
|
|
32
|
+
c = sqlite3.connect(sys.argv[1])
|
|
33
|
+
c.execute("create table meta (key text, value integer)")
|
|
34
|
+
c.execute("insert into meta values ('version', 24)")
|
|
35
|
+
c.execute("create table cookies (name text, value text, host_key text, encrypted_value blob, expires_utc integer)")
|
|
36
|
+
for row in json.loads(sys.argv[2]):
|
|
37
|
+
encrypted = bytes.fromhex(row[3][4:]) if isinstance(row[3], str) and row[3].startswith('hex:') else row[3]
|
|
38
|
+
c.execute("insert into cookies values (?, ?, ?, ?, ?)", [row[0], row[1], row[2], encrypted, row[4]])
|
|
39
|
+
c.commit()
|
|
40
|
+
c.close()
|
|
41
|
+
`, dbPath, JSON.stringify(rows)], { stdio: "ignore" });
|
|
42
|
+
if (options.windowsKey) {
|
|
43
|
+
writeFileSync(join(base, "Local State"), JSON.stringify({ os_crypt: { encrypted_key: Buffer.concat([Buffer.from("DPAPI"), Buffer.from("protected")]).toString("base64") } }));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function encryptWindowsCookie(value, key, version = "v10", hostKey) {
|
|
48
|
+
const nonce = Buffer.alloc(12, 7);
|
|
49
|
+
const cipher = createCipheriv("aes-256-gcm", key, nonce);
|
|
50
|
+
const plaintext = hostKey ? Buffer.concat([createHash("sha256").update(hostKey).digest(), Buffer.from(value)]) : Buffer.from(value);
|
|
51
|
+
return Buffer.concat([Buffer.from(version), nonce, cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]).toString("hex");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function writeWindowsDpapiCommand(bin, argsPath) {
|
|
55
|
+
const script = "#!/bin/sh\n[ -n \"$ARGS_FILE\" ] && printf '%s\\n' \"$@\" > \"$ARGS_FILE\"\nencoded=0\nfor arg do [ \"$arg\" = \"-EncodedCommand\" ] && encoded=1; [ \"$arg\" = \"$DPAPI_PROTECTED\" ] && exit 1; done\n[ \"$encoded\" = 1 ] || exit 1\n[ \"$PIWA_PROTECTED\" = \"$DPAPI_PROTECTED\" ] || exit 1\nprintf '%s' \"$DPAPI_KEY\"\n";
|
|
56
|
+
writeFileSync(join(bin, "powershell.exe"), script);
|
|
57
|
+
chmodSync(join(bin, "powershell.exe"), 0o755);
|
|
58
|
+
return argsPath ? { ARGS_FILE: argsPath } : {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function makeEnvironment(home, bin, extra = {}) {
|
|
62
|
+
const env = {
|
|
63
|
+
...process.env,
|
|
64
|
+
HOME: home,
|
|
65
|
+
USERPROFILE: home,
|
|
66
|
+
PI_ALLOW_BROWSER_COOKIES: "1",
|
|
67
|
+
PATH: `${bin}:${process.env.PATH ?? ""}`,
|
|
68
|
+
...extra,
|
|
69
|
+
};
|
|
70
|
+
delete env.PI_CODING_AGENT_DIR;
|
|
71
|
+
delete env.XDG_CONFIG_HOME;
|
|
72
|
+
return env;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function writePasswordCommand(bin, countPath, targetPlatform = process.platform, argsPath) {
|
|
76
|
+
const command = targetPlatform === "darwin" ? "security" : "secret-tool";
|
|
77
|
+
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\n[ -n "$ARGS_FILE" ] && printf '%s\\n' "$@" > "$ARGS_FILE"\nprintf peanuts\n`;
|
|
78
|
+
writeFileSync(join(bin, command), script);
|
|
79
|
+
chmodSync(join(bin, command), 0o755);
|
|
80
|
+
return { COUNT_FILE: countPath, ...(argsPath ? { ARGS_FILE: argsPath } : {}) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function writeFailThenSucceedPasswordCommand(bin, countPath) {
|
|
84
|
+
const command = process.platform === "darwin" ? "security" : "secret-tool";
|
|
85
|
+
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nn=$((n + 1))\nprintf '%s' $n > "$COUNT_FILE"\n[ "$n" = 1 ] && exit 1\nprintf peanuts\n`;
|
|
86
|
+
writeFileSync(join(bin, command), script);
|
|
87
|
+
chmodSync(join(bin, command), 0o755);
|
|
88
|
+
return { COUNT_FILE: countPath };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function writeFailPasswordCommand(bin, countPath, targetPlatform = process.platform) {
|
|
92
|
+
const command = targetPlatform === "darwin" ? "security" : "secret-tool";
|
|
93
|
+
const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\nprintf 'sensitive stderr' >&2\nexit 1\n`;
|
|
94
|
+
writeFileSync(join(bin, command), script);
|
|
95
|
+
chmodSync(join(bin, command), 0o755);
|
|
96
|
+
return { COUNT_FILE: countPath };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function runCookies(home, env, options = "{ requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", platformOverride) {
|
|
100
|
+
return runCookieScript(env, `const r = await m.getGoogleCookies(${options}); console.log(JSON.stringify({ result: r, diagnostic: m.getLastGoogleCookieDiagnostic(), details: m.getLastGoogleCookieDiagnosticDetails() }));`, platformOverride);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function runCookieScript(env, body, platformOverride) {
|
|
104
|
+
const override = platformOverride
|
|
105
|
+
? `Object.defineProperty(process, "platform", { value: ${JSON.stringify(platformOverride)} }); `
|
|
106
|
+
: "";
|
|
107
|
+
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
108
|
+
encoding: "utf8",
|
|
109
|
+
env,
|
|
110
|
+
input: `${override}const m = await import(${JSON.stringify(moduleUrl)}); ${body}`,
|
|
111
|
+
});
|
|
112
|
+
assert.equal(child.status, 0, child.stderr);
|
|
113
|
+
return JSON.parse(child.stdout);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function skipWithoutPython(t) {
|
|
117
|
+
if (!python) t.skip("fixture creation requires Python on macOS/Linux");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
test("cookie extraction remains opt-in even when a browser database exists", (t) => {
|
|
121
|
+
skipWithoutPython(t);
|
|
122
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-opt-out-"));
|
|
123
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
124
|
+
createFixture(home, "Default", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
|
|
125
|
+
const env = makeEnvironment(home, bin);
|
|
126
|
+
delete env.PI_ALLOW_BROWSER_COOKIES;
|
|
127
|
+
const result = runCookies(home, env);
|
|
128
|
+
assert.equal(result.result, null);
|
|
129
|
+
assert.match(result.diagnostic, /disabled/);
|
|
130
|
+
rmSync(home, { recursive: true, force: true });
|
|
131
|
+
rmSync(bin, { recursive: true, force: true });
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("auto-discovery finds a non-default Chromium profile", (t) => {
|
|
135
|
+
skipWithoutPython(t);
|
|
136
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-"));
|
|
137
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
138
|
+
createFixture(home, "Profile 2", [
|
|
139
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
140
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
141
|
+
]);
|
|
142
|
+
const env = makeEnvironment(home, bin);
|
|
143
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
144
|
+
const result = runCookies(home, env);
|
|
145
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
146
|
+
rmSync(home, { recursive: true, force: true });
|
|
147
|
+
rmSync(bin, { recursive: true, force: true });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("auto-discovery finds a Brave profile on macOS", (t) => {
|
|
151
|
+
skipWithoutPython(t);
|
|
152
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-brave-profile-"));
|
|
153
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
154
|
+
createFixture(home, "Default", [
|
|
155
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
156
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
157
|
+
], { browser: "Brave", targetPlatform: "darwin" });
|
|
158
|
+
const env = makeEnvironment(home, bin);
|
|
159
|
+
const argsPath = join(home, "password-args");
|
|
160
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
|
|
161
|
+
const result = runCookies(home, env, undefined, "darwin");
|
|
162
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
163
|
+
assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
|
|
164
|
+
"find-generic-password", "-w", "-a", "Brave", "-s", "Brave Safe Storage",
|
|
165
|
+
]);
|
|
166
|
+
rmSync(home, { recursive: true, force: true });
|
|
167
|
+
rmSync(bin, { recursive: true, force: true });
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("browser selection checks only the requested preset", (t) => {
|
|
171
|
+
skipWithoutPython(t);
|
|
172
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-selected-browser-"));
|
|
173
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
174
|
+
createFixture(home, "Profile 1", [
|
|
175
|
+
["__Secure-1PSID", "helium-one", ".google.com", null, 1],
|
|
176
|
+
["__Secure-1PSIDTS", "helium-two", ".google.com", null, 2],
|
|
177
|
+
], { browser: "Helium", targetPlatform: "darwin" });
|
|
178
|
+
createFixture(home, "Profile 1", [
|
|
179
|
+
["__Secure-1PSID", "chrome-one", ".google.com", null, 1],
|
|
180
|
+
["__Secure-1PSIDTS", "chrome-two", ".google.com", null, 2],
|
|
181
|
+
], { browser: "Chrome", targetPlatform: "darwin" });
|
|
182
|
+
const env = makeEnvironment(home, bin);
|
|
183
|
+
const argsPath = join(home, "password-args");
|
|
184
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
|
|
185
|
+
const result = runCookies(home, env, "{ browser: 'helium', profile: 'Profile 1', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", "darwin");
|
|
186
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "helium-two", "__Secure-1PSID": "helium-one" });
|
|
187
|
+
assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
|
|
188
|
+
"find-generic-password", "-w", "-a", "Helium", "-s", "Helium Storage Key",
|
|
189
|
+
]);
|
|
190
|
+
rmSync(home, { recursive: true, force: true });
|
|
191
|
+
rmSync(bin, { recursive: true, force: true });
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("Windows Chrome profiles decrypt v10 cookies with DPAPI keys", (t) => {
|
|
195
|
+
skipWithoutPython(t);
|
|
196
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-"));
|
|
197
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
198
|
+
const argsPath = join(home, "powershell-args");
|
|
199
|
+
const key = Buffer.alloc(32, 3);
|
|
200
|
+
createFixture(home, "Default", [
|
|
201
|
+
["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v10", ".google.com")}`, 1],
|
|
202
|
+
["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v10", ".google.com")}`, 2],
|
|
203
|
+
], { targetPlatform: "win32", windowsKey: key });
|
|
204
|
+
const protectedValue = Buffer.from("protected").toString("base64");
|
|
205
|
+
const env = makeEnvironment(home, bin, { LOCALAPPDATA: join(home, "AppData", "Local"), DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: protectedValue, TEMP: tmpdir(), TMP: tmpdir(), ...writeWindowsDpapiCommand(bin, argsPath) });
|
|
206
|
+
const result = runCookies(home, env, undefined, "win32");
|
|
207
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
208
|
+
const args = readFileSync(argsPath, "utf8").trim().split("\n");
|
|
209
|
+
assert.equal(args.includes("-EncodedCommand"), true);
|
|
210
|
+
assert.equal(args.includes(protectedValue), false);
|
|
211
|
+
rmSync(home, { recursive: true, force: true });
|
|
212
|
+
rmSync(bin, { recursive: true, force: true });
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test("cookie queries keep high Chromium expiry values safe", (t) => {
|
|
216
|
+
skipWithoutPython(t);
|
|
217
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-high-expiry-"));
|
|
218
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
219
|
+
createFixture(home, "Profile 2", [
|
|
220
|
+
["__Secure-1PSID", "expired", ".google.com", null, 1],
|
|
221
|
+
["__Secure-1PSID", "future", ".google.com", null, "9223372036854775807"],
|
|
222
|
+
["__Secure-1PSIDTS", "session", ".google.com", null, 0],
|
|
223
|
+
]);
|
|
224
|
+
const env = makeEnvironment(home, bin);
|
|
225
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
226
|
+
const result = runCookieScript(env, "const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));");
|
|
227
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
|
|
228
|
+
rmSync(home, { recursive: true, force: true });
|
|
229
|
+
rmSync(bin, { recursive: true, force: true });
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("cookie expiry filtering preserves same-second validity", (t) => {
|
|
233
|
+
skipWithoutPython(t);
|
|
234
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-subsecond-expiry-"));
|
|
235
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
236
|
+
const nowMs = 1_700_000_000_500;
|
|
237
|
+
const sameSecondFutureChromeMicros = (nowMs + 400 + 11644473600000) * 1000;
|
|
238
|
+
createFixture(home, "Profile 2", [
|
|
239
|
+
["__Secure-1PSID", "future", ".google.com", null, sameSecondFutureChromeMicros],
|
|
240
|
+
["__Secure-1PSIDTS", "session", ".google.com", null, 0],
|
|
241
|
+
]);
|
|
242
|
+
const env = makeEnvironment(home, bin);
|
|
243
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
244
|
+
const result = runCookieScript(env, `Date.now = () => ${nowMs}; const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));`);
|
|
245
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
|
|
246
|
+
rmSync(home, { recursive: true, force: true });
|
|
247
|
+
rmSync(bin, { recursive: true, force: true });
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test("Windows Edge uses the USERPROFILE AppData fallback and reports unsupported v20 cookies", (t) => {
|
|
251
|
+
skipWithoutPython(t);
|
|
252
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-edge-"));
|
|
253
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
254
|
+
const key = Buffer.alloc(32, 4);
|
|
255
|
+
createFixture(home, "Default", [
|
|
256
|
+
["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v20")}`, 1],
|
|
257
|
+
["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v20")}`, 2],
|
|
258
|
+
], { browser: "Edge", targetPlatform: "win32", windowsKey: key });
|
|
259
|
+
const env = makeEnvironment(home, bin, { DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: Buffer.from("protected").toString("base64"), TEMP: tmpdir(), TMP: tmpdir() });
|
|
260
|
+
delete env.LOCALAPPDATA;
|
|
261
|
+
writeWindowsDpapiCommand(bin);
|
|
262
|
+
const result = runCookies(home, env, undefined, "win32");
|
|
263
|
+
assert.equal(result.result, null);
|
|
264
|
+
assert.match(result.diagnostic, /v20 app-bound cookies are not supported/);
|
|
265
|
+
rmSync(home, { recursive: true, force: true });
|
|
266
|
+
rmSync(bin, { recursive: true, force: true });
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("required-cookie preflight avoids password invocation for unrelated profiles", (t) => {
|
|
270
|
+
skipWithoutPython(t);
|
|
271
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-preflight-"));
|
|
272
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
273
|
+
createFixture(home, "Profile 1", [["NID", "unrelated", ".google.com", null, 1]]);
|
|
274
|
+
const countPath = join(home, "password-count");
|
|
275
|
+
const env = makeEnvironment(home, bin);
|
|
276
|
+
Object.assign(env, writePasswordCommand(bin, countPath));
|
|
277
|
+
const result = runCookies(home, env);
|
|
278
|
+
assert.equal(result.result, null);
|
|
279
|
+
assert.equal(result.diagnostic.includes("required Gemini cookies"), true);
|
|
280
|
+
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 1" && attempt.status === "missing-required-cookies"), true);
|
|
281
|
+
assert.equal(existsSync(countPath), false);
|
|
282
|
+
rmSync(home, { recursive: true, force: true });
|
|
283
|
+
rmSync(bin, { recursive: true, force: true });
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("diagnostics report browser profile when password-store access fails", (t) => {
|
|
287
|
+
skipWithoutPython(t);
|
|
288
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-keychain-failure-"));
|
|
289
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
290
|
+
createFixture(home, "Default", [
|
|
291
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
292
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
293
|
+
], { browser: "Helium", targetPlatform: "darwin" });
|
|
294
|
+
const env = makeEnvironment(home, bin);
|
|
295
|
+
Object.assign(env, writeFailPasswordCommand(bin, join(home, "password-count"), "darwin"));
|
|
296
|
+
const result = runCookies(home, env, undefined, "darwin");
|
|
297
|
+
assert.equal(result.result, null);
|
|
298
|
+
assert.equal(result.diagnostic, "Could not read Helium cookie encryption password");
|
|
299
|
+
assert.deepEqual(result.details.attempts[0], { browser: "Helium", profile: "Default", status: "password-read-failed" });
|
|
300
|
+
assert.doesNotMatch(JSON.stringify(result), /one|two|peanuts|sensitive stderr/);
|
|
301
|
+
rmSync(home, { recursive: true, force: true });
|
|
302
|
+
rmSync(bin, { recursive: true, force: true });
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("diagnostics distinguish required cookie decryption failure", (t) => {
|
|
306
|
+
skipWithoutPython(t);
|
|
307
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-decrypt-failure-"));
|
|
308
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
309
|
+
const encrypted = `hex:${Buffer.from("v10bad-ciphertext").toString("hex")}`;
|
|
310
|
+
createFixture(home, "Profile 2", [
|
|
311
|
+
["__Secure-1PSID", "", ".google.com", encrypted, 1],
|
|
312
|
+
["__Secure-1PSIDTS", "", ".google.com", encrypted, 2],
|
|
313
|
+
]);
|
|
314
|
+
const env = makeEnvironment(home, bin);
|
|
315
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
316
|
+
const result = runCookies(home, env);
|
|
317
|
+
assert.equal(result.result, null);
|
|
318
|
+
assert.match(result.diagnostic, /could not be decrypted/);
|
|
319
|
+
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "decryption-failed"), true);
|
|
320
|
+
assert.doesNotMatch(JSON.stringify(result), /peanuts|bad-ciphertext/);
|
|
321
|
+
rmSync(home, { recursive: true, force: true });
|
|
322
|
+
rmSync(bin, { recursive: true, force: true });
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("browser encryption password is cached within a process", (t) => {
|
|
326
|
+
skipWithoutPython(t);
|
|
327
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-"));
|
|
328
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
329
|
+
createFixture(home, "Profile 2", [
|
|
330
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
331
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
332
|
+
]);
|
|
333
|
+
const countPath = join(home, "password-count");
|
|
334
|
+
const env = makeEnvironment(home, bin);
|
|
335
|
+
Object.assign(env, writePasswordCommand(bin, countPath));
|
|
336
|
+
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
337
|
+
encoding: "utf8",
|
|
338
|
+
env,
|
|
339
|
+
input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] });`,
|
|
340
|
+
});
|
|
341
|
+
assert.equal(child.status, 0, child.stderr);
|
|
342
|
+
assert.equal(readFileSync(countPath, "utf8"), "1");
|
|
343
|
+
rmSync(home, { recursive: true, force: true });
|
|
344
|
+
rmSync(bin, { recursive: true, force: true });
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("failed password lookups are retried instead of cached", (t) => {
|
|
348
|
+
skipWithoutPython(t);
|
|
349
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-failure-"));
|
|
350
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
351
|
+
createFixture(home, "Profile 2", [
|
|
352
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
353
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
354
|
+
]);
|
|
355
|
+
const countPath = join(home, "password-count");
|
|
356
|
+
const env = makeEnvironment(home, bin);
|
|
357
|
+
Object.assign(env, writeFailThenSucceedPasswordCommand(bin, countPath));
|
|
358
|
+
const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
|
|
359
|
+
encoding: "utf8",
|
|
360
|
+
env,
|
|
361
|
+
input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); const options = { profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }; const first = await getGoogleCookies(options); const second = await getGoogleCookies(options); console.log(JSON.stringify({ first, second }));`,
|
|
362
|
+
});
|
|
363
|
+
assert.equal(child.status, 0, child.stderr);
|
|
364
|
+
const result = JSON.parse(child.stdout);
|
|
365
|
+
assert.equal(result.first, null);
|
|
366
|
+
assert.deepEqual(result.second.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
367
|
+
assert.equal(readFileSync(countPath, "utf8"), "2");
|
|
368
|
+
rmSync(home, { recursive: true, force: true });
|
|
369
|
+
rmSync(bin, { recursive: true, force: true });
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test("configured profile names cannot escape the browser profile root", (t) => {
|
|
373
|
+
skipWithoutPython(t);
|
|
374
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-traversal-"));
|
|
375
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
376
|
+
const env = makeEnvironment(home, bin);
|
|
377
|
+
const result = runCookies(home, env, "{ profile: '../Profile 2', requiredCookies: ['__Secure-1PSID'] }");
|
|
378
|
+
assert.equal(result.result, null);
|
|
379
|
+
assert.match(result.diagnostic, /profile directory name/);
|
|
380
|
+
rmSync(home, { recursive: true, force: true });
|
|
381
|
+
rmSync(bin, { recursive: true, force: true });
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
test("explicit profile symlinks cannot escape the browser profile root", (t) => {
|
|
385
|
+
skipWithoutPython(t);
|
|
386
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-symlink-"));
|
|
387
|
+
const outsideHome = mkdtempSync(join(tmpdir(), "pi-cookie-outside-"));
|
|
388
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
389
|
+
createFixture(outsideHome, "Outside", [
|
|
390
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
391
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
392
|
+
]);
|
|
393
|
+
const browserRoot = process.platform === "darwin"
|
|
394
|
+
? join(home, "Library", "Application Support", "Google", "Chrome")
|
|
395
|
+
: join(home, ".config", "google-chrome");
|
|
396
|
+
const outsideProfile = process.platform === "darwin"
|
|
397
|
+
? join(outsideHome, "Library", "Application Support", "Google", "Chrome", "Outside")
|
|
398
|
+
: join(outsideHome, ".config", "google-chrome", "Outside");
|
|
399
|
+
mkdirSync(browserRoot, { recursive: true });
|
|
400
|
+
symlinkSync(outsideProfile, join(browserRoot, "link"), "dir");
|
|
401
|
+
const env = makeEnvironment(home, bin);
|
|
402
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
403
|
+
const result = runCookies(home, env, "{ profile: 'link', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }");
|
|
404
|
+
assert.equal(result.result, null);
|
|
405
|
+
assert.match(result.diagnostic, /inside the browser profile root/);
|
|
406
|
+
rmSync(home, { recursive: true, force: true });
|
|
407
|
+
rmSync(outsideHome, { recursive: true, force: true });
|
|
408
|
+
rmSync(bin, { recursive: true, force: true });
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
test("sqlite3 CLI fallback reads a copied database when node sqlite is unavailable", (t) => {
|
|
412
|
+
skipWithoutPython(t);
|
|
413
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-fallback-"));
|
|
414
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
415
|
+
createFixture(home, "Profile 2", [
|
|
416
|
+
["__Secure-1PSID", "one", ".google.com", null, 1],
|
|
417
|
+
["__Secure-1PSIDTS", "two", ".google.com", null, 2],
|
|
418
|
+
]);
|
|
419
|
+
const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1" });
|
|
420
|
+
Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
|
|
421
|
+
const result = runCookies(home, env);
|
|
422
|
+
assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
|
|
423
|
+
rmSync(home, { recursive: true, force: true });
|
|
424
|
+
rmSync(bin, { recursive: true, force: true });
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
test("unavailable SQLite backends produce actionable sanitized diagnostics", (t) => {
|
|
428
|
+
skipWithoutPython(t);
|
|
429
|
+
const home = mkdtempSync(join(tmpdir(), "pi-cookie-diagnostic-"));
|
|
430
|
+
const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
|
|
431
|
+
createFixture(home, "Profile 2", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
|
|
432
|
+
const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1", PATH: bin });
|
|
433
|
+
const result = runCookies(home, env);
|
|
434
|
+
assert.equal(result.result, null);
|
|
435
|
+
assert.match(result.diagnostic, /SQLite backend unavailable/);
|
|
436
|
+
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "sqlite-unavailable"), true);
|
|
437
|
+
assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "missing-required-cookies"), false);
|
|
438
|
+
assert.doesNotMatch(result.diagnostic, /one|peanuts|stderr|password/i);
|
|
439
|
+
rmSync(home, { recursive: true, force: true });
|
|
440
|
+
rmSync(bin, { recursive: true, force: true });
|
|
441
|
+
});
|