@vantran-se/openchamber-web 1.23.1 → 1.24.3
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/bin/cli.test.js +29 -6
- package/bin/lib/cli-http.js +5 -1
- package/bin/lib/commands-status.js +5 -0
- package/dist/assets/{CodeMirrorCommentWidgets-BOpqXpFU.js → CodeMirrorCommentWidgets-BjJHrzmU.js} +1 -1
- package/dist/assets/DiffView-COVQhWGd.js +4 -0
- package/dist/assets/FilesView-B1V5JxFX.js +13 -0
- package/dist/assets/GitView-CDOJy5Ay.js +6 -0
- package/dist/assets/GuestAttachDialog-D3S0Rjic.js +1 -0
- package/dist/assets/{JsonTreeView-nd_E8eVM.js → JsonTreeView-D0C9nU7K.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LinearIssuesView-D7FKg1XJ.js +1 -0
- package/dist/assets/{MarkdownImageGallery-CVYds3sQ.js → MarkdownImageGallery-BrFjAVEf.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-DWepTafh.js +12 -0
- package/dist/assets/{OnboardingScreen-Dd2IbPTn.js → OnboardingScreen-Dyxxiqdt.js} +1 -1
- package/dist/assets/{PatchDiff-nUu5i4bG.js → PatchDiff-DnEhjXcC.js} +1 -1
- package/dist/assets/PierreDiffViewer-DyxZVVVR.js +210 -0
- package/dist/assets/PlanView-LW2z_EAP.js +5 -0
- package/dist/assets/PluginPane-B4tKno2h.js +3 -0
- package/dist/assets/SettingsView-DEaMulN9.js +29 -0
- package/dist/assets/{SettingsWindow-BccxY81J.js → SettingsWindow-FLDJXOgQ.js} +1 -1
- package/dist/assets/SubmoduleDiffSummary-CvVwD-Vi.js +1 -0
- package/dist/assets/ToolOutputDialog-BiP0x2Rw.js +15 -0
- package/dist/assets/{ToolPartDiffPreview-BFVgk0UK.js → ToolPartDiffPreview-CkR4msKP.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-z3_H74UR.js → VirtualizedFileDiff-0pyr_mHY.js} +3 -3
- package/dist/assets/{WalkthroughView-BqM9GFbJ.js → WalkthroughView-yNj4nOP5.js} +2 -2
- package/dist/assets/appThemeRegistry-BuUKhbYQ.js +1 -0
- package/dist/assets/commitAndPush-DvJKa3Ks.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-Bdazp9Qo.js → computeVirtualFileMetrics-DxTBMuu-.js} +1 -1
- package/dist/assets/de-DgxgFyGG.js +10 -0
- package/dist/assets/es-BFsZj5F_.js +16 -0
- package/dist/assets/fr-jdZ5KKQi.js +14 -0
- package/dist/assets/{index-eo1-D_7z.js → index-CKHjPKbq.js} +1 -1
- package/dist/assets/index-Cbci4i1W.js +40 -0
- package/dist/assets/index-DqaMWNrC.css +1 -0
- package/dist/assets/{isDiffPlainText-BvKH712-.js → isDiffPlainText-D7FkBMP6.js} +1 -1
- package/dist/assets/{isFilePlainText-BdVVPukf.js → isFilePlainText-CL2vsrIZ.js} +1 -1
- package/dist/assets/ja-C5kKrhO4.js +16 -0
- package/dist/assets/ko-DXDTT_0O.js +16 -0
- package/dist/assets/main-CZALtVek.js +896 -0
- package/dist/assets/main-CgXMBNvG.js +2 -0
- package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
- package/dist/assets/markdownCore-Dh7WEsdM.js +5 -0
- package/dist/assets/miniChat-CwTmDixi.js +2 -0
- package/dist/assets/mobile-CLf2vCtO.js +2 -0
- package/dist/assets/{patchFileDiff-B7LjppSS.js → patchFileDiff-Bsba8KFp.js} +3 -3
- package/dist/assets/pl-D-7x4Y8Q.js +16 -0
- package/dist/assets/pt-BR-CSBZrHa8.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-C5gAFBk0.js +2 -0
- package/dist/assets/renderMobileApp-V4hYd32H.js +25 -0
- package/dist/assets/runtimeEndpointReset-DhlHCn-2.js +25 -0
- package/dist/assets/{scheduledTasksApi-hceovDei.js → scheduledTasksApi-DzjbLd8P.js} +1 -1
- package/dist/assets/shikiHighlight-8_3csmr6.js +1 -0
- package/dist/assets/textMateThemeFromAppTheme-CHo2fCgW.js +1 -0
- package/dist/assets/tr-Dr-oJ22L.js +7 -0
- package/dist/assets/uk-9Nx83UcI.js +16 -0
- package/dist/assets/useAppFontEffects-khZXpFL_.js +7333 -0
- package/dist/assets/useInlineCommentController-DkQ_gqpn.js +2 -0
- package/dist/assets/useRootScrollLock-DdvHf9Pt.js +2 -0
- package/dist/assets/{vendor-base-ui-BY_5qla_.js → vendor-base-ui-CsXYnR5c.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DWA1bm1F.js → vendor-codemirror-language-data-CdzUmUyZ.js} +2 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
- package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
- package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
- package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
- package/dist/assets/{vendor-zod-B6551dwG.js → vendor-zod-CgAdXWZO.js} +4 -4
- package/dist/assets/{web-components-B_Z64So5.js → web-components-B8IcVQAA.js} +2 -2
- package/dist/assets/zh-CN-Bxy_Hj3r.js +16 -0
- package/dist/assets/zh-TW-0BB4gpHM.js +16 -0
- package/dist/index.html +6 -4
- package/dist/mini-chat.html +6 -4
- package/dist/mobile.html +6 -4
- package/package.json +12 -9
- package/server/built-in-extensions/registry.json +4 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +44 -10
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
- package/server/lib/agent-tool/runtime.js +62 -15
- package/server/lib/agent-tool/runtime.test.js +88 -2
- package/server/lib/changelog/update-notes.js +2 -1
- package/server/lib/changelog/update-notes.test.js +19 -0
- package/server/lib/event-stream/DOCUMENTATION.md +23 -0
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +292 -0
- package/server/lib/event-stream/global-hub.js +53 -23
- package/server/lib/event-stream/global-hub.test.js +160 -0
- package/server/lib/event-stream/global-ws-bridge.js +1 -0
- package/server/lib/event-stream/index.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -1
- package/server/lib/fs/git-process.test.js +77 -0
- package/server/lib/fs/routes.js +58 -5
- package/server/lib/fs/routes.test.js +116 -0
- package/server/lib/fs/search.js +2 -1
- package/server/lib/git/DOCUMENTATION.md +20 -5
- package/server/lib/git/routes.js +16 -3
- package/server/lib/git/serial-refresh.js +93 -0
- package/server/lib/git/serial-refresh.test.js +112 -0
- package/server/lib/git/service.js +429 -70
- package/server/lib/git/service.test.js +418 -0
- package/server/lib/github/pr-status.js +5 -5
- package/server/lib/github/pr-status.test.js +1 -1
- package/server/lib/github/routes.js +4 -4
- package/server/lib/guests/DOCUMENTATION.md +68 -0
- package/server/lib/guests/auth-store.js +184 -0
- package/server/lib/guests/auth-store.test.js +112 -0
- package/server/lib/guests/background.test.js +83 -0
- package/server/lib/guests/builtins.js +34 -0
- package/server/lib/guests/builtins.test.js +174 -0
- package/server/lib/guests/catalog.js +477 -0
- package/server/lib/guests/catalog.test.js +390 -0
- package/server/lib/guests/clone.js +297 -0
- package/server/lib/guests/extract-zip.js +136 -0
- package/server/lib/guests/extract-zip.test.js +109 -0
- package/server/lib/guests/files.js +308 -0
- package/server/lib/guests/files.test.js +262 -0
- package/server/lib/guests/grant-scope.js +81 -0
- package/server/lib/guests/grant-scope.test.js +75 -0
- package/server/lib/guests/host-session.js +73 -0
- package/server/lib/guests/host-session.test.js +30 -0
- package/server/lib/guests/html-styles.js +6 -0
- package/server/lib/guests/html-styles.test.js +45 -0
- package/server/lib/guests/html-tokens.js +73 -0
- package/server/lib/guests/html-tokens.test.js +53 -0
- package/server/lib/guests/install.js +406 -0
- package/server/lib/guests/install.test.js +338 -0
- package/server/lib/guests/oauth.js +501 -0
- package/server/lib/guests/oauth.test.js +481 -0
- package/server/lib/guests/persist.js +336 -0
- package/server/lib/guests/persist.test.js +288 -0
- package/server/lib/guests/request.js +112 -0
- package/server/lib/guests/request.test.js +206 -0
- package/server/lib/guests/routes.js +838 -0
- package/server/lib/guests/service.js +538 -0
- package/server/lib/guests/service.test.js +277 -0
- package/server/lib/guests/sockets.js +129 -0
- package/server/lib/guests/sockets.test.js +110 -0
- package/server/lib/guests/ssh-install.test.js +188 -0
- package/server/lib/guests/storage.js +68 -0
- package/server/lib/guests/storage.test.js +59 -0
- package/server/lib/guests/updates.js +294 -0
- package/server/lib/guests/updates.test.js +334 -0
- package/server/lib/guests/upload.js +50 -0
- package/server/lib/guests/upload.test.js +131 -0
- package/server/lib/linear/DOCUMENTATION.md +1 -1
- package/server/lib/message-queue/DOCUMENTATION.md +10 -1
- package/server/lib/message-queue/runtime.js +21 -1
- package/server/lib/message-queue/runtime.test.js +52 -5
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
- package/server/lib/openchamber-sessions/routes.js +62 -29
- package/server/lib/openchamber-sessions/routes.test.js +96 -0
- package/server/lib/opencode/DOCUMENTATION.md +55 -1
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/core-routes.js +39 -1
- package/server/lib/opencode/feature-routes-runtime.js +15 -0
- package/server/lib/opencode/lifecycle-process.test.js +84 -0
- package/server/lib/opencode/lifecycle.js +54 -67
- package/server/lib/opencode/openchamber-routes.js +72 -14
- package/server/lib/opencode/openchamber-routes.test.js +71 -3
- package/server/lib/opencode/session-runtime.js +68 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/opencode/settings-helpers.js +8 -0
- package/server/lib/opencode/settings-helpers.test.js +13 -1
- package/server/lib/opencode/settings-normalization-runtime.js +2 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
- package/server/lib/opencode/settings-registry.json +15 -0
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/shutdown-runtime.test.js +24 -0
- package/server/lib/opencode/theme-archive.js +53 -0
- package/server/lib/opencode/theme-catalog.js +171 -0
- package/server/lib/opencode/theme-catalog.test.js +125 -0
- package/server/lib/opencode/theme-import.test.js +144 -0
- package/server/lib/opencode/theme-runtime.js +100 -28
- package/server/lib/opencode/theme-runtime.test.js +15 -0
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
- package/server/lib/permission-auto-accept/runtime.js +13 -0
- package/server/lib/permission-auto-accept/runtime.test.js +37 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +0 -1
- package/server/lib/quota/providers/index.js +0 -7
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/routing/DOCUMENTATION.md +83 -0
- package/server/lib/routing/defaults.js +98 -0
- package/server/lib/routing/feature-flag.js +11 -0
- package/server/lib/routing/history.js +34 -0
- package/server/lib/routing/jev.js +98 -0
- package/server/lib/routing/routes.http.test.js +100 -0
- package/server/lib/routing/routes.js +81 -0
- package/server/lib/routing/runtime.js +217 -0
- package/server/lib/routing/runtime.test.js +188 -0
- package/server/lib/routing/store.js +249 -0
- package/server/lib/routing/store.test.js +96 -0
- package/server/lib/scheduled-tasks/runtime.js +2 -2
- package/server/lib/scheduled-tasks/runtime.test.js +14 -0
- package/server/lib/security/request-security.js +9 -5
- package/server/lib/security/request-security.test.js +37 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -2
- package/server/lib/small-model/call.js +37 -6
- package/server/lib/small-model/call.test.js +182 -0
- package/server/lib/terminal/DOCUMENTATION.md +23 -2
- package/server/lib/terminal/runtime.js +27 -5
- package/server/lib/terminal/runtime.test.js +67 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/service.test.js +78 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
- package/server/lib/ui-auth/session-cookie.js +51 -0
- package/server/lib/ui-auth/session-cookie.test.js +46 -0
- package/server/lib/ui-auth/ui-auth.js +56 -17
- package/server/lib/ui-auth/ui-auth.test.js +96 -0
- package/dist/assets/DiffView-CyLmb-wF.js +0 -4
- package/dist/assets/DirtyBranchSwitchDialog-pu5kcoir.js +0 -1
- package/dist/assets/FilesView-WtJB0y_l.js +0 -13
- package/dist/assets/GitView-DkNrV0BK.js +0 -6
- package/dist/assets/LinearIssuesView-B0H0Otii.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DSqVN2d8.js +0 -12
- package/dist/assets/PierreDiffViewer-Bsq9z-sw.js +0 -161
- package/dist/assets/PlanView-CAFziKH5.js +0 -5
- package/dist/assets/SettingsView-BRittavZ.js +0 -28
- package/dist/assets/ToolOutputDialog-B0uYaJio.js +0 -15
- package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
- package/dist/assets/de-c7CYLCAW.js +0 -10
- package/dist/assets/es-BKAVPQmQ.js +0 -16
- package/dist/assets/fr-Bj1glqfV.js +0 -14
- package/dist/assets/index-BYFyOu_D.css +0 -1
- package/dist/assets/index-BfwRClDe.js +0 -40
- package/dist/assets/ja-5jwSIbK0.js +0 -16
- package/dist/assets/ko-BaDbg-Eb.js +0 -16
- package/dist/assets/main-CGG2_uHq.js +0 -2
- package/dist/assets/main-CcrSaL4J.js +0 -930
- package/dist/assets/markdownCore-DsmQr3bt.js +0 -5
- package/dist/assets/miniChat-DEaAhP4b.js +0 -2
- package/dist/assets/mobile-BC3rsvv0.js +0 -2
- package/dist/assets/pl-BFKVBDFu.js +0 -16
- package/dist/assets/pt-BR-qKfHvkDL.js +0 -16
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-CR9d1Mr0.js +0 -2
- package/dist/assets/renderMobileApp-Da5dwobZ.js +0 -25
- package/dist/assets/runtimeEndpointReset-CLYVRw2H.js +0 -41
- package/dist/assets/shikiHighlight-D1Z9G58W.js +0 -1
- package/dist/assets/tr-DYXPoEDG.js +0 -7
- package/dist/assets/uk-CwAoloR8.js +0 -16
- package/dist/assets/useAppFontEffects-DeStGcUT.js +0 -7282
- package/dist/assets/useGitComparison-CpxioduU.js +0 -1
- package/dist/assets/useInlineCommentController-gmUnJtrb.js +0 -2
- package/dist/assets/useRootScrollLock--a3cPz8s.js +0 -1
- package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
- package/dist/assets/zh-CN-D9MG0lqF.js +0 -16
- package/dist/assets/zh-TW-1HNK7shh.js +0 -16
- package/server/lib/quota/providers/crof.js +0 -96
- package/server/lib/quota/providers/crof.test.js +0 -98
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GUEST_REQUEST_RESPONSE_MAX,
|
|
3
|
+
GUEST_REQUEST_TIMEOUT_MS,
|
|
4
|
+
isGuestRequestPath,
|
|
5
|
+
resolveIntegrationApi,
|
|
6
|
+
} from '@openchamber/sdk';
|
|
7
|
+
|
|
8
|
+
import { dropGuestTokens } from './auth-store.js';
|
|
9
|
+
import { resolveHostAccessToken } from './host-session.js';
|
|
10
|
+
import { GuestOAuthError, guestAuthorizationHeader, refreshGuestAccessToken, takeUsableGuestAuth } from './oauth.js';
|
|
11
|
+
|
|
12
|
+
const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
13
|
+
|
|
14
|
+
export const joinGuestRequestUrl = (apiOrigin, path, query) => {
|
|
15
|
+
if (!isGuestRequestPath(path)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
let url;
|
|
19
|
+
try {
|
|
20
|
+
url = new URL(path, `${apiOrigin}/`);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (url.origin !== apiOrigin) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (query) {
|
|
28
|
+
for (const [key, value] of Object.entries(query)) {
|
|
29
|
+
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
url.searchParams.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return url;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const readCappedBody = async (response) => {
|
|
39
|
+
const text = await response.text();
|
|
40
|
+
if (text.length <= GUEST_REQUEST_RESPONSE_MAX) {
|
|
41
|
+
return text;
|
|
42
|
+
}
|
|
43
|
+
return text.slice(0, GUEST_REQUEST_RESPONSE_MAX);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const sendAuthorized = async (url, method, body, accessToken, authorization) => {
|
|
47
|
+
const headers = {
|
|
48
|
+
Accept: 'application/json',
|
|
49
|
+
Authorization: guestAuthorizationHeader(accessToken, authorization),
|
|
50
|
+
};
|
|
51
|
+
if (body !== undefined && method !== 'GET') {
|
|
52
|
+
headers['Content-Type'] = 'application/json';
|
|
53
|
+
}
|
|
54
|
+
return fetch(url, {
|
|
55
|
+
method,
|
|
56
|
+
headers,
|
|
57
|
+
body: method === 'GET' || body === undefined ? undefined : body,
|
|
58
|
+
redirect: 'manual',
|
|
59
|
+
signal: AbortSignal.timeout(GUEST_REQUEST_TIMEOUT_MS),
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const proxyGuestRequest = async ({ guest, persistPath, method, path, query, body }) => {
|
|
64
|
+
const api = resolveIntegrationApi(guest.integration ?? {});
|
|
65
|
+
if (!api) {
|
|
66
|
+
throw new GuestOAuthError('This guest does not declare an API origin.', 'NO_INTEGRATION');
|
|
67
|
+
}
|
|
68
|
+
if (!METHODS.has(method)) {
|
|
69
|
+
throw new GuestOAuthError('Unsupported request method.', 'BAD_METHOD');
|
|
70
|
+
}
|
|
71
|
+
const url = joinGuestRequestUrl(api.apiOrigin, path, query);
|
|
72
|
+
if (!url) {
|
|
73
|
+
throw new GuestOAuthError('Request path must stay on the declared apiOrigin.', 'BAD_PATH');
|
|
74
|
+
}
|
|
75
|
+
const hostToken = await resolveHostAccessToken(guest.integration);
|
|
76
|
+
const stored = hostToken ? null : await takeUsableGuestAuth(guest, persistPath);
|
|
77
|
+
let accessToken = hostToken ?? stored?.accessToken;
|
|
78
|
+
if (!accessToken) {
|
|
79
|
+
throw new GuestOAuthError('Not connected.', 'DISCONNECTED');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let response = await sendAuthorized(url, method, body, accessToken, api.authorization);
|
|
83
|
+
if (response.status === 401) {
|
|
84
|
+
const refreshed = hostToken
|
|
85
|
+
? await resolveHostAccessToken(guest.integration)
|
|
86
|
+
: await refreshGuestAccessToken({ guest, persistPath }).catch(() => null);
|
|
87
|
+
// Only the tokens this request was refused with are dropped. A refresh
|
|
88
|
+
// that came back null because the user connected again meanwhile (new
|
|
89
|
+
// tokens, maybe a new target) must leave that new connection alone.
|
|
90
|
+
const refusedWith = accessToken;
|
|
91
|
+
const dropRefused = () => dropGuestTokens(guest.id, persistPath, (current) => current?.accessToken === refusedWith);
|
|
92
|
+
if (!refreshed || refreshed === accessToken) {
|
|
93
|
+
if (!hostToken) {
|
|
94
|
+
await dropRefused();
|
|
95
|
+
}
|
|
96
|
+
throw new GuestOAuthError('Not connected.', 'DISCONNECTED');
|
|
97
|
+
}
|
|
98
|
+
accessToken = refreshed;
|
|
99
|
+
response = await sendAuthorized(url, method, body, accessToken, api.authorization);
|
|
100
|
+
if (response.status === 401) {
|
|
101
|
+
if (!hostToken) {
|
|
102
|
+
await dropGuestTokens(guest.id, persistPath, (current) => current?.accessToken === refreshed);
|
|
103
|
+
}
|
|
104
|
+
throw new GuestOAuthError('Not connected.', 'DISCONNECTED');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
status: response.status,
|
|
110
|
+
body: await readCappedBody(response),
|
|
111
|
+
};
|
|
112
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { getGuestAuth, guestAuthPersistPath, patchGuestAuth } from './auth-store.js';
|
|
7
|
+
import { credentialTarget } from './oauth.js';
|
|
8
|
+
import { joinGuestRequestUrl, proxyGuestRequest } from './request.js';
|
|
9
|
+
|
|
10
|
+
const clickupGuest = {
|
|
11
|
+
id: 'clickup',
|
|
12
|
+
integration: {
|
|
13
|
+
name: 'ClickUp',
|
|
14
|
+
description: 'Tasks',
|
|
15
|
+
oauth: {
|
|
16
|
+
authorizeUrl: 'https://app.clickup.com/api',
|
|
17
|
+
tokenUrl: 'https://api.clickup.com/api/v2/oauth/token',
|
|
18
|
+
apiOrigin: 'https://api.clickup.com',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('joinGuestRequestUrl', () => {
|
|
24
|
+
test('stays on the declared origin and rejects escapes', () => {
|
|
25
|
+
expect(joinGuestRequestUrl('https://api.clickup.com', '/api/v2/user')?.href)
|
|
26
|
+
.toBe('https://api.clickup.com/api/v2/user');
|
|
27
|
+
expect(joinGuestRequestUrl('https://api.clickup.com', '/api/../secret')).toBeNull();
|
|
28
|
+
expect(joinGuestRequestUrl('https://api.clickup.com', 'https://evil.example/x')).toBeNull();
|
|
29
|
+
expect(joinGuestRequestUrl('https://api.clickup.com', '//evil.example/x')).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('proxyGuestRequest', () => {
|
|
34
|
+
test('attaches the stored bearer and returns the capped body', async () => {
|
|
35
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
36
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
37
|
+
await patchGuestAuth('clickup', { accessToken: 'tok-1', target: credentialTarget(clickupGuest.integration) }, persistPath);
|
|
38
|
+
const originalFetch = globalThis.fetch;
|
|
39
|
+
const seen = [];
|
|
40
|
+
globalThis.fetch = async (url, init) => {
|
|
41
|
+
seen.push({ href: String(url), auth: init.headers.Authorization });
|
|
42
|
+
return new Response('{"ok":true}', { status: 200 });
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
const result = await proxyGuestRequest({
|
|
46
|
+
guest: clickupGuest,
|
|
47
|
+
persistPath,
|
|
48
|
+
method: 'GET',
|
|
49
|
+
path: '/api/v2/list/1/task',
|
|
50
|
+
});
|
|
51
|
+
expect(result).toEqual({ status: 200, body: '{"ok":true}' });
|
|
52
|
+
expect(seen).toEqual([{
|
|
53
|
+
href: 'https://api.clickup.com/api/v2/list/1/task',
|
|
54
|
+
auth: 'Bearer tok-1',
|
|
55
|
+
}]);
|
|
56
|
+
} finally {
|
|
57
|
+
globalThis.fetch = originalFetch;
|
|
58
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('sends a pasted token as the Authorization header', async () => {
|
|
63
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
64
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
65
|
+
await patchGuestAuth('clickup', { accessToken: 'pk_tok', target: { apiOrigin: 'https://api.clickup.com' } }, persistPath);
|
|
66
|
+
const originalFetch = globalThis.fetch;
|
|
67
|
+
const seen = [];
|
|
68
|
+
globalThis.fetch = async (url, init) => {
|
|
69
|
+
seen.push({ href: String(url), auth: init.headers.Authorization });
|
|
70
|
+
return new Response('{"ok":true}', { status: 200 });
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const result = await proxyGuestRequest({
|
|
74
|
+
guest: {
|
|
75
|
+
id: 'clickup',
|
|
76
|
+
integration: {
|
|
77
|
+
name: 'ClickUp',
|
|
78
|
+
description: 'Tasks',
|
|
79
|
+
token: { apiOrigin: 'https://api.clickup.com' },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
persistPath,
|
|
83
|
+
method: 'GET',
|
|
84
|
+
path: '/api/v2/user',
|
|
85
|
+
});
|
|
86
|
+
expect(result).toEqual({ status: 200, body: '{"ok":true}' });
|
|
87
|
+
expect(seen).toEqual([{
|
|
88
|
+
href: 'https://api.clickup.com/api/v2/user',
|
|
89
|
+
auth: 'pk_tok',
|
|
90
|
+
}]);
|
|
91
|
+
} finally {
|
|
92
|
+
globalThis.fetch = originalFetch;
|
|
93
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('drops tokens when a 401 cannot refresh', async () => {
|
|
98
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
99
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
100
|
+
await patchGuestAuth('clickup', { accessToken: 'tok-old', target: credentialTarget(clickupGuest.integration) }, persistPath);
|
|
101
|
+
const originalFetch = globalThis.fetch;
|
|
102
|
+
globalThis.fetch = async () => new Response('nope', { status: 401 });
|
|
103
|
+
try {
|
|
104
|
+
await proxyGuestRequest({
|
|
105
|
+
guest: clickupGuest,
|
|
106
|
+
persistPath,
|
|
107
|
+
method: 'GET',
|
|
108
|
+
path: '/api/v2/user',
|
|
109
|
+
});
|
|
110
|
+
throw new Error('should have thrown');
|
|
111
|
+
} catch (error) {
|
|
112
|
+
expect(error.code).toBe('DISCONNECTED');
|
|
113
|
+
}
|
|
114
|
+
expect((await getGuestAuth('clickup', persistPath))?.accessToken).toBeUndefined();
|
|
115
|
+
globalThis.fetch = originalFetch;
|
|
116
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('refuses a disconnected guest', async () => {
|
|
120
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
121
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
122
|
+
try {
|
|
123
|
+
await proxyGuestRequest({
|
|
124
|
+
guest: clickupGuest,
|
|
125
|
+
persistPath,
|
|
126
|
+
method: 'GET',
|
|
127
|
+
path: '/api/v2/user',
|
|
128
|
+
});
|
|
129
|
+
throw new Error('should have thrown');
|
|
130
|
+
} catch (error) {
|
|
131
|
+
expect(error.code).toBe('DISCONNECTED');
|
|
132
|
+
}
|
|
133
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('credential target', () => {
|
|
138
|
+
test('drops a token minted for another API origin instead of sending it', async () => {
|
|
139
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
140
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
141
|
+
await patchGuestAuth('clickup', { accessToken: 'tok-1', target: { apiOrigin: 'https://api.old.example' } }, persistPath);
|
|
142
|
+
const originalFetch = globalThis.fetch;
|
|
143
|
+
let requested = 0;
|
|
144
|
+
globalThis.fetch = async () => {
|
|
145
|
+
requested += 1;
|
|
146
|
+
return new Response('{"ok":true}', { status: 200 });
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
await expect(proxyGuestRequest({ guest: clickupGuest, persistPath, method: 'GET', path: '/api/v2/user' }))
|
|
150
|
+
.rejects.toMatchObject({ code: 'DISCONNECTED' });
|
|
151
|
+
expect(requested).toBe(0);
|
|
152
|
+
expect((await getGuestAuth('clickup', persistPath))?.accessToken).toBeUndefined();
|
|
153
|
+
} finally {
|
|
154
|
+
globalThis.fetch = originalFetch;
|
|
155
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('a token without a recorded target never counts', async () => {
|
|
160
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
161
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
162
|
+
await patchGuestAuth('clickup', { accessToken: 'tok-1' }, persistPath);
|
|
163
|
+
try {
|
|
164
|
+
await expect(proxyGuestRequest({ guest: clickupGuest, persistPath, method: 'GET', path: '/api/v2/user' }))
|
|
165
|
+
.rejects.toMatchObject({ code: 'DISCONNECTED' });
|
|
166
|
+
} finally {
|
|
167
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('a 401 while the user reconnects', () => {
|
|
173
|
+
test('drops only the tokens the request was refused with, not the new connection', async () => {
|
|
174
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-guest-req-'));
|
|
175
|
+
const persistPath = guestAuthPersistPath(dir);
|
|
176
|
+
const target = credentialTarget(clickupGuest.integration);
|
|
177
|
+
await patchGuestAuth('clickup', {
|
|
178
|
+
clientId: 'app-id', clientSecret: 'app-secret', clientTarget: target,
|
|
179
|
+
accessToken: 'access-a', refreshToken: 'refresh-a', target,
|
|
180
|
+
}, persistPath);
|
|
181
|
+
const originalFetch = globalThis.fetch;
|
|
182
|
+
let releaseRefresh;
|
|
183
|
+
const refreshGate = new Promise((resolve) => { releaseRefresh = resolve; });
|
|
184
|
+
globalThis.fetch = async (url) => {
|
|
185
|
+
if (String(url) === 'https://api.clickup.com/api/v2/oauth/token') {
|
|
186
|
+
await refreshGate;
|
|
187
|
+
return new Response(JSON.stringify({ access_token: 'access-a2', refresh_token: 'refresh-a2', token_type: 'Bearer', expires_in: 3600 }), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
188
|
+
}
|
|
189
|
+
return new Response('nope', { status: 401 });
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
const request = proxyGuestRequest({ guest: clickupGuest, persistPath, method: 'GET', path: '/api/v2/user' });
|
|
193
|
+
// The user connects again while the refresh is in flight.
|
|
194
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
195
|
+
await patchGuestAuth('clickup', { accessToken: 'access-b', refreshToken: 'refresh-b', target }, persistPath);
|
|
196
|
+
releaseRefresh();
|
|
197
|
+
await expect(request).rejects.toMatchObject({ code: 'DISCONNECTED' });
|
|
198
|
+
const stored = await getGuestAuth('clickup', persistPath);
|
|
199
|
+
expect(stored.accessToken).toBe('access-b');
|
|
200
|
+
expect(stored.refreshToken).toBe('refresh-b');
|
|
201
|
+
} finally {
|
|
202
|
+
globalThis.fetch = originalFetch;
|
|
203
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|