@codemem/core 0.49.1 → 0.50.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-types.d.ts +7 -0
- package/dist/api-types.d.ts.map +1 -1
- package/dist/better-sqlite-coordinator-runtime.d.ts.map +1 -1
- package/dist/better-sqlite-coordinator-store.d.ts +56 -3
- package/dist/better-sqlite-coordinator-store.d.ts.map +1 -1
- package/dist/boundary-readiness-inventory.d.ts +27 -0
- package/dist/boundary-readiness-inventory.d.ts.map +1 -0
- package/dist/coordinator-account-link-receiver.d.ts +15 -0
- package/dist/coordinator-account-link-receiver.d.ts.map +1 -1
- package/dist/coordinator-account-link-status-client.d.ts +1 -1
- package/dist/coordinator-account-link-status-client.d.ts.map +1 -1
- package/dist/coordinator-actions.d.ts +12 -0
- package/dist/coordinator-actions.d.ts.map +1 -1
- package/dist/coordinator-api.d.ts +7 -0
- package/dist/coordinator-api.d.ts.map +1 -1
- package/dist/coordinator-auth-historical-store-test-fixture.d.ts.map +1 -1
- package/dist/coordinator-auth-link-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-auth-schema-stage.d.ts +14 -2
- package/dist/coordinator-auth-schema-stage.d.ts.map +1 -1
- package/dist/coordinator-block-tombstone-test-harness.d.ts +3 -0
- package/dist/coordinator-block-tombstone-test-harness.d.ts.map +1 -0
- package/dist/coordinator-bootstrap-authorization-api-test-harness.d.ts.map +1 -1
- package/dist/coordinator-bootstrap-authorization-test-harness.d.ts.map +1 -1
- package/dist/coordinator-bootstrap-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-boundary-readiness-client.d.ts +35 -0
- package/dist/coordinator-boundary-readiness-client.d.ts.map +1 -0
- package/dist/coordinator-boundary-readiness-route.d.ts +52 -0
- package/dist/coordinator-boundary-readiness-route.d.ts.map +1 -0
- package/dist/coordinator-boundary-readiness-test-harness.d.ts +15 -0
- package/dist/coordinator-boundary-readiness-test-harness.d.ts.map +1 -0
- package/dist/coordinator-boundary-readiness.d.ts +161 -0
- package/dist/coordinator-boundary-readiness.d.ts.map +1 -0
- package/dist/coordinator-browser-auth-app.d.ts +1 -1
- package/dist/coordinator-browser-auth-app.d.ts.map +1 -1
- package/dist/coordinator-browser-auth-callback.d.ts +2 -1
- package/dist/coordinator-browser-auth-callback.d.ts.map +1 -1
- package/dist/coordinator-controller-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-d1-schema-inventory.d.ts +2 -0
- package/dist/coordinator-d1-schema-inventory.d.ts.map +1 -1
- package/dist/coordinator-d1-scope-authorization-test-harness.d.ts.map +1 -1
- package/dist/coordinator-device-auth-link.d.ts +1 -0
- package/dist/coordinator-device-auth-link.d.ts.map +1 -1
- package/dist/coordinator-device-rejoin-browser-evidence.d.ts +28 -0
- package/dist/coordinator-device-rejoin-browser-evidence.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-browser-transaction-test-harness.d.ts +8 -0
- package/dist/coordinator-device-rejoin-browser-transaction-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-browser-transaction.d.ts +43 -0
- package/dist/coordinator-device-rejoin-browser-transaction.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-browser-view.d.ts +30 -0
- package/dist/coordinator-device-rejoin-browser-view.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-browser.d.ts +26 -0
- package/dist/coordinator-device-rejoin-browser.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-client-requests.d.ts +70 -0
- package/dist/coordinator-device-rejoin-client-requests.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-client.d.ts +15 -0
- package/dist/coordinator-device-rejoin-client.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-confirmation-test-harness.d.ts +22 -0
- package/dist/coordinator-device-rejoin-confirmation-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-confirmation.d.ts +18 -0
- package/dist/coordinator-device-rejoin-confirmation.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-destinations-test-harness.d.ts +7 -0
- package/dist/coordinator-device-rejoin-destinations-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-destinations.d.ts +25 -0
- package/dist/coordinator-device-rejoin-destinations.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-display.d.ts +14 -0
- package/dist/coordinator-device-rejoin-display.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-event-client.d.ts +30 -0
- package/dist/coordinator-device-rejoin-event-client.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-events.d.ts +7 -0
- package/dist/coordinator-device-rejoin-events.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-finalize-test-harness.d.ts +14 -0
- package/dist/coordinator-device-rejoin-finalize-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-finalize.d.ts +36 -0
- package/dist/coordinator-device-rejoin-finalize.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-http.d.ts +11 -0
- package/dist/coordinator-device-rejoin-http.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-link-evidence-test-harness.d.ts +17 -0
- package/dist/coordinator-device-rejoin-link-evidence-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-link-evidence.d.ts +29 -0
- package/dist/coordinator-device-rejoin-link-evidence.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-link-lineage.d.ts +7 -0
- package/dist/coordinator-device-rejoin-link-lineage.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-oidc-pins.d.ts +14 -0
- package/dist/coordinator-device-rejoin-oidc-pins.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-proof.d.ts +41 -0
- package/dist/coordinator-device-rejoin-proof.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-schema-test-harness.d.ts +8 -0
- package/dist/coordinator-device-rejoin-schema-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-schema.d.ts +9 -0
- package/dist/coordinator-device-rejoin-schema.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-start-evidence-test-harness.d.ts +40 -0
- package/dist/coordinator-device-rejoin-start-evidence-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-start-evidence.d.ts +25 -0
- package/dist/coordinator-device-rejoin-start-evidence.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-start-http.d.ts +12 -0
- package/dist/coordinator-device-rejoin-start-http.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-start-input.d.ts +23 -0
- package/dist/coordinator-device-rejoin-start-input.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-start-write.d.ts +38 -0
- package/dist/coordinator-device-rejoin-start-write.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-status-http.d.ts +10 -0
- package/dist/coordinator-device-rejoin-status-http.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-status-live-test-harness.d.ts +33 -0
- package/dist/coordinator-device-rejoin-status-live-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-status-projection.d.ts +28 -0
- package/dist/coordinator-device-rejoin-status-projection.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-status-test-harness.d.ts +8 -0
- package/dist/coordinator-device-rejoin-status-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-rejoin-status.d.ts +39 -0
- package/dist/coordinator-device-rejoin-status.d.ts.map +1 -0
- package/dist/coordinator-device-removal-commands.d.ts +13 -0
- package/dist/coordinator-device-removal-commands.d.ts.map +1 -0
- package/dist/coordinator-device-removal-commit-test-harness.d.ts +3 -0
- package/dist/coordinator-device-removal-commit-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal-commit.d.ts +44 -0
- package/dist/coordinator-device-removal-commit.d.ts.map +1 -0
- package/dist/coordinator-device-removal-dependents-test-harness.d.ts +9 -0
- package/dist/coordinator-device-removal-dependents-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal-dependents.d.ts +34 -0
- package/dist/coordinator-device-removal-dependents.d.ts.map +1 -0
- package/dist/coordinator-device-removal-list-test-harness.d.ts +4 -0
- package/dist/coordinator-device-removal-list-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal-list.d.ts +40 -0
- package/dist/coordinator-device-removal-list.d.ts.map +1 -0
- package/dist/coordinator-device-removal-preview-test-harness.d.ts +9 -0
- package/dist/coordinator-device-removal-preview-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal-routes.d.ts +13 -0
- package/dist/coordinator-device-removal-routes.d.ts.map +1 -0
- package/dist/coordinator-device-removal-target.d.ts +98 -0
- package/dist/coordinator-device-removal-target.d.ts.map +1 -0
- package/dist/coordinator-device-removal-test-harness.d.ts +70 -0
- package/dist/coordinator-device-removal-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal-writer-test-harness.d.ts +8 -0
- package/dist/coordinator-device-removal-writer-test-harness.d.ts.map +1 -0
- package/dist/coordinator-device-removal.d.ts +233 -0
- package/dist/coordinator-device-removal.d.ts.map +1 -0
- package/dist/coordinator-device-revocation-client.d.ts +2 -0
- package/dist/coordinator-device-revocation-client.d.ts.map +1 -1
- package/dist/coordinator-device-revocation-handler-test-harness.d.ts.map +1 -1
- package/dist/coordinator-device-revocation-handler.d.ts +1 -1
- package/dist/coordinator-device-revocation-handler.d.ts.map +1 -1
- package/dist/coordinator-device-revocation-route.d.ts.map +1 -1
- package/dist/coordinator-device-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-device-revocation.d.ts +20 -2
- package/dist/coordinator-device-revocation.d.ts.map +1 -1
- package/dist/coordinator-enrollment-reconciler.d.ts.map +1 -1
- package/dist/coordinator-enrollment-test-fixtures.d.ts +126 -0
- package/dist/coordinator-enrollment-test-fixtures.d.ts.map +1 -0
- package/dist/coordinator-history-sql-equivalence-test-fixtures.d.ts +1 -1
- package/dist/coordinator-history-sql-equivalence-test-fixtures.d.ts.map +1 -1
- package/dist/coordinator-identity-grant-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-identity-group-grant-test-harness.d.ts.map +1 -1
- package/dist/coordinator-invitation-lift-test-harness.d.ts +6 -0
- package/dist/coordinator-invitation-lift-test-harness.d.ts.map +1 -0
- package/dist/coordinator-invitation-removal.d.ts +71 -0
- package/dist/coordinator-invitation-removal.d.ts.map +1 -0
- package/dist/coordinator-join-review-guards.d.ts +2 -0
- package/dist/coordinator-join-review-guards.d.ts.map +1 -1
- package/dist/coordinator-join-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-key-id-fill-api-test-harness.d.ts +12 -0
- package/dist/coordinator-key-id-fill-api-test-harness.d.ts.map +1 -0
- package/dist/coordinator-key-id-fill-api.d.ts +19 -0
- package/dist/coordinator-key-id-fill-api.d.ts.map +1 -0
- package/dist/coordinator-legacy-device-ownership.d.ts +66 -5
- package/dist/coordinator-legacy-device-ownership.d.ts.map +1 -1
- package/dist/coordinator-legacy-owner-compatibility.d.ts +3 -0
- package/dist/coordinator-legacy-owner-compatibility.d.ts.map +1 -1
- package/dist/coordinator-membership-enrollment-test-harness.d.ts +4 -0
- package/dist/coordinator-membership-enrollment-test-harness.d.ts.map +1 -0
- package/dist/coordinator-membership-enrollment.d.ts +15 -0
- package/dist/coordinator-membership-enrollment.d.ts.map +1 -0
- package/dist/coordinator-owner-enrollment-commit.d.ts +1 -1
- package/dist/coordinator-owner-enrollment-commit.d.ts.map +1 -1
- package/dist/coordinator-owner-enrollment-qualification-test-harness.d.ts.map +1 -1
- package/dist/coordinator-owner-enrollment-qualification.d.ts +1 -0
- package/dist/coordinator-owner-enrollment-qualification.d.ts.map +1 -1
- package/dist/coordinator-owner-resolution-review-test-fixtures.d.ts.map +1 -1
- package/dist/coordinator-peer-discovery-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-peer-removal-api-test-harness.d.ts +29 -0
- package/dist/coordinator-peer-removal-api-test-harness.d.ts.map +1 -0
- package/dist/coordinator-peer-removal-query-test-harness.d.ts +4 -0
- package/dist/coordinator-peer-removal-query-test-harness.d.ts.map +1 -0
- package/dist/coordinator-peer-removal-query.d.ts +32 -0
- package/dist/coordinator-peer-removal-query.d.ts.map +1 -0
- package/dist/coordinator-peer-revocation-route.d.ts +45 -0
- package/dist/coordinator-peer-revocation-route.d.ts.map +1 -0
- package/dist/coordinator-peer-revocation.d.ts +61 -0
- package/dist/coordinator-peer-revocation.d.ts.map +1 -0
- package/dist/coordinator-presence-capabilities.d.ts +10 -0
- package/dist/coordinator-presence-capabilities.d.ts.map +1 -0
- package/dist/coordinator-project-revocation-test-harness.d.ts +1 -1
- package/dist/coordinator-project-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-recipient-revocation-test-harness.d.ts.map +1 -1
- package/dist/coordinator-refresh-lifecycle.d.ts +11 -0
- package/dist/coordinator-refresh-lifecycle.d.ts.map +1 -0
- package/dist/coordinator-rejoin-discovery.d.ts +16 -0
- package/dist/coordinator-rejoin-discovery.d.ts.map +1 -0
- package/dist/coordinator-rejoin-timestamp.d.ts +3 -0
- package/dist/coordinator-rejoin-timestamp.d.ts.map +1 -0
- package/dist/coordinator-removal-notice.d.ts +21 -0
- package/dist/coordinator-removal-notice.d.ts.map +1 -0
- package/dist/coordinator-removal-progress-listing-test-harness.d.ts +3 -0
- package/dist/coordinator-removal-progress-listing-test-harness.d.ts.map +1 -0
- package/dist/coordinator-runtime-ynLTJI6d.js +1712 -0
- package/dist/coordinator-runtime-ynLTJI6d.js.map +1 -0
- package/dist/coordinator-runtime.d.ts +20 -1
- package/dist/coordinator-runtime.d.ts.map +1 -1
- package/dist/coordinator-scope-authorization-api-test-harness.d.ts.map +1 -1
- package/dist/coordinator-store-contract.d.ts +21 -3
- package/dist/coordinator-store-contract.d.ts.map +1 -1
- package/dist/coordinator-store-test-harness.d.ts.map +1 -1
- package/dist/coordinator-sync-config.d.ts +14 -0
- package/dist/coordinator-sync-config.d.ts.map +1 -1
- package/dist/d1-coordinator-runtime.d.ts +3 -1
- package/dist/d1-coordinator-runtime.d.ts.map +1 -1
- package/dist/d1-coordinator-store.d.ts +63 -3
- package/dist/d1-coordinator-store.d.ts.map +1 -1
- package/dist/database-runtime-primitives.d.ts +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/device-identity-binding.d.ts +24 -0
- package/dist/device-identity-binding.d.ts.map +1 -1
- package/dist/device-identity-inventory.d.ts +19 -1
- package/dist/device-identity-inventory.d.ts.map +1 -1
- package/dist/device-retirement.d.ts +43 -0
- package/dist/device-retirement.d.ts.map +1 -0
- package/dist/identity-device-assignment.d.ts +8 -0
- package/dist/identity-device-assignment.d.ts.map +1 -1
- package/dist/index.d.ts +34 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11649 -10631
- package/dist/index.js.map +1 -1
- package/dist/internal/cloudflare-coordinator.js +2317 -1542
- package/dist/internal/cloudflare-coordinator.js.map +1 -1
- package/dist/internal/relay-runtime.js +28 -28
- package/dist/legacy-pairing-assignment-conversion.d.ts +46 -0
- package/dist/legacy-pairing-assignment-conversion.d.ts.map +1 -0
- package/dist/legacy-pairing-assignment-state.d.ts +11 -0
- package/dist/legacy-pairing-assignment-state.d.ts.map +1 -0
- package/dist/legacy-team-setup-errors.d.ts +2 -1
- package/dist/legacy-team-setup-errors.d.ts.map +1 -1
- package/dist/local-origin-claim.d.ts +48 -0
- package/dist/local-origin-claim.d.ts.map +1 -0
- package/dist/maintenance/ai-structured.d.ts +2 -0
- package/dist/maintenance/ai-structured.d.ts.map +1 -1
- package/dist/observer-config.d.ts.map +1 -1
- package/dist/owned-recipient-d1-test-harness.d.ts.map +1 -1
- package/dist/owner-enrollment-link-authority.d.ts +1 -0
- package/dist/owner-enrollment-link-authority.d.ts.map +1 -1
- package/dist/{owner-enrollment-start-BsDwgxAh.js → owner-enrollment-start-D8QzF1Ar.js} +5548 -3637
- package/dist/owner-enrollment-start-D8QzF1Ar.js.map +1 -0
- package/dist/pairing-removal.d.ts +57 -0
- package/dist/pairing-removal.d.ts.map +1 -0
- package/dist/peer-project-filter-change.d.ts +33 -0
- package/dist/peer-project-filter-change.d.ts.map +1 -0
- package/dist/peer-project-filter-management.d.ts +7 -0
- package/dist/peer-project-filter-management.d.ts.map +1 -0
- package/dist/peer-project-filter-retention.d.ts +17 -0
- package/dist/peer-project-filter-retention.d.ts.map +1 -0
- package/dist/peer-removal-check-state.d.ts +24 -0
- package/dist/peer-removal-check-state.d.ts.map +1 -0
- package/dist/peer-removal.d.ts +34 -0
- package/dist/peer-removal.d.ts.map +1 -0
- package/dist/peer-traversal-coordinator-attempt-write-test-fixtures.d.ts.map +1 -1
- package/dist/peer-traversal-coordinator-decision-test-fixtures.d.ts.map +1 -1
- package/dist/policy-team-device-eligibility.d.ts +10 -0
- package/dist/policy-team-device-eligibility.d.ts.map +1 -1
- package/dist/project-boundary-migration-hold.d.ts +50 -0
- package/dist/project-boundary-migration-hold.d.ts.map +1 -0
- package/dist/project-boundary-migration-records.d.ts +46 -0
- package/dist/project-boundary-migration-records.d.ts.map +1 -0
- package/dist/project-filters-narrowing.d.ts +11 -0
- package/dist/project-filters-narrowing.d.ts.map +1 -0
- package/dist/project-scope-resume.d.ts +26 -0
- package/dist/project-scope-resume.d.ts.map +1 -0
- package/dist/project-scope-settings.d.ts +7 -0
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/dist/project-scope-withdrawal.d.ts +48 -0
- package/dist/project-scope-withdrawal.d.ts.map +1 -0
- package/dist/project-withdrawal-state.d.ts +36 -0
- package/dist/project-withdrawal-state.d.ts.map +1 -0
- package/dist/{recipient-policy-contract-Ca40IBUh.js → recipient-policy-contract-BHxfaQZ2.js} +12 -5
- package/dist/recipient-policy-contract-BHxfaQZ2.js.map +1 -0
- package/dist/recipient-policy-contract.d.ts +7 -0
- package/dist/recipient-policy-contract.d.ts.map +1 -1
- package/dist/recipient-policy-contract.js +2 -2
- package/dist/recipient-policy-edges.d.ts.map +1 -1
- package/dist/recipient-policy-intent.d.ts +1 -0
- package/dist/recipient-policy-intent.d.ts.map +1 -1
- package/dist/recipient-policy-onboarding.d.ts.map +1 -1
- package/dist/recipient-policy-reconciler.d.ts.map +1 -1
- package/dist/recipient-policy-reconciliation.d.ts.map +1 -1
- package/dist/recipient-policy-team-create.d.ts +22 -0
- package/dist/recipient-policy-team-create.d.ts.map +1 -0
- package/dist/{relay-health-CeyhVeuq.js → relay-health-B8BpHFaE.js} +14 -14
- package/dist/{relay-health-CeyhVeuq.js.map → relay-health-B8BpHFaE.js.map} +1 -1
- package/dist/{relay-peer-client-DmZfZebO.js → relay-peer-client-w7WdS1AP.js} +3083 -2634
- package/dist/relay-peer-client-w7WdS1AP.js.map +1 -0
- package/dist/relay-server-test-fixtures.d.ts.map +1 -1
- package/dist/replication-cursor-orphan-cleanup.d.ts +14 -0
- package/dist/replication-cursor-orphan-cleanup.d.ts.map +1 -0
- package/dist/retired-device-aliases.d.ts +28 -0
- package/dist/retired-device-aliases.d.ts.map +1 -0
- package/dist/same-actor-peers.d.ts +5 -1
- package/dist/same-actor-peers.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts +1 -0
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/schema.d.ts +4456 -3623
- package/dist/schema.d.ts.map +1 -1
- package/dist/{scope-membership-cache-read-B6z47l2W.js → scope-resolution-B7FK15hx.js} +2242 -1608
- package/dist/scope-resolution-B7FK15hx.js.map +1 -0
- package/dist/semantic-worker-entry.js +1 -1
- package/dist/{semantic-worker-job-BLaC4xRY.js → semantic-worker-job-BjujlM4-.js} +3 -3
- package/dist/{semantic-worker-job-BLaC4xRY.js.map → semantic-worker-job-BjujlM4-.js.map} +1 -1
- package/dist/{semantic-worker-ranking-5-VSzEmx.js → semantic-worker-ranking-WaUCapnY.js} +66 -60
- package/dist/semantic-worker-ranking-WaUCapnY.js.map +1 -0
- package/dist/share-provisioning.d.ts +4 -0
- package/dist/share-provisioning.d.ts.map +1 -1
- package/dist/shared-owned-device-enrollment-test-harness.d.ts.map +1 -1
- package/dist/shared-owned-project-invites-test-harness.d.ts.map +1 -1
- package/dist/shared-owned-recipient-invites-test-harness.d.ts.map +1 -1
- package/dist/shared-ownership-writer-lifecycle-test-harness.d.ts.map +1 -1
- package/dist/snapshot-cross-scope-reconcile.d.ts +25 -0
- package/dist/snapshot-cross-scope-reconcile.d.ts.map +1 -0
- package/dist/{sync-auth-constants-BVzVfSmn.js → sync-auth-constants-DNUSV-Tn.js} +4482 -2842
- package/dist/sync-auth-constants-DNUSV-Tn.js.map +1 -0
- package/dist/sync-bootstrap.d.ts +2 -0
- package/dist/sync-bootstrap.d.ts.map +1 -1
- package/dist/sync-capability.d.ts +1 -1
- package/dist/sync-capability.d.ts.map +1 -1
- package/dist/sync-channel-progress.d.ts +7 -0
- package/dist/sync-channel-progress.d.ts.map +1 -1
- package/dist/sync-daemon.d.ts +4 -1
- package/dist/sync-daemon.d.ts.map +1 -1
- package/dist/sync-pass.d.ts.map +1 -1
- package/dist/sync-peer-addresses.d.ts +4 -2
- package/dist/sync-peer-addresses.d.ts.map +1 -1
- package/dist/sync-reachability-pass-BpTtRqcV.js +2 -0
- package/dist/{sync-reachability-pass-Dhn4N2hr.js → sync-reachability-pass-DKEORTbs.js} +2638 -2591
- package/dist/sync-reachability-pass-DKEORTbs.js.map +1 -0
- package/dist/sync-replication.d.ts +21 -3
- package/dist/sync-replication.d.ts.map +1 -1
- package/dist/sync-scope-protocol.d.ts.map +1 -1
- package/dist/test-environment-isolation.d.ts +2 -0
- package/dist/test-environment-isolation.d.ts.map +1 -0
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/dist/test-utils.d.ts +4 -0
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/{validated-vector-index-audit-B64yhEBF.js → validated-vector-index-audit-BtUovYuM.js} +269 -637
- package/dist/validated-vector-index-audit-BtUovYuM.js.map +1 -0
- package/dist/viewer-device-removal-commit.d.ts +56 -0
- package/dist/viewer-device-removal-commit.d.ts.map +1 -0
- package/dist/viewer-device-removal-evidence.d.ts +17 -0
- package/dist/viewer-device-removal-evidence.d.ts.map +1 -0
- package/dist/{scope-membership-semantics-B8qXaMqx.js → workspace-identity-C7EPmSZe.js} +121 -49
- package/dist/workspace-identity-C7EPmSZe.js.map +1 -0
- package/package.json +3 -3
- package/dist/coordinator-runtime-CEc6KhBE.js +0 -594
- package/dist/coordinator-runtime-CEc6KhBE.js.map +0 -1
- package/dist/owner-enrollment-start-BsDwgxAh.js.map +0 -1
- package/dist/recipient-policy-contract-Ca40IBUh.js.map +0 -1
- package/dist/relay-peer-client-DmZfZebO.js.map +0 -1
- package/dist/scope-membership-cache-read-B6z47l2W.js.map +0 -1
- package/dist/scope-membership-semantics-B8qXaMqx.js.map +0 -1
- package/dist/semantic-worker-ranking-5-VSzEmx.js.map +0 -1
- package/dist/sync-auth-constants-BVzVfSmn.js.map +0 -1
- package/dist/sync-reachability-pass-C_-w0t6b.js +0 -2
- package/dist/sync-reachability-pass-Dhn4N2hr.js.map +0 -1
- package/dist/validated-vector-index-audit-B64yhEBF.js.map +0 -1
- package/dist/workspace-identity-DI8bBR0Y.js +0 -76
- package/dist/workspace-identity-DI8bBR0Y.js.map +0 -1
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import { r as e } from "./scope-membership-cache-read-B6z47l2W.js";
|
|
2
|
-
import { p as t } from "./scope-membership-semantics-B8qXaMqx.js";
|
|
3
|
-
import { O as n } from "./sync-auth-constants-BVzVfSmn.js";
|
|
4
|
-
import { A as r, B as i, D as a, L as o, M as s, R as c, V as l, W as u, ct as d, f, it as p, j as m, k as h, p as g } from "./relay-peer-client-DmZfZebO.js";
|
|
5
|
-
import { networkInterfaces as _ } from "node:os";
|
|
6
|
-
//#region src/memory-retirement-trust.ts
|
|
7
|
-
function v(e) {
|
|
8
|
-
return !!(e?.public_key && e.pinned_fingerprint && t(e.public_key) === e.pinned_fingerprint);
|
|
9
|
-
}
|
|
10
|
-
function y(e, t) {
|
|
11
|
-
if (!e.inTransaction) throw Error("retirement_trust_transaction_required");
|
|
12
|
-
let n = e.prepare("SELECT public_key, pinned_fingerprint FROM sync_peers WHERE peer_device_id = ?").get(t.peerDeviceId);
|
|
13
|
-
v(n) && e.prepare("INSERT OR IGNORE INTO memory_retirement_peer_trust\n (local_device_id, peer_device_id, public_key, pinned_fingerprint) VALUES (?, ?, ?, ?)").run(t.localDeviceId, t.peerDeviceId, n.public_key, n.pinned_fingerprint);
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/coordinator-runtime.ts
|
|
17
|
-
function b(e) {
|
|
18
|
-
return typeof e == "string" ? e.trim() : "";
|
|
19
|
-
}
|
|
20
|
-
function x(e, t) {
|
|
21
|
-
let n = [], r = /* @__PURE__ */ new Set();
|
|
22
|
-
for (let i of [...e, ...t]) {
|
|
23
|
-
let e = i.trim();
|
|
24
|
-
!e || r.has(e) || (r.add(e), n.push(e));
|
|
25
|
-
}
|
|
26
|
-
return n;
|
|
27
|
-
}
|
|
28
|
-
function S(e, t) {
|
|
29
|
-
let n = Date.parse(b(e)), r = Date.parse(b(t));
|
|
30
|
-
return Number.isFinite(n) ? Number.isFinite(r) && r < n ? t : e : Number.isFinite(r) ? t : e;
|
|
31
|
-
}
|
|
32
|
-
var C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), E = 3e4;
|
|
33
|
-
function D(e, t) {
|
|
34
|
-
let n = e + E;
|
|
35
|
-
for (let r of t) {
|
|
36
|
-
if (r.stale) continue;
|
|
37
|
-
let t = Date.parse(b(r.expires_at));
|
|
38
|
-
if (Number.isFinite(t)) {
|
|
39
|
-
if (t <= e) return e;
|
|
40
|
-
n = Math.min(n, t);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return n;
|
|
44
|
-
}
|
|
45
|
-
function O(e) {
|
|
46
|
-
w.delete(e), T.set(e, (T.get(e) ?? 0) + 1);
|
|
47
|
-
}
|
|
48
|
-
function k(e, t) {
|
|
49
|
-
let n = [...t.syncCoordinatorGroups].sort().join(",");
|
|
50
|
-
return [
|
|
51
|
-
e.dbPath,
|
|
52
|
-
t.syncCoordinatorUrl,
|
|
53
|
-
n,
|
|
54
|
-
A(e),
|
|
55
|
-
t.syncHost,
|
|
56
|
-
t.syncPort,
|
|
57
|
-
t.syncAdvertise,
|
|
58
|
-
t.syncCoordinatorPresenceTtlS
|
|
59
|
-
].join("|");
|
|
60
|
-
}
|
|
61
|
-
function A(e) {
|
|
62
|
-
let t = process.env.CODEMEM_KEYS_DIR?.trim() || "";
|
|
63
|
-
try {
|
|
64
|
-
let n = e.db.prepare("SELECT device_id, fingerprint FROM sync_device LIMIT 1").get();
|
|
65
|
-
return `${t}|${n?.device_id ?? ""}|${n?.fingerprint ?? ""}`;
|
|
66
|
-
} catch {
|
|
67
|
-
return t;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function j(e, t) {
|
|
71
|
-
return [
|
|
72
|
-
k(e, t),
|
|
73
|
-
t.syncEnabled ? "sync-enabled" : "sync-disabled",
|
|
74
|
-
t.syncHost,
|
|
75
|
-
t.syncPort,
|
|
76
|
-
t.syncAdvertise,
|
|
77
|
-
t.syncCoordinatorPresenceTtlS
|
|
78
|
-
].join("|");
|
|
79
|
-
}
|
|
80
|
-
function M(e) {
|
|
81
|
-
return Number(e.db.prepare("SELECT COUNT(1) AS total FROM sync_peers").get()?.total ?? 0);
|
|
82
|
-
}
|
|
83
|
-
function ee(e) {
|
|
84
|
-
let t = Math.max(1, e.syncCoordinatorPresenceTtlS), n = Math.floor(t / 2);
|
|
85
|
-
return Math.max(5, Math.min(60, n > 0 ? n : 1)) * 1e3;
|
|
86
|
-
}
|
|
87
|
-
function N() {
|
|
88
|
-
return 3e4;
|
|
89
|
-
}
|
|
90
|
-
async function P(e, t, n, r) {
|
|
91
|
-
let i = k(e, t), a = C.get(i);
|
|
92
|
-
if (a && r < a.nextRefreshAtMs) {
|
|
93
|
-
n.presence_status = a.status, n.presence_error = a.error, n.advertised_addresses = a.advertisedAddresses;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
let a = (await I(e, t))?.responses?.[0], o = a && typeof a == "object" ? a.addresses ?? [] : [];
|
|
98
|
-
n.presence_status = "posted", n.presence_error = null, n.advertised_addresses = o, C.set(i, {
|
|
99
|
-
status: "posted",
|
|
100
|
-
error: null,
|
|
101
|
-
advertisedAddresses: o,
|
|
102
|
-
nextRefreshAtMs: r + ee(t)
|
|
103
|
-
});
|
|
104
|
-
} catch (e) {
|
|
105
|
-
let t = e instanceof Error ? e.message : String(e), a = t.includes("unknown_device") ? "not_enrolled" : "error", o = a === "not_enrolled" ? r : r + N();
|
|
106
|
-
n.presence_status = a, n.presence_error = t, n.advertised_addresses = [], C.set(i, {
|
|
107
|
-
status: a,
|
|
108
|
-
error: t,
|
|
109
|
-
advertisedAddresses: [],
|
|
110
|
-
nextRefreshAtMs: o
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function F(e) {
|
|
115
|
-
let t = e.syncAdvertise.toLowerCase();
|
|
116
|
-
if (t && t !== "auto" && t !== "default") return r([], t.split(",").map((e) => e.trim()).filter(Boolean), { defaultHttpPort: e.syncPort });
|
|
117
|
-
if (e.syncHost && e.syncHost !== "0.0.0.0") return [s(h(e.syncHost, e.syncPort))].filter(Boolean);
|
|
118
|
-
let n = Object.values(_()).flatMap((e) => e ?? []).filter((e) => !e.internal).map((e) => e.address).filter((e) => e && e !== "127.0.0.1" && e !== "::1").map((t) => s(h(t, e.syncPort))).filter(Boolean);
|
|
119
|
-
return [...new Set(n)];
|
|
120
|
-
}
|
|
121
|
-
async function I(e, t, n) {
|
|
122
|
-
if (!o(t)) return null;
|
|
123
|
-
let r = n?.keysDir ?? (process.env.CODEMEM_KEYS_DIR?.trim() || void 0), [a, s] = p(e.db, { keysDir: r }), c = d(r);
|
|
124
|
-
if (!c) throw Error("public key missing");
|
|
125
|
-
let m = i(t.syncCoordinatorUrl), h = {
|
|
126
|
-
fingerprint: s,
|
|
127
|
-
public_key: c,
|
|
128
|
-
addresses: F(t),
|
|
129
|
-
ttl_s: Math.max(1, t.syncCoordinatorPresenceTtlS),
|
|
130
|
-
capabilities: {
|
|
131
|
-
sync_capability: f,
|
|
132
|
-
sync_features: g
|
|
133
|
-
}
|
|
134
|
-
}, _ = [];
|
|
135
|
-
for (let n of t.syncCoordinatorGroups) {
|
|
136
|
-
let i = {
|
|
137
|
-
...h,
|
|
138
|
-
group_id: n
|
|
139
|
-
}, o = Buffer.from(JSON.stringify(i), "utf8"), s = `${m}/v1/presence`, c = u({
|
|
140
|
-
deviceId: a,
|
|
141
|
-
dbPath: e.dbPath,
|
|
142
|
-
method: "POST",
|
|
143
|
-
url: s,
|
|
144
|
-
bodyBytes: o,
|
|
145
|
-
keysDir: r
|
|
146
|
-
}), [d, f] = await l("POST", s, {
|
|
147
|
-
headers: c,
|
|
148
|
-
body: i,
|
|
149
|
-
bodyBytes: o,
|
|
150
|
-
timeoutS: Math.max(1, t.syncCoordinatorTimeoutS)
|
|
151
|
-
});
|
|
152
|
-
if (d !== 200 || !f) {
|
|
153
|
-
let e = typeof f?.error == "string" ? f.error : "unknown";
|
|
154
|
-
throw Error(`coordinator presence failed (${d}: ${e})`);
|
|
155
|
-
}
|
|
156
|
-
_.push(f);
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
groups: t.syncCoordinatorGroups,
|
|
160
|
-
responses: _
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
async function L(e, t, n) {
|
|
164
|
-
if (!o(t)) return [];
|
|
165
|
-
let a = n?.keysDir ?? (process.env.CODEMEM_KEYS_DIR?.trim() || void 0), [s] = p(e.db, { keysDir: a }), c = i(t.syncCoordinatorUrl), d = /* @__PURE__ */ new Map();
|
|
166
|
-
for (let n of t.syncCoordinatorGroups) {
|
|
167
|
-
let i = `${c}/v1/peers?group_id=${encodeURIComponent(n)}`, o = u({
|
|
168
|
-
deviceId: s,
|
|
169
|
-
dbPath: e.dbPath,
|
|
170
|
-
method: "GET",
|
|
171
|
-
url: i,
|
|
172
|
-
bodyBytes: Buffer.alloc(0),
|
|
173
|
-
keysDir: a
|
|
174
|
-
}), [f, p] = await l("GET", i, {
|
|
175
|
-
headers: o,
|
|
176
|
-
timeoutS: Math.max(1, t.syncCoordinatorTimeoutS)
|
|
177
|
-
});
|
|
178
|
-
if (f !== 200 || !p) {
|
|
179
|
-
let e = typeof p?.error == "string" ? p.error : "unknown";
|
|
180
|
-
throw Error(`coordinator lookup failed (${f}: ${e})`);
|
|
181
|
-
}
|
|
182
|
-
let m = Array.isArray(p.items) ? p.items : [];
|
|
183
|
-
for (let e of m) {
|
|
184
|
-
if (!e || typeof e != "object") continue;
|
|
185
|
-
let t = e, i = b(t.device_id), a = b(t.fingerprint);
|
|
186
|
-
if (!i) continue;
|
|
187
|
-
let o = t.stale ? [] : Array.isArray(t.addresses) ? t.addresses.filter((e) => typeof e == "string") : [], s = `${i}:${a}`, l = d.get(s);
|
|
188
|
-
if (!l) {
|
|
189
|
-
d.set(s, {
|
|
190
|
-
...t,
|
|
191
|
-
addresses: r([], o),
|
|
192
|
-
coordinator_id: c,
|
|
193
|
-
groups: [n],
|
|
194
|
-
fresh_groups: t.stale ? [] : [n]
|
|
195
|
-
});
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
l.addresses = r(Array.isArray(l.addresses) ? l.addresses : [], o), l.groups = x(Array.isArray(l.groups) ? l.groups : [], [n]), l.fresh_groups = x(Array.isArray(l.fresh_groups) ? l.fresh_groups : [], t.stale ? [] : [n]);
|
|
199
|
-
let u = !!l.stale, f = !!t.stale;
|
|
200
|
-
l.stale = u && f;
|
|
201
|
-
let p = !f && (u || b(t.last_seen_at) > b(l.last_seen_at)) || f && u && b(t.last_seen_at) > b(l.last_seen_at);
|
|
202
|
-
p && (l.last_seen_at = t.last_seen_at), f ? u && p && (l.expires_at = t.expires_at) : l.expires_at = u ? t.expires_at : S(l.expires_at, t.expires_at);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return [...d.values()];
|
|
206
|
-
}
|
|
207
|
-
function R(e) {
|
|
208
|
-
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
209
|
-
}
|
|
210
|
-
function z(e) {
|
|
211
|
-
if (!Array.isArray(e) || e.length === 0) return null;
|
|
212
|
-
let t = [];
|
|
213
|
-
for (let n of e) {
|
|
214
|
-
if (typeof n != "string" || !n.trim()) return null;
|
|
215
|
-
t.push(n.trim());
|
|
216
|
-
}
|
|
217
|
-
return t;
|
|
218
|
-
}
|
|
219
|
-
function B(e) {
|
|
220
|
-
if (typeof e != "string" || e.trim().length === 0) return [];
|
|
221
|
-
try {
|
|
222
|
-
return R(JSON.parse(e));
|
|
223
|
-
} catch {
|
|
224
|
-
return [];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function V(e, t, n) {
|
|
228
|
-
let i = b(e.peer_device_id), a = b(e.pinned_fingerprint);
|
|
229
|
-
if (!i || !a) return !1;
|
|
230
|
-
let o = t.get(`${i}:${a}`);
|
|
231
|
-
if (!o?.length) return !1;
|
|
232
|
-
let s = r(B(e.addresses_json), []), c = e.manual_addresses_json == null ? s : B(e.manual_addresses_json), l = m(s, o, c, { successfulAddress: e.last_success_address ?? void 0 });
|
|
233
|
-
return JSON.stringify(l) === JSON.stringify(s) && e.manual_addresses_json != null ? !1 : (n(JSON.stringify(l), JSON.stringify(c), i, a), !0);
|
|
234
|
-
}
|
|
235
|
-
function H(e, t) {
|
|
236
|
-
let n = /* @__PURE__ */ new Map();
|
|
237
|
-
for (let e of t) {
|
|
238
|
-
if (e.stale) continue;
|
|
239
|
-
let t = b(e.device_id), i = b(e.fingerprint);
|
|
240
|
-
if (!t || !i) continue;
|
|
241
|
-
let a = R(e.addresses);
|
|
242
|
-
if (a.length === 0) continue;
|
|
243
|
-
let o = `${t}:${i}`;
|
|
244
|
-
n.set(o, r(n.get(o) ?? [], a));
|
|
245
|
-
}
|
|
246
|
-
if (n.size === 0) return 0;
|
|
247
|
-
let i = e.prepare("SELECT peer_device_id, pinned_fingerprint, addresses_json, manual_addresses_json, last_success_address FROM sync_peers").all(), a = e.prepare("UPDATE sync_peers SET addresses_json = ?, manual_addresses_json = ? WHERE peer_device_id = ? AND pinned_fingerprint = ?"), o = (e, t, n, r) => {
|
|
248
|
-
a.run(e, t, n, r);
|
|
249
|
-
}, s = 0;
|
|
250
|
-
return e.transaction(() => {
|
|
251
|
-
for (let e of i) V(e, n, o) && (s += 1);
|
|
252
|
-
}).immediate(), s;
|
|
253
|
-
}
|
|
254
|
-
function U(t, n) {
|
|
255
|
-
let { localDeviceId: r, peerDeviceId: i, coordinatorId: a, peerGroupIds: o, peerPublicKey: s } = n, c = n.kinds?.length ? n.kinds : ["managed_project"], l = t.prepare("SELECT public_key FROM sync_device WHERE device_id = ?").pluck().get(r), u = t.prepare(`SELECT scope.scope_id, scope.coordinator_id, scope.group_id
|
|
256
|
-
FROM scope_memberships local_member
|
|
257
|
-
JOIN scope_memberships peer_member
|
|
258
|
-
ON peer_member.scope_id = local_member.scope_id
|
|
259
|
-
JOIN replication_scopes scope
|
|
260
|
-
ON scope.scope_id = local_member.scope_id
|
|
261
|
-
WHERE local_member.device_id = ?
|
|
262
|
-
AND peer_member.device_id = ?
|
|
263
|
-
AND scope.status = 'active'
|
|
264
|
-
AND scope.kind IN (${c.map(() => "?").join(", ")})
|
|
265
|
-
AND scope.authority_type = 'coordinator'
|
|
266
|
-
ORDER BY scope.scope_id`).all(r, i, ...c), d = [], f = !1;
|
|
267
|
-
for (let n of u) {
|
|
268
|
-
let c = b(n.scope_id), u = b(n.group_id);
|
|
269
|
-
if (!c || b(n.coordinator_id) !== a || !u || o !== null && !o.includes(u)) continue;
|
|
270
|
-
let p = {
|
|
271
|
-
coordinatorId: a,
|
|
272
|
-
groupId: u
|
|
273
|
-
}, m = e(t, {
|
|
274
|
-
deviceId: r,
|
|
275
|
-
scopeId: c,
|
|
276
|
-
authority: p,
|
|
277
|
-
expectedPublicKey: l ?? ""
|
|
278
|
-
}), h = e(t, {
|
|
279
|
-
deviceId: i,
|
|
280
|
-
scopeId: c,
|
|
281
|
-
authority: p,
|
|
282
|
-
expectedPublicKey: s
|
|
283
|
-
});
|
|
284
|
-
if (!(!m.authorized || !h.authorized)) {
|
|
285
|
-
if (m.freshness !== "fresh" || h.freshness !== "fresh") {
|
|
286
|
-
f = !0;
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
d.push({
|
|
290
|
-
scopeId: c,
|
|
291
|
-
groupId: u
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
scopes: d,
|
|
297
|
-
indeterminate: f
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function W(e, t, n, r, i, a) {
|
|
301
|
-
let { scopes: o, indeterminate: s } = U(e, {
|
|
302
|
-
localDeviceId: t,
|
|
303
|
-
peerDeviceId: n,
|
|
304
|
-
coordinatorId: r,
|
|
305
|
-
peerGroupIds: i,
|
|
306
|
-
peerPublicKey: a
|
|
307
|
-
}), [c] = o;
|
|
308
|
-
return c ? {
|
|
309
|
-
state: "authorized",
|
|
310
|
-
groupId: c.groupId
|
|
311
|
-
} : { state: s ? "indeterminate" : "not_authorized" };
|
|
312
|
-
}
|
|
313
|
-
function G(e, t, n, r, i) {
|
|
314
|
-
let o = n.stale ? [] : R(n.addresses);
|
|
315
|
-
a(e, t, o, {
|
|
316
|
-
name: b(n.display_name) || void 0,
|
|
317
|
-
pinnedFingerprint: r,
|
|
318
|
-
publicKey: i,
|
|
319
|
-
coordinatorCandidates: !0
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
function K(e, t, n) {
|
|
323
|
-
let r = 0;
|
|
324
|
-
for (let i of n) {
|
|
325
|
-
let n = b(i.device_id), a = b(i.public_key), o = b(i.fingerprint), s = b(i.coordinator_id), c = z(i.groups);
|
|
326
|
-
if (!n || n === t || !a || !o || !s || !c || !q(a, o)) continue;
|
|
327
|
-
let l = W(e, t, n, s, c, a);
|
|
328
|
-
if (l.state !== "authorized") continue;
|
|
329
|
-
let u = e.prepare("SELECT pinned_fingerprint, public_key, claimed_local_actor, actor_id,\n pending_bootstrap_grant_id, trust_provenance\n FROM sync_peers WHERE peer_device_id = ? LIMIT 1").get(n);
|
|
330
|
-
if (u && (u.claimed_local_actor === 1 || b(u.pinned_fingerprint) && b(u.pinned_fingerprint) !== o || b(u.public_key) && b(u.public_key) !== a)) continue;
|
|
331
|
-
let d = !!(b(u?.pinned_fingerprint) || b(u?.public_key)), f = !u || u.claimed_local_actor === 0 && u.actor_id == null && u.pending_bootstrap_grant_id == null && (!d || u.trust_provenance === "coordinator_policy");
|
|
332
|
-
G(e, n, i, o, a), f && e.prepare("UPDATE sync_peers SET discovered_via_coordinator_id = ?,\n discovered_via_group_id = ?, trust_provenance = 'coordinator_policy'\n WHERE peer_device_id = ?\n AND claimed_local_actor = 0 AND actor_id IS NULL\n AND pending_bootstrap_grant_id IS NULL").run(s, l.groupId, n), r += 1;
|
|
333
|
-
}
|
|
334
|
-
return r;
|
|
335
|
-
}
|
|
336
|
-
function q(e, n) {
|
|
337
|
-
try {
|
|
338
|
-
return t(e) === n;
|
|
339
|
-
} catch {
|
|
340
|
-
return !1;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
function J(e, t) {
|
|
344
|
-
let n = e.prepare("SELECT peer_device_id, public_key, discovered_via_coordinator_id, discovered_via_group_id\n FROM sync_peers\n WHERE claimed_local_actor = 0\n AND actor_id IS NULL\n AND pending_bootstrap_grant_id IS NULL\n AND trust_provenance = 'coordinator_policy'\n AND discovered_via_coordinator_id IS NOT NULL\n AND discovered_via_group_id IS NOT NULL\n AND (pinned_fingerprint IS NOT NULL OR public_key IS NOT NULL)").all(), r = 0;
|
|
345
|
-
for (let i of n) {
|
|
346
|
-
let n = b(i.peer_device_id), a = b(i.discovered_via_coordinator_id), o = b(i.discovered_via_group_id);
|
|
347
|
-
if (!n || !a || !o || W(e, t, n, a, null, b(i.public_key)).state !== "not_authorized") continue;
|
|
348
|
-
y(e, {
|
|
349
|
-
localDeviceId: t,
|
|
350
|
-
peerDeviceId: n
|
|
351
|
-
});
|
|
352
|
-
let s = e.prepare("DELETE FROM sync_peers\n WHERE peer_device_id = ? AND claimed_local_actor = 0\n AND actor_id IS NULL AND pending_bootstrap_grant_id IS NULL\n AND trust_provenance = 'coordinator_policy'\n AND discovered_via_coordinator_id = ? AND discovered_via_group_id = ?").run(n, a, o);
|
|
353
|
-
r += s.changes;
|
|
354
|
-
}
|
|
355
|
-
return r;
|
|
356
|
-
}
|
|
357
|
-
function te(e, t, n) {
|
|
358
|
-
return e.prepare("SELECT public_key, pinned_fingerprint FROM sync_peers\n WHERE peer_device_id = ? AND discovered_via_coordinator_id = ?\n AND trust_provenance = 'coordinator_policy'\n AND claimed_local_actor = 0 AND actor_id IS NULL\n AND pending_bootstrap_grant_id IS NULL").get(t, n);
|
|
359
|
-
}
|
|
360
|
-
function ne(e, t, n) {
|
|
361
|
-
let r = b(n.device_id), i = b(n.coordinator_id), a = b(n.public_key), o = b(n.fingerprint), s = z(n.groups);
|
|
362
|
-
if (!r || r === t || !i || !s || !q(a, o)) return null;
|
|
363
|
-
let c = te(e, r, i);
|
|
364
|
-
if (!c?.public_key || !c.pinned_fingerprint || !q(c.public_key, c.pinned_fingerprint)) return null;
|
|
365
|
-
let l = W(e, t, r, i, s, a);
|
|
366
|
-
return l.state !== "authorized" || W(e, t, r, i, null, c.public_key).state !== "not_authorized" ? null : {
|
|
367
|
-
peerDeviceId: r,
|
|
368
|
-
coordinatorId: i,
|
|
369
|
-
groupId: l.groupId,
|
|
370
|
-
publicKey: a,
|
|
371
|
-
fingerprint: o,
|
|
372
|
-
previousPublicKey: c.public_key,
|
|
373
|
-
previousFingerprint: c.pinned_fingerprint
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
function re(e, t, n) {
|
|
377
|
-
y(e, {
|
|
378
|
-
localDeviceId: t,
|
|
379
|
-
peerDeviceId: n.peerDeviceId
|
|
380
|
-
}), e.prepare("UPDATE sync_peers SET public_key = ?, pinned_fingerprint = ?, discovered_via_group_id = ?\n WHERE peer_device_id = ? AND discovered_via_coordinator_id = ?\n AND public_key = ? AND pinned_fingerprint = ?\n AND trust_provenance = 'coordinator_policy'\n AND claimed_local_actor = 0 AND actor_id IS NULL\n AND pending_bootstrap_grant_id IS NULL").run(n.publicKey, n.fingerprint, n.groupId, n.peerDeviceId, n.coordinatorId, n.previousPublicKey, n.previousFingerprint);
|
|
381
|
-
}
|
|
382
|
-
function Y(e, t, n) {
|
|
383
|
-
return e.transaction(() => {
|
|
384
|
-
let r = /* @__PURE__ */ new Set();
|
|
385
|
-
for (let i of n) {
|
|
386
|
-
let n = ne(e, t, i);
|
|
387
|
-
n && (re(e, t, n), ie(e, n, i), r.add(n.peerDeviceId));
|
|
388
|
-
}
|
|
389
|
-
J(e, t);
|
|
390
|
-
let i = n.filter((e) => !r.has(b(e.device_id)));
|
|
391
|
-
return r.size + K(e, t, i);
|
|
392
|
-
}).immediate();
|
|
393
|
-
}
|
|
394
|
-
function ie(e, t, n) {
|
|
395
|
-
n.stale || V(e.prepare("SELECT peer_device_id, pinned_fingerprint, addresses_json, manual_addresses_json,\n last_success_address FROM sync_peers WHERE peer_device_id = ?").get(t.peerDeviceId), /* @__PURE__ */ new Map([[`${t.peerDeviceId}:${t.fingerprint}`, R(n.addresses)]]), (t, n, r, i) => {
|
|
396
|
-
e.prepare("UPDATE sync_peers SET addresses_json = ?,\n manual_addresses_json = COALESCE(manual_addresses_json, ?)\n WHERE peer_device_id = ? AND pinned_fingerprint = ?").run(t, n, r, i);
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
async function X(e, t, n) {
|
|
400
|
-
if (!o(t)) return {
|
|
401
|
-
peers: [],
|
|
402
|
-
trusted: 0
|
|
403
|
-
};
|
|
404
|
-
let r = n?.keysDir ?? (process.env.CODEMEM_KEYS_DIR?.trim() || void 0), [i] = p(e.db, { keysDir: r }), a = await L(e, t, { keysDir: r });
|
|
405
|
-
return H(e.db, a), {
|
|
406
|
-
peers: a,
|
|
407
|
-
trusted: Y(e.db, i, a)
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
async function ae(e, t, n, r) {
|
|
411
|
-
if (r?.peers) return Z(r.peers);
|
|
412
|
-
let i = c();
|
|
413
|
-
if (!o(i)) return /* @__PURE__ */ new Set();
|
|
414
|
-
try {
|
|
415
|
-
let r = await L({
|
|
416
|
-
db: e,
|
|
417
|
-
dbPath: t
|
|
418
|
-
}, i, { keysDir: n });
|
|
419
|
-
return H(e, r), Z(r);
|
|
420
|
-
} catch {
|
|
421
|
-
return /* @__PURE__ */ new Set();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function Z(e) {
|
|
425
|
-
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
426
|
-
for (let a of e) {
|
|
427
|
-
let e = b(a.device_id);
|
|
428
|
-
if (!e) continue;
|
|
429
|
-
let o = b(a.fingerprint), s = o ? `${e}:${o}` : "";
|
|
430
|
-
a.stale ? (n.add(e), s && i.add(s)) : (t.add(e), s && r.add(s));
|
|
431
|
-
}
|
|
432
|
-
for (let e of t) n.delete(e);
|
|
433
|
-
for (let e of r) i.delete(e);
|
|
434
|
-
return /* @__PURE__ */ new Set([...n, ...i]);
|
|
435
|
-
}
|
|
436
|
-
async function Q(e, t, n) {
|
|
437
|
-
if (!o(t)) return [];
|
|
438
|
-
let r = process.env.CODEMEM_KEYS_DIR?.trim() || void 0, [a] = p(e.db, { keysDir: r }), s = i(t.syncCoordinatorUrl), c = /* @__PURE__ */ new Map();
|
|
439
|
-
for (let i of t.syncCoordinatorGroups) {
|
|
440
|
-
let o = `${s}/v1/reciprocal-approvals?${new URLSearchParams({
|
|
441
|
-
group_id: i,
|
|
442
|
-
direction: n.direction,
|
|
443
|
-
status: n.status?.trim() || "pending"
|
|
444
|
-
}).toString()}`, d = u({
|
|
445
|
-
deviceId: a,
|
|
446
|
-
dbPath: e.dbPath,
|
|
447
|
-
method: "GET",
|
|
448
|
-
url: o,
|
|
449
|
-
bodyBytes: Buffer.alloc(0),
|
|
450
|
-
keysDir: r
|
|
451
|
-
}), [f, p] = await l("GET", o, {
|
|
452
|
-
headers: d,
|
|
453
|
-
timeoutS: Math.max(1, t.syncCoordinatorTimeoutS)
|
|
454
|
-
});
|
|
455
|
-
if (f !== 200 || !p) {
|
|
456
|
-
let e = typeof p?.error == "string" ? p.error : "unknown";
|
|
457
|
-
throw Error(`coordinator reciprocal approval lookup failed (${f}: ${e})`);
|
|
458
|
-
}
|
|
459
|
-
let m = Array.isArray(p.items) ? p.items : [];
|
|
460
|
-
for (let e of m) {
|
|
461
|
-
if (!e || typeof e != "object") continue;
|
|
462
|
-
let t = e, n = b(t.request_id);
|
|
463
|
-
n && c.set(n, t);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return [...c.values()];
|
|
467
|
-
}
|
|
468
|
-
async function oe(e, t, r) {
|
|
469
|
-
if (!o(t)) throw Error("Coordinator not configured.");
|
|
470
|
-
let a = r.groupId.trim(), s = r.requestedDeviceId.trim(), c = r.expectedIncomingRequestId?.trim();
|
|
471
|
-
if (!a || !s) throw Error("groupId and requestedDeviceId are required.");
|
|
472
|
-
if (r.expectedIncomingRequestId !== void 0 && !c) throw Error("expectedIncomingRequestId must not be empty when provided.");
|
|
473
|
-
let d = process.env.CODEMEM_KEYS_DIR?.trim() || void 0, [f] = p(e.db, { keysDir: d }), m = `${i(t.syncCoordinatorUrl)}/v1/reciprocal-approvals`, h = {
|
|
474
|
-
group_id: a,
|
|
475
|
-
requested_device_id: s,
|
|
476
|
-
...c === void 0 ? {} : { expected_incoming_request_id: c }
|
|
477
|
-
}, g = Buffer.from(JSON.stringify(h), "utf8"), _ = u({
|
|
478
|
-
deviceId: f,
|
|
479
|
-
dbPath: e.dbPath,
|
|
480
|
-
method: "POST",
|
|
481
|
-
url: m,
|
|
482
|
-
bodyBytes: g,
|
|
483
|
-
keysDir: d
|
|
484
|
-
}), [v, y] = await l("POST", m, {
|
|
485
|
-
headers: _,
|
|
486
|
-
body: h,
|
|
487
|
-
bodyBytes: g,
|
|
488
|
-
timeoutS: Math.max(1, t.syncCoordinatorTimeoutS)
|
|
489
|
-
});
|
|
490
|
-
if (v !== 200 || !y || !y.request || typeof y.request != "object") {
|
|
491
|
-
let r = typeof y?.error == "string" ? y.error : "unknown";
|
|
492
|
-
throw v === 409 && r === "reciprocal_approval_request_changed" ? (O(j(e, t)), new n()) : Error(`coordinator reciprocal approval create failed (${v}: ${r})`);
|
|
493
|
-
}
|
|
494
|
-
return O(j(e, t)), y.request;
|
|
495
|
-
}
|
|
496
|
-
function $(e, t) {
|
|
497
|
-
let n = /* @__PURE__ */ new Map();
|
|
498
|
-
for (let r of e) {
|
|
499
|
-
let e = b(r[t]);
|
|
500
|
-
e && n.set(e, r);
|
|
501
|
-
}
|
|
502
|
-
return n;
|
|
503
|
-
}
|
|
504
|
-
async function se(e, t) {
|
|
505
|
-
let n = M(e);
|
|
506
|
-
if (!o(t)) return {
|
|
507
|
-
enabled: !1,
|
|
508
|
-
configured: !1,
|
|
509
|
-
sync_enabled: t.syncEnabled,
|
|
510
|
-
coordinator_url: t.syncCoordinatorUrl || null,
|
|
511
|
-
groups: t.syncCoordinatorGroups,
|
|
512
|
-
paired_peer_count: n
|
|
513
|
-
};
|
|
514
|
-
let r = process.env.CODEMEM_KEYS_DIR?.trim() || void 0, [i] = p(e.db, { keysDir: r }), a = j(e, t), s = T.get(a) ?? 0, c = Date.now(), l = w.get(a);
|
|
515
|
-
if (l && c < l.nextRefreshAtMs) {
|
|
516
|
-
let n = structuredClone(l.snapshot);
|
|
517
|
-
if (await P(e, t, n, c), c = Date.now(), n.presence_status === "not_enrolled") return O(a), n.fresh_peer_count = 0, n.stale_peer_count = 0, n.discovered_peer_count = 0, n.discovered_devices = [], n.reciprocal_approvals = {
|
|
518
|
-
incoming: [],
|
|
519
|
-
outgoing: []
|
|
520
|
-
}, {
|
|
521
|
-
...n,
|
|
522
|
-
paired_peer_count: M(e)
|
|
523
|
-
};
|
|
524
|
-
if (c < l.nextRefreshAtMs) return Y(e.db, i, l.discoveredPeers), {
|
|
525
|
-
...n,
|
|
526
|
-
paired_peer_count: M(e)
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
let u = {
|
|
530
|
-
enabled: !0,
|
|
531
|
-
configured: !0,
|
|
532
|
-
sync_enabled: t.syncEnabled,
|
|
533
|
-
coordinator_url: t.syncCoordinatorUrl,
|
|
534
|
-
groups: t.syncCoordinatorGroups,
|
|
535
|
-
paired_peer_count: n,
|
|
536
|
-
presence_status: "unknown",
|
|
537
|
-
presence_error: null,
|
|
538
|
-
advertised_addresses: [],
|
|
539
|
-
fresh_peer_count: 0,
|
|
540
|
-
stale_peer_count: 0,
|
|
541
|
-
discovered_peer_count: 0,
|
|
542
|
-
discovered_devices: []
|
|
543
|
-
};
|
|
544
|
-
await P(e, t, u, c);
|
|
545
|
-
let d = [];
|
|
546
|
-
try {
|
|
547
|
-
let { peers: n } = await X(e, t, { keysDir: r });
|
|
548
|
-
d = structuredClone(n);
|
|
549
|
-
let i = [], a = [];
|
|
550
|
-
try {
|
|
551
|
-
i = await Q(e, t, { direction: "incoming" }), a = await Q(e, t, { direction: "outgoing" });
|
|
552
|
-
} catch (e) {
|
|
553
|
-
u.reciprocal_approval_error = e instanceof Error ? e.message : String(e);
|
|
554
|
-
}
|
|
555
|
-
let o = $(i, "requesting_device_id"), s = $(a, "requested_device_id");
|
|
556
|
-
u.discovered_peer_count = n.length, u.fresh_peer_count = n.filter((e) => !e.stale).length, u.stale_peer_count = n.filter((e) => !!e.stale).length, u.reciprocal_approvals = {
|
|
557
|
-
incoming: i,
|
|
558
|
-
outgoing: a
|
|
559
|
-
}, u.discovered_devices = n.map((e) => ({
|
|
560
|
-
device_id: e.device_id,
|
|
561
|
-
display_name: e.display_name ?? null,
|
|
562
|
-
fingerprint: e.fingerprint ?? null,
|
|
563
|
-
addresses: Array.isArray(e.addresses) ? e.addresses : [],
|
|
564
|
-
groups: Array.isArray(e.groups) ? e.groups : [],
|
|
565
|
-
last_seen_at: e.last_seen_at ?? null,
|
|
566
|
-
expires_at: e.expires_at ?? null,
|
|
567
|
-
stale: !!e.stale,
|
|
568
|
-
needs_local_approval: o.has(b(e.device_id)),
|
|
569
|
-
waiting_for_peer_approval: s.has(b(e.device_id)),
|
|
570
|
-
incoming_reciprocal_request_id: o.get(b(e.device_id))?.request_id ?? null,
|
|
571
|
-
outgoing_reciprocal_request_id: s.get(b(e.device_id))?.request_id ?? null
|
|
572
|
-
}));
|
|
573
|
-
} catch (e) {
|
|
574
|
-
u.lookup_error = e instanceof Error ? e.message : String(e);
|
|
575
|
-
}
|
|
576
|
-
return u.presence_status !== "not_enrolled" && !u.lookup_error && !u.reciprocal_approval_error && (T.get(a) ?? 0) === s && w.set(a, {
|
|
577
|
-
snapshot: structuredClone(u),
|
|
578
|
-
discoveredPeers: d,
|
|
579
|
-
nextRefreshAtMs: D(Date.now(), d)
|
|
580
|
-
}), u;
|
|
581
|
-
}
|
|
582
|
-
async function ce(e) {
|
|
583
|
-
let t = e.syncCoordinatorGroup || e.syncCoordinatorGroups[0] || "";
|
|
584
|
-
if (!t || !e.syncCoordinatorUrl || !e.syncCoordinatorAdminSecret) return [];
|
|
585
|
-
let n = `${i(e.syncCoordinatorUrl)}/v1/admin/join-requests?group_id=${encodeURIComponent(t)}`, [r, a] = await l("GET", n, {
|
|
586
|
-
headers: { "X-Codemem-Coordinator-Admin": e.syncCoordinatorAdminSecret },
|
|
587
|
-
timeoutS: Math.max(1, e.syncCoordinatorTimeoutS)
|
|
588
|
-
});
|
|
589
|
-
return r !== 200 || !a ? [] : Array.isArray(a.items) ? a.items.filter((e) => !!e && typeof e == "object") : [];
|
|
590
|
-
}
|
|
591
|
-
//#endregion
|
|
592
|
-
export { Q as a, H as c, K as d, ce as i, I as l, oe as n, L as o, ae as r, X as s, se as t, U as u };
|
|
593
|
-
|
|
594
|
-
//# sourceMappingURL=coordinator-runtime-CEc6KhBE.js.map
|