@dxos/echo-db 2.33.5-dev.ea3876ba → 2.33.5-dev.fee8f5fe
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 +5 -6
- 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 +10 -21
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +12 -4
- 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 +4 -4
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +8 -13
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +5 -4
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +16 -10
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.d.ts +2 -2
- package/dist/src/halo/halo.d.ts.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/index.js +5 -1
- package/dist/src/halo/index.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 +5 -3
- 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 +7 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +4 -5
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +4 -4
- package/dist/src/invitations/greeting-initiator.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.d.ts +1 -1
- package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +2 -2
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/index.js +5 -1
- package/dist/src/invitations/index.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +6 -2
- 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 +7 -9
- 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 +2 -2
- 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 +4 -5
- package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.js +5 -6
- 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 +10 -1
- package/dist/src/packlets/database/index.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.d.ts +5 -4
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +5 -8
- 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 +15 -11
- 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 +5 -1
- 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 +5 -6
- package/dist/src/packlets/database/testing.js.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +1 -0
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.js +3 -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 +14 -10
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +39 -15
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +42 -22
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/index.js +5 -1
- package/dist/src/parties/index.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +5 -10
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +30 -54
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts +3 -4
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +9 -7
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +16 -15
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/{pipeline.d.ts → feed-muxer.d.ts} +10 -15
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -44
- package/dist/src/pipeline/feed-muxer.js.map +1 -0
- package/dist/src/pipeline/feed-muxer.test.d.ts +2 -0
- package/dist/src/pipeline/feed-muxer.test.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.test.js → feed-muxer.test.js} +20 -18
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -0
- package/dist/src/pipeline/index.d.ts +2 -2
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +7 -3
- package/dist/src/pipeline/index.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 +5 -4
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +11 -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-feed-provider.d.ts +2 -3
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +2 -17
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/{party-core.d.ts → party-pipeline.d.ts} +26 -11
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -31
- package/dist/src/pipeline/party-pipeline.js.map +1 -0
- package/dist/src/pipeline/party-pipeline.test.d.ts +2 -0
- package/dist/src/pipeline/party-pipeline.test.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.test.js → party-pipeline.test.js} +64 -46
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
- 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/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/index.js +5 -1
- package/dist/src/protocol/index.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/index.js +5 -1
- package/dist/src/snapshots/index.js.map +1 -1
- package/dist/src/snapshots/snapshot-generator.d.ts +3 -3
- 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/index.js +5 -1
- package/dist/src/testing/index.js.map +1 -1
- 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 +19 -19
- package/src/api/index.ts +0 -5
- package/src/api/schema.test.ts +1 -2
- package/src/echo.test.ts +16 -5
- package/src/echo.ts +11 -20
- package/src/halo/contact-manager.ts +3 -2
- package/src/halo/halo-factory.ts +11 -23
- package/src/halo/halo-party.ts +22 -14
- package/src/halo/halo.test.ts +4 -3
- package/src/halo/halo.ts +2 -2
- package/src/halo/identity.ts +2 -2
- package/src/halo/party-opener.ts +5 -3
- package/src/halo/preferences.ts +10 -12
- package/src/index.ts +3 -2
- package/src/invitations/greeting-initiator.ts +10 -9
- package/src/invitations/greeting-protocol-provider.ts +5 -9
- package/src/invitations/greeting-responder.ts +15 -17
- package/src/invitations/halo-recovery-initiator.ts +4 -4
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +8 -5
- package/src/invitations/offline-invitation-claimer.ts +8 -10
- package/src/{database → packlets/database}/data-mirror.test.ts +3 -3
- 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 +7 -6
- 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 +21 -19
- package/src/{database → packlets/database}/item-demuxer.ts +10 -9
- 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 +4 -7
- package/src/{database → packlets/database}/timeframe-clock.ts +4 -0
- package/src/{errors.ts → packlets/errors/index.ts} +0 -0
- package/src/parties/data-party.test.ts +58 -25
- package/src/parties/data-party.ts +48 -20
- package/src/parties/party-factory.ts +40 -84
- package/src/parties/party-manager.test.ts +24 -15
- package/src/parties/party-manager.ts +10 -6
- package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +23 -19
- package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -55
- package/src/pipeline/index.ts +2 -2
- package/src/pipeline/message-selector.ts +32 -35
- package/src/pipeline/metadata-store.test.ts +8 -4
- package/src/pipeline/metadata-store.ts +12 -6
- package/src/pipeline/party-feed-provider.ts +3 -16
- package/src/pipeline/{party-core.test.ts → party-pipeline.test.ts} +67 -48
- package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -31
- package/src/pipeline/party-processor.ts +23 -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 +14 -18
- 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
- package/dist/src/pipeline/party-core.d.ts.map +0 -1
- package/dist/src/pipeline/party-core.js.map +0 -1
- package/dist/src/pipeline/party-core.test.d.ts +0 -2
- package/dist/src/pipeline/party-core.test.d.ts.map +0 -1
- package/dist/src/pipeline/party-core.test.js.map +0 -1
- package/dist/src/pipeline/pipeline.d.ts.map +0 -1
- package/dist/src/pipeline/pipeline.js.map +0 -1
- package/dist/src/pipeline/pipeline.test.d.ts +0 -2
- package/dist/src/pipeline/pipeline.test.d.ts.map +0 -1
- package/dist/src/pipeline/pipeline.test.js.map +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
|
-
import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider,
|
|
8
|
+
import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider, Keyring, KeyType, codec as haloCodec } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { codec } from '@dxos/echo-protocol';
|
|
11
11
|
import { FeedStore } from '@dxos/feed-store';
|
|
@@ -22,24 +22,29 @@ import { SnapshotStore } from '../snapshots';
|
|
|
22
22
|
import { DataParty } from './data-party';
|
|
23
23
|
|
|
24
24
|
describe('DataParty', () => {
|
|
25
|
-
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey,
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const snapshotStore = new SnapshotStore(
|
|
25
|
+
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, feedHints: PublicKey[]) => {
|
|
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);
|
|
34
|
+
const writableFeed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
const party = new DataParty(
|
|
34
37
|
partyKey,
|
|
35
38
|
modelFactory,
|
|
36
39
|
snapshotStore,
|
|
37
40
|
partyFeedProvider,
|
|
41
|
+
metadataStore,
|
|
38
42
|
identity.createCredentialsSigner(),
|
|
39
43
|
identity.preferences,
|
|
40
|
-
networkManager
|
|
41
|
-
hints
|
|
44
|
+
networkManager
|
|
42
45
|
);
|
|
46
|
+
party._setFeedHints([...feedHints, writableFeed.key]);
|
|
47
|
+
return party;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
50
|
test('open & close', async () => {
|
|
@@ -59,8 +64,8 @@ describe('DataParty', () => {
|
|
|
59
64
|
const party = await createParty(identity, partyKey.publicKey, []);
|
|
60
65
|
await party.open();
|
|
61
66
|
|
|
62
|
-
const feed = await party.
|
|
63
|
-
await party.
|
|
67
|
+
const feed = await party.getWriteFeed();
|
|
68
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
64
69
|
keyring,
|
|
65
70
|
partyKey,
|
|
66
71
|
feed.key,
|
|
@@ -72,6 +77,33 @@ describe('DataParty', () => {
|
|
|
72
77
|
await party.close();
|
|
73
78
|
});
|
|
74
79
|
|
|
80
|
+
test('data is immediately available after re-opening', async () => {
|
|
81
|
+
const keyring = new Keyring();
|
|
82
|
+
const identity = await createTestIdentityCredentials(keyring);
|
|
83
|
+
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
84
|
+
const party = await createParty(identity, partyKey.publicKey, []);
|
|
85
|
+
await party.open();
|
|
86
|
+
|
|
87
|
+
const feed = await party.getWriteFeed();
|
|
88
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
89
|
+
keyring,
|
|
90
|
+
partyKey,
|
|
91
|
+
feed.key,
|
|
92
|
+
partyKey
|
|
93
|
+
));
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < 10; i++) {
|
|
96
|
+
await party.database.createItem({ type: 'test:item' });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await party.close();
|
|
100
|
+
await party.open();
|
|
101
|
+
|
|
102
|
+
expect(party.database.select({ type: 'test:item' }).exec().entities).toHaveLength(10);
|
|
103
|
+
|
|
104
|
+
await party.close();
|
|
105
|
+
});
|
|
106
|
+
|
|
75
107
|
test('authenticates its own credentials', async () => {
|
|
76
108
|
const keyring = new Keyring();
|
|
77
109
|
const identity = await createTestIdentityCredentials(keyring);
|
|
@@ -79,15 +111,16 @@ describe('DataParty', () => {
|
|
|
79
111
|
|
|
80
112
|
const party = await createParty(identity, partyKey.publicKey, []);
|
|
81
113
|
await party.open();
|
|
82
|
-
const feed = await party.
|
|
83
|
-
await party.
|
|
114
|
+
const feed = await party.getWriteFeed();
|
|
115
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
84
116
|
keyring,
|
|
85
117
|
partyKey,
|
|
86
118
|
feed.key,
|
|
87
119
|
partyKey
|
|
88
120
|
));
|
|
121
|
+
await party.processor.feedAdded.waitForCount(1);
|
|
89
122
|
|
|
90
|
-
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner());
|
|
123
|
+
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner(), party.credentialsWriter);
|
|
91
124
|
const credentialsProvider = createCredentialsProvider(identity.createCredentialsSigner(), party.key, feed.key);
|
|
92
125
|
|
|
93
126
|
const wrappedCredentials = haloCodec.decode(credentialsProvider.get());
|
|
@@ -103,14 +136,16 @@ describe('DataParty', () => {
|
|
|
103
136
|
|
|
104
137
|
const party = await createParty(identityA, partyKey.publicKey, []);
|
|
105
138
|
await party.open();
|
|
106
|
-
const feed = await party.
|
|
107
|
-
await party.
|
|
139
|
+
const feed = await party.getWriteFeed();
|
|
140
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
108
141
|
keyring,
|
|
109
142
|
partyKey,
|
|
110
143
|
feed.key,
|
|
111
144
|
partyKey
|
|
112
145
|
));
|
|
113
|
-
|
|
146
|
+
await party.processor.feedAdded.waitForCount(1);
|
|
147
|
+
|
|
148
|
+
const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner(), party.credentialsWriter);
|
|
114
149
|
|
|
115
150
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
116
151
|
const credentialsProvider = createCredentialsProvider(identityB.createCredentialsSigner(), party.key, feed.key);
|
|
@@ -128,14 +163,14 @@ describe('DataParty', () => {
|
|
|
128
163
|
|
|
129
164
|
const partyA = await createParty(identityA, partyKey.publicKey, []);
|
|
130
165
|
await partyA.open();
|
|
131
|
-
const feedA = await partyA.
|
|
132
|
-
await partyA.
|
|
166
|
+
const feedA = await partyA.getWriteFeed();
|
|
167
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
133
168
|
keyring,
|
|
134
169
|
partyKey,
|
|
135
170
|
feedA.key,
|
|
136
171
|
partyKey
|
|
137
172
|
));
|
|
138
|
-
await partyA.
|
|
173
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
139
174
|
keyring,
|
|
140
175
|
partyKey.publicKey,
|
|
141
176
|
identityA.identityKey,
|
|
@@ -143,9 +178,7 @@ describe('DataParty', () => {
|
|
|
143
178
|
));
|
|
144
179
|
|
|
145
180
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
146
|
-
const partyB = await createParty(identityB, partyKey.publicKey, [
|
|
147
|
-
{ type: KeyType.FEED, publicKey: feedA.key }
|
|
148
|
-
]);
|
|
181
|
+
const partyB = await createParty(identityB, partyKey.publicKey, [feedA.key]);
|
|
149
182
|
await partyB.open();
|
|
150
183
|
|
|
151
184
|
await partyA.database.createItem({ type: 'test:item-a' });
|
|
@@ -164,14 +197,14 @@ describe('DataParty', () => {
|
|
|
164
197
|
|
|
165
198
|
const partyA = await createParty(identityA, partyKeyA.publicKey, []);
|
|
166
199
|
await partyA.open();
|
|
167
|
-
const feedA = await partyA.
|
|
168
|
-
await partyA.
|
|
200
|
+
const feedA = await partyA.getWriteFeed();
|
|
201
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
169
202
|
identityA.keyring,
|
|
170
203
|
partyKeyA,
|
|
171
204
|
feedA.key,
|
|
172
205
|
partyKeyA
|
|
173
206
|
));
|
|
174
|
-
await partyA.
|
|
207
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
175
208
|
identityA.keyring,
|
|
176
209
|
partyKeyA.publicKey,
|
|
177
210
|
identityA.identityKey,
|
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized, Event } from '@dxos/async';
|
|
8
|
-
import { KeyHint } from '@dxos/credentials';
|
|
9
8
|
import { PublicKey } from '@dxos/crypto';
|
|
10
9
|
import { timed } from '@dxos/debug';
|
|
11
10
|
import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { FeedDescriptor } from '@dxos/feed-store';
|
|
12
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
13
|
import { NetworkManager } from '@dxos/network-manager';
|
|
14
14
|
import { ObjectModel } from '@dxos/object-model';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { ResultSet } from '../api';
|
|
17
17
|
import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
|
|
18
18
|
import { InvitationFactory } from '../invitations';
|
|
19
|
-
import {
|
|
19
|
+
import { Database, Item } from '../packlets/database';
|
|
20
|
+
import { PartyFeedProvider, PartyProtocolFactory, PartyPipeline, PipelineOptions, MetadataStore } from '../pipeline';
|
|
20
21
|
import { createAuthPlugin, createOfflineInvitationPlugin, createAuthenticator, createCredentialsProvider } from '../protocol';
|
|
21
22
|
import { CredentialsSigner } from '../protocol/credentials-signer';
|
|
23
|
+
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
22
24
|
import { SnapshotStore } from '../snapshots';
|
|
23
25
|
import { CONTACT_DEBOUNCE_INTERVAL } from './party-manager';
|
|
24
26
|
|
|
@@ -40,31 +42,31 @@ export interface PartyMember {
|
|
|
40
42
|
export class DataParty {
|
|
41
43
|
public readonly update = new Event<void>();
|
|
42
44
|
|
|
43
|
-
private readonly _partyCore:
|
|
45
|
+
private readonly _partyCore: PartyPipeline;
|
|
44
46
|
private readonly _preferences?: PartyPreferences;
|
|
45
47
|
private _invitationManager?: InvitationFactory;
|
|
46
48
|
private _protocol?: PartyProtocolFactory;
|
|
49
|
+
private _feedHints: PublicKey[] = []
|
|
47
50
|
|
|
48
51
|
constructor (
|
|
49
52
|
partyKey: PartyKey,
|
|
50
53
|
modelFactory: ModelFactory,
|
|
51
54
|
snapshotStore: SnapshotStore,
|
|
52
55
|
private readonly _feedProvider: PartyFeedProvider,
|
|
56
|
+
private readonly _metadataStore: MetadataStore,
|
|
53
57
|
private readonly _credentialsSigner: CredentialsSigner,
|
|
54
58
|
// TODO(dmaretskyi): Pull this out to a higher level. Should preferences be part of client API instead?
|
|
55
59
|
private readonly _profilePreferences: Preferences | undefined,
|
|
56
60
|
private readonly _networkManager: NetworkManager,
|
|
57
|
-
private readonly
|
|
58
|
-
|
|
59
|
-
_options: PartyOptions = {}
|
|
61
|
+
private readonly _initialTimeframe?: Timeframe,
|
|
62
|
+
_options: PipelineOptions = {}
|
|
60
63
|
) {
|
|
61
|
-
this._partyCore = new
|
|
64
|
+
this._partyCore = new PartyPipeline(
|
|
62
65
|
partyKey,
|
|
63
66
|
_feedProvider,
|
|
64
67
|
modelFactory,
|
|
65
68
|
snapshotStore,
|
|
66
69
|
this._credentialsSigner.getIdentityKey().publicKey,
|
|
67
|
-
_initialTimeframe,
|
|
68
70
|
_options
|
|
69
71
|
);
|
|
70
72
|
|
|
@@ -125,14 +127,8 @@ export class DataParty {
|
|
|
125
127
|
return this._invitationManager;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return this._feedProvider;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get preferences (): PartyPreferences {
|
|
134
|
-
assert(this._preferences, 'Preferences not available.');
|
|
135
|
-
return this._preferences;
|
|
130
|
+
get credentialsWriter () {
|
|
131
|
+
return this._partyCore.credentialsWriter;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
134
|
get title () {
|
|
@@ -145,6 +141,13 @@ export class DataParty {
|
|
|
145
141
|
await this._preferences?.setLastKnownTitle(title);
|
|
146
142
|
}
|
|
147
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
_setFeedHints (feedHints: PublicKey[]) {
|
|
148
|
+
this._feedHints = feedHints;
|
|
149
|
+
}
|
|
150
|
+
|
|
148
151
|
/**
|
|
149
152
|
* Opens the pipeline and connects the streams.
|
|
150
153
|
*/
|
|
@@ -155,11 +158,25 @@ export class DataParty {
|
|
|
155
158
|
return this;
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
|
|
161
|
+
// TODO(dmaretskyi): May be undefined in some tests.
|
|
162
|
+
const party = this._metadataStore.getParty(this._partyCore.key);
|
|
163
|
+
|
|
164
|
+
await this._partyCore.open({
|
|
165
|
+
feedHints: this._feedHints,
|
|
166
|
+
initialTimeframe: this._initialTimeframe,
|
|
167
|
+
targetTimeframe: party?.latestTimeframe
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Keep updating latest reached timeframe in the metadata.
|
|
171
|
+
// This timeframe will be waited for when opening the party next time.
|
|
172
|
+
this._partyCore.timeframeUpdate.on(timeframe => {
|
|
173
|
+
void this._metadataStore.setTimeframe(this._partyCore.key, timeframe);
|
|
174
|
+
});
|
|
159
175
|
|
|
160
176
|
this._invitationManager = new InvitationFactory(
|
|
161
177
|
this._partyCore.processor,
|
|
162
178
|
this._credentialsSigner,
|
|
179
|
+
this._partyCore.credentialsWriter,
|
|
163
180
|
this._networkManager
|
|
164
181
|
);
|
|
165
182
|
|
|
@@ -173,13 +190,13 @@ export class DataParty {
|
|
|
173
190
|
this._protocol = new PartyProtocolFactory(
|
|
174
191
|
this._partyCore.key,
|
|
175
192
|
this._networkManager,
|
|
176
|
-
this._feedProvider,
|
|
177
193
|
deviceKey.publicKey,
|
|
178
194
|
createCredentialsProvider(this._credentialsSigner, this._partyCore.key, writeFeed.key)
|
|
179
195
|
);
|
|
180
196
|
|
|
181
197
|
await this._protocol.start([
|
|
182
|
-
|
|
198
|
+
createReplicatorPlugin(this._feedProvider),
|
|
199
|
+
createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner, this.credentialsWriter), deviceKey.publicKey),
|
|
183
200
|
createOfflineInvitationPlugin(this._invitationManager, deviceKey.publicKey)
|
|
184
201
|
]);
|
|
185
202
|
|
|
@@ -199,6 +216,9 @@ export class DataParty {
|
|
|
199
216
|
return this;
|
|
200
217
|
}
|
|
201
218
|
|
|
219
|
+
// Save the latest reached timeframe.
|
|
220
|
+
await this._metadataStore.setTimeframe(this._partyCore.key, this._partyCore.timeframe);
|
|
221
|
+
|
|
202
222
|
await this._partyCore.close();
|
|
203
223
|
await this._protocol?.stop();
|
|
204
224
|
|
|
@@ -210,6 +230,14 @@ export class DataParty {
|
|
|
210
230
|
return this;
|
|
211
231
|
}
|
|
212
232
|
|
|
233
|
+
async getWriteFeed (): Promise<FeedDescriptor> {
|
|
234
|
+
return this._feedProvider.createOrOpenWritableFeed();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
getFeeds (): FeedDescriptor[] {
|
|
238
|
+
return this._feedProvider.getFeeds();
|
|
239
|
+
}
|
|
240
|
+
|
|
213
241
|
get isActive (): boolean {
|
|
214
242
|
assert(this._preferences, 'PartyActivator required');
|
|
215
243
|
return this._preferences.isActive;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
createEnvelopeMessage,
|
|
10
10
|
createFeedAdmitMessage,
|
|
11
11
|
createPartyGenesisMessage,
|
|
12
|
-
KeyHint,
|
|
13
12
|
KeyType,
|
|
14
13
|
SecretProvider,
|
|
15
14
|
wrapMessage
|
|
@@ -21,12 +20,12 @@ import { ModelFactory } from '@dxos/model-factory';
|
|
|
21
20
|
import { NetworkManager } from '@dxos/network-manager';
|
|
22
21
|
import { ObjectModel } from '@dxos/object-model';
|
|
23
22
|
|
|
24
|
-
import { IdentityNotInitializedError } from '../errors';
|
|
25
23
|
import {
|
|
26
24
|
createDataPartyAdmissionMessages,
|
|
27
25
|
GreetingInitiator, InvitationDescriptor, InvitationDescriptorType, OfflineInvitationClaimer
|
|
28
26
|
} from '../invitations';
|
|
29
|
-
import {
|
|
27
|
+
import { IdentityNotInitializedError } from '../packlets/errors';
|
|
28
|
+
import { MetadataStore, PartyFeedProvider, PipelineOptions } from '../pipeline';
|
|
30
29
|
import { IdentityCredentialsProvider } from '../protocol/identity-credentials';
|
|
31
30
|
import { SnapshotStore } from '../snapshots';
|
|
32
31
|
import { DataParty, PARTY_ITEM_TYPE } from './data-party';
|
|
@@ -43,7 +42,8 @@ export class PartyFactory {
|
|
|
43
42
|
private readonly _modelFactory: ModelFactory,
|
|
44
43
|
private readonly _snapshotStore: SnapshotStore,
|
|
45
44
|
private readonly _feedProviderFactory: (partyKey: PublicKey) => PartyFeedProvider,
|
|
46
|
-
private readonly
|
|
45
|
+
private readonly _metadataStore: MetadataStore,
|
|
46
|
+
private readonly _options: PipelineOptions = {}
|
|
47
47
|
) {}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -57,13 +57,15 @@ export class PartyFactory {
|
|
|
57
57
|
const partyKey = await identity.keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
58
58
|
const party = await this.constructParty(partyKey.publicKey);
|
|
59
59
|
|
|
60
|
+
const writableFeed = await party.getWriteFeed();
|
|
61
|
+
// Hint at the newly created writable feed so that we can start replicating from it.
|
|
62
|
+
party._setFeedHints([writableFeed.key]);
|
|
63
|
+
|
|
60
64
|
// Connect the pipeline.
|
|
61
65
|
await party.open();
|
|
62
66
|
|
|
63
|
-
const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
|
|
64
|
-
|
|
65
67
|
// PartyGenesis (self-signed by Party).
|
|
66
|
-
await party.
|
|
68
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
67
69
|
identity.keyring,
|
|
68
70
|
partyKey,
|
|
69
71
|
writableFeed.key,
|
|
@@ -71,7 +73,7 @@ export class PartyFactory {
|
|
|
71
73
|
);
|
|
72
74
|
|
|
73
75
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
74
|
-
await party.
|
|
76
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
75
77
|
identity.keyring,
|
|
76
78
|
partyKey.publicKey,
|
|
77
79
|
wrapMessage(identity.identityGenesis),
|
|
@@ -80,7 +82,7 @@ export class PartyFactory {
|
|
|
80
82
|
|
|
81
83
|
// FeedAdmit (signed by the Device KeyChain).
|
|
82
84
|
// TODO(dmaretskyi): Is this really needed since a feed is already admitted by party genesis message.
|
|
83
|
-
await party.
|
|
85
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
84
86
|
identity.keyring,
|
|
85
87
|
partyKey.publicKey,
|
|
86
88
|
writableFeed.key,
|
|
@@ -89,7 +91,7 @@ export class PartyFactory {
|
|
|
89
91
|
|
|
90
92
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
91
93
|
if (identity.identityInfo) {
|
|
92
|
-
await party.
|
|
94
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
93
95
|
identity.keyring,
|
|
94
96
|
partyKey.publicKey,
|
|
95
97
|
wrapMessage(identity.identityInfo),
|
|
@@ -106,61 +108,14 @@ export class PartyFactory {
|
|
|
106
108
|
return party;
|
|
107
109
|
}
|
|
108
110
|
|
|
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
111
|
/**
|
|
154
112
|
* Constructs a party object from an existing set of feeds.
|
|
155
113
|
* @param partyKey
|
|
156
114
|
* @param hints
|
|
157
115
|
*/
|
|
158
|
-
async constructParty (partyKey: PartyKey,
|
|
116
|
+
async constructParty (partyKey: PartyKey, initialTimeframe?: Timeframe) {
|
|
159
117
|
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
160
118
|
|
|
161
|
-
// TODO(marik-d): Support read-only parties if this feed doesn't exist?
|
|
162
|
-
const feedProvider = this._feedProviderFactory(partyKey);
|
|
163
|
-
|
|
164
119
|
//
|
|
165
120
|
// Create the party.
|
|
166
121
|
//
|
|
@@ -168,11 +123,11 @@ export class PartyFactory {
|
|
|
168
123
|
partyKey,
|
|
169
124
|
this._modelFactory,
|
|
170
125
|
this._snapshotStore,
|
|
171
|
-
|
|
126
|
+
this._feedProviderFactory(partyKey),
|
|
127
|
+
this._metadataStore,
|
|
172
128
|
identity.createCredentialsSigner(),
|
|
173
129
|
identity.preferences,
|
|
174
130
|
this._networkManager,
|
|
175
|
-
hints,
|
|
176
131
|
initialTimeframe,
|
|
177
132
|
this._options
|
|
178
133
|
);
|
|
@@ -184,13 +139,12 @@ export class PartyFactory {
|
|
|
184
139
|
assert(snapshot.partyKey);
|
|
185
140
|
log(`Constructing ${humanize(snapshot.partyKey)} from snapshot at ${JSON.stringify(snapshot.timeframe)}.`);
|
|
186
141
|
|
|
187
|
-
const party = await this.constructParty(PublicKey.from(snapshot.partyKey),
|
|
142
|
+
const party = await this.constructParty(PublicKey.from(snapshot.partyKey), snapshot.timeframe);
|
|
188
143
|
await party.restoreFromSnapshot(snapshot);
|
|
189
144
|
return party;
|
|
190
145
|
}
|
|
191
146
|
|
|
192
147
|
async joinParty (invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<DataParty> {
|
|
193
|
-
const haloInvitation = !!invitationDescriptor.identityKey;
|
|
194
148
|
const originalInvitation = invitationDescriptor;
|
|
195
149
|
|
|
196
150
|
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
@@ -218,19 +172,19 @@ export class PartyFactory {
|
|
|
218
172
|
|
|
219
173
|
await initiator.connect();
|
|
220
174
|
const { partyKey, hints } = await initiator.redeemInvitation(secretProvider);
|
|
221
|
-
const party = await this.
|
|
175
|
+
const party = await this.constructParty(partyKey);
|
|
176
|
+
party._setFeedHints(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;
|
|
@@ -244,13 +198,15 @@ export class PartyFactory {
|
|
|
244
198
|
const partyKey = await identity.keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
245
199
|
const party = await this.constructParty(partyKey.publicKey);
|
|
246
200
|
|
|
201
|
+
const writableFeed = await party.getWriteFeed();
|
|
202
|
+
// Hint at the newly created writable feed so that we can start replicating from it.
|
|
203
|
+
party._setFeedHints([writableFeed.key]);
|
|
204
|
+
|
|
247
205
|
// Connect the pipeline.
|
|
248
206
|
await party.open();
|
|
249
207
|
|
|
250
|
-
const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
|
|
251
|
-
|
|
252
208
|
// PartyGenesis (self-signed by Party).
|
|
253
|
-
await party.
|
|
209
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
254
210
|
identity.keyring,
|
|
255
211
|
partyKey,
|
|
256
212
|
writableFeed.key,
|
|
@@ -258,7 +214,7 @@ export class PartyFactory {
|
|
|
258
214
|
);
|
|
259
215
|
|
|
260
216
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
261
|
-
await party.
|
|
217
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
262
218
|
identity.keyring,
|
|
263
219
|
partyKey.publicKey,
|
|
264
220
|
wrapMessage(identity.identityGenesis),
|
|
@@ -266,7 +222,7 @@ export class PartyFactory {
|
|
|
266
222
|
));
|
|
267
223
|
|
|
268
224
|
// FeedAdmit (signed by the Device KeyChain).
|
|
269
|
-
await party.
|
|
225
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
270
226
|
identity.keyring,
|
|
271
227
|
partyKey.publicKey,
|
|
272
228
|
writableFeed.key,
|
|
@@ -275,7 +231,7 @@ export class PartyFactory {
|
|
|
275
231
|
|
|
276
232
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
277
233
|
if (identity.identityInfo) {
|
|
278
|
-
await party.
|
|
234
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
279
235
|
identity.keyring,
|
|
280
236
|
partyKey.publicKey,
|
|
281
237
|
wrapMessage(identity.identityInfo),
|
|
@@ -285,7 +241,7 @@ export class PartyFactory {
|
|
|
285
241
|
|
|
286
242
|
// const keyAdmitMessage = snapshot.halo?.messages?.[1];
|
|
287
243
|
// assert(keyAdmitMessage);
|
|
288
|
-
// await party.
|
|
244
|
+
// await party.writeCredentialsMessage(createEnvelopeMessage(
|
|
289
245
|
// identity.signer,
|
|
290
246
|
// partyKey.publicKey,
|
|
291
247
|
// keyAdmitMessage,
|
|
@@ -293,13 +249,14 @@ export class PartyFactory {
|
|
|
293
249
|
// ));
|
|
294
250
|
|
|
295
251
|
// for(const message of snapshot.halo?.messages?.slice(2) || []) {
|
|
296
|
-
// await party.
|
|
252
|
+
// await party.writeCredentialsMessage(message);
|
|
297
253
|
// }
|
|
298
254
|
|
|
299
255
|
// Write messages to create ECHO items.
|
|
300
256
|
const feedWriter = createFeedWriter(writableFeed.feed);
|
|
301
257
|
for (const item of snapshot.database?.items || []) {
|
|
302
258
|
const message: FeedMessage = {
|
|
259
|
+
timeframe: new Timeframe(),
|
|
303
260
|
echo: {
|
|
304
261
|
itemId: item.itemId ?? failUndefined(),
|
|
305
262
|
genesis: {
|
|
@@ -310,8 +267,7 @@ export class PartyFactory {
|
|
|
310
267
|
itemMutation: {
|
|
311
268
|
parentId: item.parentId
|
|
312
269
|
},
|
|
313
|
-
snapshot: item.model
|
|
314
|
-
timeframe: new Timeframe()
|
|
270
|
+
snapshot: item.model
|
|
315
271
|
}
|
|
316
272
|
};
|
|
317
273
|
await feedWriter.write(message);
|