@dxos/echo-db 2.33.5-dev.ea3876ba → 2.33.5-dev.ebc105f7
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 +1 -0
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +9 -20
- package/dist/src/echo.js.map +1 -1
- 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 +4 -3
- 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 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- 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 -17
- 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 -9
- 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 -29
- 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 +8 -4
- 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 -28
- 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 +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/api/index.ts +0 -5
- package/src/api/schema.test.ts +1 -2
- package/src/echo.test.ts +1 -1
- package/src/echo.ts +10 -20
- 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 +4 -3
- 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 -2
- 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 -17
- package/src/parties/data-party.ts +17 -11
- package/src/parties/party-factory.ts +26 -72
- package/src/parties/party-manager.test.ts +20 -10
- package/src/parties/party-manager.ts +2 -1
- package/src/pipeline/message-selector.ts +32 -35
- package/src/pipeline/metadata-store.test.ts +8 -4
- package/src/pipeline/metadata-store.ts +5 -5
- package/src/pipeline/party-core.test.ts +33 -35
- 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 +1 -1
- 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/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
|
@@ -7,10 +7,10 @@ import debug from 'debug';
|
|
|
7
7
|
import { EchoEnvelope, ItemID, ItemMutation, ItemType, FeedWriter } from '@dxos/echo-protocol';
|
|
8
8
|
import { Model, StateManager } from '@dxos/model-factory';
|
|
9
9
|
|
|
10
|
-
import { ItemManager } from '../database';
|
|
11
10
|
import { Entity } from './entity';
|
|
11
|
+
import { ItemManager } from './item-manager';
|
|
12
12
|
import type { Link } from './link';
|
|
13
|
-
import {
|
|
13
|
+
import { createItemSelection, Selection } from './selection';
|
|
14
14
|
|
|
15
15
|
const log = debug('dxos:echo-db:item');
|
|
16
16
|
|
|
@@ -7,9 +7,9 @@ import assert from 'assert';
|
|
|
7
7
|
import { ItemID, ItemType } from '@dxos/echo-protocol';
|
|
8
8
|
import { Model, StateManager } from '@dxos/model-factory';
|
|
9
9
|
|
|
10
|
-
import { ItemManager } from '../database';
|
|
11
10
|
import { Entity } from './entity';
|
|
12
11
|
import { Item } from './item';
|
|
12
|
+
import { ItemManager } from './item-manager';
|
|
13
13
|
|
|
14
14
|
export interface LinkData {
|
|
15
15
|
sourceId: ItemID
|
|
File without changes
|
|
@@ -84,25 +84,21 @@ export const itemFilterToPredicate = (filter: ItemFilter | ItemIdFilter): Predic
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
export const linkFilterToPredicate = (filter: LinkFilter): Predicate<Link> =>
|
|
88
|
-
return link => (!filter.type || testOneOrMultiple(filter.type, link.type));
|
|
89
|
-
};
|
|
87
|
+
export const linkFilterToPredicate = (filter: LinkFilter): Predicate<Link> => link => (!filter.type || testOneOrMultiple(filter.type, link.type));
|
|
90
88
|
|
|
91
89
|
export const createQueryOptionsFilter = ({
|
|
92
90
|
deleted = ItemFilterDeleted.HIDE_DELETED
|
|
93
|
-
}: QueryOptions): Predicate<Entity> => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
};
|
|
91
|
+
}: QueryOptions): Predicate<Entity> => entity => {
|
|
92
|
+
if (entity.model === null) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
switch (deleted) {
|
|
97
|
+
case ItemFilterDeleted.HIDE_DELETED:
|
|
98
|
+
return !(entity instanceof Item) || !entity.deleted;
|
|
99
|
+
case ItemFilterDeleted.SHOW_DELETED:
|
|
100
|
+
return true;
|
|
101
|
+
case ItemFilterDeleted.SHOW_DELETED_ONLY:
|
|
102
|
+
return entity instanceof Item && entity.deleted;
|
|
103
|
+
}
|
|
108
104
|
};
|
|
File without changes
|
|
@@ -24,9 +24,7 @@ const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
|
24
24
|
|
|
25
25
|
const createModel = (id: ItemID) => modelFactory.createModel(ObjectModel.meta.type, id, {}, PublicKey.random());
|
|
26
26
|
|
|
27
|
-
const createItem = (id: ItemID, type: ItemType, parent?: Item<any>) =>
|
|
28
|
-
return new Item(null as any, id, type, createModel(id), undefined, parent);
|
|
29
|
-
};
|
|
27
|
+
const createItem = (id: ItemID, type: ItemType, parent?: Item<any>) => new Item(null as any, id, type, createModel(id), undefined, parent);
|
|
30
28
|
|
|
31
29
|
const createLink = (id: ItemID, type: ItemType, source: Item<any>, target: Item<any>) => {
|
|
32
30
|
const link = new Link(null as any, id, type, createModel(id), {
|
|
@@ -262,17 +260,11 @@ describe('Selection', () => {
|
|
|
262
260
|
test('complex reducer', () => {
|
|
263
261
|
const query = createReducer({ numItems: 0, numLinks: 0 })
|
|
264
262
|
.filter({ type: ITEM_ORG })
|
|
265
|
-
.call((items: Item[], { numItems, ...rest }) => {
|
|
266
|
-
return { ...rest, numItems: numItems + items.length, stage: 'a' };
|
|
267
|
-
})
|
|
263
|
+
.call((items: Item[], { numItems, ...rest }) => ({ ...rest, numItems: numItems + items.length, stage: 'a' }))
|
|
268
264
|
.children({ type: ITEM_PROJECT })
|
|
269
|
-
.call((items: Item[], { numItems, ...rest }) => {
|
|
270
|
-
return { ...rest, numItems: numItems + items.length, stage: 'b' };
|
|
271
|
-
})
|
|
265
|
+
.call((items: Item[], { numItems, ...rest }) => ({ ...rest, numItems: numItems + items.length, stage: 'b' }))
|
|
272
266
|
.links({ type: LINK_MEMBER })
|
|
273
|
-
.call((links: Link[], { numLinks, ...rest }) => {
|
|
274
|
-
return { ...rest, numLinks: numLinks + links.length, stage: 'c' };
|
|
275
|
-
})
|
|
267
|
+
.call((links: Link[], { numLinks, ...rest }) => ({ ...rest, numLinks: numLinks + links.length, stage: 'c' }))
|
|
276
268
|
.target()
|
|
277
269
|
.exec();
|
|
278
270
|
|
|
@@ -57,13 +57,7 @@ export const createSelection = <R>(
|
|
|
57
57
|
* @param update
|
|
58
58
|
* @param value Initial reducer value.
|
|
59
59
|
*/
|
|
60
|
-
export const createItemSelection = <R>(
|
|
61
|
-
root: Item<any>,
|
|
62
|
-
update: Event<Entity[]>,
|
|
63
|
-
value: R
|
|
64
|
-
): Selection<Item<any>, R> => {
|
|
65
|
-
return new Selection(() => [[root], value], update, root, value !== undefined);
|
|
66
|
-
};
|
|
60
|
+
export const createItemSelection = <R>(root: Item<any>, update: Event<Entity[]>, value: R): Selection<Item<any>, R> => new Selection(() => [[root], value], update, root, value !== undefined);
|
|
67
61
|
|
|
68
62
|
/**
|
|
69
63
|
* Selections are used to construct database subscriptions.
|
|
File without changes
|
|
@@ -8,14 +8,14 @@ import { PublicKey } from '@dxos/crypto';
|
|
|
8
8
|
import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
|
|
9
9
|
import { ModelFactory } from '@dxos/model-factory';
|
|
10
10
|
|
|
11
|
-
import { Database } from '../api';
|
|
12
11
|
import { DataServiceHost } from './data-service-host';
|
|
13
12
|
import { DataServiceRouter } from './data-service-router';
|
|
13
|
+
import { Database } from './database';
|
|
14
14
|
import { FeedDatabaseBackend, RemoteDatabaseBackend } from './database-backend';
|
|
15
15
|
|
|
16
16
|
export const createInMemoryDatabase = async (modelFactory: ModelFactory) => {
|
|
17
17
|
const feed = new MockFeedWriter<EchoEnvelope>();
|
|
18
|
-
const inboundStream = new Readable({ read () {}, objectMode: true });
|
|
18
|
+
const inboundStream = new Readable({ read: () => {}, objectMode: true });
|
|
19
19
|
feed.written.on(([data, meta]) => inboundStream.push({ data, meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe([[meta.feedKey, meta.seq]]) } }));
|
|
20
20
|
|
|
21
21
|
const database = new Database(
|
|
File without changes
|
|
File without changes
|
|
@@ -23,9 +23,11 @@ import { DataParty } from './data-party';
|
|
|
23
23
|
|
|
24
24
|
describe('DataParty', () => {
|
|
25
25
|
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, hints: KeyHint[]) => {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const snapshotStore = new SnapshotStore(
|
|
26
|
+
|
|
27
|
+
const storage = createStorage('', StorageType.RAM);
|
|
28
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
29
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
30
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
29
31
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
30
32
|
const networkManager = new NetworkManager();
|
|
31
33
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, identity.keyring, feedStore, partyKey);
|
|
@@ -59,8 +61,8 @@ describe('DataParty', () => {
|
|
|
59
61
|
const party = await createParty(identity, partyKey.publicKey, []);
|
|
60
62
|
await party.open();
|
|
61
63
|
|
|
62
|
-
const feed = await party.
|
|
63
|
-
await party.
|
|
64
|
+
const feed = await party.getWriteFeed();
|
|
65
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
64
66
|
keyring,
|
|
65
67
|
partyKey,
|
|
66
68
|
feed.key,
|
|
@@ -79,15 +81,15 @@ describe('DataParty', () => {
|
|
|
79
81
|
|
|
80
82
|
const party = await createParty(identity, partyKey.publicKey, []);
|
|
81
83
|
await party.open();
|
|
82
|
-
const feed = await party.
|
|
83
|
-
await party.
|
|
84
|
+
const feed = await party.getWriteFeed();
|
|
85
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
84
86
|
keyring,
|
|
85
87
|
partyKey,
|
|
86
88
|
feed.key,
|
|
87
89
|
partyKey
|
|
88
90
|
));
|
|
89
91
|
|
|
90
|
-
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner());
|
|
92
|
+
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner(), party.credentialsWriter);
|
|
91
93
|
const credentialsProvider = createCredentialsProvider(identity.createCredentialsSigner(), party.key, feed.key);
|
|
92
94
|
|
|
93
95
|
const wrappedCredentials = haloCodec.decode(credentialsProvider.get());
|
|
@@ -103,14 +105,14 @@ describe('DataParty', () => {
|
|
|
103
105
|
|
|
104
106
|
const party = await createParty(identityA, partyKey.publicKey, []);
|
|
105
107
|
await party.open();
|
|
106
|
-
const feed = await party.
|
|
107
|
-
await party.
|
|
108
|
+
const feed = await party.getWriteFeed();
|
|
109
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
108
110
|
keyring,
|
|
109
111
|
partyKey,
|
|
110
112
|
feed.key,
|
|
111
113
|
partyKey
|
|
112
114
|
));
|
|
113
|
-
const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner());
|
|
115
|
+
const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner(), party.credentialsWriter);
|
|
114
116
|
|
|
115
117
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
116
118
|
const credentialsProvider = createCredentialsProvider(identityB.createCredentialsSigner(), party.key, feed.key);
|
|
@@ -128,14 +130,14 @@ describe('DataParty', () => {
|
|
|
128
130
|
|
|
129
131
|
const partyA = await createParty(identityA, partyKey.publicKey, []);
|
|
130
132
|
await partyA.open();
|
|
131
|
-
const feedA = await partyA.
|
|
132
|
-
await partyA.
|
|
133
|
+
const feedA = await partyA.getWriteFeed();
|
|
134
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
133
135
|
keyring,
|
|
134
136
|
partyKey,
|
|
135
137
|
feedA.key,
|
|
136
138
|
partyKey
|
|
137
139
|
));
|
|
138
|
-
await partyA.
|
|
140
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
139
141
|
keyring,
|
|
140
142
|
partyKey.publicKey,
|
|
141
143
|
identityA.identityKey,
|
|
@@ -164,14 +166,14 @@ describe('DataParty', () => {
|
|
|
164
166
|
|
|
165
167
|
const partyA = await createParty(identityA, partyKeyA.publicKey, []);
|
|
166
168
|
await partyA.open();
|
|
167
|
-
const feedA = await partyA.
|
|
168
|
-
await partyA.
|
|
169
|
+
const feedA = await partyA.getWriteFeed();
|
|
170
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
169
171
|
identityA.keyring,
|
|
170
172
|
partyKeyA,
|
|
171
173
|
feedA.key,
|
|
172
174
|
partyKeyA
|
|
173
175
|
));
|
|
174
|
-
await partyA.
|
|
176
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
175
177
|
identityA.keyring,
|
|
176
178
|
partyKeyA.publicKey,
|
|
177
179
|
identityA.identityKey,
|
|
@@ -9,16 +9,19 @@ import { KeyHint } from '@dxos/credentials';
|
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { timed } from '@dxos/debug';
|
|
11
11
|
import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
|
+
import { FeedDescriptor } from '@dxos/feed-store';
|
|
12
13
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
14
|
import { NetworkManager } from '@dxos/network-manager';
|
|
14
15
|
import { ObjectModel } from '@dxos/object-model';
|
|
15
16
|
|
|
16
|
-
import {
|
|
17
|
+
import { ResultSet } from '../api';
|
|
17
18
|
import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
|
|
18
19
|
import { InvitationFactory } from '../invitations';
|
|
20
|
+
import { Database, Item } from '../packlets/database';
|
|
19
21
|
import { PartyFeedProvider, PartyProtocolFactory, PartyCore, PartyOptions } from '../pipeline';
|
|
20
22
|
import { createAuthPlugin, createOfflineInvitationPlugin, createAuthenticator, createCredentialsProvider } from '../protocol';
|
|
21
23
|
import { CredentialsSigner } from '../protocol/credentials-signer';
|
|
24
|
+
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
22
25
|
import { SnapshotStore } from '../snapshots';
|
|
23
26
|
import { CONTACT_DEBOUNCE_INTERVAL } from './party-manager';
|
|
24
27
|
|
|
@@ -125,14 +128,8 @@ export class DataParty {
|
|
|
125
128
|
return this._invitationManager;
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return this._feedProvider;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get preferences (): PartyPreferences {
|
|
134
|
-
assert(this._preferences, 'Preferences not available.');
|
|
135
|
-
return this._preferences;
|
|
131
|
+
get credentialsWriter () {
|
|
132
|
+
return this._partyCore.credentialsWriter;
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
get title () {
|
|
@@ -160,6 +157,7 @@ export class DataParty {
|
|
|
160
157
|
this._invitationManager = new InvitationFactory(
|
|
161
158
|
this._partyCore.processor,
|
|
162
159
|
this._credentialsSigner,
|
|
160
|
+
this._partyCore.credentialsWriter,
|
|
163
161
|
this._networkManager
|
|
164
162
|
);
|
|
165
163
|
|
|
@@ -173,13 +171,13 @@ export class DataParty {
|
|
|
173
171
|
this._protocol = new PartyProtocolFactory(
|
|
174
172
|
this._partyCore.key,
|
|
175
173
|
this._networkManager,
|
|
176
|
-
this._feedProvider,
|
|
177
174
|
deviceKey.publicKey,
|
|
178
175
|
createCredentialsProvider(this._credentialsSigner, this._partyCore.key, writeFeed.key)
|
|
179
176
|
);
|
|
180
177
|
|
|
181
178
|
await this._protocol.start([
|
|
182
|
-
|
|
179
|
+
createReplicatorPlugin(this._feedProvider),
|
|
180
|
+
createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner, this.credentialsWriter), deviceKey.publicKey),
|
|
183
181
|
createOfflineInvitationPlugin(this._invitationManager, deviceKey.publicKey)
|
|
184
182
|
]);
|
|
185
183
|
|
|
@@ -210,6 +208,14 @@ export class DataParty {
|
|
|
210
208
|
return this;
|
|
211
209
|
}
|
|
212
210
|
|
|
211
|
+
async getWriteFeed (): Promise<FeedDescriptor> {
|
|
212
|
+
return this._feedProvider.createOrOpenWritableFeed();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
getFeeds (): FeedDescriptor[] {
|
|
216
|
+
return this._feedProvider.getFeeds();
|
|
217
|
+
}
|
|
218
|
+
|
|
213
219
|
get isActive (): boolean {
|
|
214
220
|
assert(this._preferences, 'PartyActivator required');
|
|
215
221
|
return this._preferences.isActive;
|
|
@@ -21,11 +21,11 @@ import { ModelFactory } from '@dxos/model-factory';
|
|
|
21
21
|
import { NetworkManager } from '@dxos/network-manager';
|
|
22
22
|
import { ObjectModel } from '@dxos/object-model';
|
|
23
23
|
|
|
24
|
-
import { IdentityNotInitializedError } from '../errors';
|
|
25
24
|
import {
|
|
26
25
|
createDataPartyAdmissionMessages,
|
|
27
26
|
GreetingInitiator, InvitationDescriptor, InvitationDescriptorType, OfflineInvitationClaimer
|
|
28
27
|
} from '../invitations';
|
|
28
|
+
import { IdentityNotInitializedError } from '../packlets/errors';
|
|
29
29
|
import { PartyFeedProvider, PartyOptions } from '../pipeline';
|
|
30
30
|
import { IdentityCredentialsProvider } from '../protocol/identity-credentials';
|
|
31
31
|
import { SnapshotStore } from '../snapshots';
|
|
@@ -60,10 +60,10 @@ export class PartyFactory {
|
|
|
60
60
|
// Connect the pipeline.
|
|
61
61
|
await party.open();
|
|
62
62
|
|
|
63
|
-
const writableFeed = await party.
|
|
63
|
+
const writableFeed = await party.getWriteFeed();
|
|
64
64
|
|
|
65
65
|
// PartyGenesis (self-signed by Party).
|
|
66
|
-
await party.
|
|
66
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
67
67
|
identity.keyring,
|
|
68
68
|
partyKey,
|
|
69
69
|
writableFeed.key,
|
|
@@ -71,7 +71,7 @@ export class PartyFactory {
|
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
74
|
-
await party.
|
|
74
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
75
75
|
identity.keyring,
|
|
76
76
|
partyKey.publicKey,
|
|
77
77
|
wrapMessage(identity.identityGenesis),
|
|
@@ -80,7 +80,7 @@ export class PartyFactory {
|
|
|
80
80
|
|
|
81
81
|
// FeedAdmit (signed by the Device KeyChain).
|
|
82
82
|
// TODO(dmaretskyi): Is this really needed since a feed is already admitted by party genesis message.
|
|
83
|
-
await party.
|
|
83
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
84
84
|
identity.keyring,
|
|
85
85
|
partyKey.publicKey,
|
|
86
86
|
writableFeed.key,
|
|
@@ -89,7 +89,7 @@ export class PartyFactory {
|
|
|
89
89
|
|
|
90
90
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
91
91
|
if (identity.identityInfo) {
|
|
92
|
-
await party.
|
|
92
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
93
93
|
identity.keyring,
|
|
94
94
|
partyKey.publicKey,
|
|
95
95
|
wrapMessage(identity.identityInfo),
|
|
@@ -106,50 +106,6 @@ export class PartyFactory {
|
|
|
106
106
|
return party;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/**
|
|
110
|
-
* Constructs a party object and creates a local write feed for it.
|
|
111
|
-
* @param partyKey
|
|
112
|
-
* @param hints
|
|
113
|
-
*/
|
|
114
|
-
async addParty (partyKey: PartyKey, hints: KeyHint[] = []) {
|
|
115
|
-
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
116
|
-
|
|
117
|
-
/*
|
|
118
|
-
* TODO(telackey): We shouldn't have to add our key here, it should be in the hints, but our hint
|
|
119
|
-
* mechanism is broken by not waiting on the messages to be processed before returning.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
const feedProvider = this._feedProviderFactory(partyKey);
|
|
123
|
-
const { feed } = await feedProvider.createOrOpenWritableFeed();
|
|
124
|
-
const feedKeyPair = identity.keyring.getKey(feed.key);
|
|
125
|
-
assert(feedKeyPair, 'Keypair for writable feed not found.');
|
|
126
|
-
const party = new DataParty(
|
|
127
|
-
partyKey,
|
|
128
|
-
this._modelFactory,
|
|
129
|
-
this._snapshotStore,
|
|
130
|
-
feedProvider,
|
|
131
|
-
identity.createCredentialsSigner(),
|
|
132
|
-
identity.preferences,
|
|
133
|
-
this._networkManager,
|
|
134
|
-
hints,
|
|
135
|
-
undefined,
|
|
136
|
-
this._options
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
await party.open();
|
|
140
|
-
const isHalo = identity.identityKey.publicKey.equals(partyKey);
|
|
141
|
-
const signingKey = isHalo ? identity.deviceKey : identity.deviceKeyChain;
|
|
142
|
-
assert(signingKey, 'No device key or keychain.');
|
|
143
|
-
// Write the Feed genesis message.
|
|
144
|
-
await party.processor.writeHaloMessage(createFeedAdmitMessage(
|
|
145
|
-
identity.keyring,
|
|
146
|
-
partyKey,
|
|
147
|
-
feedKeyPair.publicKey,
|
|
148
|
-
[signingKey]
|
|
149
|
-
));
|
|
150
|
-
return party;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
109
|
/**
|
|
154
110
|
* Constructs a party object from an existing set of feeds.
|
|
155
111
|
* @param partyKey
|
|
@@ -190,7 +146,6 @@ export class PartyFactory {
|
|
|
190
146
|
}
|
|
191
147
|
|
|
192
148
|
async joinParty (invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<DataParty> {
|
|
193
|
-
const haloInvitation = !!invitationDescriptor.identityKey;
|
|
194
149
|
const originalInvitation = invitationDescriptor;
|
|
195
150
|
|
|
196
151
|
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
@@ -218,19 +173,18 @@ export class PartyFactory {
|
|
|
218
173
|
|
|
219
174
|
await initiator.connect();
|
|
220
175
|
const { partyKey, hints } = await initiator.redeemInvitation(secretProvider);
|
|
221
|
-
const party = await this.
|
|
176
|
+
const party = await this.constructParty(partyKey, hints);
|
|
177
|
+
await party.open();
|
|
222
178
|
await initiator.destroy();
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
));
|
|
233
|
-
}
|
|
179
|
+
|
|
180
|
+
// Copy our signed IdentityInfo into the new Party.
|
|
181
|
+
if (identity.identityInfo) {
|
|
182
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
183
|
+
identity.keyring,
|
|
184
|
+
partyKey,
|
|
185
|
+
wrapMessage(identity.identityInfo),
|
|
186
|
+
[identity.deviceKeyChain]
|
|
187
|
+
));
|
|
234
188
|
}
|
|
235
189
|
|
|
236
190
|
return party;
|
|
@@ -247,10 +201,10 @@ export class PartyFactory {
|
|
|
247
201
|
// Connect the pipeline.
|
|
248
202
|
await party.open();
|
|
249
203
|
|
|
250
|
-
const writableFeed = await party.
|
|
204
|
+
const writableFeed = await party.getWriteFeed();
|
|
251
205
|
|
|
252
206
|
// PartyGenesis (self-signed by Party).
|
|
253
|
-
await party.
|
|
207
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
254
208
|
identity.keyring,
|
|
255
209
|
partyKey,
|
|
256
210
|
writableFeed.key,
|
|
@@ -258,7 +212,7 @@ export class PartyFactory {
|
|
|
258
212
|
);
|
|
259
213
|
|
|
260
214
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
261
|
-
await party.
|
|
215
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
262
216
|
identity.keyring,
|
|
263
217
|
partyKey.publicKey,
|
|
264
218
|
wrapMessage(identity.identityGenesis),
|
|
@@ -266,7 +220,7 @@ export class PartyFactory {
|
|
|
266
220
|
));
|
|
267
221
|
|
|
268
222
|
// FeedAdmit (signed by the Device KeyChain).
|
|
269
|
-
await party.
|
|
223
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
270
224
|
identity.keyring,
|
|
271
225
|
partyKey.publicKey,
|
|
272
226
|
writableFeed.key,
|
|
@@ -275,7 +229,7 @@ export class PartyFactory {
|
|
|
275
229
|
|
|
276
230
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
277
231
|
if (identity.identityInfo) {
|
|
278
|
-
await party.
|
|
232
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
279
233
|
identity.keyring,
|
|
280
234
|
partyKey.publicKey,
|
|
281
235
|
wrapMessage(identity.identityInfo),
|
|
@@ -285,7 +239,7 @@ export class PartyFactory {
|
|
|
285
239
|
|
|
286
240
|
// const keyAdmitMessage = snapshot.halo?.messages?.[1];
|
|
287
241
|
// assert(keyAdmitMessage);
|
|
288
|
-
// await party.
|
|
242
|
+
// await party.writeCredentialsMessage(createEnvelopeMessage(
|
|
289
243
|
// identity.signer,
|
|
290
244
|
// partyKey.publicKey,
|
|
291
245
|
// keyAdmitMessage,
|
|
@@ -293,13 +247,14 @@ export class PartyFactory {
|
|
|
293
247
|
// ));
|
|
294
248
|
|
|
295
249
|
// for(const message of snapshot.halo?.messages?.slice(2) || []) {
|
|
296
|
-
// await party.
|
|
250
|
+
// await party.writeCredentialsMessage(message);
|
|
297
251
|
// }
|
|
298
252
|
|
|
299
253
|
// Write messages to create ECHO items.
|
|
300
254
|
const feedWriter = createFeedWriter(writableFeed.feed);
|
|
301
255
|
for (const item of snapshot.database?.items || []) {
|
|
302
256
|
const message: FeedMessage = {
|
|
257
|
+
timeframe: new Timeframe(),
|
|
303
258
|
echo: {
|
|
304
259
|
itemId: item.itemId ?? failUndefined(),
|
|
305
260
|
genesis: {
|
|
@@ -310,8 +265,7 @@ export class PartyFactory {
|
|
|
310
265
|
itemMutation: {
|
|
311
266
|
parentId: item.parentId
|
|
312
267
|
},
|
|
313
|
-
snapshot: item.model
|
|
314
|
-
timeframe: new Timeframe()
|
|
268
|
+
snapshot: item.model
|
|
315
269
|
}
|
|
316
270
|
};
|
|
317
271
|
await feedWriter.write(message);
|
|
@@ -32,8 +32,8 @@ 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';
|
|
@@ -55,9 +55,11 @@ const log = debug('dxos:echo:parties:party-manager:test');
|
|
|
55
55
|
*/
|
|
56
56
|
const setup = async () => {
|
|
57
57
|
const keyring = new Keyring();
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
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 });
|
|
61
63
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
62
64
|
const networkManager = new NetworkManager();
|
|
63
65
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
@@ -148,11 +150,11 @@ describe('Party manager', () => {
|
|
|
148
150
|
|
|
149
151
|
test('Create from cold start', async () => {
|
|
150
152
|
const storage = createStorage('', StorageType.RAM);
|
|
151
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
153
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
152
154
|
const keyring = new Keyring();
|
|
153
|
-
const
|
|
155
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
156
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
154
157
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
155
|
-
const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
|
|
156
158
|
const networkManager = new NetworkManager();
|
|
157
159
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
158
160
|
|
|
@@ -188,15 +190,23 @@ describe('Party manager', () => {
|
|
|
188
190
|
assert(feedKey);
|
|
189
191
|
|
|
190
192
|
const feedStream = createWritableFeedStream(feed);
|
|
191
|
-
feedStream.write({ halo: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identity.identityKey) });
|
|
192
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(),
|
|
193
204
|
echo: checkType<EchoEnvelope>({
|
|
194
205
|
itemId: 'foo',
|
|
195
206
|
genesis: {
|
|
196
207
|
itemType: PARTY_ITEM_TYPE,
|
|
197
208
|
modelType: ObjectModel.meta.type
|
|
198
|
-
}
|
|
199
|
-
timeframe: new Timeframe()
|
|
209
|
+
}
|
|
200
210
|
})
|
|
201
211
|
});
|
|
202
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;
|