@pellux/goodvibes-sdk 0.38.0 → 1.1.0
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/contracts/artifacts/operator-contract.json +4468 -916
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +4 -0
- package/dist/events/communication.d.ts +1 -1
- package/dist/events/surfaces.d.ts +25 -3
- package/dist/events/surfaces.d.ts.map +1 -1
- package/dist/events/surfaces.js +22 -1
- package/dist/events/workflows.d.ts +7 -6
- package/dist/events/workflows.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/platform/agents/archetypes.d.ts.map +1 -1
- package/dist/platform/agents/archetypes.js +7 -0
- package/dist/platform/agents/index.d.ts +1 -0
- package/dist/platform/agents/index.d.ts.map +1 -1
- package/dist/platform/agents/index.js +1 -0
- package/dist/platform/agents/orchestrator-runner.d.ts +16 -3
- package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator-runner.js +20 -6
- package/dist/platform/agents/orchestrator.d.ts +42 -10
- package/dist/platform/agents/orchestrator.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator.js +68 -20
- package/dist/platform/agents/planner-decomposition-runner.d.ts +38 -0
- package/dist/platform/agents/planner-decomposition-runner.d.ts.map +1 -0
- package/dist/platform/agents/planner-decomposition-runner.js +113 -0
- package/dist/platform/agents/turn-knowledge-injection.d.ts +88 -3
- package/dist/platform/agents/turn-knowledge-injection.d.ts.map +1 -1
- package/dist/platform/agents/turn-knowledge-injection.js +147 -30
- package/dist/platform/agents/worktree.d.ts +126 -8
- package/dist/platform/agents/worktree.d.ts.map +1 -1
- package/dist/platform/agents/worktree.js +240 -19
- package/dist/platform/agents/wrfc-controller.d.ts +24 -1
- package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-controller.js +161 -35
- package/dist/platform/agents/wrfc-gate-runtime.d.ts +9 -0
- package/dist/platform/agents/wrfc-gate-runtime.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-gate-runtime.js +7 -3
- package/dist/platform/agents/wrfc-gates.d.ts +1 -1
- package/dist/platform/agents/wrfc-gates.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-gates.js +7 -1
- package/dist/platform/agents/wrfc-types.d.ts +23 -3
- package/dist/platform/agents/wrfc-types.d.ts.map +1 -1
- package/dist/platform/automation/types.d.ts +9 -1
- package/dist/platform/automation/types.d.ts.map +1 -1
- package/dist/platform/calendar/calendar-api-shared.d.ts +25 -0
- package/dist/platform/calendar/calendar-api-shared.d.ts.map +1 -0
- package/dist/platform/calendar/calendar-api-shared.js +100 -0
- package/dist/platform/calendar/calendar-connector.d.ts +79 -0
- package/dist/platform/calendar/calendar-connector.d.ts.map +1 -0
- package/dist/platform/calendar/calendar-connector.js +155 -0
- package/dist/platform/calendar/google-calendar-api.d.ts +25 -0
- package/dist/platform/calendar/google-calendar-api.d.ts.map +1 -0
- package/dist/platform/calendar/google-calendar-api.js +89 -0
- package/dist/platform/calendar/http-fetch-adapter.d.ts +25 -0
- package/dist/platform/calendar/http-fetch-adapter.d.ts.map +1 -0
- package/dist/platform/calendar/http-fetch-adapter.js +25 -0
- package/dist/platform/calendar/ics-parser.d.ts +35 -0
- package/dist/platform/calendar/ics-parser.d.ts.map +1 -0
- package/dist/platform/calendar/ics-parser.js +236 -0
- package/dist/platform/calendar/index.d.ts +41 -0
- package/dist/platform/calendar/index.d.ts.map +1 -0
- package/dist/platform/calendar/index.js +49 -0
- package/dist/platform/calendar/merged-calendar-model.d.ts +67 -0
- package/dist/platform/calendar/merged-calendar-model.d.ts.map +1 -0
- package/dist/platform/calendar/merged-calendar-model.js +181 -0
- package/dist/platform/calendar/microsoft-graph-api.d.ts +25 -0
- package/dist/platform/calendar/microsoft-graph-api.d.ts.map +1 -0
- package/dist/platform/calendar/microsoft-graph-api.js +95 -0
- package/dist/platform/calendar/oauth-flow.d.ts +62 -0
- package/dist/platform/calendar/oauth-flow.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-flow.js +305 -0
- package/dist/platform/calendar/oauth-providers.d.ts +43 -0
- package/dist/platform/calendar/oauth-providers.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-providers.js +120 -0
- package/dist/platform/calendar/oauth-token-store.d.ts +72 -0
- package/dist/platform/calendar/oauth-token-store.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-token-store.js +189 -0
- package/dist/platform/calendar/oauth-types.d.ts +274 -0
- package/dist/platform/calendar/oauth-types.d.ts.map +1 -0
- package/dist/platform/calendar/oauth-types.js +22 -0
- package/dist/platform/calendar/rrule.d.ts +39 -0
- package/dist/platform/calendar/rrule.d.ts.map +1 -0
- package/dist/platform/calendar/rrule.js +261 -0
- package/dist/platform/calendar/subscription-store.d.ts +118 -0
- package/dist/platform/calendar/subscription-store.d.ts.map +1 -0
- package/dist/platform/calendar/subscription-store.js +293 -0
- package/dist/platform/calendar/types.d.ts +170 -0
- package/dist/platform/calendar/types.d.ts.map +1 -0
- package/dist/platform/calendar/types.js +21 -0
- package/dist/platform/companion/companion-chat-attachments.d.ts +29 -0
- package/dist/platform/companion/companion-chat-attachments.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-attachments.js +121 -0
- package/dist/platform/companion/companion-chat-branching.d.ts +66 -0
- package/dist/platform/companion/companion-chat-branching.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-branching.js +142 -0
- package/dist/platform/companion/companion-chat-broker-bridge.d.ts +40 -0
- package/dist/platform/companion/companion-chat-broker-bridge.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-broker-bridge.js +14 -0
- package/dist/platform/companion/companion-chat-broker-sync.d.ts +38 -0
- package/dist/platform/companion/companion-chat-broker-sync.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-broker-sync.js +80 -0
- package/dist/platform/companion/companion-chat-gc.d.ts +63 -0
- package/dist/platform/companion/companion-chat-gc.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-gc.js +38 -0
- package/dist/platform/companion/companion-chat-manager.d.ts +91 -23
- package/dist/platform/companion/companion-chat-manager.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-manager.js +195 -223
- package/dist/platform/companion/companion-chat-persistence.d.ts +9 -1
- package/dist/platform/companion/companion-chat-persistence.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-persistence.js +10 -2
- package/dist/platform/companion/companion-chat-routes.d.ts +2 -1
- package/dist/platform/companion/companion-chat-routes.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-routes.js +113 -4
- package/dist/platform/companion/companion-chat-turn-execution.d.ts +61 -0
- package/dist/platform/companion/companion-chat-turn-execution.d.ts.map +1 -0
- package/dist/platform/companion/companion-chat-turn-execution.js +107 -0
- package/dist/platform/companion/companion-chat-types.d.ts +67 -0
- package/dist/platform/companion/companion-chat-types.d.ts.map +1 -1
- package/dist/platform/config/credential-status.d.ts +28 -0
- package/dist/platform/config/credential-status.d.ts.map +1 -0
- package/dist/platform/config/credential-status.js +75 -0
- package/dist/platform/config/index.d.ts +25 -0
- package/dist/platform/config/index.d.ts.map +1 -1
- package/dist/platform/config/index.js +18 -0
- package/dist/platform/config/manager.d.ts +9 -0
- package/dist/platform/config/manager.d.ts.map +1 -1
- package/dist/platform/config/manager.js +21 -2
- package/dist/platform/config/migrations.d.ts +48 -0
- package/dist/platform/config/migrations.d.ts.map +1 -0
- package/dist/platform/config/migrations.js +54 -0
- package/dist/platform/config/schema-domain-core.d.ts +10 -1
- package/dist/platform/config/schema-domain-core.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-core.js +46 -3
- package/dist/platform/config/schema-domain-runtime.d.ts +8 -0
- package/dist/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-runtime.js +32 -0
- package/dist/platform/config/schema-types.d.ts +21 -7
- package/dist/platform/config/schema-types.d.ts.map +1 -1
- package/dist/platform/config/schema.d.ts.map +1 -1
- package/dist/platform/config/schema.js +2 -0
- package/dist/platform/control-plane/approval-broker.d.ts +11 -0
- package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/approval-broker.js +17 -1
- package/dist/platform/control-plane/approval-hunk-apply.d.ts +77 -0
- package/dist/platform/control-plane/approval-hunk-apply.d.ts.map +1 -0
- package/dist/platform/control-plane/approval-hunk-apply.js +80 -0
- package/dist/platform/control-plane/gateway-disabled-response.d.ts +20 -0
- package/dist/platform/control-plane/gateway-disabled-response.d.ts.map +1 -0
- package/dist/platform/control-plane/gateway-disabled-response.js +24 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.d.ts +68 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.d.ts.map +1 -0
- package/dist/platform/control-plane/gateway-scope-enforcement.js +91 -0
- package/dist/platform/control-plane/gateway-utils.d.ts +17 -0
- package/dist/platform/control-plane/gateway-utils.d.ts.map +1 -1
- package/dist/platform/control-plane/gateway-utils.js +30 -0
- package/dist/platform/control-plane/gateway.d.ts +12 -2
- package/dist/platform/control-plane/gateway.d.ts.map +1 -1
- package/dist/platform/control-plane/gateway.js +27 -31
- package/dist/platform/control-plane/index.d.ts +8 -1
- package/dist/platform/control-plane/index.d.ts.map +1 -1
- package/dist/platform/control-plane/index.js +8 -0
- package/dist/platform/control-plane/invoke-input-validation.d.ts +56 -0
- package/dist/platform/control-plane/invoke-input-validation.d.ts.map +1 -0
- package/dist/platform/control-plane/invoke-input-validation.js +163 -0
- package/dist/platform/control-plane/method-catalog-admin.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-admin.js +12 -1
- package/dist/platform/control-plane/method-catalog-calendar.d.ts +16 -0
- package/dist/platform/control-plane/method-catalog-calendar.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-calendar.js +21 -0
- package/dist/platform/control-plane/method-catalog-channels.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-channels.js +32 -3
- package/dist/platform/control-plane/method-catalog-control-automation.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control-automation.js +19 -34
- package/dist/platform/control-plane/method-catalog-control-companion.d.ts +15 -0
- package/dist/platform/control-plane/method-catalog-control-companion.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-control-companion.js +176 -0
- package/dist/platform/control-plane/method-catalog-control-core.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control-core.js +104 -122
- package/dist/platform/control-plane/method-catalog-control.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control.js +4 -0
- package/dist/platform/control-plane/method-catalog-email.d.ts +17 -0
- package/dist/platform/control-plane/method-catalog-email.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-email.js +21 -0
- package/dist/platform/control-plane/method-catalog-events.d.ts +28 -0
- package/dist/platform/control-plane/method-catalog-events.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-events.js +74 -1
- package/dist/platform/control-plane/method-catalog-fleet.d.ts +24 -0
- package/dist/platform/control-plane/method-catalog-fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-fleet.js +65 -0
- package/dist/platform/control-plane/method-catalog-push.d.ts +30 -0
- package/dist/platform/control-plane/method-catalog-push.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-push.js +80 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.d.ts +84 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.d.ts.map +1 -0
- package/dist/platform/control-plane/method-catalog-route-reconcile.js +103 -0
- package/dist/platform/control-plane/method-catalog-runtime.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-runtime.js +83 -1
- package/dist/platform/control-plane/method-catalog-shared.d.ts +29 -0
- package/dist/platform/control-plane/method-catalog-shared.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog.d.ts +9 -0
- package/dist/platform/control-plane/method-catalog.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog.js +34 -3
- package/dist/platform/control-plane/operator-contract-schemas-admin.d.ts +8 -0
- package/dist/platform/control-plane/operator-contract-schemas-admin.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-admin.js +22 -1
- package/dist/platform/control-plane/operator-contract-schemas-fleet.d.ts +18 -0
- package/dist/platform/control-plane/operator-contract-schemas-fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/operator-contract-schemas-fleet.js +182 -0
- package/dist/platform/control-plane/operator-contract-schemas-permissions.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-permissions.js +5 -0
- package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts +37 -0
- package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-runtime.js +100 -3
- package/dist/platform/control-plane/operator-contract-schemas.d.ts +1 -0
- package/dist/platform/control-plane/operator-contract-schemas.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas.js +1 -0
- package/dist/platform/control-plane/operator-contract.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract.js +8 -0
- package/dist/platform/control-plane/routes/checkpoints.d.ts +39 -0
- package/dist/platform/control-plane/routes/checkpoints.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/checkpoints.js +166 -0
- package/dist/platform/control-plane/routes/fleet.d.ts +53 -0
- package/dist/platform/control-plane/routes/fleet.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/fleet.js +153 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.d.ts +30 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/gateway-verb-error.js +36 -0
- package/dist/platform/control-plane/routes/index.d.ts +0 -6
- package/dist/platform/control-plane/routes/index.d.ts.map +1 -1
- package/dist/platform/control-plane/routes/index.js +5 -5
- package/dist/platform/control-plane/routes/invocation-params.d.ts +23 -0
- package/dist/platform/control-plane/routes/invocation-params.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/invocation-params.js +9 -0
- package/dist/platform/control-plane/routes/push.d.ts +26 -0
- package/dist/platform/control-plane/routes/push.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/push.js +104 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.d.ts +31 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/register-gateway-verb-groups.js +16 -0
- package/dist/platform/control-plane/routes/register-w3-s2.d.ts +26 -0
- package/dist/platform/control-plane/routes/register-w3-s2.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/register-w3-s2.js +8 -0
- package/dist/platform/control-plane/routes/session-search.d.ts +37 -0
- package/dist/platform/control-plane/routes/session-search.d.ts.map +1 -0
- package/dist/platform/control-plane/routes/session-search.js +113 -0
- package/dist/platform/control-plane/session-broker-gc.d.ts +16 -0
- package/dist/platform/control-plane/session-broker-gc.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-gc.js +23 -6
- package/dist/platform/control-plane/session-broker-helpers.d.ts +3 -3
- package/dist/platform/control-plane/session-broker-helpers.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-inputs.d.ts +18 -0
- package/dist/platform/control-plane/session-broker-inputs.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-inputs.js +34 -0
- package/dist/platform/control-plane/session-broker-sessions.d.ts +102 -3
- package/dist/platform/control-plane/session-broker-sessions.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-sessions.js +179 -5
- package/dist/platform/control-plane/session-broker-state.d.ts +20 -1
- package/dist/platform/control-plane/session-broker-state.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-state.js +67 -5
- package/dist/platform/control-plane/session-broker.d.ts +51 -38
- package/dist/platform/control-plane/session-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker.js +183 -75
- package/dist/platform/control-plane/session-store-importer.d.ts +57 -0
- package/dist/platform/control-plane/session-store-importer.d.ts.map +1 -0
- package/dist/platform/control-plane/session-store-importer.js +227 -0
- package/dist/platform/control-plane/session-types.d.ts +142 -7
- package/dist/platform/control-plane/session-types.d.ts.map +1 -1
- package/dist/platform/core/execution-plan.d.ts +43 -1
- package/dist/platform/core/execution-plan.d.ts.map +1 -1
- package/dist/platform/core/execution-plan.js +46 -10
- package/dist/platform/core/index.d.ts +1 -0
- package/dist/platform/core/index.d.ts.map +1 -1
- package/dist/platform/core/index.js +1 -0
- package/dist/platform/core/orchestrator-runtime.d.ts +23 -3
- package/dist/platform/core/orchestrator-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-tool-runtime.d.ts +7 -0
- package/dist/platform/core/orchestrator-tool-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-tool-runtime.js +10 -0
- package/dist/platform/core/orchestrator-turn-loop.d.ts +13 -6
- package/dist/platform/core/orchestrator-turn-loop.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-turn-loop.js +29 -22
- package/dist/platform/core/orchestrator.d.ts +16 -10
- package/dist/platform/core/orchestrator.d.ts.map +1 -1
- package/dist/platform/core/orchestrator.js +23 -8
- package/dist/platform/core/plan-decomposition.d.ts +196 -0
- package/dist/platform/core/plan-decomposition.d.ts.map +1 -0
- package/dist/platform/core/plan-decomposition.js +417 -0
- package/dist/platform/core/plan-proposal.d.ts +39 -0
- package/dist/platform/core/plan-proposal.d.ts.map +1 -1
- package/dist/platform/core/wrfc-routing.d.ts +1 -0
- package/dist/platform/core/wrfc-routing.d.ts.map +1 -1
- package/dist/platform/core/wrfc-routing.js +51 -1
- package/dist/platform/daemon/boot.d.ts +69 -0
- package/dist/platform/daemon/boot.d.ts.map +1 -0
- package/dist/platform/daemon/boot.js +61 -0
- package/dist/platform/daemon/cli.js +2 -1
- package/dist/platform/daemon/control-plane.d.ts.map +1 -1
- package/dist/platform/daemon/control-plane.js +50 -1
- package/dist/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/platform/daemon/facade-composition.js +6 -0
- package/dist/platform/daemon/facade.d.ts +15 -6
- package/dist/platform/daemon/facade.d.ts.map +1 -1
- package/dist/platform/daemon/facade.js +48 -43
- package/dist/platform/daemon/http/router-route-contexts.d.ts +1 -0
- package/dist/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/platform/daemon/http/router-route-contexts.js +1 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.d.ts +13 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.d.ts.map +1 -0
- package/dist/platform/daemon/http/router-session-broker-adapter.js +27 -0
- package/dist/platform/daemon/http/router.d.ts +2 -1
- package/dist/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/platform/daemon/http/router.js +42 -40
- package/dist/platform/daemon/http/runtime-route-types.d.ts +42 -4
- package/dist/platform/daemon/http/runtime-route-types.d.ts.map +1 -1
- package/dist/platform/daemon/http/webui-serving.d.ts +68 -0
- package/dist/platform/daemon/http/webui-serving.d.ts.map +1 -0
- package/dist/platform/daemon/http/webui-serving.js +230 -0
- package/dist/platform/daemon/index.d.ts +2 -0
- package/dist/platform/daemon/index.d.ts.map +1 -1
- package/dist/platform/daemon/index.js +1 -0
- package/dist/platform/daemon/service-manager.d.ts +16 -0
- package/dist/platform/daemon/service-manager.d.ts.map +1 -1
- package/dist/platform/daemon/service-manager.js +79 -15
- package/dist/platform/intelligence/tree-sitter/service.d.ts.map +1 -1
- package/dist/platform/intelligence/tree-sitter/service.js +16 -2
- package/dist/platform/knowledge/browser-history/readers.d.ts.map +1 -1
- package/dist/platform/knowledge/browser-history/readers.js +15 -5
- package/dist/platform/knowledge/knowledge-api.d.ts +1 -1
- package/dist/platform/knowledge/project-planning/service.d.ts +14 -1
- package/dist/platform/knowledge/project-planning/service.d.ts.map +1 -1
- package/dist/platform/knowledge/project-planning/service.js +77 -0
- package/dist/platform/knowledge/project-planning/types.d.ts +32 -0
- package/dist/platform/knowledge/project-planning/types.d.ts.map +1 -1
- package/dist/platform/orchestration/bookkeeping.d.ts +12 -0
- package/dist/platform/orchestration/bookkeeping.d.ts.map +1 -0
- package/dist/platform/orchestration/bookkeeping.js +91 -0
- package/dist/platform/orchestration/budget.d.ts +2 -2
- package/dist/platform/orchestration/cancellation.d.ts +2 -2
- package/dist/platform/orchestration/controller-compat.d.ts +16 -3
- package/dist/platform/orchestration/controller-compat.d.ts.map +1 -1
- package/dist/platform/orchestration/controller-compat.js +18 -4
- package/dist/platform/orchestration/dirty-guard.js +1 -1
- package/dist/platform/orchestration/engine.d.ts +26 -1
- package/dist/platform/orchestration/engine.d.ts.map +1 -1
- package/dist/platform/orchestration/engine.js +229 -25
- package/dist/platform/orchestration/index.d.ts +6 -4
- package/dist/platform/orchestration/index.d.ts.map +1 -1
- package/dist/platform/orchestration/index.js +3 -2
- package/dist/platform/orchestration/persistence.d.ts.map +1 -1
- package/dist/platform/orchestration/persistence.js +6 -3
- package/dist/platform/orchestration/phase-runner.d.ts +33 -6
- package/dist/platform/orchestration/phase-runner.d.ts.map +1 -1
- package/dist/platform/orchestration/phase-runner.js +98 -25
- package/dist/platform/orchestration/proposal-workstream.d.ts +56 -0
- package/dist/platform/orchestration/proposal-workstream.d.ts.map +1 -0
- package/dist/platform/orchestration/proposal-workstream.js +76 -0
- package/dist/platform/orchestration/scheduler.d.ts +20 -1
- package/dist/platform/orchestration/scheduler.d.ts.map +1 -1
- package/dist/platform/orchestration/scheduler.js +16 -0
- package/dist/platform/orchestration/types.d.ts +289 -4
- package/dist/platform/orchestration/types.d.ts.map +1 -1
- package/dist/platform/orchestration/types.js +32 -0
- package/dist/platform/orchestration/worktree-isolation.d.ts +33 -0
- package/dist/platform/orchestration/worktree-isolation.d.ts.map +1 -0
- package/dist/platform/orchestration/worktree-isolation.js +248 -0
- package/dist/platform/presentation/glyphs.d.ts +91 -0
- package/dist/platform/presentation/glyphs.d.ts.map +1 -0
- package/dist/platform/presentation/glyphs.js +93 -0
- package/dist/platform/presentation/index.d.ts +28 -0
- package/dist/platform/presentation/index.d.ts.map +1 -0
- package/dist/platform/presentation/index.js +27 -0
- package/dist/platform/presentation/thinking-phrases.d.ts +12 -0
- package/dist/platform/presentation/thinking-phrases.d.ts.map +1 -0
- package/dist/platform/presentation/thinking-phrases.js +32 -0
- package/dist/platform/presentation/tones.d.ts +121 -0
- package/dist/platform/presentation/tones.d.ts.map +1 -0
- package/dist/platform/presentation/tones.js +145 -0
- package/dist/platform/presentation/waiting-wording.d.ts +54 -0
- package/dist/platform/presentation/waiting-wording.d.ts.map +1 -0
- package/dist/platform/presentation/waiting-wording.js +51 -0
- package/dist/platform/providers/runtime-snapshot.d.ts.map +1 -1
- package/dist/platform/providers/runtime-snapshot.js +12 -2
- package/dist/platform/push/delivery.d.ts +48 -0
- package/dist/platform/push/delivery.d.ts.map +1 -0
- package/dist/platform/push/delivery.js +117 -0
- package/dist/platform/push/encryption.d.ts +41 -0
- package/dist/platform/push/encryption.d.ts.map +1 -0
- package/dist/platform/push/encryption.js +82 -0
- package/dist/platform/push/index.d.ts +17 -0
- package/dist/platform/push/index.d.ts.map +1 -0
- package/dist/platform/push/index.js +10 -0
- package/dist/platform/push/service.d.ts +75 -0
- package/dist/platform/push/service.d.ts.map +1 -0
- package/dist/platform/push/service.js +95 -0
- package/dist/platform/push/subscription-store.d.ts +50 -0
- package/dist/platform/push/subscription-store.d.ts.map +1 -0
- package/dist/platform/push/subscription-store.js +123 -0
- package/dist/platform/push/types.d.ts +68 -0
- package/dist/platform/push/types.d.ts.map +1 -0
- package/dist/platform/push/types.js +13 -0
- package/dist/platform/push/vapid.d.ts +54 -0
- package/dist/platform/push/vapid.d.ts.map +1 -0
- package/dist/platform/push/vapid.js +113 -0
- package/dist/platform/runtime/bootstrap-services.d.ts +62 -2
- package/dist/platform/runtime/bootstrap-services.d.ts.map +1 -1
- package/dist/platform/runtime/bootstrap-services.js +217 -50
- package/dist/platform/runtime/daemon-version-compat.d.ts +39 -0
- package/dist/platform/runtime/daemon-version-compat.d.ts.map +1 -0
- package/dist/platform/runtime/daemon-version-compat.js +75 -0
- package/dist/platform/runtime/detached-daemon-runtime.d.ts +26 -0
- package/dist/platform/runtime/detached-daemon-runtime.d.ts.map +1 -0
- package/dist/platform/runtime/detached-daemon-runtime.js +49 -0
- package/dist/platform/runtime/emitters/workflows.d.ts +1 -1
- package/dist/platform/runtime/emitters/workflows.d.ts.map +1 -1
- package/dist/platform/runtime/events/index.d.ts +13 -0
- package/dist/platform/runtime/events/index.d.ts.map +1 -1
- package/dist/platform/runtime/events/index.js +13 -0
- package/dist/platform/runtime/feature-flags/flags.d.ts.map +1 -1
- package/dist/platform/runtime/feature-flags/flags.js +39 -1
- package/dist/platform/runtime/fleet/adapters/agent.d.ts +2 -2
- package/dist/platform/runtime/fleet/adapters/agent.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/agent.js +4 -4
- package/dist/platform/runtime/fleet/adapters/automation.d.ts +1 -1
- package/dist/platform/runtime/fleet/adapters/automation.js +1 -1
- package/dist/platform/runtime/fleet/adapters/code-index.d.ts +1 -1
- package/dist/platform/runtime/fleet/adapters/code-index.js +1 -1
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts +40 -18
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/orchestration.js +138 -34
- package/dist/platform/runtime/fleet/adapters/schedule.d.ts +4 -4
- package/dist/platform/runtime/fleet/adapters/schedule.js +4 -4
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts +3 -4
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/trigger.js +3 -4
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts +13 -0
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/adapters/wrfc.js +49 -2
- package/dist/platform/runtime/fleet/registry.d.ts +7 -7
- package/dist/platform/runtime/fleet/registry.d.ts.map +1 -1
- package/dist/platform/runtime/fleet/registry.js +41 -7
- package/dist/platform/runtime/fleet/types.d.ts +9 -9
- package/dist/platform/runtime/fleet/types.d.ts.map +1 -1
- package/dist/platform/runtime/memory-spine/client.d.ts +127 -0
- package/dist/platform/runtime/memory-spine/client.d.ts.map +1 -0
- package/dist/platform/runtime/memory-spine/client.js +113 -0
- package/dist/platform/runtime/memory-spine/index.d.ts +11 -0
- package/dist/platform/runtime/memory-spine/index.d.ts.map +1 -0
- package/dist/platform/runtime/memory-spine/index.js +10 -0
- package/dist/platform/runtime/operator-client.d.ts +20 -2
- package/dist/platform/runtime/operator-client.d.ts.map +1 -1
- package/dist/platform/runtime/operator-client.js +11 -1
- package/dist/platform/runtime/provider-accounts/registry.d.ts.map +1 -1
- package/dist/platform/runtime/provider-accounts/registry.js +11 -1
- package/dist/platform/runtime/services.d.ts +11 -9
- package/dist/platform/runtime/services.d.ts.map +1 -1
- package/dist/platform/runtime/services.js +24 -9
- package/dist/platform/runtime/session-spine/client.d.ts +234 -0
- package/dist/platform/runtime/session-spine/client.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/client.js +449 -0
- package/dist/platform/runtime/session-spine/index.d.ts +12 -0
- package/dist/platform/runtime/session-spine/index.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/index.js +11 -0
- package/dist/platform/runtime/session-spine/union-cache.d.ts +225 -0
- package/dist/platform/runtime/session-spine/union-cache.d.ts.map +1 -0
- package/dist/platform/runtime/session-spine/union-cache.js +333 -0
- package/dist/platform/runtime/shell-command-ops.d.ts +3 -1
- package/dist/platform/runtime/shell-command-ops.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client-validators.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client-validators.js +22 -0
- package/dist/platform/runtime/transports/daemon-http-client.d.ts.map +1 -1
- package/dist/platform/runtime/transports/daemon-http-client.js +25 -2
- package/dist/platform/runtime/transports/http-types.d.ts +9 -2
- package/dist/platform/runtime/transports/http-types.d.ts.map +1 -1
- package/dist/platform/state/canonical-memory.d.ts +95 -0
- package/dist/platform/state/canonical-memory.d.ts.map +1 -0
- package/dist/platform/state/canonical-memory.js +155 -0
- package/dist/platform/state/code-index-chunking.js +1 -1
- package/dist/platform/state/code-index-db.d.ts +1 -1
- package/dist/platform/state/code-index-reindex.d.ts +73 -0
- package/dist/platform/state/code-index-reindex.d.ts.map +1 -0
- package/dist/platform/state/code-index-reindex.js +156 -0
- package/dist/platform/state/code-index-store.d.ts.map +1 -1
- package/dist/platform/state/code-index-store.js +11 -3
- package/dist/platform/state/index.d.ts +8 -0
- package/dist/platform/state/index.d.ts.map +1 -1
- package/dist/platform/state/index.js +4 -0
- package/dist/platform/state/memory-recall-contract.d.ts +118 -0
- package/dist/platform/state/memory-recall-contract.d.ts.map +1 -0
- package/dist/platform/state/memory-recall-contract.js +170 -0
- package/dist/platform/state/memory-registry.d.ts +8 -0
- package/dist/platform/state/memory-registry.d.ts.map +1 -1
- package/dist/platform/state/memory-registry.js +10 -0
- package/dist/platform/state/memory-store.d.ts +2 -0
- package/dist/platform/state/memory-store.d.ts.map +1 -1
- package/dist/platform/state/memory-store.js +4 -0
- package/dist/platform/state/memory-vector-store.d.ts.map +1 -1
- package/dist/platform/state/memory-vector-store.js +14 -3
- package/dist/platform/state/sqlite-store.d.ts +2 -0
- package/dist/platform/state/sqlite-store.d.ts.map +1 -1
- package/dist/platform/state/sqlite-store.js +4 -0
- package/dist/platform/state/sqlite-vec-loader.d.ts +1 -1
- package/dist/platform/state/sqlite-vec-loader.js +1 -1
- package/dist/platform/state/vibe-projection.d.ts +67 -0
- package/dist/platform/state/vibe-projection.d.ts.map +1 -0
- package/dist/platform/state/vibe-projection.js +115 -0
- package/dist/platform/tools/agent/index.d.ts.map +1 -1
- package/dist/platform/tools/agent/index.js +8 -0
- package/dist/platform/tools/agent/manager.d.ts +22 -10
- package/dist/platform/tools/agent/manager.d.ts.map +1 -1
- package/dist/platform/tools/agent/manager.js +13 -7
- package/dist/platform/tools/agent/schema.d.ts +26 -0
- package/dist/platform/tools/agent/schema.d.ts.map +1 -1
- package/dist/platform/tools/agent/schema.js +2 -2
- package/dist/platform/tools/agent/wrfc-batch-policy.d.ts +13 -0
- package/dist/platform/tools/agent/wrfc-batch-policy.d.ts.map +1 -1
- package/dist/platform/tools/agent/wrfc-batch-policy.js +60 -0
- package/dist/platform/tools/exec/runtime.d.ts +10 -0
- package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
- package/dist/platform/tools/exec/runtime.js +27 -10
- package/dist/platform/tools/exec/schema.d.ts +2 -2
- package/dist/platform/tools/exec/schema.d.ts.map +1 -1
- package/dist/platform/tools/exec/schema.js +2 -1
- package/dist/platform/tools/fetch/runtime.d.ts +1 -1
- package/dist/platform/tools/index.d.ts +2 -0
- package/dist/platform/tools/index.d.ts.map +1 -1
- package/dist/platform/tools/index.js +2 -0
- package/dist/platform/tools/registry.d.ts +1 -1
- package/dist/platform/tools/registry.js +1 -1
- package/dist/platform/tools/state/index.d.ts +9 -0
- package/dist/platform/tools/state/index.d.ts.map +1 -1
- package/dist/platform/tools/state/index.js +60 -3
- package/dist/platform/types/foundation-contract.d.ts +1 -1
- package/dist/platform/types/foundation-contract.d.ts.map +1 -1
- package/dist/platform/types/index.d.ts +1 -1
- package/dist/platform/types/index.d.ts.map +1 -1
- package/dist/platform/types/tools.d.ts +1 -1
- package/dist/platform/utils/request-body.d.ts.map +1 -1
- package/dist/platform/utils/request-body.js +50 -5
- package/dist/platform/version.js +1 -1
- package/package.json +25 -9
- package/dist/platform/control-plane/routes/automation.d.ts +0 -3
- package/dist/platform/control-plane/routes/automation.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/automation.js +0 -63
- package/dist/platform/control-plane/routes/context.d.ts +0 -2
- package/dist/platform/control-plane/routes/context.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/context.js +0 -1
- package/dist/platform/control-plane/routes/operator.d.ts +0 -8
- package/dist/platform/control-plane/routes/operator.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/operator.js +0 -415
- package/dist/platform/control-plane/routes/remote.d.ts +0 -3
- package/dist/platform/control-plane/routes/remote.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/remote.js +0 -35
- package/dist/platform/control-plane/routes/sessions.d.ts +0 -3
- package/dist/platform/control-plane/routes/sessions.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/sessions.js +0 -43
- package/dist/platform/control-plane/routes/tasks.d.ts +0 -3
- package/dist/platform/control-plane/routes/tasks.d.ts.map +0 -1
- package/dist/platform/control-plane/routes/tasks.js +0 -22
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/encryption.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-push payload encryption, implemented with Node's built-in crypto
|
|
5
|
+
* (node:crypto) — no third-party web-push dependency. This is the daemon-side
|
|
6
|
+
* (Node/Bun) delivery path only; nothing here is imported by the runtime-neutral
|
|
7
|
+
* or browser bundles (see scripts/browser-compat-check.ts).
|
|
8
|
+
*
|
|
9
|
+
* Two standards are combined here, exactly as a browser Push service expects:
|
|
10
|
+
*
|
|
11
|
+
* - RFC 8291 (Message Encryption for Web Push): derive a shared secret from an
|
|
12
|
+
* ephemeral P-256 keypair and the subscription's public key + auth secret.
|
|
13
|
+
* - RFC 8188 (aes128gcm content encoding): expand that secret into a
|
|
14
|
+
* content-encryption key + nonce and encrypt one record, then frame it with
|
|
15
|
+
* the salt / record-size / sender-public-key header the receiver reads back.
|
|
16
|
+
*
|
|
17
|
+
* The output Buffer is the raw request body sent to the subscription endpoint
|
|
18
|
+
* with `Content-Encoding: aes128gcm`.
|
|
19
|
+
*/
|
|
20
|
+
import { createCipheriv, createECDH, createHmac, randomBytes } from 'node:crypto';
|
|
21
|
+
/**
|
|
22
|
+
* Single fixed record size. Push payloads here (an approval summary, a
|
|
23
|
+
* completion note) are far below this, so one aes128gcm record always
|
|
24
|
+
* suffices; a payload that would not fit is rejected honestly rather than
|
|
25
|
+
* silently truncated or split.
|
|
26
|
+
*/
|
|
27
|
+
const RECORD_SIZE = 4096;
|
|
28
|
+
const KEY_INFO_PREFIX = Buffer.from('WebPush: info\0', 'utf8');
|
|
29
|
+
const CEK_INFO = Buffer.from('Content-Encoding: aes128gcm\0', 'utf8');
|
|
30
|
+
const NONCE_INFO = Buffer.from('Content-Encoding: nonce\0', 'utf8');
|
|
31
|
+
/** HKDF (RFC 5869) specialized to a single output block (length <= 32). */
|
|
32
|
+
function hkdf(salt, ikm, info, length) {
|
|
33
|
+
const prk = createHmac('sha256', salt).update(ikm).digest();
|
|
34
|
+
const okm = createHmac('sha256', prk).update(Buffer.concat([info, Buffer.from([0x01])])).digest();
|
|
35
|
+
return okm.subarray(0, length);
|
|
36
|
+
}
|
|
37
|
+
function base64UrlToBuffer(value) {
|
|
38
|
+
return Buffer.from(value, 'base64url');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Encrypt `plaintext` for a subscription's key material.
|
|
42
|
+
*
|
|
43
|
+
* A fresh ephemeral sender keypair and salt are generated per call (RFC 8291
|
|
44
|
+
* requires this — the same salt/key pair must never encrypt two messages), so
|
|
45
|
+
* the result is non-deterministic by design.
|
|
46
|
+
*/
|
|
47
|
+
export function encryptPushPayload(keys, plaintext) {
|
|
48
|
+
const receiverPublic = base64UrlToBuffer(keys.p256dh);
|
|
49
|
+
const authSecret = base64UrlToBuffer(keys.auth);
|
|
50
|
+
if (receiverPublic.length !== 65) {
|
|
51
|
+
throw new Error('Push subscription p256dh key is not a 65-byte uncompressed P-256 point');
|
|
52
|
+
}
|
|
53
|
+
if (authSecret.length !== 16) {
|
|
54
|
+
throw new Error('Push subscription auth secret is not 16 bytes');
|
|
55
|
+
}
|
|
56
|
+
// Ephemeral sender (application-server) keypair for this one message.
|
|
57
|
+
const sender = createECDH('prime256v1');
|
|
58
|
+
sender.generateKeys();
|
|
59
|
+
const senderPublic = sender.getPublicKey();
|
|
60
|
+
const sharedSecret = sender.computeSecret(receiverPublic);
|
|
61
|
+
const salt = randomBytes(16);
|
|
62
|
+
// RFC 8291: mix the shared secret with the auth secret and both public keys.
|
|
63
|
+
const keyInfo = Buffer.concat([KEY_INFO_PREFIX, receiverPublic, senderPublic]);
|
|
64
|
+
const ikm = hkdf(authSecret, sharedSecret, keyInfo, 32);
|
|
65
|
+
// RFC 8188: expand into the content-encryption key and nonce.
|
|
66
|
+
const contentEncryptionKey = hkdf(salt, ikm, CEK_INFO, 16);
|
|
67
|
+
const nonce = hkdf(salt, ikm, NONCE_INFO, 12);
|
|
68
|
+
// One record: plaintext followed by the 0x02 last-record delimiter.
|
|
69
|
+
const record = Buffer.concat([plaintext, Buffer.from([0x02])]);
|
|
70
|
+
if (record.length + 16 > RECORD_SIZE) {
|
|
71
|
+
throw new Error(`Push payload too large for a single aes128gcm record (max ${RECORD_SIZE - 17} bytes)`);
|
|
72
|
+
}
|
|
73
|
+
const cipher = createCipheriv('aes-128-gcm', contentEncryptionKey, nonce);
|
|
74
|
+
const ciphertext = Buffer.concat([cipher.update(record), cipher.final(), cipher.getAuthTag()]);
|
|
75
|
+
// aes128gcm header: salt(16) | record-size(4, big-endian) | keyid-len(1) | keyid(=senderPublic).
|
|
76
|
+
const header = Buffer.alloc(16 + 4 + 1 + senderPublic.length);
|
|
77
|
+
salt.copy(header, 0);
|
|
78
|
+
header.writeUInt32BE(RECORD_SIZE, 16);
|
|
79
|
+
header.writeUInt8(senderPublic.length, 20);
|
|
80
|
+
senderPublic.copy(header, 21);
|
|
81
|
+
return { body: Buffer.concat([header, ciphertext]), contentEncoding: 'aes128gcm' };
|
|
82
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/index.ts — the browser-push module barrel (VAPID custody, subscription
|
|
3
|
+
* store, RFC 8291 encryption, and the delivery path). Daemon-side only; not
|
|
4
|
+
* part of the runtime-neutral or browser bundles.
|
|
5
|
+
*/
|
|
6
|
+
export { encryptPushPayload } from './encryption.js';
|
|
7
|
+
export type { SubscriptionKeyMaterial, EncryptedPushPayload } from './encryption.js';
|
|
8
|
+
export { VapidManager, VAPID_SECRET_KEY } from './vapid.js';
|
|
9
|
+
export type { VapidSecretStore, VapidManagerOptions } from './vapid.js';
|
|
10
|
+
export { PushSubscriptionStore, toPublicSubscription } from './subscription-store.js';
|
|
11
|
+
export type { RegisterSubscriptionInput } from './subscription-store.js';
|
|
12
|
+
export { deliverToSubscription, deliverToAll } from './delivery.js';
|
|
13
|
+
export type { PushTransport, DeliveryDeps } from './delivery.js';
|
|
14
|
+
export { PushService } from './service.js';
|
|
15
|
+
export type { PushServiceDeps, SubscribeInput, ApprovalSource, ApprovalNotice } from './service.js';
|
|
16
|
+
export type { StoredPushSubscription, PublicPushSubscription, PushDeliveryOutcome, PushDeliveryReceipt, PushUrgency, PushMessage, } from './types.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/push/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACtF,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpG,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/index.ts — the browser-push module barrel (VAPID custody, subscription
|
|
3
|
+
* store, RFC 8291 encryption, and the delivery path). Daemon-side only; not
|
|
4
|
+
* part of the runtime-neutral or browser bundles.
|
|
5
|
+
*/
|
|
6
|
+
export { encryptPushPayload } from './encryption.js';
|
|
7
|
+
export { VapidManager, VAPID_SECRET_KEY } from './vapid.js';
|
|
8
|
+
export { PushSubscriptionStore, toPublicSubscription } from './subscription-store.js';
|
|
9
|
+
export { deliverToSubscription, deliverToAll } from './delivery.js';
|
|
10
|
+
export { PushService } from './service.js';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/service.ts
|
|
3
|
+
*
|
|
4
|
+
* PushService — the seam the gateway verbs and the daemon event sources both
|
|
5
|
+
* talk to. It owns the subscription store, the VAPID key custody, and the
|
|
6
|
+
* delivery path, and it turns a real daemon event (an approval that needs a
|
|
7
|
+
* decision) into a fan-out of encrypted pushes.
|
|
8
|
+
*
|
|
9
|
+
* Honest-degrade posture, end to end:
|
|
10
|
+
* - No subscriptions -> `deliver()` returns an empty receipt list; nothing is
|
|
11
|
+
* faked as sent.
|
|
12
|
+
* - A subscription whose endpoint is gone (404/410) is pruned by the delivery
|
|
13
|
+
* path and reported as `pruned`.
|
|
14
|
+
* - VAPID keys are minted lazily on first real need; a daemon that never uses
|
|
15
|
+
* push never generates or stores a key.
|
|
16
|
+
*/
|
|
17
|
+
import { type PushTransport } from './delivery.js';
|
|
18
|
+
import { PushSubscriptionStore } from './subscription-store.js';
|
|
19
|
+
import { VapidManager } from './vapid.js';
|
|
20
|
+
import type { PublicPushSubscription, PushDeliveryReceipt, PushMessage, SubscriptionKeyMaterial } from './types.js';
|
|
21
|
+
/** The slice of the approval broker the push delivery source subscribes to. */
|
|
22
|
+
export interface ApprovalSource {
|
|
23
|
+
subscribe(listener: (approval: ApprovalNotice) => void): () => void;
|
|
24
|
+
}
|
|
25
|
+
/** The minimum an approval record needs to expose to become a push. */
|
|
26
|
+
export interface ApprovalNotice {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly status: string;
|
|
29
|
+
readonly request?: {
|
|
30
|
+
readonly tool?: string;
|
|
31
|
+
readonly analysis?: {
|
|
32
|
+
readonly summary?: string;
|
|
33
|
+
};
|
|
34
|
+
} | undefined;
|
|
35
|
+
}
|
|
36
|
+
export interface PushServiceDeps {
|
|
37
|
+
readonly vapid: VapidManager;
|
|
38
|
+
readonly store: PushSubscriptionStore;
|
|
39
|
+
/** Overridable delivery transport; production uses the built-in fetch. */
|
|
40
|
+
readonly transport?: PushTransport | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface SubscribeInput {
|
|
43
|
+
readonly principalId: string;
|
|
44
|
+
readonly endpoint: string;
|
|
45
|
+
readonly keys: SubscriptionKeyMaterial;
|
|
46
|
+
}
|
|
47
|
+
export declare class PushService {
|
|
48
|
+
private readonly vapid;
|
|
49
|
+
private readonly store;
|
|
50
|
+
private readonly transport?;
|
|
51
|
+
/** Approval ids already pushed, so re-publishes (claim/approve) don't re-notify. */
|
|
52
|
+
private readonly notifiedApprovals;
|
|
53
|
+
constructor(deps: PushServiceDeps);
|
|
54
|
+
/** The public VAPID key clients subscribe with. */
|
|
55
|
+
getPublicKey(): Promise<string>;
|
|
56
|
+
subscribe(input: SubscribeInput): Promise<PublicPushSubscription>;
|
|
57
|
+
listSubscriptions(principalId: string): Promise<PublicPushSubscription[]>;
|
|
58
|
+
/** Delete a subscription for a principal. False when the id was already absent. */
|
|
59
|
+
unsubscribe(id: string, principalId: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Send a test push to one of the principal's subscriptions and return the
|
|
62
|
+
* honest receipt (delivered / pruned / failed). Returns null when the id is
|
|
63
|
+
* not a subscription owned by this principal, so the verb can 404.
|
|
64
|
+
*/
|
|
65
|
+
verify(id: string, principalId: string): Promise<PushDeliveryReceipt | null>;
|
|
66
|
+
/** Fan a message out to every stored subscription. */
|
|
67
|
+
deliver(message: PushMessage): Promise<PushDeliveryReceipt[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Wire a real event source: when an approval is created (status `pending`),
|
|
70
|
+
* push it to every registered device. Later re-publishes of the same approval
|
|
71
|
+
* (claimed/approved/denied) do not re-notify. Returns an unsubscribe handle.
|
|
72
|
+
*/
|
|
73
|
+
attachApprovalSource(source: ApprovalSource): () => void;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/platform/push/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAuC,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACrE;AAED,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,SAAS,CAAC;CAC9G;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;CACxC;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAA4B;IACvD,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;gBAE3C,IAAI,EAAE,eAAe;IAMjC,mDAAmD;IACnD,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAIzB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKvE,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAIzE,mFAAmF;IACnF,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9D;;;;OAIG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAclF,sDAAsD;IACtD,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAI7D;;;;OAIG;IACH,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI;CAsBzD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/service.ts
|
|
3
|
+
*
|
|
4
|
+
* PushService — the seam the gateway verbs and the daemon event sources both
|
|
5
|
+
* talk to. It owns the subscription store, the VAPID key custody, and the
|
|
6
|
+
* delivery path, and it turns a real daemon event (an approval that needs a
|
|
7
|
+
* decision) into a fan-out of encrypted pushes.
|
|
8
|
+
*
|
|
9
|
+
* Honest-degrade posture, end to end:
|
|
10
|
+
* - No subscriptions -> `deliver()` returns an empty receipt list; nothing is
|
|
11
|
+
* faked as sent.
|
|
12
|
+
* - A subscription whose endpoint is gone (404/410) is pruned by the delivery
|
|
13
|
+
* path and reported as `pruned`.
|
|
14
|
+
* - VAPID keys are minted lazily on first real need; a daemon that never uses
|
|
15
|
+
* push never generates or stores a key.
|
|
16
|
+
*/
|
|
17
|
+
import { logger } from '../utils/logger.js';
|
|
18
|
+
import { deliverToAll, deliverToSubscription } from './delivery.js';
|
|
19
|
+
import { PushSubscriptionStore, toPublicSubscription } from './subscription-store.js';
|
|
20
|
+
import { VapidManager } from './vapid.js';
|
|
21
|
+
export class PushService {
|
|
22
|
+
vapid;
|
|
23
|
+
store;
|
|
24
|
+
transport;
|
|
25
|
+
/** Approval ids already pushed, so re-publishes (claim/approve) don't re-notify. */
|
|
26
|
+
notifiedApprovals = new Set();
|
|
27
|
+
constructor(deps) {
|
|
28
|
+
this.vapid = deps.vapid;
|
|
29
|
+
this.store = deps.store;
|
|
30
|
+
this.transport = deps.transport;
|
|
31
|
+
}
|
|
32
|
+
/** The public VAPID key clients subscribe with. */
|
|
33
|
+
getPublicKey() {
|
|
34
|
+
return this.vapid.getPublicKey();
|
|
35
|
+
}
|
|
36
|
+
async subscribe(input) {
|
|
37
|
+
const record = await this.store.register(input);
|
|
38
|
+
return toPublicSubscription(record);
|
|
39
|
+
}
|
|
40
|
+
listSubscriptions(principalId) {
|
|
41
|
+
return this.store.listPublic(principalId);
|
|
42
|
+
}
|
|
43
|
+
/** Delete a subscription for a principal. False when the id was already absent. */
|
|
44
|
+
unsubscribe(id, principalId) {
|
|
45
|
+
return this.store.remove(id, principalId);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Send a test push to one of the principal's subscriptions and return the
|
|
49
|
+
* honest receipt (delivered / pruned / failed). Returns null when the id is
|
|
50
|
+
* not a subscription owned by this principal, so the verb can 404.
|
|
51
|
+
*/
|
|
52
|
+
async verify(id, principalId) {
|
|
53
|
+
const record = await this.store.get(id);
|
|
54
|
+
if (!record || record.principalId !== principalId)
|
|
55
|
+
return null;
|
|
56
|
+
return deliverToSubscription(record, {
|
|
57
|
+
title: 'GoodVibes test notification',
|
|
58
|
+
body: 'Browser push is wired up and working.',
|
|
59
|
+
urgency: 'normal',
|
|
60
|
+
}, { vapid: this.vapid, store: this.store, transport: this.transport });
|
|
61
|
+
}
|
|
62
|
+
/** Fan a message out to every stored subscription. */
|
|
63
|
+
deliver(message) {
|
|
64
|
+
return deliverToAll(message, { vapid: this.vapid, store: this.store, transport: this.transport });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Wire a real event source: when an approval is created (status `pending`),
|
|
68
|
+
* push it to every registered device. Later re-publishes of the same approval
|
|
69
|
+
* (claimed/approved/denied) do not re-notify. Returns an unsubscribe handle.
|
|
70
|
+
*/
|
|
71
|
+
attachApprovalSource(source) {
|
|
72
|
+
return source.subscribe((approval) => {
|
|
73
|
+
if (approval.status !== 'pending')
|
|
74
|
+
return;
|
|
75
|
+
if (this.notifiedApprovals.has(approval.id))
|
|
76
|
+
return;
|
|
77
|
+
this.notifiedApprovals.add(approval.id);
|
|
78
|
+
const tool = approval.request?.tool ?? 'a tool';
|
|
79
|
+
const summary = approval.request?.analysis?.summary ?? 'A pending action needs your decision.';
|
|
80
|
+
// Fire-and-forget: an approval must never block on a push, and a delivery
|
|
81
|
+
// failure is already captured as an honest receipt/outcome inside deliver().
|
|
82
|
+
void this.deliver({
|
|
83
|
+
title: 'Approval required',
|
|
84
|
+
body: `${tool}: ${summary}`,
|
|
85
|
+
data: { kind: 'approval', approvalId: approval.id },
|
|
86
|
+
urgency: 'high',
|
|
87
|
+
}).catch((error) => {
|
|
88
|
+
logger.warn('PushService: approval fan-out failed', {
|
|
89
|
+
approvalId: approval.id,
|
|
90
|
+
error: error instanceof Error ? error.message : String(error),
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/subscription-store.ts
|
|
3
|
+
*
|
|
4
|
+
* The on-disk record of which devices an operator has registered for browser
|
|
5
|
+
* push. Persisted with the same atomic-JSON `PersistentStore` the approval and
|
|
6
|
+
* session stores use — the capability URLs and key material stay on disk in the
|
|
7
|
+
* daemon's own state directory, never on the wire.
|
|
8
|
+
*
|
|
9
|
+
* Delete means delete: `remove()` drops the record entirely (it does not flag a
|
|
10
|
+
* tombstone), and `list()` cannot return it afterward. Pruning a dead endpoint
|
|
11
|
+
* uses the same `remove()` path.
|
|
12
|
+
*/
|
|
13
|
+
import type { PublicPushSubscription, StoredPushSubscription, SubscriptionKeyMaterial } from './types.js';
|
|
14
|
+
export interface RegisterSubscriptionInput {
|
|
15
|
+
readonly principalId: string;
|
|
16
|
+
readonly endpoint: string;
|
|
17
|
+
readonly keys: SubscriptionKeyMaterial;
|
|
18
|
+
}
|
|
19
|
+
/** The redacted, wire-safe projection of a stored subscription. */
|
|
20
|
+
export declare function toPublicSubscription(record: StoredPushSubscription): PublicPushSubscription;
|
|
21
|
+
export declare class PushSubscriptionStore {
|
|
22
|
+
private readonly store;
|
|
23
|
+
private records;
|
|
24
|
+
constructor(filePath: string);
|
|
25
|
+
private ensureLoaded;
|
|
26
|
+
private flush;
|
|
27
|
+
/**
|
|
28
|
+
* Register (or refresh) a subscription. Two subscriptions from the same
|
|
29
|
+
* principal for the same endpoint collapse onto one record — a browser that
|
|
30
|
+
* re-subscribes with rotated keys updates in place rather than piling up
|
|
31
|
+
* duplicate capability URLs.
|
|
32
|
+
*/
|
|
33
|
+
register(input: RegisterSubscriptionInput): Promise<StoredPushSubscription>;
|
|
34
|
+
/** All subscriptions for a principal, redacted for the wire. */
|
|
35
|
+
listPublic(principalId: string): Promise<PublicPushSubscription[]>;
|
|
36
|
+
/** The full record (endpoint + keys) for a delivery. Not for the wire. */
|
|
37
|
+
get(id: string): Promise<StoredPushSubscription | null>;
|
|
38
|
+
/** Every stored subscription — the delivery fan-out reads this. Not for the wire. */
|
|
39
|
+
all(): Promise<readonly StoredPushSubscription[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Delete a subscription. Returns true if a record was actually removed, false
|
|
42
|
+
* if the id was already absent — the caller reports an honest 404 rather than
|
|
43
|
+
* a 200-noop. An optional `principalId` scopes the delete so one operator
|
|
44
|
+
* cannot remove another's device.
|
|
45
|
+
*/
|
|
46
|
+
remove(id: string, principalId?: string): Promise<boolean>;
|
|
47
|
+
/** Record the outcome of the last delivery attempt against a subscription. */
|
|
48
|
+
recordOutcome(id: string, outcome: StoredPushSubscription['lastOutcome']): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=subscription-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-store.d.ts","sourceRoot":"","sources":["../../../src/platform/push/subscription-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;CACxC;AAcD,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,CAU3F;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;IAC9D,OAAO,CAAC,OAAO,CAAyC;gBAE5C,QAAQ,EAAE,MAAM;YAId,YAAY;YAOZ,KAAK;IAInB;;;;;OAKG;IACG,QAAQ,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAyBjF,gEAAgE;IAC1D,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAOxE,0EAA0E;IACpE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAK7D,qFAAqF;IAC/E,GAAG,IAAI,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC;IAIvD;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWhE,8EAA8E;IACxE,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/F"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/subscription-store.ts
|
|
3
|
+
*
|
|
4
|
+
* The on-disk record of which devices an operator has registered for browser
|
|
5
|
+
* push. Persisted with the same atomic-JSON `PersistentStore` the approval and
|
|
6
|
+
* session stores use — the capability URLs and key material stay on disk in the
|
|
7
|
+
* daemon's own state directory, never on the wire.
|
|
8
|
+
*
|
|
9
|
+
* Delete means delete: `remove()` drops the record entirely (it does not flag a
|
|
10
|
+
* tombstone), and `list()` cannot return it afterward. Pruning a dead endpoint
|
|
11
|
+
* uses the same `remove()` path.
|
|
12
|
+
*/
|
|
13
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
14
|
+
import { PersistentStore } from '../state/persistent-store.js';
|
|
15
|
+
function endpointOrigin(endpoint) {
|
|
16
|
+
try {
|
|
17
|
+
return new URL(endpoint).origin;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 'invalid';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function endpointHash(endpoint) {
|
|
24
|
+
return createHash('sha256').update(endpoint).digest('base64url').slice(0, 16);
|
|
25
|
+
}
|
|
26
|
+
/** The redacted, wire-safe projection of a stored subscription. */
|
|
27
|
+
export function toPublicSubscription(record) {
|
|
28
|
+
return {
|
|
29
|
+
id: record.id,
|
|
30
|
+
principalId: record.principalId,
|
|
31
|
+
endpointOrigin: endpointOrigin(record.endpoint),
|
|
32
|
+
endpointHash: endpointHash(record.endpoint),
|
|
33
|
+
createdAt: record.createdAt,
|
|
34
|
+
lastDeliveryAt: record.lastDeliveryAt,
|
|
35
|
+
lastOutcome: record.lastOutcome,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export class PushSubscriptionStore {
|
|
39
|
+
store;
|
|
40
|
+
records = null;
|
|
41
|
+
constructor(filePath) {
|
|
42
|
+
this.store = new PersistentStore(filePath);
|
|
43
|
+
}
|
|
44
|
+
async ensureLoaded() {
|
|
45
|
+
if (this.records)
|
|
46
|
+
return this.records;
|
|
47
|
+
const snapshot = await this.store.load();
|
|
48
|
+
this.records = snapshot?.subscriptions ? [...snapshot.subscriptions] : [];
|
|
49
|
+
return this.records;
|
|
50
|
+
}
|
|
51
|
+
async flush() {
|
|
52
|
+
await this.store.persist({ subscriptions: this.records ?? [] });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Register (or refresh) a subscription. Two subscriptions from the same
|
|
56
|
+
* principal for the same endpoint collapse onto one record — a browser that
|
|
57
|
+
* re-subscribes with rotated keys updates in place rather than piling up
|
|
58
|
+
* duplicate capability URLs.
|
|
59
|
+
*/
|
|
60
|
+
async register(input) {
|
|
61
|
+
const records = await this.ensureLoaded();
|
|
62
|
+
const existingIndex = records.findIndex((r) => r.principalId === input.principalId && r.endpoint === input.endpoint);
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
if (existingIndex >= 0) {
|
|
65
|
+
const prior = records[existingIndex];
|
|
66
|
+
const updated = { ...prior, keys: input.keys };
|
|
67
|
+
records[existingIndex] = updated;
|
|
68
|
+
await this.flush();
|
|
69
|
+
return updated;
|
|
70
|
+
}
|
|
71
|
+
const record = {
|
|
72
|
+
id: `push-${randomUUID()}`,
|
|
73
|
+
principalId: input.principalId,
|
|
74
|
+
endpoint: input.endpoint,
|
|
75
|
+
keys: input.keys,
|
|
76
|
+
createdAt: now,
|
|
77
|
+
};
|
|
78
|
+
records.push(record);
|
|
79
|
+
await this.flush();
|
|
80
|
+
return record;
|
|
81
|
+
}
|
|
82
|
+
/** All subscriptions for a principal, redacted for the wire. */
|
|
83
|
+
async listPublic(principalId) {
|
|
84
|
+
const records = await this.ensureLoaded();
|
|
85
|
+
return records
|
|
86
|
+
.filter((r) => r.principalId === principalId)
|
|
87
|
+
.map(toPublicSubscription);
|
|
88
|
+
}
|
|
89
|
+
/** The full record (endpoint + keys) for a delivery. Not for the wire. */
|
|
90
|
+
async get(id) {
|
|
91
|
+
const records = await this.ensureLoaded();
|
|
92
|
+
return records.find((r) => r.id === id) ?? null;
|
|
93
|
+
}
|
|
94
|
+
/** Every stored subscription — the delivery fan-out reads this. Not for the wire. */
|
|
95
|
+
async all() {
|
|
96
|
+
return [...(await this.ensureLoaded())];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Delete a subscription. Returns true if a record was actually removed, false
|
|
100
|
+
* if the id was already absent — the caller reports an honest 404 rather than
|
|
101
|
+
* a 200-noop. An optional `principalId` scopes the delete so one operator
|
|
102
|
+
* cannot remove another's device.
|
|
103
|
+
*/
|
|
104
|
+
async remove(id, principalId) {
|
|
105
|
+
const records = await this.ensureLoaded();
|
|
106
|
+
const index = records.findIndex((r) => r.id === id && (principalId === undefined || r.principalId === principalId));
|
|
107
|
+
if (index < 0)
|
|
108
|
+
return false;
|
|
109
|
+
records.splice(index, 1);
|
|
110
|
+
await this.flush();
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/** Record the outcome of the last delivery attempt against a subscription. */
|
|
114
|
+
async recordOutcome(id, outcome) {
|
|
115
|
+
const records = await this.ensureLoaded();
|
|
116
|
+
const index = records.findIndex((r) => r.id === id);
|
|
117
|
+
if (index < 0)
|
|
118
|
+
return;
|
|
119
|
+
const prior = records[index];
|
|
120
|
+
records[index] = { ...prior, lastDeliveryAt: Date.now(), lastOutcome: outcome };
|
|
121
|
+
await this.flush();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/types.ts
|
|
3
|
+
*
|
|
4
|
+
* Shared shapes for the browser-push subscription lifecycle and delivery path.
|
|
5
|
+
*
|
|
6
|
+
* Custody note: a stored subscription's `endpoint` is a capability URL (anyone
|
|
7
|
+
* holding it can push to that device) and its `keys` are the receiver's
|
|
8
|
+
* encryption material. Neither is ever returned over the wire — read verbs
|
|
9
|
+
* hand back the redacted `PublicPushSubscription` view instead. The VAPID
|
|
10
|
+
* private key never appears in any shape here at all; it lives only inside the
|
|
11
|
+
* secrets store (see push/vapid.ts).
|
|
12
|
+
*/
|
|
13
|
+
import type { SubscriptionKeyMaterial } from './encryption.js';
|
|
14
|
+
export type { SubscriptionKeyMaterial } from './encryption.js';
|
|
15
|
+
/** A subscription as stored on disk (contains capability URL + key material). */
|
|
16
|
+
export interface StoredPushSubscription {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
/** The principal (operator identity) that registered this device. */
|
|
19
|
+
readonly principalId: string;
|
|
20
|
+
/** The browser Push endpoint — a capability URL, kept off the wire. */
|
|
21
|
+
readonly endpoint: string;
|
|
22
|
+
readonly keys: SubscriptionKeyMaterial;
|
|
23
|
+
readonly createdAt: number;
|
|
24
|
+
/** Timestamp of the last delivery attempt, if any. */
|
|
25
|
+
readonly lastDeliveryAt?: number | undefined;
|
|
26
|
+
/** Outcome of the last delivery attempt, if any. */
|
|
27
|
+
readonly lastOutcome?: PushDeliveryOutcome | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The redacted, wire-safe view of a subscription. The capability URL and key
|
|
31
|
+
* material are deliberately absent; the origin + short hash are enough to
|
|
32
|
+
* identify a device in a management UI without handing the capability back out.
|
|
33
|
+
*/
|
|
34
|
+
export interface PublicPushSubscription {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly principalId: string;
|
|
37
|
+
/** The endpoint's origin only (e.g. `https://push.example`), never the full path. */
|
|
38
|
+
readonly endpointOrigin: string;
|
|
39
|
+
/** A short, stable hash of the full endpoint, for de-duplication in a UI. */
|
|
40
|
+
readonly endpointHash: string;
|
|
41
|
+
readonly createdAt: number;
|
|
42
|
+
readonly lastDeliveryAt?: number | undefined;
|
|
43
|
+
readonly lastOutcome?: PushDeliveryOutcome | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type PushDeliveryOutcome = 'delivered' | 'pruned' | 'failed' | 'skipped';
|
|
46
|
+
/** Per-subscription result of a delivery fan-out, honest about what happened. */
|
|
47
|
+
export interface PushDeliveryReceipt {
|
|
48
|
+
readonly subscriptionId: string;
|
|
49
|
+
readonly endpointOrigin: string;
|
|
50
|
+
readonly outcome: PushDeliveryOutcome;
|
|
51
|
+
/** The push service's HTTP status, when a request was actually made. */
|
|
52
|
+
readonly httpStatus?: number | undefined;
|
|
53
|
+
/** Plain-language reason, especially for `pruned`/`failed`/`skipped`. */
|
|
54
|
+
readonly detail?: string | undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Message urgency, mapped straight onto the push `Urgency` header. */
|
|
57
|
+
export type PushUrgency = 'very-low' | 'low' | 'normal' | 'high';
|
|
58
|
+
/** The notification a caller wants delivered to the operator's devices. */
|
|
59
|
+
export interface PushMessage {
|
|
60
|
+
readonly title: string;
|
|
61
|
+
readonly body: string;
|
|
62
|
+
/** Optional structured data the service worker can act on (e.g. a deep link). */
|
|
63
|
+
readonly data?: Record<string, unknown> | undefined;
|
|
64
|
+
readonly urgency?: PushUrgency | undefined;
|
|
65
|
+
/** How long (seconds) the push service should retain the message if offline. */
|
|
66
|
+
readonly ttlSeconds?: number | undefined;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/platform/push/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,iFAAiF;AACjF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,oDAAoD;IACpD,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhF,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC3C,gFAAgF;IAChF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/types.ts
|
|
3
|
+
*
|
|
4
|
+
* Shared shapes for the browser-push subscription lifecycle and delivery path.
|
|
5
|
+
*
|
|
6
|
+
* Custody note: a stored subscription's `endpoint` is a capability URL (anyone
|
|
7
|
+
* holding it can push to that device) and its `keys` are the receiver's
|
|
8
|
+
* encryption material. Neither is ever returned over the wire — read verbs
|
|
9
|
+
* hand back the redacted `PublicPushSubscription` view instead. The VAPID
|
|
10
|
+
* private key never appears in any shape here at all; it lives only inside the
|
|
11
|
+
* secrets store (see push/vapid.ts).
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push/vapid.ts
|
|
3
|
+
*
|
|
4
|
+
* VAPID (RFC 8292) key custody and request signing for browser push.
|
|
5
|
+
*
|
|
6
|
+
* KEY CUSTODY — the load-bearing rule of this file:
|
|
7
|
+
* - The daemon generates one P-256 keypair on first need.
|
|
8
|
+
* - The WHOLE keypair (including the private component) is persisted only
|
|
9
|
+
* through the SecretsManager, exactly like any other credential — into the
|
|
10
|
+
* secure store, or the plaintext secrets file, per the active secret policy.
|
|
11
|
+
* It is NEVER written into the config, so it can never ride out in the
|
|
12
|
+
* secret-free config snapshot.
|
|
13
|
+
* - The private key is used only here, to sign the short-lived VAPID JWT that
|
|
14
|
+
* authorizes one delivery. It is never logged and never returned by any read
|
|
15
|
+
* verb.
|
|
16
|
+
* - Only the PUBLIC key leaves the daemon: `getPublicKey()` feeds the
|
|
17
|
+
* `push.vapid.get` verb and the `k=` parameter of the Authorization header.
|
|
18
|
+
*/
|
|
19
|
+
/** The narrow slice of SecretsManager this module needs — get/set one secret. */
|
|
20
|
+
export interface VapidSecretStore {
|
|
21
|
+
get(key: string): Promise<string | null>;
|
|
22
|
+
set(key: string, value: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface VapidManagerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The `sub` claim of the VAPID JWT — a `mailto:` or `https:` contact the push
|
|
27
|
+
* service can reach. Defaults to a local mailto when unset.
|
|
28
|
+
*/
|
|
29
|
+
readonly subject?: string | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The secret key under which the keypair is stored (a secrets-store key, not a config key). */
|
|
32
|
+
export declare const VAPID_SECRET_KEY = "push.vapid.keypair";
|
|
33
|
+
export declare class VapidManager {
|
|
34
|
+
private readonly store;
|
|
35
|
+
private readonly subject;
|
|
36
|
+
private inflight;
|
|
37
|
+
constructor(store: VapidSecretStore, options?: VapidManagerOptions);
|
|
38
|
+
/** The public application-server key clients subscribe with. Generates on first call. */
|
|
39
|
+
getPublicKey(): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Build the `Authorization: vapid ...` header value for one delivery to
|
|
42
|
+
* `endpoint`. The JWT's audience is the endpoint's origin (RFC 8292).
|
|
43
|
+
*/
|
|
44
|
+
buildAuthorizationHeader(endpoint: string): Promise<string>;
|
|
45
|
+
private signJwt;
|
|
46
|
+
/**
|
|
47
|
+
* Load the keypair from the secrets store, or generate and persist one on
|
|
48
|
+
* first use. Concurrent callers share a single in-flight generation so two
|
|
49
|
+
* simultaneous first-time deliveries cannot mint two keypairs.
|
|
50
|
+
*/
|
|
51
|
+
private ensureKeypair;
|
|
52
|
+
private loadOrGenerate;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=vapid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vapid.d.ts","sourceRoot":"","sources":["../../../src/platform/push/vapid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AASD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAyBrD,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAA4C;gBAE/B,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,mBAAwB;IAIvF,yFAAyF;IACnF,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC;;;OAGG;IACG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOjE,OAAO,CAAC,OAAO;IAkBf;;;;OAIG;IACH,OAAO,CAAC,aAAa;YAUP,cAAc;CAe7B"}
|