@dxos/echo-db 2.33.4-dev.faf06c70 → 2.33.5-dev.0d84e06f
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/src/api/index.d.ts +0 -5
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +0 -5
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/schema.test.js +1 -1
- package/dist/src/api/schema.test.js.map +1 -1
- package/dist/src/echo.d.ts +5 -12
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +11 -22
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +12 -0
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/contact-manager.d.ts +2 -1
- package/dist/src/halo/contact-manager.d.ts.map +1 -1
- package/dist/src/halo/contact-manager.js +1 -1
- package/dist/src/halo/contact-manager.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +5 -11
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +1 -1
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +8 -6
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.test.js +5 -4
- package/dist/src/halo/halo.test.js.map +1 -1
- package/dist/src/halo/identity.js +2 -2
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +2 -2
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts +1 -1
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +8 -11
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.js +5 -9
- package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts +6 -4
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +11 -14
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +1 -1
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +5 -2
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/invitation-factory.js +4 -3
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +6 -8
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
- package/dist/src/packlets/database/data-mirror.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.js +0 -0
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
- package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
- package/dist/src/packlets/database/data-service-host.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
- package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
- package/dist/src/packlets/database/data-service-router.js.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.d.ts +0 -0
- package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.js +0 -0
- package/dist/src/packlets/database/database-backend.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.d.ts +2 -1
- package/dist/src/packlets/database/database.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.js +2 -2
- package/dist/src/packlets/database/database.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
- package/dist/src/packlets/database/database.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.js +3 -3
- package/dist/src/packlets/database/database.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
- package/dist/src/packlets/database/entity.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/entity.js +0 -0
- package/dist/src/packlets/database/entity.js.map +1 -0
- package/dist/src/{database → packlets/database}/index.d.ts +5 -0
- package/dist/src/packlets/database/index.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/index.js +5 -0
- package/dist/src/packlets/database/index.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.d.ts +3 -2
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +3 -5
- package/dist/src/packlets/database/item-demuxer.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
- package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.js +2 -2
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
- package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.js +13 -12
- package/dist/src/packlets/database/item-manager.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
- package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
- package/dist/src/packlets/database/item-manager.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/item.d.ts +1 -1
- package/dist/src/packlets/database/item.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/item.js +0 -0
- package/dist/src/packlets/database/item.js.map +1 -0
- package/dist/src/{api → packlets/database}/link.d.ts +1 -1
- package/dist/src/packlets/database/link.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/link.js +0 -0
- package/dist/src/packlets/database/link.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
- package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.js +0 -0
- package/dist/src/packlets/database/selection/index.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
- package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
- package/dist/src/packlets/database/selection/queries.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
- package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.js +0 -0
- package/dist/src/packlets/database/selection/result.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
- package/dist/src/packlets/database/selection/selection.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
- package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
- package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.js +0 -0
- package/dist/src/packlets/database/selection/util.js.map +1 -0
- package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
- package/dist/src/packlets/database/testing.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/testing.js +4 -4
- package/dist/src/packlets/database/testing.js.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +0 -0
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.js +0 -0
- package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
- package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
- package/dist/src/packlets/errors/index.d.ts.map +1 -0
- package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
- package/dist/src/packlets/errors/index.js.map +1 -0
- package/dist/src/parties/data-party.d.ts +8 -5
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +13 -10
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +18 -18
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +0 -6
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +20 -48
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +2 -1
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +13 -10
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +3 -3
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +30 -39
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +3 -3
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +5 -5
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/metadata-store.test.js +9 -5
- package/dist/src/pipeline/metadata-store.test.js.map +1 -1
- package/dist/src/pipeline/party-core.d.ts +4 -3
- package/dist/src/pipeline/party-core.d.ts.map +1 -1
- package/dist/src/pipeline/party-core.js +7 -7
- package/dist/src/pipeline/party-core.js.map +1 -1
- package/dist/src/pipeline/party-core.test.js +30 -55
- package/dist/src/pipeline/party-core.test.js.map +1 -1
- package/dist/src/pipeline/party-processor.d.ts +21 -9
- package/dist/src/pipeline/party-processor.d.ts.map +1 -1
- package/dist/src/pipeline/party-processor.js +0 -8
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/pipeline/pipeline.d.ts +3 -5
- package/dist/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/pipeline.js +8 -11
- package/dist/src/pipeline/pipeline.js.map +1 -1
- package/dist/src/pipeline/pipeline.test.js +4 -5
- package/dist/src/pipeline/pipeline.test.js.map +1 -1
- package/dist/src/protocol/auth-plugin.d.ts +1 -1
- package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
- package/dist/src/protocol/auth-plugin.js +1 -3
- package/dist/src/protocol/auth-plugin.js.map +1 -1
- package/dist/src/protocol/authenticator.d.ts +4 -4
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +12 -16
- package/dist/src/protocol/authenticator.js.map +1 -1
- package/dist/src/protocol/authenticator.test.js +1 -4
- package/dist/src/protocol/authenticator.test.js.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.js +1 -3
- package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
- package/dist/src/protocol/identity-credentials.d.ts +2 -2
- package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +4 -4
- package/dist/src/protocol/identity-credentials.js.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.js +1 -3
- package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
- package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js +2 -55
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/protocol/replicator-plugin.d.ts +7 -0
- package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
- package/dist/src/protocol/replicator-plugin.js +36 -0
- package/dist/src/protocol/replicator-plugin.js.map +1 -0
- package/dist/src/snapshots/snapshot-generator.d.ts +2 -2
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +13 -15
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.d.ts +3 -3
- package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +5 -5
- package/dist/src/snapshots/snapshot-store.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.test.js +2 -2
- package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
- package/dist/src/snapshots/snapshot.test.js +1 -1
- package/dist/src/snapshots/snapshot.test.js.map +1 -1
- package/dist/src/testing/benchmark.test.d.ts +2 -0
- package/dist/src/testing/benchmark.test.d.ts.map +1 -0
- package/dist/src/testing/benchmark.test.js +25 -0
- package/dist/src/testing/benchmark.test.js.map +1 -0
- package/dist/src/testing/testing-factories.d.ts +1 -1
- package/dist/src/testing/testing-factories.d.ts.map +1 -1
- package/dist/src/testing/testing-factories.js +2 -2
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/src/testing/testing.d.ts +3 -4
- package/dist/src/testing/testing.d.ts.map +1 -1
- package/dist/src/testing/testing.js +3 -4
- package/dist/src/testing/testing.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/api/index.ts +0 -5
- package/src/api/schema.test.ts +1 -2
- package/src/echo.test.ts +16 -1
- package/src/echo.ts +15 -37
- package/src/halo/contact-manager.ts +3 -2
- package/src/halo/halo-factory.ts +6 -18
- package/src/halo/halo-party.ts +12 -6
- package/src/halo/halo.test.ts +5 -4
- package/src/halo/identity.ts +2 -2
- package/src/halo/party-opener.ts +2 -2
- package/src/halo/preferences.ts +10 -12
- package/src/index.ts +3 -3
- package/src/invitations/greeting-protocol-provider.ts +5 -9
- package/src/invitations/greeting-responder.ts +15 -17
- package/src/invitations/halo-recovery-initiator.ts +1 -1
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +8 -5
- package/src/invitations/offline-invitation-claimer.ts +6 -8
- package/src/{database → packlets/database}/data-mirror.test.ts +1 -1
- package/src/{database → packlets/database}/data-mirror.ts +1 -1
- package/src/{database → packlets/database}/data-service-host.ts +2 -1
- package/src/{database → packlets/database}/data-service-router.ts +0 -0
- package/src/{database → packlets/database}/database-backend.ts +0 -0
- package/src/{api → packlets/database}/database.test.ts +2 -1
- package/src/{api → packlets/database}/database.ts +3 -1
- package/src/{api → packlets/database}/entity.ts +1 -1
- package/src/{database → packlets/database}/index.ts +5 -0
- package/src/{database → packlets/database}/item-demuxer.test.ts +1 -1
- package/src/{database → packlets/database}/item-demuxer.ts +5 -5
- package/src/{database → packlets/database}/item-manager.test.ts +0 -0
- package/src/{database → packlets/database}/item-manager.ts +5 -3
- package/src/{api → packlets/database}/item.ts +2 -2
- package/src/{api → packlets/database}/link.ts +1 -1
- package/src/{api → packlets/database}/selection/index.ts +0 -0
- package/src/{api → packlets/database}/selection/queries.ts +14 -18
- package/src/{api → packlets/database}/selection/result.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
- package/src/{api → packlets/database}/selection/selection.ts +1 -7
- package/src/{api → packlets/database}/selection/util.ts +0 -0
- package/src/{database → packlets/database}/testing.ts +2 -2
- package/src/{database → packlets/database}/timeframe-clock.ts +0 -0
- package/src/{errors.ts → packlets/errors/index.ts} +0 -0
- package/src/parties/data-party.test.ts +19 -18
- package/src/parties/data-party.ts +17 -11
- package/src/parties/party-factory.ts +26 -72
- package/src/parties/party-manager.test.ts +20 -11
- package/src/parties/party-manager.ts +2 -1
- package/src/pipeline/message-selector.ts +33 -45
- package/src/pipeline/metadata-store.test.ts +9 -5
- package/src/pipeline/metadata-store.ts +5 -5
- package/src/pipeline/party-core.test.ts +33 -73
- package/src/pipeline/party-core.ts +8 -9
- package/src/pipeline/party-processor.ts +23 -15
- package/src/pipeline/pipeline.test.ts +4 -5
- package/src/pipeline/pipeline.ts +12 -15
- package/src/protocol/auth-plugin.ts +1 -3
- package/src/protocol/authenticator.test.ts +1 -4
- package/src/protocol/authenticator.ts +33 -33
- package/src/protocol/halo-recovery-plugin.ts +4 -6
- package/src/protocol/identity-credentials.ts +4 -4
- package/src/protocol/offline-invitation-plugin.ts +4 -6
- package/src/protocol/party-protocol-factory.ts +3 -56
- package/src/protocol/replicator-plugin.ts +37 -0
- package/src/snapshots/snapshot-generator.ts +13 -17
- package/src/snapshots/snapshot-store.test.ts +2 -2
- package/src/snapshots/snapshot-store.ts +5 -6
- package/src/snapshots/snapshot.test.ts +1 -1
- package/src/testing/benchmark.test.ts +30 -0
- package/src/testing/testing-factories.ts +3 -3
- package/src/testing/testing.ts +4 -8
- package/dist/src/api/database.d.ts.map +0 -1
- package/dist/src/api/database.js.map +0 -1
- package/dist/src/api/database.test.d.ts.map +0 -1
- package/dist/src/api/database.test.js.map +0 -1
- package/dist/src/api/entity.d.ts.map +0 -1
- package/dist/src/api/entity.js.map +0 -1
- package/dist/src/api/item.d.ts.map +0 -1
- package/dist/src/api/item.js.map +0 -1
- package/dist/src/api/link.d.ts.map +0 -1
- package/dist/src/api/link.js.map +0 -1
- package/dist/src/api/selection/index.d.ts.map +0 -1
- package/dist/src/api/selection/index.js.map +0 -1
- package/dist/src/api/selection/queries.d.ts.map +0 -1
- package/dist/src/api/selection/queries.js.map +0 -1
- package/dist/src/api/selection/result.d.ts.map +0 -1
- package/dist/src/api/selection/result.js.map +0 -1
- package/dist/src/api/selection/selection.d.ts.map +0 -1
- package/dist/src/api/selection/selection.js.map +0 -1
- package/dist/src/api/selection/selection.test.d.ts.map +0 -1
- package/dist/src/api/selection/selection.test.js.map +0 -1
- package/dist/src/api/selection/util.d.ts.map +0 -1
- package/dist/src/api/selection/util.js.map +0 -1
- package/dist/src/database/data-mirror.d.ts.map +0 -1
- package/dist/src/database/data-mirror.js.map +0 -1
- package/dist/src/database/data-mirror.test.d.ts.map +0 -1
- package/dist/src/database/data-mirror.test.js.map +0 -1
- package/dist/src/database/data-service-host.d.ts.map +0 -1
- package/dist/src/database/data-service-host.js.map +0 -1
- package/dist/src/database/data-service-router.d.ts.map +0 -1
- package/dist/src/database/data-service-router.js.map +0 -1
- package/dist/src/database/database-backend.d.ts.map +0 -1
- package/dist/src/database/database-backend.js.map +0 -1
- package/dist/src/database/index.d.ts.map +0 -1
- package/dist/src/database/index.js.map +0 -1
- package/dist/src/database/item-demuxer.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.js.map +0 -1
- package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.test.js.map +0 -1
- package/dist/src/database/item-manager.d.ts.map +0 -1
- package/dist/src/database/item-manager.js.map +0 -1
- package/dist/src/database/item-manager.test.d.ts.map +0 -1
- package/dist/src/database/item-manager.test.js.map +0 -1
- package/dist/src/database/testing.d.ts.map +0 -1
- package/dist/src/database/testing.js.map +0 -1
- package/dist/src/database/timeframe-clock.d.ts.map +0 -1
- package/dist/src/database/timeframe-clock.js.map +0 -1
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js.map +0 -1
- package/dist/src/util/index.d.ts +0 -2
- package/dist/src/util/index.d.ts.map +0 -1
- package/dist/src/util/index.js +0 -17
- package/dist/src/util/index.js.map +0 -1
- package/dist/src/util/persistant-ram-storage.d.ts +0 -6
- package/dist/src/util/persistant-ram-storage.d.ts.map +0 -1
- package/dist/src/util/persistant-ram-storage.js +0 -32
- package/dist/src/util/persistant-ram-storage.js.map +0 -1
- package/src/util/index.ts +0 -5
- package/src/util/persistant-ram-storage.ts +0 -33
|
@@ -32,13 +32,12 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
32
32
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
33
33
|
import { afterTest, testTimeout } from '@dxos/testutils';
|
|
34
34
|
|
|
35
|
-
import { Item } from '../api';
|
|
36
35
|
import { defaultInvitationAuthenticator, OfflineInvitationClaimer } from '../invitations';
|
|
36
|
+
import { Item } from '../packlets/database';
|
|
37
37
|
import { MetadataStore, PartyFeedProvider } from '../pipeline';
|
|
38
38
|
import { createTestIdentityCredentials } from '../protocol/identity-credentials';
|
|
39
39
|
import { SnapshotStore } from '../snapshots';
|
|
40
40
|
import { messageLogger } from '../testing';
|
|
41
|
-
import { createRamStorage } from '../util';
|
|
42
41
|
import { PARTY_ITEM_TYPE } from './data-party';
|
|
43
42
|
import { PartyFactory } from './party-factory';
|
|
44
43
|
import { PartyManager } from './party-manager';
|
|
@@ -56,9 +55,11 @@ const log = debug('dxos:echo:parties:party-manager:test');
|
|
|
56
55
|
*/
|
|
57
56
|
const setup = async () => {
|
|
58
57
|
const keyring = new Keyring();
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const snapshotStore = new SnapshotStore(
|
|
58
|
+
|
|
59
|
+
const storage = createStorage('', StorageType.RAM);
|
|
60
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
61
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
62
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
62
63
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
63
64
|
const networkManager = new NetworkManager();
|
|
64
65
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
@@ -149,11 +150,11 @@ describe('Party manager', () => {
|
|
|
149
150
|
|
|
150
151
|
test('Create from cold start', async () => {
|
|
151
152
|
const storage = createStorage('', StorageType.RAM);
|
|
152
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
153
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
153
154
|
const keyring = new Keyring();
|
|
154
|
-
const
|
|
155
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
156
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
155
157
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
156
|
-
const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
|
|
157
158
|
const networkManager = new NetworkManager();
|
|
158
159
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
159
160
|
|
|
@@ -189,15 +190,23 @@ describe('Party manager', () => {
|
|
|
189
190
|
assert(feedKey);
|
|
190
191
|
|
|
191
192
|
const feedStream = createWritableFeedStream(feed);
|
|
192
|
-
feedStream.write({ halo: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identity.identityKey) });
|
|
193
193
|
feedStream.write({
|
|
194
|
+
timeframe: new Timeframe(),
|
|
195
|
+
halo: createPartyGenesisMessage(
|
|
196
|
+
keyring,
|
|
197
|
+
partyKey,
|
|
198
|
+
feedKey.publicKey,
|
|
199
|
+
identity.identityKey
|
|
200
|
+
)
|
|
201
|
+
});
|
|
202
|
+
feedStream.write({
|
|
203
|
+
timeframe: new Timeframe(),
|
|
194
204
|
echo: checkType<EchoEnvelope>({
|
|
195
205
|
itemId: 'foo',
|
|
196
206
|
genesis: {
|
|
197
207
|
itemType: PARTY_ITEM_TYPE,
|
|
198
208
|
modelType: ObjectModel.meta.type
|
|
199
|
-
}
|
|
200
|
-
timeframe: new Timeframe()
|
|
209
|
+
}
|
|
201
210
|
})
|
|
202
211
|
});
|
|
203
212
|
}
|
|
@@ -175,7 +175,8 @@ export class PartyManager {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
log(`Adding party partyKey=${partyKey.toHex()} hints=${hints.length}`);
|
|
178
|
-
const party = await this._partyFactory.
|
|
178
|
+
const party = await this._partyFactory.constructParty(partyKey, hints);
|
|
179
|
+
await party.open();
|
|
179
180
|
await this._metadataStore.addParty(party.key);
|
|
180
181
|
this._setParty(party);
|
|
181
182
|
return party;
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getPartyCredentialMessageType, PartyCredential } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { MessageSelector } from '@dxos/echo-protocol';
|
|
11
11
|
|
|
12
|
-
import { TimeframeClock } from '../database';
|
|
13
|
-
import {
|
|
12
|
+
import { TimeframeClock } from '../packlets/database';
|
|
13
|
+
import { PartyStateProvider } from './party-processor';
|
|
14
14
|
|
|
15
15
|
const log = debug('dxos:echo-db:message-selector');
|
|
16
16
|
|
|
@@ -23,56 +23,44 @@ const log = debug('dxos:echo-db:message-selector');
|
|
|
23
23
|
* @param partyProcessor
|
|
24
24
|
* @param timeframeClock
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const { data: { echo } } = candidates[i];
|
|
35
|
-
const feedKey = PublicKey.from(candidates[i].key);
|
|
36
|
-
if (!echo) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
26
|
+
export const createMessageSelector = (partyProcessor: PartyStateProvider, timeframeClock: TimeframeClock): MessageSelector => candidates => {
|
|
27
|
+
// Check ECHO message candidates first since they are less expensive than HALO cancidates.
|
|
28
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
29
|
+
const { data: { timeframe, echo } } = candidates[i];
|
|
30
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
31
|
+
if (!echo) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
35
|
+
assert(timeframe);
|
|
36
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
37
|
+
return i;
|
|
44
38
|
}
|
|
39
|
+
}
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
// Check HALO message candidates.
|
|
42
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
43
|
+
const { data: { timeframe, halo } } = candidates[i];
|
|
44
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
45
|
+
if (!halo) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
assert(timeframe);
|
|
50
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
if (partyProcessor.genesisRequired) {
|
|
55
|
+
try { // TODO(dmaretskyi): Get getPartyCredentialMessageType crashes for some reason.
|
|
59
56
|
// TODO(telackey): Add check that this is for the right Party.
|
|
60
57
|
if (getPartyCredentialMessageType(halo) === PartyCredential.Type.PARTY_GENESIS) {
|
|
61
58
|
return i;
|
|
62
59
|
}
|
|
63
|
-
}
|
|
64
|
-
if (admitsKeys(halo).find(key => key.equals(feedKey))) {
|
|
65
|
-
// TODO(marik-d): Calling `Keyring.signingKeys` is expensive. Is there any way to optimize/cache this?
|
|
66
|
-
for (const signedBy of Keyring.signingKeys(halo)) {
|
|
67
|
-
if (partyProcessor.isMemberKey(signedBy) || signedBy.equals(partyProcessor.partyKey)) {
|
|
68
|
-
return i;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
60
|
+
} catch { }
|
|
73
61
|
}
|
|
62
|
+
}
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
64
|
+
// Not ready for this message yet.
|
|
65
|
+
log('Skipping...');
|
|
66
|
+
};
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/crypto';
|
|
8
|
+
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
8
9
|
|
|
9
|
-
import { createRamStorage } from '../util';
|
|
10
10
|
import { MetadataStore } from './metadata-store';
|
|
11
11
|
|
|
12
12
|
describe('MetadataStore in-memory', () => {
|
|
13
13
|
it('Creates party and adds feeds to it', async () => {
|
|
14
|
-
const
|
|
14
|
+
const storage = createStorage('', StorageType.RAM);
|
|
15
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
15
16
|
await store.load();
|
|
16
17
|
expect(store.parties?.length).toBe(0);
|
|
17
18
|
|
|
@@ -33,7 +34,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
it('Creates party when adding feed', async () => {
|
|
36
|
-
const
|
|
37
|
+
const storage = createStorage('', StorageType.RAM);
|
|
38
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
37
39
|
await store.load();
|
|
38
40
|
|
|
39
41
|
const partyKey = PublicKey.random();
|
|
@@ -45,7 +47,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
it('Doesn\'t add same feed twice', async () => {
|
|
48
|
-
const
|
|
50
|
+
const storage = createStorage('', StorageType.RAM);
|
|
51
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
49
52
|
await store.load();
|
|
50
53
|
|
|
51
54
|
const partyKey = PublicKey.random();
|
|
@@ -60,7 +63,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
60
63
|
|
|
61
64
|
// TODO(yivlad): Doesn't work for now.
|
|
62
65
|
it.skip('Resets storage', async () => {
|
|
63
|
-
const
|
|
66
|
+
const storage = createStorage('snapshots', StorageType.RAM);
|
|
67
|
+
const store = new MetadataStore(storage.directory(''));
|
|
64
68
|
|
|
65
69
|
const partyKey = PublicKey.random();
|
|
66
70
|
const feedKey = PublicKey.random();
|
|
@@ -8,7 +8,7 @@ import debug from 'debug';
|
|
|
8
8
|
import { PublicKey } from '@dxos/crypto';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
10
10
|
import { EchoMetadata, PartyMetadata, schema } from '@dxos/echo-protocol';
|
|
11
|
-
import {
|
|
11
|
+
import { Directory } from '@dxos/random-access-multi-storage';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
|
|
@@ -28,7 +28,7 @@ export class MetadataStore {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
constructor (
|
|
31
|
-
private readonly
|
|
31
|
+
private readonly _directory: Directory
|
|
32
32
|
) {}
|
|
33
33
|
|
|
34
34
|
get version (): number {
|
|
@@ -47,7 +47,7 @@ export class MetadataStore {
|
|
|
47
47
|
* Loads metadata from persistent storage.
|
|
48
48
|
*/
|
|
49
49
|
async load (): Promise<void> {
|
|
50
|
-
const file = this.
|
|
50
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
51
51
|
try {
|
|
52
52
|
const { size } = await file.stat();
|
|
53
53
|
if (size === 0) {
|
|
@@ -75,7 +75,7 @@ export class MetadataStore {
|
|
|
75
75
|
updated: new Date()
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const file = this.
|
|
78
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
79
79
|
|
|
80
80
|
try {
|
|
81
81
|
const encoded = Buffer.from(schema.getCodecForType('dxos.echo.metadata.EchoMetadata').encode(data));
|
|
@@ -90,7 +90,7 @@ export class MetadataStore {
|
|
|
90
90
|
*/
|
|
91
91
|
async clear (): Promise<void> {
|
|
92
92
|
log('Clearing all echo metadata...');
|
|
93
|
-
await this.
|
|
93
|
+
await this._directory.destroy();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -8,7 +8,8 @@ import { it as test } from 'mocha';
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { createId, PublicKey } from '@dxos/crypto';
|
|
11
|
-
import {
|
|
11
|
+
import { checkType } from '@dxos/debug';
|
|
12
|
+
import { codec, FeedMessage, Timeframe } from '@dxos/echo-protocol';
|
|
12
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
13
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
14
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -16,23 +17,23 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
16
17
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
17
18
|
import { afterTest } from '@dxos/testutils';
|
|
18
19
|
|
|
19
|
-
import { MetadataStore, PartyFeedProvider
|
|
20
|
+
import { MetadataStore, PartyFeedProvider } from '../pipeline';
|
|
21
|
+
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
20
22
|
import { SnapshotStore } from '../snapshots';
|
|
21
|
-
import { createRamStorage } from '../util';
|
|
22
23
|
import { PartyCore } from './party-core';
|
|
23
24
|
|
|
24
25
|
describe('PartyCore', () => {
|
|
25
26
|
const setup = async () => {
|
|
26
27
|
const storage = createStorage('', StorageType.RAM);
|
|
27
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
28
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
28
29
|
afterTest(async () => feedStore.close());
|
|
29
30
|
|
|
30
31
|
const keyring = new Keyring();
|
|
31
32
|
|
|
32
|
-
const metadataStore = new MetadataStore(
|
|
33
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
33
34
|
|
|
34
35
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
35
|
-
const snapshotStore = new SnapshotStore(
|
|
36
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
36
37
|
|
|
37
38
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
38
39
|
|
|
@@ -51,7 +52,7 @@ describe('PartyCore', () => {
|
|
|
51
52
|
afterTest(async () => party.close());
|
|
52
53
|
|
|
53
54
|
// PartyGenesis (self-signed by Party).
|
|
54
|
-
await party.
|
|
55
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
55
56
|
keyring,
|
|
56
57
|
partyKey,
|
|
57
58
|
feed.key,
|
|
@@ -59,7 +60,7 @@ describe('PartyCore', () => {
|
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
// FeedAdmit (signed by the Device KeyChain).
|
|
62
|
-
await party.
|
|
63
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
63
64
|
keyring,
|
|
64
65
|
partyKey.publicKey,
|
|
65
66
|
feed.key,
|
|
@@ -120,7 +121,7 @@ describe('PartyCore', () => {
|
|
|
120
121
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
121
122
|
|
|
122
123
|
const eventFired = feedStore.feedOpenedEvent.waitForCount(1);
|
|
123
|
-
await party.
|
|
124
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
124
125
|
keyring,
|
|
125
126
|
party.key,
|
|
126
127
|
feedKey.publicKey,
|
|
@@ -132,15 +133,15 @@ describe('PartyCore', () => {
|
|
|
132
133
|
|
|
133
134
|
test('opens feed from hints', async () => {
|
|
134
135
|
const storage = createStorage('', StorageType.RAM);
|
|
135
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
136
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
136
137
|
afterTest(async () => feedStore.close());
|
|
137
138
|
|
|
138
139
|
const keyring = new Keyring();
|
|
139
140
|
|
|
140
|
-
const metadataStore = new MetadataStore(
|
|
141
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
141
142
|
|
|
142
143
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
143
|
-
const snapshotStore = new SnapshotStore(
|
|
144
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
144
145
|
|
|
145
146
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
146
147
|
|
|
@@ -175,16 +176,16 @@ describe('PartyCore', () => {
|
|
|
175
176
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
176
177
|
|
|
177
178
|
const itemId = createId();
|
|
178
|
-
await feed.feed.append({
|
|
179
|
+
await feed.feed.append(checkType<FeedMessage>({
|
|
180
|
+
timeframe: new Timeframe(),
|
|
179
181
|
echo: {
|
|
180
182
|
itemId,
|
|
181
183
|
genesis: {
|
|
182
184
|
itemType: 'dxos:example',
|
|
183
185
|
modelType: ObjectModel.meta.type
|
|
184
|
-
}
|
|
185
|
-
timeframe: new Timeframe()
|
|
186
|
+
}
|
|
186
187
|
}
|
|
187
|
-
});
|
|
188
|
+
}));
|
|
188
189
|
|
|
189
190
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
190
191
|
});
|
|
@@ -197,7 +198,7 @@ describe('PartyCore', () => {
|
|
|
197
198
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
198
199
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
199
200
|
|
|
200
|
-
await party.
|
|
201
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
201
202
|
keyring,
|
|
202
203
|
party.key,
|
|
203
204
|
feed2.key,
|
|
@@ -205,16 +206,16 @@ describe('PartyCore', () => {
|
|
|
205
206
|
));
|
|
206
207
|
|
|
207
208
|
const itemId = createId();
|
|
208
|
-
await feed2.append({
|
|
209
|
+
await feed2.append(checkType<FeedMessage>({
|
|
210
|
+
timeframe: new Timeframe(),
|
|
209
211
|
echo: {
|
|
210
212
|
itemId,
|
|
211
213
|
genesis: {
|
|
212
214
|
itemType: 'dxos:example',
|
|
213
215
|
modelType: ObjectModel.meta.type
|
|
214
|
-
}
|
|
215
|
-
timeframe: new Timeframe()
|
|
216
|
+
}
|
|
216
217
|
}
|
|
217
|
-
});
|
|
218
|
+
}));
|
|
218
219
|
|
|
219
220
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
220
221
|
});
|
|
@@ -226,7 +227,7 @@ describe('PartyCore', () => {
|
|
|
226
227
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
227
228
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
228
229
|
|
|
229
|
-
await party.
|
|
230
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
230
231
|
keyring,
|
|
231
232
|
party.key,
|
|
232
233
|
feedKey.publicKey,
|
|
@@ -235,53 +236,16 @@ describe('PartyCore', () => {
|
|
|
235
236
|
|
|
236
237
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
237
238
|
const itemId = createId();
|
|
238
|
-
await feed2.append({
|
|
239
|
+
await feed2.append(checkType<FeedMessage>({
|
|
240
|
+
timeframe: new Timeframe(),
|
|
239
241
|
echo: {
|
|
240
242
|
itemId,
|
|
241
243
|
genesis: {
|
|
242
244
|
itemType: 'dxos:example',
|
|
243
245
|
modelType: ObjectModel.meta.type
|
|
244
|
-
}
|
|
245
|
-
timeframe: new Timeframe()
|
|
246
|
+
}
|
|
246
247
|
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
test('self-admitting feed with a hint', async () => {
|
|
253
|
-
const { party, keyring, partyKey, feedStore } = await setup();
|
|
254
|
-
await party.open();
|
|
255
|
-
|
|
256
|
-
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
257
|
-
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
258
|
-
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
259
|
-
|
|
260
|
-
await party.processor.takeHints([{
|
|
261
|
-
type: KeyType.FEED,
|
|
262
|
-
publicKey: feedKey.publicKey
|
|
263
|
-
}]);
|
|
264
|
-
|
|
265
|
-
await feed2.append({
|
|
266
|
-
halo: createFeedAdmitMessage(
|
|
267
|
-
keyring,
|
|
268
|
-
party.key,
|
|
269
|
-
feedKey.publicKey,
|
|
270
|
-
[partyKey]
|
|
271
|
-
)
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
const itemId = createId();
|
|
275
|
-
await feed2.append({
|
|
276
|
-
echo: {
|
|
277
|
-
itemId,
|
|
278
|
-
genesis: {
|
|
279
|
-
itemType: 'dxos:example',
|
|
280
|
-
modelType: ObjectModel.meta.type
|
|
281
|
-
},
|
|
282
|
-
timeframe: new Timeframe()
|
|
283
|
-
}
|
|
284
|
-
});
|
|
248
|
+
}));
|
|
285
249
|
|
|
286
250
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
287
251
|
});
|
|
@@ -290,13 +254,13 @@ describe('PartyCore', () => {
|
|
|
290
254
|
const peer1 = await setup();
|
|
291
255
|
|
|
292
256
|
const storage = createStorage('', StorageType.RAM);
|
|
293
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
257
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
294
258
|
afterTest(async () => feedStore.close());
|
|
295
259
|
|
|
296
|
-
const metadataStore = new MetadataStore(
|
|
260
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
297
261
|
|
|
298
262
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
299
|
-
const snapshotStore = new SnapshotStore(
|
|
263
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
300
264
|
|
|
301
265
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, peer1.keyring, feedStore, peer1.party.key);
|
|
302
266
|
|
|
@@ -310,7 +274,7 @@ describe('PartyCore', () => {
|
|
|
310
274
|
|
|
311
275
|
const feed2 = await partyFeedProvider.createOrOpenWritableFeed();
|
|
312
276
|
|
|
313
|
-
await peer1.party.
|
|
277
|
+
await peer1.party.credentialsWriter.write(createFeedAdmitMessage(
|
|
314
278
|
peer1.keyring,
|
|
315
279
|
peer1.party.key,
|
|
316
280
|
feed2.key,
|
|
@@ -324,12 +288,8 @@ describe('PartyCore', () => {
|
|
|
324
288
|
afterTest(async () => party2.close());
|
|
325
289
|
|
|
326
290
|
createTestProtocolPair(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
).createPlugins().map(r => r.createExtension()),
|
|
330
|
-
new ReplicatorProtocolPluginFactory(
|
|
331
|
-
partyFeedProvider
|
|
332
|
-
).createPlugins().map(r => r.createExtension())
|
|
291
|
+
[createReplicatorPlugin(peer1.partyFeedProvider).createExtension()],
|
|
292
|
+
[createReplicatorPlugin(partyFeedProvider).createExtension()]
|
|
333
293
|
);
|
|
334
294
|
|
|
335
295
|
const item1 = await peer1.party.database.createItem();
|
|
@@ -5,15 +5,14 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
|
-
import { KeyHint, KeyType } from '@dxos/credentials';
|
|
8
|
+
import { KeyHint, KeyType, Message as HaloMessage } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { timed } from '@dxos/debug';
|
|
11
|
-
import { createFeedWriter, DatabaseSnapshot, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { createFeedWriter, DatabaseSnapshot, FeedWriter, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
13
|
import { SubscriptionGroup } from '@dxos/util';
|
|
14
14
|
|
|
15
|
-
import { Database } from '../
|
|
16
|
-
import { FeedDatabaseBackend, TimeframeClock } from '../database';
|
|
15
|
+
import { Database, FeedDatabaseBackend, TimeframeClock } from '../packlets/database';
|
|
17
16
|
import { createMessageSelector, PartyProcessor, PartyFeedProvider, Pipeline } from '../pipeline';
|
|
18
17
|
import { createAutomaticSnapshots, SnapshotStore } from '../snapshots';
|
|
19
18
|
|
|
@@ -99,6 +98,11 @@ export class PartyCore {
|
|
|
99
98
|
return feed;
|
|
100
99
|
}
|
|
101
100
|
|
|
101
|
+
get credentialsWriter (): FeedWriter<HaloMessage> {
|
|
102
|
+
assert(this._pipeline?.outboundHaloStream, 'Party not open');
|
|
103
|
+
return this._pipeline?.outboundHaloStream;
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
/**
|
|
103
107
|
* Opens the pipeline and connects the streams.
|
|
104
108
|
*/
|
|
@@ -147,11 +151,6 @@ export class PartyCore {
|
|
|
147
151
|
// TODO(burdon): Support read-only parties.
|
|
148
152
|
const [readStream, writeStream] = await this._pipeline.open();
|
|
149
153
|
|
|
150
|
-
// Must happen after open.
|
|
151
|
-
if (this._pipeline.outboundHaloStream) {
|
|
152
|
-
this._partyProcessor.setOutboundStream(this._pipeline.outboundHaloStream);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
154
|
//
|
|
156
155
|
// Database
|
|
157
156
|
//
|
|
@@ -12,22 +12,40 @@ import {
|
|
|
12
12
|
PartyState,
|
|
13
13
|
Message as HaloMessage,
|
|
14
14
|
IdentityEventType,
|
|
15
|
-
PartyEventType
|
|
15
|
+
PartyEventType,
|
|
16
|
+
SignedMessage
|
|
16
17
|
} from '@dxos/credentials';
|
|
17
18
|
import { PublicKey } from '@dxos/crypto';
|
|
18
|
-
import { FeedKey,
|
|
19
|
+
import { FeedKey, IHaloStream, PartyKey, HaloStateSnapshot } from '@dxos/echo-protocol';
|
|
19
20
|
import { jsonReplacer } from '@dxos/util';
|
|
20
21
|
|
|
21
22
|
const log = debug('dxos:echo-db:party-processor');
|
|
22
23
|
|
|
24
|
+
export interface CredentialProcessor {
|
|
25
|
+
processMessage (message: IHaloStream): Promise<void>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PartyStateProvider {
|
|
29
|
+
partyKey: PublicKey
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether PartyGenesis was already processed.
|
|
33
|
+
*/
|
|
34
|
+
genesisRequired: boolean
|
|
35
|
+
memberKeys: PublicKey[]
|
|
36
|
+
feedKeys: PublicKey[]
|
|
37
|
+
getFeedOwningMember (feedKey: FeedKey): PublicKey | undefined
|
|
38
|
+
isFeedAdmitted (feedKey: FeedKey): boolean
|
|
39
|
+
|
|
40
|
+
getOfflineInvitation (invitationID: Buffer): SignedMessage | undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
/**
|
|
24
44
|
* TODO(burdon): Wrapper/Bridge between HALO APIs.
|
|
25
45
|
*/
|
|
26
|
-
export class PartyProcessor {
|
|
46
|
+
export class PartyProcessor implements CredentialProcessor, PartyStateProvider {
|
|
27
47
|
private readonly _state: PartyState;
|
|
28
48
|
|
|
29
|
-
private _outboundHaloStream: FeedWriter<HaloMessage> | undefined;
|
|
30
|
-
|
|
31
49
|
readonly feedAdded = new Event<FeedKey>()
|
|
32
50
|
|
|
33
51
|
public readonly keyOrInfoAdded = new Event<PublicKey>();
|
|
@@ -124,16 +142,6 @@ export class PartyProcessor {
|
|
|
124
142
|
await this._state.processMessages([data]);
|
|
125
143
|
}
|
|
126
144
|
|
|
127
|
-
setOutboundStream (stream: FeedWriter<HaloMessage>) {
|
|
128
|
-
this._outboundHaloStream = stream;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async writeHaloMessage (message: HaloMessage): Promise<WriteReceipt> {
|
|
132
|
-
assert(this._outboundHaloStream, 'Party is closed or read-only');
|
|
133
|
-
// TODO(marik-d): Wait for the message to be processed?
|
|
134
|
-
return this._outboundHaloStream.write(message);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
145
|
makeSnapshot (): HaloStateSnapshot {
|
|
138
146
|
return {
|
|
139
147
|
messages: this._haloMessages
|
|
@@ -15,7 +15,7 @@ import { createSetPropertyMutation } from '@dxos/model-factory';
|
|
|
15
15
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
16
16
|
import { jsonReplacer } from '@dxos/util';
|
|
17
17
|
|
|
18
|
-
import { TimeframeClock } from '../database';
|
|
18
|
+
import { TimeframeClock } from '../packlets/database';
|
|
19
19
|
import { PartyProcessor } from './party-processor';
|
|
20
20
|
import { Pipeline } from './pipeline';
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ const log = debug('dxos:echo:pipeline:test');
|
|
|
25
25
|
describe('pipeline', () => {
|
|
26
26
|
test('streams', async () => {
|
|
27
27
|
const storage = createStorage('', StorageType.RAM);
|
|
28
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
28
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
29
29
|
const feedKeys: Uint8Array[] = [];
|
|
30
30
|
const feedSelector: FeedSelector = descriptor => !!feedKeys.find(key => descriptor.key.equals(key));
|
|
31
31
|
const feedReadStream = new FeedStoreIterator(feedSelector, () => 0, new Timeframe());
|
|
@@ -87,7 +87,7 @@ describe('pipeline', () => {
|
|
|
87
87
|
|
|
88
88
|
test('writing', async () => {
|
|
89
89
|
const storage = createStorage('', StorageType.RAM);
|
|
90
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
90
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
91
91
|
const feedReadStream = new FeedStoreIterator(() => true, () => 0, new Timeframe());
|
|
92
92
|
|
|
93
93
|
const { publicKey, secretKey } = createKeyPair();
|
|
@@ -133,8 +133,7 @@ describe('pipeline', () => {
|
|
|
133
133
|
itemId: '123',
|
|
134
134
|
genesis: {
|
|
135
135
|
itemType: 'foo'
|
|
136
|
-
}
|
|
137
|
-
timeframe: expect.any(Timeframe)
|
|
136
|
+
}
|
|
138
137
|
});
|
|
139
138
|
});
|
|
140
139
|
});
|