@xopcai/xopc 0.0.372 → 0.0.374
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-BQ3PMp2q.js → activity-store-BeYLqqr8.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D4iAZErG.js → agent-avatar-dicebear-BrA20N2m.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BZrOdxou.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BYB0G2aF.js → agent-plugin-dialog-B3ux1AhY.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-D0JBkZPV.js → agents-CXlXFU6M.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-HBZvVyzF.js → agents-admin-api-B4tgTbWG.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C1tQxHaP.js → app-management-settings-panel-BXahEVPm.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BfavIBbb.js → appearance-settings-CE2qJMkD.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CUS5S1qa.js → apps-page-DGVOnCxZ.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BO3I9zRP.js → archive-plugin-bI9OLnXj.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-iY0KMPSa.js → automations-page-BWL7eT4_.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-LQsa5ohY.js → automations-workspace-BxIShhkZ.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-gFD7vH9R.js → binary-plugins-dOwLzjeH.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cft0fd_O.js → block-editor-3n446-mX.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DxRoKFun.js → browser-automation-inputs-i7h1Svpf.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-C6EWx_Y4.js → browser-automations-page-BmTK7Gtn.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CKlt_8IS.js → browser-settings-page-DBQ-WETQ.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-CY4SiHcP.js → capabilities-CquUV0DP.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-gjQtMhKu.js → capabilities-D4KFLtqM.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-UrQ8EY_o.js → capabilities-page-D-nQ6Zzi.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-C9HIr2CZ.js → capabilities-settings-panel-Dx1fpBmH.js} +6 -6
- package/dist/gateway/static/root/assets/{capability-header-actions-uxIiW_2_.js → capability-header-actions-BRMqvQVb.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-By3dmQ4Y.js → channels-DXfEP1FR.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DeDTSl64.js → chat-terminal-dock-BRdzCjWO.js} +1 -1
- package/dist/gateway/static/root/assets/cloud-credits-BMYMiiNn.js +1 -0
- package/dist/gateway/static/root/assets/{computer-settings-page-Cw1Z1epy.js → computer-settings-page-BhCHMRpD.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-D664WEhj.js → connector-service-page-BXE8Z-Ll.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-sjyjY7Fl.js → connectors-page-D9RZjhw8.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BVmFrPfX.js → date-picker-BJ7N92wm.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-YIoP-e5-.js → dependency-picker-gyxCM-hb.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CzS468vR.js → desktop-pet-B-WM4l-L.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BPcgZUcK.js → desktop-pet-settings-usJqcew5.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-Cgba-4m9.js → device-pairing-wizard-DoSR4DGk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-_nHmZtnY.js → directory-picker-path-field-DqVlV2YH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-IIky9Iqr.js → extension-debug-page-CbgEonkK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C-7ngTTj.js → extension-page-CUule9SU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-VFWspV08.js → extension-provider-DxlAZ2iy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-_hovFCWi.js → extension-settings-page-_OFukkEJ.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-CUHrPpGV.js → fallback-models-CiSc3h8i.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-7RKqgU_U.js → gateway-config-swr-BoRkBnsw.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-BwX_fHUS.js → gateway-realtime-C3WQQY10.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-cLCDEe4D.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-sbaOzlEH.js → gateway-settings-qSUrpS1h.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-jiV5sbEX.js → gateway-startup-retry-TYSQEQcG.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DjquRIFR.js → home-page-COjDsuzg.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-DO4mXb6I.js → image-generation-api-_pKiNfSq.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-xWWIeT_t.js → imports-page-DdvIj-ZL.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BWDK2eIj.js → index-DEaVabvo.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DWazrDgz.js → keyboard-shortcuts-settings-DbqFlNsF.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CkxDdlYU.js → local-app-workbench-page-REowUzkp.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BISZ4bi5.js → local-apps-page-DdCMNn_z.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-pox8evDV.js → local-session-drafts-Cg9RdsNN.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-COVscAqC.js → locale-store-rWFLl-p4.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-GiCulc9k.js → logs-page-B_6fHDoi.js} +1 -1
- package/dist/gateway/static/root/assets/management-settings-D4vcSRE3.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-B_qnAcW2.js → markdown-view-BHFFusQs.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C0Pc-wSY.js → media-plugins-BVPTMWJI.js} +1 -1
- package/dist/gateway/static/root/assets/messages-C1SUo4gG.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-cache-Jj8dvYcv.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-CqealmSc.js → note-detail-panel-B7U6EbAi.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-api-sBgBcyLW.js → notes-api-CSLVCZBn.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BtTU5mnS.js → notes-page-BzHVaH8j.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-Yt-BpPRh.js → page-context-capture-button-D7Y4vFRN.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-E6huhFk4.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-etM6Ijfe.js → product-open-page-CK_czbBx.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-C6aeRrWe.js → product-preview-content-CU6KlaVP.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-K4ASOTki.js → project-detail-page-c3ye2bdq.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BssImjwl.js → projects-page-BA1UuuRF.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-Bh9UBb-f.js → registry-api-CoMBYjHD.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BznC_5H0.js → remote-access-hub-D_FLVZAm.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BJAzqQik.js → runtime-tools-settings-panel-Cxjmwdyf.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-uZUXm03X.js → scenes-page-Av47PHdM.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-SA3Ld7zf.js → schema-form-IM7QeSm3.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-Di3Q846r.js → send-session-input-CLhR1uEp.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-yjpEz4pP.js → session-api-u_4_kFQt.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-CWjhJxJs.js → session-manager-B06ZCie_.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DdL8zVrF.js → sessions-page-Bol3ScEc.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DpCanqrD.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-CUJQMNF7.js → settings-page-BeVtwwVd.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BGBWC0Bc.js → setup-status-panel-zTmrMwMm.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-HCHM8qnf.js → share-link-dialog-XhiuPKF4.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DJmyACyp.js → share-preview-page-Vc0TQuZ8.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-c0dfWz6h.js → shares-api-BVSb1vh4.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BzqcGh7W.js → shares-settings-Bkhkt_6M.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-9XSn7R8L.js → skill-api-Dgwc707w.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Ge5XymHa.js → skill-reload-api-BsLx_FXd.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DwyDfh9g.js → skills-page-CFIte-vM.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-B6axBPLO.js → system-settings-panel-Ck6zGDHb.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-ftCTqBDB.js → task-detail-page-C3ZPEZqw.js} +1 -1
- package/dist/gateway/static/root/assets/{task-expandable-content-hYcgCEE3.js → task-expandable-content-DxeBTJvh.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BOfCKgl6.js → theme-store-KcQhCg1-.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-DDWFXcST.js → tracing-settings-page-DJRAP3nb.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-BYU2v0im.js → tunnel-api-CjxMpAm2.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-Dnhp9xQ4.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CSckcjFx.js → use-autosave-C-IWxbzm.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-OFlldkKg.js → use-composer-attachments-Dxphaxk-.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-BF1TeNXP.js → use-file-preview-expanded-Du37Gofn.js} +2 -2
- package/dist/gateway/static/root/assets/{user-model-page-CqnGITYf.js → user-model-page-sx1lNWKf.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-GEw5x2fU.js → voice-api-key-field-7BImy8Jc.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-3yyVwXln.js → voice-config-api-6MINytQl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BDM7BEKH.js → work-discovery-overlay-CVd_y3K2.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BBwx-tUb.js → workflow-run-setup-panel-Dwg40uGK.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BHigZn6E.js → workflows-page-BQR4JdXB.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-CTm8s6Jr.js → workspace-api-CXiyhTwv.js} +2 -2
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CaKc_J7j.js +1 -0
- package/dist/gateway/static/root/index.html +26 -26
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/cloud-credits.js +80 -0
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/realtime-protocol/src/voice.js +11 -0
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +7 -0
- package/dist/src/agent/embedded/run-turn.js +39 -3
- package/dist/src/agent/embedded/xopc-stream-bridge.js +18 -0
- package/dist/src/agent/image/generation/openai-images-provider.d.ts +2 -1
- package/dist/src/agent/image/generation/openai-images-provider.js +13 -7
- package/dist/src/agent/image/generation/providers/xopc-cloud.js +14 -2
- package/dist/src/agent-config/schema.d.ts +13 -0
- package/dist/src/agent-config/schema.js +2 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/shared.js +2 -1
- package/dist/src/cli/commands/models.js +41 -0
- package/dist/src/computer/runtime.js +3 -0
- package/dist/src/config/gateway-bind.js +2 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/models-json.d.ts +8 -8
- package/dist/src/config/schema.d.ts +13 -12
- package/dist/src/config/schema.js +7 -3
- package/dist/src/daemon/constants.js +14 -9
- package/dist/src/daemon/index.js +4 -1
- package/dist/src/daemon/install-plan.js +2 -1
- package/dist/src/daemon/launchd.js +2 -1
- package/dist/src/daemon/schtasks.js +2 -1
- package/dist/src/daemon/service-audit.js +2 -1
- package/dist/src/daemon/service.js +2 -1
- package/dist/src/daemon/systemd.js +2 -1
- package/dist/src/gateway/client-ip.js +2 -1
- package/dist/src/gateway/hono/app.js +2 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
- package/dist/src/gateway/hono/middleware/auth.d.ts +3 -5
- package/dist/src/gateway/hono/middleware/auth.js +56 -14
- package/dist/src/gateway/hono/middleware/logger.js +2 -1
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.d.ts +16 -0
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.js +43 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +3 -2
- package/dist/src/gateway/hono/oauth-async.js +2 -1
- package/dist/src/gateway/hono/routes/browser.js +2 -1
- package/dist/src/gateway/hono/routes/config.js +2 -1
- package/dist/src/gateway/hono/routes/device-pairing-approval.d.ts +3 -8
- package/dist/src/gateway/hono/routes/device-pairing-approval.js +5 -20
- package/dist/src/gateway/hono/routes/devices.js +25 -9
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +6 -6
- package/dist/src/gateway/hono/routes/shares.js +2 -1
- package/dist/src/gateway/hono/routes/usage.js +15 -5
- package/dist/src/gateway/hono/routes/voice.js +1 -0
- package/dist/src/gateway/host.js +9 -4
- package/dist/src/gateway/index.js +8 -4
- package/dist/src/gateway/listen.js +2 -1
- package/dist/src/gateway/rate-limit/auth-policy.js +7 -11
- package/dist/src/gateway/rate-limit/buckets.d.ts +6 -0
- package/dist/src/gateway/rate-limit/buckets.js +211 -189
- package/dist/src/gateway/rate-limit/env-flags.js +4 -1
- package/dist/src/gateway/rate-limit/index.js +13 -4
- package/dist/src/gateway/runtime-config.js +5 -3
- package/dist/src/gateway/security/audit.js +3 -2
- package/dist/src/gateway/security/browser-session.js +2 -1
- package/dist/src/gateway/security/device-request-proof.d.ts +28 -0
- package/dist/src/gateway/security/device-request-proof.js +122 -0
- package/dist/src/gateway/security/loopback.js +7 -6
- package/dist/src/gateway/service.js +8 -6
- package/dist/src/gateway/tailscale-auth.js +2 -1
- package/dist/src/gateway/ws-security.js +2 -1
- package/dist/src/infra/rate-limit/failure-limiter.js +78 -90
- package/dist/src/infra/rate-limit/index.js +11 -3
- package/dist/src/infra/rate-limit/keyed-store.js +52 -47
- package/dist/src/infra/rate-limit/rate-limiter.js +55 -58
- package/dist/src/infra/update-service-refresh.js +2 -1
- package/dist/src/personal-agent/repository.d.ts +3 -0
- package/dist/src/personal-agent/repository.js +1 -0
- package/dist/src/personal-agent/service.d.ts +6 -2
- package/dist/src/personal-agent/service.js +4 -3
- package/dist/src/platform/client.d.ts +2 -2
- package/dist/src/platform/contracts.d.ts +2 -2
- package/dist/src/providers/model-call.js +15 -1
- package/dist/src/providers/xopc-cloud-account-service.d.ts +7 -23
- package/dist/src/providers/xopc-cloud-account-service.js +49 -29
- package/dist/src/providers/xopc-cloud-credit-budget.d.ts +14 -0
- package/dist/src/providers/xopc-cloud-credit-budget.js +61 -0
- package/dist/src/realtime/runtime.js +6 -0
- package/dist/src/realtime/tickets.d.ts +1 -0
- package/dist/src/realtime/tickets.js +4 -0
- package/dist/src/remote-access/exposure-guards.js +2 -1
- package/dist/src/share/share-rate-limit.js +2 -1
- package/dist/src/share/share-url.js +2 -1
- package/dist/src/share/site-share-router.js +2 -1
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +9 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +94 -5
- package/dist/src/storage/sqlite/device-access-repository.d.ts +7 -0
- package/dist/src/storage/sqlite/device-access-repository.js +22 -4
- package/dist/src/storage/sqlite/migrations/242_cloud_usage_receipts.sql +5 -0
- package/dist/src/storage/sqlite/migrations/243_voice_opening_greetings.sql +12 -0
- package/dist/src/storage/sqlite/migrations/244_device_request_proofs.sql +8 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tunnel/broker-client.js +2 -0
- package/dist/src/tunnel/tunnel-config.js +2 -2
- package/dist/src/tunnel/tunnel-rate-limit.js +2 -1
- package/dist/src/usage/cloud-capability.d.ts +2 -0
- package/dist/src/usage/cloud-capability.js +34 -0
- package/dist/src/usage/cloud-receipts.d.ts +10 -0
- package/dist/src/usage/cloud-receipts.js +55 -0
- package/dist/src/usage/cost.js +1 -0
- package/dist/src/usage/recorder.js +3 -1
- package/dist/src/usage/scenario-registry.js +15 -0
- package/dist/src/utils/logger/redact.js +4 -1
- package/dist/src/voice/platform-streams.d.ts +6 -0
- package/dist/src/voice/platform-streams.js +43 -4
- package/dist/src/voice/realtime/agentEngine.js +138 -83
- package/dist/src/voice/realtime/engine.d.ts +6 -0
- package/dist/src/voice/realtime/opening-greeting.d.ts +12 -0
- package/dist/src/voice/realtime/opening-greeting.js +22 -0
- package/dist/src/voice/realtime/runtime.js +116 -22
- package/dist/src/voice/realtime/runtime.types.d.ts +4 -0
- package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +28 -14
- package/dist/src/voice/tts/providers/xopc-cloud-speech.js +39 -29
- package/dist/src/voice/tts/speech-provider-types.d.ts +1 -0
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BdxzGSiO.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BheKaO6d.js +0 -1
- package/dist/gateway/static/root/assets/management-settings-GUpOcTqa.js +0 -1
- package/dist/gateway/static/root/assets/messages-Bb2GK-Nj.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-DyPPksMP.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-C8SEQpEu.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DmawLOHR.js +0 -1
- package/dist/gateway/static/root/assets/usage-page-BvPcpxTQ.js +0 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { logAuthEvent } from "../../../utils/logger/audit.js";
|
|
2
2
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../../../utils/logger.js";
|
|
4
|
-
import { authenticateDeviceAccessToken, getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
5
|
-
import { safeEqualSecret } from "../../security/secret-equal.js";
|
|
6
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
7
4
|
import { authPolicyConfig, buckets, resolveAuthRateLimit } from "../../rate-limit/buckets.js";
|
|
8
5
|
import { resolveAuthTracking } from "../../rate-limit/auth-policy.js";
|
|
9
6
|
import { isAuthRateLimitGloballyDisabled } from "../../rate-limit/env-flags.js";
|
|
10
|
-
import "../../rate-limit/index.js";
|
|
7
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
8
|
+
import { authenticateDeviceAccessToken, getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
9
|
+
import { getOrCreateGatewayIdentity, init_gateway_identity_repository } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
10
|
+
import { safeEqualSecret } from "../../security/secret-equal.js";
|
|
11
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
11
12
|
import { authenticateBrowserSession } from "../../../storage/sqlite/browser-session-repository.js";
|
|
13
|
+
import { PROOF_HEADER, acquireProofBodyBudget, consumeRequestNonce, parseRequestProof, proofDigest, requestProofMessage, verifyRequestProofSignature } from "../../security/device-request-proof.js";
|
|
12
14
|
import { isChromeExtensionOrigin } from "../../security/origin-check.js";
|
|
13
15
|
import { browserCookieRequestAllowed, readBrowserSessionCookie, writeBrowserSessionCookie } from "../../security/browser-session.js";
|
|
14
16
|
import { authorizeTrustedProxy } from "../../trusted-proxy.js";
|
|
@@ -16,6 +18,8 @@ import { setGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
|
16
18
|
import { createMiddleware } from "hono/factory";
|
|
17
19
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
18
20
|
//#region src/gateway/hono/middleware/auth.ts
|
|
21
|
+
init_gateway_identity_repository();
|
|
22
|
+
init_rate_limit();
|
|
19
23
|
init_device_access_repository();
|
|
20
24
|
init_logger();
|
|
21
25
|
const log = createLogger("Gateway:Auth");
|
|
@@ -250,16 +254,54 @@ function auth(config) {
|
|
|
250
254
|
error: "Forbidden",
|
|
251
255
|
code: "extension_origin_mismatch"
|
|
252
256
|
}, 403);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
let releaseBodyBudget = () => {};
|
|
258
|
+
try {
|
|
259
|
+
const proofHeader = c.req.header(PROOF_HEADER);
|
|
260
|
+
if (device?.requestProofVersion || proofHeader) {
|
|
261
|
+
const proof = parseRequestProof(proofHeader);
|
|
262
|
+
const url = new URL(c.req.url);
|
|
263
|
+
if (!device || !proof || Math.abs(Date.now() - proof.timestamp) > 12e4 || !verifyRequestProofSignature(device, proof, requestProofMessage({
|
|
264
|
+
gatewayId: getOrCreateGatewayIdentity().id,
|
|
265
|
+
credential: providedCredential,
|
|
266
|
+
method: c.req.method,
|
|
267
|
+
target: url.pathname + url.search,
|
|
268
|
+
headers: (name) => c.req.header(name),
|
|
269
|
+
proof
|
|
270
|
+
}))) return c.json({
|
|
271
|
+
error: "Unauthorized",
|
|
272
|
+
code: "REQUEST_PROOF_INVALID"
|
|
273
|
+
}, 401);
|
|
274
|
+
const release = /^(multipart\/form-data|application\/octet-stream)/i.test(c.req.header("content-type") ?? "") || Number(c.req.header("content-length") ?? 0) > 65536 ? acquireProofBodyBudget(device.id) : () => {};
|
|
275
|
+
if (!release) {
|
|
276
|
+
c.header("Retry-After", "1");
|
|
277
|
+
return c.json({
|
|
278
|
+
error: "Too Many Requests",
|
|
279
|
+
code: "REQUEST_CONCURRENCY_LIMIT"
|
|
280
|
+
}, 429);
|
|
281
|
+
}
|
|
282
|
+
releaseBodyBudget = release;
|
|
283
|
+
if (proofDigest(Buffer.from(await c.req.raw.clone().arrayBuffer())) !== proof.digest) return c.json({
|
|
284
|
+
error: "Unauthorized",
|
|
285
|
+
code: "REQUEST_BODY_MISMATCH"
|
|
286
|
+
}, 401);
|
|
287
|
+
if (!consumeRequestNonce(device.id, proof)) return c.json({
|
|
288
|
+
error: "Unauthorized",
|
|
289
|
+
code: "REQUEST_REPLAYED"
|
|
290
|
+
}, 401);
|
|
291
|
+
}
|
|
292
|
+
recordSuccess(rl);
|
|
293
|
+
setGatewayPrincipal(c, {
|
|
294
|
+
kind: "device",
|
|
295
|
+
principalId: deviceIdentity.deviceId,
|
|
296
|
+
deviceId: deviceIdentity.deviceId,
|
|
297
|
+
accessSessionId: deviceIdentity.accessSessionId,
|
|
298
|
+
scopes: deviceIdentity.scopes
|
|
299
|
+
});
|
|
300
|
+
await next();
|
|
301
|
+
return;
|
|
302
|
+
} finally {
|
|
303
|
+
releaseBodyBudget();
|
|
304
|
+
}
|
|
263
305
|
}
|
|
264
306
|
const blocked = checkBlocked(rl);
|
|
265
307
|
if (blocked.blocked) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
+
import { getClientIpFromHeaders, init_loopback } from "../../security/loopback.js";
|
|
3
4
|
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
|
-
import { getClientIpFromHeaders } from "../../security/loopback.js";
|
|
5
5
|
import { createMiddleware } from "hono/factory";
|
|
6
6
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
7
7
|
//#region src/gateway/hono/middleware/logger.ts
|
|
8
|
+
init_loopback();
|
|
8
9
|
init_logger();
|
|
9
10
|
const log = createLogger("Gateway:HTTP");
|
|
10
11
|
function resolveRemoteAddress(c) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
export type PairingPublicRouteOptions = {
|
|
3
|
+
getTrustedProxyContext?: () => {
|
|
4
|
+
trustedProxies?: string[];
|
|
5
|
+
allowRealIpFallback?: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function pairingClientKey(c: Context, options?: PairingPublicRouteOptions): string;
|
|
9
|
+
/** Shared local-hop budgets allow normal mobile polling while bounding pre-auth work. */
|
|
10
|
+
export declare function publicDeviceRateLimit(family: string, options?: PairingPublicRouteOptions): import("hono").MiddlewareHandler<any, string, {}, Response & import("hono").TypedResponse<{
|
|
11
|
+
ok: false;
|
|
12
|
+
error: {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
}, 429, "json">>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { buckets } from "../../rate-limit/buckets.js";
|
|
2
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
3
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
|
+
import { createMiddleware } from "hono/factory";
|
|
5
|
+
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
6
|
+
//#region src/gateway/hono/middleware/public-device-rate-limit.ts
|
|
7
|
+
init_rate_limit();
|
|
8
|
+
function pairingClientKey(c, options) {
|
|
9
|
+
let remoteAddress;
|
|
10
|
+
try {
|
|
11
|
+
remoteAddress = getConnInfo(c).remote.address;
|
|
12
|
+
} catch {
|
|
13
|
+
remoteAddress = void 0;
|
|
14
|
+
}
|
|
15
|
+
const proxy = options?.getTrustedProxyContext?.();
|
|
16
|
+
return resolveClientIpFromRequest({
|
|
17
|
+
remoteAddress,
|
|
18
|
+
getHeader: (name) => c.req.header(name),
|
|
19
|
+
trustedProxies: proxy?.trustedProxies,
|
|
20
|
+
allowRealIpFallback: proxy?.allowRealIpFallback
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Shared local-hop budgets allow normal mobile polling while bounding pre-auth work. */
|
|
24
|
+
function publicDeviceRateLimit(family, options) {
|
|
25
|
+
return createMiddleware(async (c, next) => {
|
|
26
|
+
const source = buckets.publicDeviceSource().consume(`${family}:${pairingClientKey(c, options)}`);
|
|
27
|
+
const total = buckets.publicDeviceGlobal().consume(family);
|
|
28
|
+
if (!source.allowed || !total.allowed) {
|
|
29
|
+
const retry = Math.max(source.retryAfterMs, total.retryAfterMs);
|
|
30
|
+
c.header("Retry-After", String(Math.max(1, Math.ceil(retry / 1e3))));
|
|
31
|
+
return c.json({
|
|
32
|
+
ok: false,
|
|
33
|
+
error: {
|
|
34
|
+
code: "RATE_LIMITED",
|
|
35
|
+
message: "Too many requests"
|
|
36
|
+
}
|
|
37
|
+
}, 429);
|
|
38
|
+
}
|
|
39
|
+
return next();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { pairingClientKey, publicDeviceRateLimit };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
4
3
|
import { buckets } from "../../rate-limit/buckets.js";
|
|
5
|
-
import "../../rate-limit/index.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
6
6
|
import { createMiddleware } from "hono/factory";
|
|
7
7
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
8
8
|
//#region src/gateway/hono/middleware/strict-rate-limit.ts
|
|
@@ -10,6 +10,7 @@ import { getConnInfo } from "@hono/node-server/conninfo";
|
|
|
10
10
|
* Per-client request-rate gate for sensitive admin/mutation endpoints.
|
|
11
11
|
* Backed by `buckets.strictApi()` — see {@link ../../rate-limit/buckets.ts}.
|
|
12
12
|
*/
|
|
13
|
+
init_rate_limit();
|
|
13
14
|
init_logger();
|
|
14
15
|
const log = createLogger("Hono:StrictRateLimit");
|
|
15
16
|
function resolveClientIp(c, deps) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { init_host, isLoopbackHost } from "../host.js";
|
|
3
4
|
import { getOAuthProviderInterfaces, init_registry } from "../../auth/oauth/registry.js";
|
|
4
5
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
5
|
-
import { isLoopbackHost } from "../host.js";
|
|
6
6
|
import { resolveReverseProxyPublicUrl } from "../public-url.js";
|
|
7
7
|
import { buildCapabilityPlansForConfig } from "../../capabilities/readiness/from-config.js";
|
|
8
8
|
import "../../capabilities/readiness/index.js";
|
|
@@ -18,6 +18,7 @@ import { Hono } from "hono";
|
|
|
18
18
|
*/
|
|
19
19
|
init_registry();
|
|
20
20
|
init_credentials();
|
|
21
|
+
init_host();
|
|
21
22
|
init_logger();
|
|
22
23
|
const log = createLogger("OAuthAsync");
|
|
23
24
|
function buildOAuthCompletionReadiness(config, catalog) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { deleteBrowserTabBinding, getBrowserTabBinding, init_browser_tab_binding_repository, setBrowserTabBinding } from "../../../storage/sqlite/browser-tab-binding-repository.js";
|
|
2
2
|
import { browserTabBindingRequestSchema } from "../../../../packages/gateway-contract/src/browser-tab-binding.js";
|
|
3
3
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
4
|
+
import { init_loopback, isLoopbackClientIp } from "../../security/loopback.js";
|
|
4
5
|
import { getDevice, init_device_access_repository } from "../../../storage/sqlite/device-access-repository.js";
|
|
5
6
|
import "../../../../packages/browser-control-contract/src/index.js";
|
|
6
7
|
import { createBrowserDriver } from "../../../browser/drivers/create-driver.js";
|
|
7
8
|
import { checkBrowserReadiness } from "../../../browser/readiness.js";
|
|
8
|
-
import { isLoopbackClientIp } from "../../security/loopback.js";
|
|
9
9
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
10
10
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
11
11
|
//#region src/gateway/hono/routes/browser.ts
|
|
12
12
|
/** Browser Control status and driver diagnostics. */
|
|
13
13
|
init_src();
|
|
14
|
+
init_loopback();
|
|
14
15
|
init_device_access_repository();
|
|
15
16
|
init_browser_tab_binding_repository();
|
|
16
17
|
async function extensionStatus(service, includeLocalArtifacts) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { enumerateLanGatewayCandidates } from "../../host.js";
|
|
1
|
+
import { enumerateLanGatewayCandidates, init_host } from "../../host.js";
|
|
2
2
|
import { getTunnelService } from "../../../tunnel/tunnel-service.js";
|
|
3
3
|
import { buildSafeWebConfigPayload } from "../lib/config-payload.js";
|
|
4
4
|
import { applyChannelsPatch } from "./config-patch/channels.js";
|
|
@@ -6,6 +6,7 @@ import { applyGatewayPatch } from "./config-patch/gateway.js";
|
|
|
6
6
|
import { applyMiscPatch, validateGatewayAfterPatch } from "./config-patch/misc.js";
|
|
7
7
|
import "./config-patch/index.js";
|
|
8
8
|
//#region src/gateway/hono/routes/config.ts
|
|
9
|
+
init_host();
|
|
9
10
|
function localeFromRequest(c) {
|
|
10
11
|
return c.req.query("locale") ?? c.req.header("X-XOPC-Locale") ?? c.req.header("Accept-Language")?.split(",")[0];
|
|
11
12
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
trustedProxies?: string[];
|
|
5
|
-
allowRealIpFallback?: boolean;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare function pairingClientKey(c: Context, options?: PairingPublicRouteOptions): string;
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import { type PairingPublicRouteOptions } from '../middleware/public-device-rate-limit.js';
|
|
3
|
+
export { pairingClientKey, type PairingPublicRouteOptions } from '../middleware/public-device-rate-limit.js';
|
|
9
4
|
export declare function registerPairingApprovalPublicRoutes(app: Hono, options?: PairingPublicRouteOptions): void;
|
|
10
5
|
export declare function registerPairingApprovalAdminRoutes(app: Hono): void;
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
import { devicePairingCompleteSchema, devicePairingProofSchema, devicePairingRequestSchema } from "../../../../packages/gateway-contract/src/device-pairing.js";
|
|
2
2
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import { getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
4
|
-
import { resolveClientIpFromRequest } from "../../client-ip.js";
|
|
5
3
|
import { buckets } from "../../rate-limit/buckets.js";
|
|
6
|
-
import "../../rate-limit/index.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
6
|
+
import { pairingClientKey, publicDeviceRateLimit } from "../middleware/public-device-rate-limit.js";
|
|
7
7
|
import { DevicePairingError, cancelDevicePairingSetup, decideDevicePairingRequest, operateDevicePairingRequest, readDevicePairingSetup, submitDevicePairingRequest } from "../../../storage/sqlite/device-pairing-approval.js";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { bodyLimit } from "hono/body-limit";
|
|
11
|
-
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
12
11
|
//#region src/gateway/hono/routes/device-pairing-approval.ts
|
|
13
12
|
init_src();
|
|
14
13
|
init_gateway_identity_repository();
|
|
15
|
-
|
|
16
|
-
let remoteAddress;
|
|
17
|
-
try {
|
|
18
|
-
remoteAddress = getConnInfo(c).remote.address;
|
|
19
|
-
} catch {
|
|
20
|
-
remoteAddress = void 0;
|
|
21
|
-
}
|
|
22
|
-
const proxy = options?.getTrustedProxyContext?.();
|
|
23
|
-
return resolveClientIpFromRequest({
|
|
24
|
-
remoteAddress,
|
|
25
|
-
getHeader: (name) => c.req.header(name),
|
|
26
|
-
trustedProxies: proxy?.trustedProxies,
|
|
27
|
-
allowRealIpFallback: proxy?.allowRealIpFallback
|
|
28
|
-
});
|
|
29
|
-
}
|
|
14
|
+
init_rate_limit();
|
|
30
15
|
function pairingBlocked(c, key) {
|
|
31
16
|
const blocked = buckets.pairingExchange().check(key);
|
|
32
17
|
if (!blocked.blocked) return void 0;
|
|
@@ -63,7 +48,7 @@ function registerPairingApprovalPublicRoutes(app, options) {
|
|
|
63
48
|
"cancel"
|
|
64
49
|
]) {
|
|
65
50
|
const path = action === "request" ? "/api/device-pairing/requests" : `/api/device-pairing/requests/:id/${action}`;
|
|
66
|
-
app.post(path, bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
51
|
+
app.post(path, publicDeviceRateLimit("pairing", options), bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
67
52
|
const clientKey = pairingClientKey(c, options);
|
|
68
53
|
const blocked = pairingBlocked(c, clientKey);
|
|
69
54
|
if (blocked) return blocked;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { browserPairingInvitationPayloadSchema, devicePairingTargetKindSchema, formatBrowserPairingInvitation, formatMobilePairingInvitation } from "../../../../packages/gateway-contract/src/device-pairing.js";
|
|
2
2
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buckets } from "../../rate-limit/buckets.js";
|
|
4
|
+
import { init_rate_limit } from "../../rate-limit/index.js";
|
|
5
|
+
import { DeviceRefreshRateLimitError, init_device_access_repository, listDevices, revokeDevice, rotateDeviceRefreshToken } from "../../../storage/sqlite/device-access-repository.js";
|
|
4
6
|
import { getGatewayIdentityPublicKeyRaw, getOrCreateGatewayIdentity, init_gateway_identity_repository, signGatewayPayload } from "../../../storage/sqlite/gateway-identity-repository.js";
|
|
5
7
|
import { createDevicePairingSetup, init_device_pairing_repository, isDevicePairingSetupActive } from "../../../storage/sqlite/device-pairing-repository.js";
|
|
6
8
|
import { resolveSecureDeviceRoutes } from "../../device-routes.js";
|
|
7
|
-
import { buckets } from "../../rate-limit/buckets.js";
|
|
8
|
-
import "../../rate-limit/index.js";
|
|
9
9
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
10
|
-
import { pairingClientKey,
|
|
10
|
+
import { pairingClientKey, publicDeviceRateLimit } from "../middleware/public-device-rate-limit.js";
|
|
11
|
+
import { registerPairingApprovalAdminRoutes, registerPairingApprovalPublicRoutes } from "./device-pairing-approval.js";
|
|
11
12
|
import os from "node:os";
|
|
12
13
|
import { z } from "zod";
|
|
13
14
|
import { bodyLimit } from "hono/body-limit";
|
|
@@ -16,18 +17,20 @@ init_src();
|
|
|
16
17
|
init_device_access_repository();
|
|
17
18
|
init_device_pairing_repository();
|
|
18
19
|
init_gateway_identity_repository();
|
|
20
|
+
init_rate_limit();
|
|
19
21
|
const refreshRequestSchema = z.strictObject({
|
|
20
22
|
refreshToken: z.string().min(1).max(256),
|
|
21
23
|
timestamp: z.number().int().positive(),
|
|
22
24
|
nonce: z.string().min(16).max(128),
|
|
23
25
|
requestId: z.string().uuid(),
|
|
24
26
|
nextRefreshToken: z.string().min(80).max(256),
|
|
25
|
-
signature: z.string().min(1).max(256)
|
|
27
|
+
signature: z.string().min(1).max(256),
|
|
28
|
+
requestProofVersion: z.literal(1).optional()
|
|
26
29
|
});
|
|
27
30
|
const pairingProbeSchema = z.strictObject({ pairingId: z.string().uuid() });
|
|
28
31
|
const pairingSetupSchema = z.strictObject({ targetKind: devicePairingTargetKindSchema });
|
|
29
32
|
function registerDeviceAuthPublicRoutes(app, options) {
|
|
30
|
-
app.post("/api/gateway-identity/challenge", bodyLimit({ maxSize: 512 }), async (c) => {
|
|
33
|
+
app.post("/api/gateway-identity/challenge", publicDeviceRateLimit("challenge", options), bodyLimit({ maxSize: 512 }), async (c) => {
|
|
31
34
|
const budget = buckets.identityChallenge().consume("gateway");
|
|
32
35
|
if (!budget.allowed) {
|
|
33
36
|
c.header("Retry-After", String(Math.ceil(budget.retryAfterMs / 1e3)));
|
|
@@ -40,6 +43,8 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
40
43
|
purpose: "gateway-route-v1",
|
|
41
44
|
gatewayId: identity.id,
|
|
42
45
|
nonce: parsed.data.nonce,
|
|
46
|
+
serverTime: Date.now(),
|
|
47
|
+
requestProofVersion: 1,
|
|
43
48
|
expiresAt: Date.now() + 3e4
|
|
44
49
|
})).toString("base64url");
|
|
45
50
|
c.header("Cache-Control", "no-store");
|
|
@@ -49,7 +54,7 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
49
54
|
});
|
|
50
55
|
});
|
|
51
56
|
registerPairingApprovalPublicRoutes(app, options);
|
|
52
|
-
app.post("/api/device-auth/refresh", async (c) => {
|
|
57
|
+
app.post("/api/device-auth/refresh", publicDeviceRateLimit("refresh", options), bodyLimit({ maxSize: 4096 }), async (c) => {
|
|
53
58
|
const parsed = refreshRequestSchema.safeParse(await c.req.json().catch(() => null));
|
|
54
59
|
if (!parsed.success) return c.json({
|
|
55
60
|
ok: false,
|
|
@@ -66,6 +71,7 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
66
71
|
requestId: parsed.data.requestId,
|
|
67
72
|
nonce: parsed.data.nonce,
|
|
68
73
|
expiresAt: Date.now() + 3e4,
|
|
74
|
+
requestProofVersion: parsed.data.requestProofVersion ?? 0,
|
|
69
75
|
tokens
|
|
70
76
|
})).toString("base64url");
|
|
71
77
|
return c.json({
|
|
@@ -74,16 +80,26 @@ function registerDeviceAuthPublicRoutes(app, options) {
|
|
|
74
80
|
signature: signGatewayPayload(signedPayload)
|
|
75
81
|
});
|
|
76
82
|
} catch (error) {
|
|
83
|
+
if (error instanceof DeviceRefreshRateLimitError) {
|
|
84
|
+
c.header("Retry-After", String(Math.max(1, Math.ceil(error.retryAfterMs / 1e3))));
|
|
85
|
+
return c.json({
|
|
86
|
+
ok: false,
|
|
87
|
+
error: {
|
|
88
|
+
code: "RATE_LIMITED",
|
|
89
|
+
message: "Too many requests"
|
|
90
|
+
}
|
|
91
|
+
}, 429);
|
|
92
|
+
}
|
|
77
93
|
return c.json({
|
|
78
94
|
ok: false,
|
|
79
95
|
error: {
|
|
80
96
|
code: "REFRESH_DENIED",
|
|
81
|
-
message:
|
|
97
|
+
message: "Refresh denied"
|
|
82
98
|
}
|
|
83
99
|
}, 401);
|
|
84
100
|
}
|
|
85
101
|
});
|
|
86
|
-
app.post("/api/device-pairing/probe", bodyLimit({ maxSize: 512 }), async (c) => {
|
|
102
|
+
app.post("/api/device-pairing/probe", publicDeviceRateLimit("pairing", options), bodyLimit({ maxSize: 512 }), async (c) => {
|
|
87
103
|
const clientKey = pairingClientKey(c, options);
|
|
88
104
|
const blocked = buckets.pairingExchange().check(clientKey);
|
|
89
105
|
if (blocked.blocked) {
|
|
@@ -71,6 +71,7 @@ function registerEndpointToolRoutes(authenticated, deps) {
|
|
|
71
71
|
...lastSeenAt ? { lastSeenAt } : {},
|
|
72
72
|
access: access ? {
|
|
73
73
|
scopes: access.scopes,
|
|
74
|
+
requestProofVersion: access.requestProofVersion,
|
|
74
75
|
createdAt: access.createdAt,
|
|
75
76
|
...access.lastSeenAt ? { lastSeenAt: access.lastSeenAt } : {},
|
|
76
77
|
...access.revokedAt ? { revokedAt: access.revokedAt } : {}
|
|
@@ -9,6 +9,7 @@ import { getModelRegistry } from "../../../providers/model-registry.js";
|
|
|
9
9
|
import "../../../providers/constants.js";
|
|
10
10
|
import { getProviderRegistry, init_plugin_registry } from "../../../providers/plugin-registry.js";
|
|
11
11
|
import { PROVIDER_META, getAllModels, getAllProviders, getAvailableModels, getProviderAuthState, init_providers, isProviderConfigured, isProviderConfiguredSync } from "../../../providers/index.js";
|
|
12
|
+
import { XopcCloudAccountError, XopcCloudAccountService } from "../../../providers/xopc-cloud-account-service.js";
|
|
12
13
|
import { buildCapabilityPlansForConfig } from "../../../capabilities/readiness/from-config.js";
|
|
13
14
|
import "../../../capabilities/readiness/index.js";
|
|
14
15
|
import { getModelThinking } from "../../../providers/model-thinking.js";
|
|
@@ -23,7 +24,6 @@ import { dismissXopcCloudOnboarding, getXopcCloudOnboardingStatus } from "../../
|
|
|
23
24
|
import { getDomesticProviderPreset, getDomesticProviderPresetIds } from "../../../providers/domestic-presets.js";
|
|
24
25
|
import { auditModelReferences } from "../../../providers/model-reference-auditor.js";
|
|
25
26
|
import { getOnboardingFeaturedProviders, getProviderHint, getRecommendedModelsForProvider, isRecommendedModel, sortModelsForPicker, sortProvidersForPicker } from "../../../providers/presentation.js";
|
|
26
|
-
import { XopcCloudAccountError, XopcCloudAccountService } from "../../../providers/xopc-cloud-account-service.js";
|
|
27
27
|
//#region src/gateway/hono/routes/models.ts
|
|
28
28
|
init_model_policy();
|
|
29
29
|
init_models_json();
|
|
@@ -40,6 +40,7 @@ const OnboardingSchema = z.object({
|
|
|
40
40
|
draft: PersonalOnboardingDraftSchema
|
|
41
41
|
}).strict();
|
|
42
42
|
const ProfileSchema = z.object({
|
|
43
|
+
voiceCallPreferences: z.object({ openingGreetingEnabled: z.boolean() }).strict().optional(),
|
|
43
44
|
revision: z.number().int().positive(),
|
|
44
45
|
displayName: z.string().trim().min(1).max(60),
|
|
45
46
|
appearance: PersonalAppearanceSchema,
|
|
@@ -348,7 +349,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
348
349
|
ok: false,
|
|
349
350
|
error: "Invalid profile"
|
|
350
351
|
}, 400);
|
|
351
|
-
const { revision, displayName, appearance, preferences, voicePreference } = parsed.data;
|
|
352
|
+
const { revision, displayName, appearance, preferences, voicePreference, voiceCallPreferences } = parsed.data;
|
|
352
353
|
if (voicePreference) {
|
|
353
354
|
const { resolveStreamingTts } = await import("../../../voice/realtime/runtime.js");
|
|
354
355
|
const route = resolveStreamingTts(deps.service.currentConfig);
|
|
@@ -364,7 +365,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
364
365
|
error: "Selected voice is unavailable"
|
|
365
366
|
}, 400);
|
|
366
367
|
}
|
|
367
|
-
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, preferences, appearance, voicePreference);
|
|
368
|
+
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, preferences, appearance, voicePreference, voiceCallPreferences);
|
|
368
369
|
return updated ? c.json({
|
|
369
370
|
ok: true,
|
|
370
371
|
payload: updated
|
|
@@ -25,18 +25,18 @@ function secretsEqual(actual, expected) {
|
|
|
25
25
|
}
|
|
26
26
|
function registerPublicGatewayRoutes(app, service) {
|
|
27
27
|
app.get("/health", (c) => {
|
|
28
|
-
|
|
28
|
+
const health = service.getHealth();
|
|
29
|
+
return c.json({
|
|
30
|
+
status: health.ready ? "ok" : "starting",
|
|
31
|
+
ready: health.ready
|
|
32
|
+
});
|
|
29
33
|
});
|
|
30
34
|
/** Public liveness probe (no auth) — minimal payload for CLI / load balancers. */
|
|
31
35
|
app.get("/api/health", (c) => {
|
|
32
36
|
const health = service.getHealth();
|
|
33
37
|
return c.json({
|
|
34
38
|
status: health.ready ? "ok" : "starting",
|
|
35
|
-
ready: health.ready
|
|
36
|
-
httpListening: health.httpListening,
|
|
37
|
-
version: health.version,
|
|
38
|
-
uptime: health.uptime,
|
|
39
|
-
startupDurationMs: health.startupDurationMs
|
|
39
|
+
ready: health.ready
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
app.post("/api/connectors/composio/webhook", async (c) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getClientIpFromHeaders, init_loopback } from "../../security/loopback.js";
|
|
1
2
|
import { loadCompactionSourceSnapshot } from "../../../storage/sqlite/transcript-repository.js";
|
|
2
3
|
import { init_sqlite } from "../../../storage/sqlite/index.js";
|
|
3
4
|
import { FileServiceError } from "../../../files/file-service.js";
|
|
@@ -16,7 +17,6 @@ import { resolveReverseProxyPublicUrl } from "../../public-url.js";
|
|
|
16
17
|
import { audienceDefaults, cleanupStagedSite, decideShareKind, forgetStagedSite, makeDescription, makeTitle, probeShareTarget, rememberStagedSite, stageSingleHtmlAsSite } from "../../../share/share-auto.js";
|
|
17
18
|
import { deleteThumbnail, placeholderSvg, readThumbnail, scheduleThumbnail, thumbnailContentType, thumbnailExists } from "../../../share/share-thumbnail.js";
|
|
18
19
|
import { getGatewayFileSpaceService } from "../../file-space-service.js";
|
|
19
|
-
import { getClientIpFromHeaders } from "../../security/loopback.js";
|
|
20
20
|
import { SHARED_HTML_CSP } from "../../security/csp.js";
|
|
21
21
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
22
22
|
import { renderFolderLandingPage, renderShareExpiredPage, renderShareLandingPage, renderSnapshotShareLandingPage } from "../../../share/share-landing.js";
|
|
@@ -31,6 +31,7 @@ import { createHash } from "node:crypto";
|
|
|
31
31
|
import { stat } from "node:fs/promises";
|
|
32
32
|
import { Readable } from "node:stream";
|
|
33
33
|
//#region src/gateway/hono/routes/shares.ts
|
|
34
|
+
init_loopback();
|
|
34
35
|
init_sqlite();
|
|
35
36
|
function getShareUrlContext(service) {
|
|
36
37
|
const gateway = service.currentConfig.gateway;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getAiUsageEventView, listAiUsageEvents, listAiUsageTrace, summarizeAiUsage } from "../../../storage/sqlite/ai-usage-repository.js";
|
|
1
|
+
import { getAiUsageEventView, listAiUsageEvents, listAiUsageTrace, pendingAiUsageCloudReceiptIds, summarizeAiUsage } from "../../../storage/sqlite/ai-usage-repository.js";
|
|
2
|
+
import { reconcileCloudUsageReceipt } from "../../../usage/cloud-receipts.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { Hono } from "hono";
|
|
4
5
|
//#region src/gateway/hono/routes/usage.ts
|
|
@@ -41,14 +42,23 @@ function registerUsageRoutes(authenticated, _deps) {
|
|
|
41
42
|
if (error instanceof z.ZodError || error.message.startsWith("invalid_usage_")) return c.json({ error: "invalid_usage_query" }, 400);
|
|
42
43
|
throw error;
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const refreshReceipts = async (query) => {
|
|
46
|
+
await Promise.all(pendingAiUsageCloudReceiptIds(query).map(reconcileCloudUsageReceipt));
|
|
47
|
+
};
|
|
48
|
+
app.get("/summary", async (c) => {
|
|
49
|
+
const query = parseFilters(c.req.query());
|
|
50
|
+
await refreshReceipts(query);
|
|
51
|
+
return c.json(summarizeAiUsage(query));
|
|
52
|
+
});
|
|
53
|
+
app.get("/events", async (c) => {
|
|
46
54
|
const limit = z.coerce.number().int().min(1).max(200).optional().parse(c.req.query("limit"));
|
|
47
|
-
|
|
55
|
+
const query = {
|
|
48
56
|
...parseFilters(c.req.query()),
|
|
49
57
|
limit,
|
|
50
58
|
before: parseCursor(c.req.query("cursor"))
|
|
51
|
-
}
|
|
59
|
+
};
|
|
60
|
+
await refreshReceipts(query);
|
|
61
|
+
return c.json(listAiUsageEvents(query));
|
|
52
62
|
});
|
|
53
63
|
app.get("/events/:id", (c) => {
|
|
54
64
|
const event = getAiUsageEventView(c.req.param("id"));
|
package/dist/src/gateway/host.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_constants } from "../daemon/constants.js";
|
|
2
3
|
import { networkInterfaces } from "node:os";
|
|
3
4
|
//#region src/gateway/host.ts
|
|
4
5
|
/** True when the bind address is local-only (127.x, localhost, ::1). */
|
|
@@ -13,8 +14,6 @@ function isAllInterfacesHost(host) {
|
|
|
13
14
|
const normalized = host.trim();
|
|
14
15
|
return normalized === "0.0.0.0" || normalized === "::" || normalized === "*";
|
|
15
16
|
}
|
|
16
|
-
/** Vite dev server origins for the gateway console (`web/` defaults to port 3000). */
|
|
17
|
-
const GATEWAY_DEV_CONSOLE_ORIGINS = ["http://localhost:3000", "http://127.0.0.1:3000"];
|
|
18
17
|
/** Non-internal IPv4 addresses that can serve this gateway on the local network. */
|
|
19
18
|
function enumerateLanGatewayCandidates(port) {
|
|
20
19
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -86,5 +85,11 @@ function resolveAllowedBrowserOrigins(params) {
|
|
|
86
85
|
if (reverseProxyOrigin && !origins.includes(reverseProxyOrigin)) origins.push(reverseProxyOrigin);
|
|
87
86
|
return origins;
|
|
88
87
|
}
|
|
88
|
+
var GATEWAY_DEV_CONSOLE_ORIGINS;
|
|
89
|
+
var init_host = __esmMin((() => {
|
|
90
|
+
init_constants();
|
|
91
|
+
GATEWAY_DEV_CONSOLE_ORIGINS = ["http://localhost:3000", "http://127.0.0.1:3000"];
|
|
92
|
+
}));
|
|
89
93
|
//#endregion
|
|
90
|
-
|
|
94
|
+
init_host();
|
|
95
|
+
export { GATEWAY_DEV_CONSOLE_ORIGINS, buildDefaultCorsOrigins, enumerateLanGatewayCandidates, init_host, isAllInterfacesHost, isLoopbackHost, originFromGatewayPublicUrl, resolveAllowedBrowserOrigins, resolveEffectiveGatewayPort, resolveGatewayCorsOrigins, resolveGatewayServiceListenPort };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buckets } from "./rate-limit/buckets.js";
|
|
2
|
+
import { buildDefaultCorsOrigins, init_host, isAllInterfacesHost, isLoopbackHost, resolveEffectiveGatewayPort, resolveGatewayServiceListenPort } from "./host.js";
|
|
3
|
+
import { isGatewayStrictSecurityEnabled } from "./rate-limit/env-flags.js";
|
|
4
|
+
import { init_rate_limit } from "./rate-limit/index.js";
|
|
2
5
|
import { defaultGatewayBindMode, isContainerEnvironment, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost } from "../config/gateway-bind.js";
|
|
3
6
|
import { GatewayLockError, acquireGatewayLock } from "./lock.js";
|
|
4
7
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
5
8
|
import { resolveGatewayListenHost, resolveGatewayListenPlan } from "./listen.js";
|
|
6
|
-
import { buckets } from "./rate-limit/buckets.js";
|
|
7
|
-
import { isGatewayStrictSecurityEnabled } from "./rate-limit/env-flags.js";
|
|
8
|
-
import "./rate-limit/index.js";
|
|
9
9
|
import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
10
10
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
11
11
|
import { GatewayService } from "./service.js";
|
|
@@ -16,4 +16,8 @@ import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofO
|
|
|
16
16
|
import { apiError, apiOk } from "./protocol.js";
|
|
17
17
|
import "./hono/index.js";
|
|
18
18
|
import { assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, isInsecurePrivateWsAllowed, isSecureWebSocketUrl } from "./ws-security.js";
|
|
19
|
+
//#region src/gateway/index.ts
|
|
20
|
+
init_host();
|
|
21
|
+
init_rate_limit();
|
|
22
|
+
//#endregion
|
|
19
23
|
export { GatewayLockError, GatewayServer, GatewayService, acquireGatewayLock, apiError, apiOk, assertGatewayAuthConfigured, assertGatewayRuntimeConfig, assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, buckets, buildDefaultCorsOrigins, checkPortAvailable, createHonoApp, defaultGatewayBindMode, extractToken, forceFreePortAndWait, isAllInterfacesHost, isContainerEnvironment, isGatewayStrictSecurityEnabled, isInsecurePrivateWsAllowed, isLoopbackHost, isSecureWebSocketUrl, listPortListeners, parseLsofOutput, resolveEffectiveGatewayPort, resolveGatewayAuth, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost, resolveGatewayListenHost, resolveGatewayListenPlan, resolveGatewayServiceListenPort, restartGatewayProcessWithFreshPid, runGatewayLoop, validateToken };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { buildDefaultCorsOrigins, isAllInterfacesHost, isLoopbackHost } from "./host.js";
|
|
1
|
+
import { buildDefaultCorsOrigins, init_host, isAllInterfacesHost, isLoopbackHost } from "./host.js";
|
|
2
2
|
import { resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayCustomBindHost } from "../config/gateway-bind.js";
|
|
3
3
|
//#region src/gateway/listen.ts
|
|
4
|
+
init_host();
|
|
4
5
|
/** Resolve the effective HTTP listen host (CLI bind override > config bind). */
|
|
5
6
|
function resolveGatewayListenHost(params) {
|
|
6
7
|
return resolveGatewayBindHostSync({
|