@dxos/echo-db 2.33.5-dev.1fc05a51 → 2.33.5-dev.39ec2a53
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.map +1 -1
- package/dist/src/echo.js +3 -3
- 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 +7 -6
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +7 -6
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +13 -9
- 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/index.js +5 -1
- package/dist/src/halo/index.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +3 -1
- 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 +1 -1
- 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-responder.d.ts +6 -4
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +3 -2
- 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.js +2 -2
- 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 +4 -3
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +2 -3
- 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 +11 -10
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +11 -9
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +31 -10
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +33 -14
- 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 -4
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +25 -21
- 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 +8 -7
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +9 -9
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/{pipeline.d.ts → feed-muxer.d.ts} +8 -11
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -41
- 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} +18 -16
- 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 +1 -1
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +6 -5
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +2 -1
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +7 -1
- package/dist/src/pipeline/metadata-store.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 -12
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -36
- 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} +56 -39
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
- package/dist/src/pipeline/party-processor.d.ts +3 -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/authenticator.d.ts +3 -3
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +2 -2
- 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/index.js +5 -1
- package/dist/src/protocol/index.js.map +1 -1
- 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.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +1 -1
- package/dist/src/snapshots/snapshot-store.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/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/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 +3 -2
- package/src/halo/contact-manager.ts +3 -2
- package/src/halo/halo-factory.ts +10 -10
- package/src/halo/halo-party.ts +22 -15
- package/src/halo/halo.ts +2 -2
- package/src/halo/party-opener.ts +3 -1
- package/src/halo/preferences.ts +3 -2
- package/src/index.ts +3 -2
- package/src/invitations/greeting-initiator.ts +10 -9
- package/src/invitations/greeting-responder.ts +7 -5
- 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 +3 -3
- 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 +8 -5
- package/src/{database → packlets/database}/item-manager.test.ts +0 -0
- package/src/{database → packlets/database}/item-manager.ts +3 -1
- 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 +0 -0
- package/src/{api → packlets/database}/selection/result.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.test.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.ts +0 -0
- 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 +48 -17
- package/src/parties/data-party.ts +40 -16
- package/src/parties/party-factory.ts +29 -27
- package/src/parties/party-manager.test.ts +16 -10
- package/src/parties/party-manager.ts +9 -6
- package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +21 -17
- package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -51
- package/src/pipeline/index.ts +2 -2
- package/src/pipeline/message-selector.ts +7 -6
- package/src/pipeline/metadata-store.ts +8 -2
- package/src/pipeline/party-feed-provider.ts +3 -16
- package/src/pipeline/{party-core.test.ts → party-pipeline.test.ts} +55 -33
- package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -36
- package/src/pipeline/party-processor.ts +2 -18
- package/src/protocol/authenticator.test.ts +1 -4
- package/src/protocol/authenticator.ts +8 -4
- package/src/snapshots/snapshot-generator.ts +3 -3
- package/src/snapshots/snapshot-store.ts +1 -1
- package/src/snapshots/snapshot.test.ts +1 -1
- package/src/testing/testing-factories.ts +1 -1
- 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
|
@@ -8,7 +8,7 @@ import debug from 'debug';
|
|
|
8
8
|
import { Event, synchronized } from '@dxos/async';
|
|
9
9
|
import { Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { PublicKey } from '@dxos/crypto';
|
|
11
|
-
import { FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { FeedSelector, FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
12
12
|
import { FeedDescriptor, FeedStore } from '@dxos/feed-store';
|
|
13
13
|
import { ComplexMap } from '@dxos/util';
|
|
14
14
|
|
|
@@ -33,19 +33,6 @@ export class PartyFeedProvider {
|
|
|
33
33
|
return Array.from(this._feeds.values());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@synchronized
|
|
37
|
-
async openKnownFeeds () {
|
|
38
|
-
for (const feedKey of this._metadataStore.getParty(this._partyKey)?.feedKeys ?? []) {
|
|
39
|
-
if (!this._feeds.has(feedKey)) {
|
|
40
|
-
const fullKey = this._keyring.getFullKey(feedKey);
|
|
41
|
-
const feed = fullKey?.secretKey
|
|
42
|
-
? await this._feedStore.openReadWriteFeed(fullKey.publicKey, fullKey.secretKey)
|
|
43
|
-
: await this._feedStore.openReadOnlyFeed(feedKey);
|
|
44
|
-
this._trackFeed(feed);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
36
|
@synchronized
|
|
50
37
|
async createOrOpenWritableFeed () {
|
|
51
38
|
const partyMetadata = this._metadataStore.getParty(this._partyKey);
|
|
@@ -103,8 +90,8 @@ export class PartyFeedProvider {
|
|
|
103
90
|
return feed;
|
|
104
91
|
}
|
|
105
92
|
|
|
106
|
-
async createIterator (messageSelector: MessageSelector, initialTimeframe?: Timeframe) {
|
|
107
|
-
const iterator = new FeedStoreIterator(
|
|
93
|
+
async createIterator (messageSelector: MessageSelector, feedSelector: FeedSelector, initialTimeframe?: Timeframe) {
|
|
94
|
+
const iterator = new FeedStoreIterator(feedSelector, messageSelector, initialTimeframe ?? new Timeframe());
|
|
108
95
|
for (const feed of this._feeds.values()) {
|
|
109
96
|
iterator.addFeedDescriptor(feed);
|
|
110
97
|
}
|
|
@@ -8,7 +8,8 @@ import { it as test } from 'mocha';
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { createId, PublicKey } from '@dxos/crypto';
|
|
11
|
-
import {
|
|
11
|
+
import { checkType } from '@dxos/debug';
|
|
12
|
+
import { codec, FeedMessage, Timeframe } from '@dxos/echo-protocol';
|
|
12
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
13
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
14
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -16,12 +17,12 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
16
17
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
17
18
|
import { afterTest } from '@dxos/testutils';
|
|
18
19
|
|
|
19
|
-
import { MetadataStore, PartyFeedProvider } from '
|
|
20
|
+
import { MetadataStore, PartyFeedProvider } from '.';
|
|
20
21
|
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
21
22
|
import { SnapshotStore } from '../snapshots';
|
|
22
|
-
import {
|
|
23
|
+
import { PartyPipeline } from './party-pipeline';
|
|
23
24
|
|
|
24
|
-
describe('
|
|
25
|
+
describe('PartyPipeline', () => {
|
|
25
26
|
const setup = async () => {
|
|
26
27
|
const storage = createStorage('', StorageType.RAM);
|
|
27
28
|
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
@@ -38,7 +39,7 @@ describe('PartyCore', () => {
|
|
|
38
39
|
|
|
39
40
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey.publicKey);
|
|
40
41
|
|
|
41
|
-
const party = new
|
|
42
|
+
const party = new PartyPipeline(
|
|
42
43
|
partyKey.publicKey,
|
|
43
44
|
partyFeedProvider,
|
|
44
45
|
modelFactory,
|
|
@@ -47,11 +48,11 @@ describe('PartyCore', () => {
|
|
|
47
48
|
);
|
|
48
49
|
|
|
49
50
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
50
|
-
await party.open();
|
|
51
|
+
await party.open({ feedHints: [feed.key] });
|
|
51
52
|
afterTest(async () => party.close());
|
|
52
53
|
|
|
53
54
|
// PartyGenesis (self-signed by Party).
|
|
54
|
-
await party.
|
|
55
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
55
56
|
keyring,
|
|
56
57
|
partyKey,
|
|
57
58
|
feed.key,
|
|
@@ -59,7 +60,7 @@ describe('PartyCore', () => {
|
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
// FeedAdmit (signed by the Device KeyChain).
|
|
62
|
-
await party.
|
|
63
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
63
64
|
keyring,
|
|
64
65
|
partyKey.publicKey,
|
|
65
66
|
feed.key,
|
|
@@ -87,7 +88,7 @@ describe('PartyCore', () => {
|
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
test('create item with parent and then reload', async () => {
|
|
90
|
-
const { party } = await setup();
|
|
91
|
+
const { party, feedKey } = await setup();
|
|
91
92
|
|
|
92
93
|
{
|
|
93
94
|
const parent = await party.database.createItem({ model: ObjectModel, type: 'parent' });
|
|
@@ -102,7 +103,7 @@ describe('PartyCore', () => {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
await party.close();
|
|
105
|
-
await party.open();
|
|
106
|
+
await party.open({ feedHints: [feedKey] });
|
|
106
107
|
|
|
107
108
|
{
|
|
108
109
|
await party.database.select().exec().update.waitFor(result => result.entities.length === 2);
|
|
@@ -120,7 +121,7 @@ describe('PartyCore', () => {
|
|
|
120
121
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
121
122
|
|
|
122
123
|
const eventFired = feedStore.feedOpenedEvent.waitForCount(1);
|
|
123
|
-
await party.
|
|
124
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
124
125
|
keyring,
|
|
125
126
|
party.key,
|
|
126
127
|
feedKey.publicKey,
|
|
@@ -148,7 +149,7 @@ describe('PartyCore', () => {
|
|
|
148
149
|
|
|
149
150
|
const otherFeedKey = PublicKey.random();
|
|
150
151
|
|
|
151
|
-
const party = new
|
|
152
|
+
const party = new PartyPipeline(
|
|
152
153
|
partyKey.publicKey,
|
|
153
154
|
partyFeedProvider,
|
|
154
155
|
modelFactory,
|
|
@@ -160,7 +161,7 @@ describe('PartyCore', () => {
|
|
|
160
161
|
|
|
161
162
|
const feedOpened = feedStore.feedOpenedEvent.waitForCount(1);
|
|
162
163
|
|
|
163
|
-
await party.open(
|
|
164
|
+
await party.open({ feedHints: [otherFeedKey] });
|
|
164
165
|
afterTest(async () => party.close());
|
|
165
166
|
|
|
166
167
|
await feedOpened;
|
|
@@ -175,16 +176,16 @@ describe('PartyCore', () => {
|
|
|
175
176
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
176
177
|
|
|
177
178
|
const itemId = createId();
|
|
178
|
-
await feed.feed.append({
|
|
179
|
+
await feed.feed.append(checkType<FeedMessage>({
|
|
180
|
+
timeframe: new Timeframe(),
|
|
179
181
|
echo: {
|
|
180
182
|
itemId,
|
|
181
183
|
genesis: {
|
|
182
184
|
itemType: 'dxos:example',
|
|
183
185
|
modelType: ObjectModel.meta.type
|
|
184
|
-
}
|
|
185
|
-
timeframe: new Timeframe()
|
|
186
|
+
}
|
|
186
187
|
}
|
|
187
|
-
});
|
|
188
|
+
}));
|
|
188
189
|
|
|
189
190
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
190
191
|
});
|
|
@@ -197,7 +198,7 @@ describe('PartyCore', () => {
|
|
|
197
198
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
198
199
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
199
200
|
|
|
200
|
-
await party.
|
|
201
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
201
202
|
keyring,
|
|
202
203
|
party.key,
|
|
203
204
|
feed2.key,
|
|
@@ -205,16 +206,16 @@ describe('PartyCore', () => {
|
|
|
205
206
|
));
|
|
206
207
|
|
|
207
208
|
const itemId = createId();
|
|
208
|
-
await feed2.append({
|
|
209
|
+
await feed2.append(checkType<FeedMessage>({
|
|
210
|
+
timeframe: new Timeframe(),
|
|
209
211
|
echo: {
|
|
210
212
|
itemId,
|
|
211
213
|
genesis: {
|
|
212
214
|
itemType: 'dxos:example',
|
|
213
215
|
modelType: ObjectModel.meta.type
|
|
214
|
-
}
|
|
215
|
-
timeframe: new Timeframe()
|
|
216
|
+
}
|
|
216
217
|
}
|
|
217
|
-
});
|
|
218
|
+
}));
|
|
218
219
|
|
|
219
220
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
220
221
|
});
|
|
@@ -226,7 +227,7 @@ describe('PartyCore', () => {
|
|
|
226
227
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
227
228
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
228
229
|
|
|
229
|
-
await party.
|
|
230
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
230
231
|
keyring,
|
|
231
232
|
party.key,
|
|
232
233
|
feedKey.publicKey,
|
|
@@ -235,20 +236,42 @@ describe('PartyCore', () => {
|
|
|
235
236
|
|
|
236
237
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
237
238
|
const itemId = createId();
|
|
238
|
-
await feed2.append({
|
|
239
|
+
await feed2.append(checkType<FeedMessage>({
|
|
240
|
+
timeframe: new Timeframe(),
|
|
239
241
|
echo: {
|
|
240
242
|
itemId,
|
|
241
243
|
genesis: {
|
|
242
244
|
itemType: 'dxos:example',
|
|
243
245
|
modelType: ObjectModel.meta.type
|
|
244
|
-
}
|
|
245
|
-
timeframe: new Timeframe()
|
|
246
|
+
}
|
|
246
247
|
}
|
|
247
|
-
});
|
|
248
|
+
}));
|
|
248
249
|
|
|
249
250
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
250
251
|
});
|
|
251
252
|
|
|
253
|
+
test('wait to reach specific timeframe', async () => {
|
|
254
|
+
const { party, feedKey } = await setup();
|
|
255
|
+
|
|
256
|
+
{
|
|
257
|
+
const parent = await party.database.createItem({ model: ObjectModel, type: 'parent' });
|
|
258
|
+
const child = await party.database.createItem({
|
|
259
|
+
model: ObjectModel,
|
|
260
|
+
parent: parent.id,
|
|
261
|
+
type: 'child'
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
expect(child.parent).toEqual(parent);
|
|
265
|
+
expect(parent.children).toContain(child);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const timeframe = party.timeframe;
|
|
269
|
+
expect(timeframe.isEmpty()).toBeFalsy();
|
|
270
|
+
|
|
271
|
+
await party.close();
|
|
272
|
+
await party.open({ feedHints: [feedKey], targetTimeframe: timeframe });
|
|
273
|
+
});
|
|
274
|
+
|
|
252
275
|
test('two instances replicating', async () => {
|
|
253
276
|
const peer1 = await setup();
|
|
254
277
|
|
|
@@ -263,7 +286,7 @@ describe('PartyCore', () => {
|
|
|
263
286
|
|
|
264
287
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, peer1.keyring, feedStore, peer1.party.key);
|
|
265
288
|
|
|
266
|
-
const party2 = new
|
|
289
|
+
const party2 = new PartyPipeline(
|
|
267
290
|
peer1.party.key,
|
|
268
291
|
partyFeedProvider,
|
|
269
292
|
modelFactory,
|
|
@@ -273,17 +296,16 @@ describe('PartyCore', () => {
|
|
|
273
296
|
|
|
274
297
|
const feed2 = await partyFeedProvider.createOrOpenWritableFeed();
|
|
275
298
|
|
|
276
|
-
await peer1.party.
|
|
299
|
+
await peer1.party.credentialsWriter.write(createFeedAdmitMessage(
|
|
277
300
|
peer1.keyring,
|
|
278
301
|
peer1.party.key,
|
|
279
302
|
feed2.key,
|
|
280
303
|
[peer1.partyKey]
|
|
281
304
|
));
|
|
282
305
|
|
|
283
|
-
await party2.open(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}]);
|
|
306
|
+
await party2.open({
|
|
307
|
+
feedHints: [peer1.feedKey]
|
|
308
|
+
});
|
|
287
309
|
afterTest(async () => party2.close());
|
|
288
310
|
|
|
289
311
|
createTestProtocolPair(
|
|
@@ -5,21 +5,20 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
|
-
import {
|
|
8
|
+
import { KeyType, Message as HaloMessage } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { timed } from '@dxos/debug';
|
|
11
|
-
import { createFeedWriter, DatabaseSnapshot, PartyKey, PartySnapshot, Timeframe
|
|
11
|
+
import { createFeedWriter, DatabaseSnapshot, FeedSelector, FeedWriter, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
13
|
import { SubscriptionGroup } from '@dxos/util';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import { FeedDatabaseBackend, TimeframeClock } from '../database';
|
|
17
|
-
import { createMessageSelector, PartyProcessor, PartyFeedProvider, Pipeline } from '../pipeline';
|
|
15
|
+
import { createMessageSelector, PartyProcessor, PartyFeedProvider, FeedMuxer } from '.';
|
|
16
|
+
import { Database, FeedDatabaseBackend, TimeframeClock } from '../packlets/database';
|
|
18
17
|
import { createAutomaticSnapshots, SnapshotStore } from '../snapshots';
|
|
19
18
|
|
|
20
19
|
const DEFAULT_SNAPSHOT_INTERVAL = 100; // Every 100 messages.
|
|
21
20
|
|
|
22
|
-
export interface
|
|
21
|
+
export interface PipelineOptions {
|
|
23
22
|
readLogger?: (msg: any) => void;
|
|
24
23
|
writeLogger?: (msg: any) => void;
|
|
25
24
|
readOnly?: boolean;
|
|
@@ -29,6 +28,22 @@ export interface PartyOptions {
|
|
|
29
28
|
snapshotInterval?: number;
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
export interface OpenOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Keys of initial feeds needed to bootstrap the party.
|
|
34
|
+
*/
|
|
35
|
+
feedHints?: PublicKey[]
|
|
36
|
+
/**
|
|
37
|
+
* Timeframe to start processing feed messages from.
|
|
38
|
+
*/
|
|
39
|
+
initialTimeframe?: Timeframe
|
|
40
|
+
/**
|
|
41
|
+
* Timeframe which must be reached until further processing.
|
|
42
|
+
* PartyCore.open will block until this timeframe is reached.
|
|
43
|
+
*/
|
|
44
|
+
targetTimeframe?: Timeframe
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
/**
|
|
33
48
|
* Encapsulates core components needed by a party:
|
|
34
49
|
* - ECHO database with item-manager & item-demuxer.
|
|
@@ -37,7 +52,7 @@ export interface PartyOptions {
|
|
|
37
52
|
*
|
|
38
53
|
* The core class also handles the combined ECHO and HALO state snapshots.
|
|
39
54
|
*/
|
|
40
|
-
export class
|
|
55
|
+
export class PartyPipeline {
|
|
41
56
|
/**
|
|
42
57
|
* Snapshot to be restored from when party.open() is called.
|
|
43
58
|
*/
|
|
@@ -46,7 +61,7 @@ export class PartyCore {
|
|
|
46
61
|
private readonly _subscriptions = new SubscriptionGroup();
|
|
47
62
|
|
|
48
63
|
private _database?: Database;
|
|
49
|
-
private _pipeline?:
|
|
64
|
+
private _pipeline?: FeedMuxer;
|
|
50
65
|
private _partyProcessor?: PartyProcessor;
|
|
51
66
|
private _timeframeClock?: TimeframeClock;
|
|
52
67
|
|
|
@@ -56,8 +71,7 @@ export class PartyCore {
|
|
|
56
71
|
private readonly _modelFactory: ModelFactory,
|
|
57
72
|
private readonly _snapshotStore: SnapshotStore,
|
|
58
73
|
private readonly _memberKey: PublicKey,
|
|
59
|
-
private readonly
|
|
60
|
-
private readonly _options: PartyOptions = {}
|
|
74
|
+
private readonly _options: PipelineOptions = {}
|
|
61
75
|
) { }
|
|
62
76
|
|
|
63
77
|
get key (): PartyKey {
|
|
@@ -99,20 +113,29 @@ export class PartyCore {
|
|
|
99
113
|
return feed;
|
|
100
114
|
}
|
|
101
115
|
|
|
116
|
+
get credentialsWriter (): FeedWriter<HaloMessage> {
|
|
117
|
+
assert(this._pipeline?.outboundHaloStream, 'Party not open');
|
|
118
|
+
return this._pipeline?.outboundHaloStream;
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
/**
|
|
103
122
|
* Opens the pipeline and connects the streams.
|
|
104
123
|
*/
|
|
105
124
|
@synchronized
|
|
106
125
|
@timed(1_000)
|
|
107
|
-
async open (
|
|
126
|
+
async open (options: OpenOptions = {}) {
|
|
127
|
+
const {
|
|
128
|
+
feedHints = [],
|
|
129
|
+
initialTimeframe,
|
|
130
|
+
targetTimeframe
|
|
131
|
+
} = options;
|
|
132
|
+
|
|
108
133
|
if (this.isOpen) {
|
|
109
134
|
return this;
|
|
110
135
|
}
|
|
111
136
|
|
|
112
|
-
this._timeframeClock = new TimeframeClock(
|
|
137
|
+
this._timeframeClock = new TimeframeClock(initialTimeframe);
|
|
113
138
|
|
|
114
|
-
// Open all feeds known from metadata and open or create a writable feed to the party.
|
|
115
|
-
await this._feedProvider.openKnownFeeds();
|
|
116
139
|
const writableFeed = await this._feedProvider.createOrOpenWritableFeed();
|
|
117
140
|
|
|
118
141
|
if (!this._partyProcessor) {
|
|
@@ -124,12 +147,8 @@ export class PartyCore {
|
|
|
124
147
|
void this._feedProvider.createOrOpenReadOnlyFeed(feed);
|
|
125
148
|
}));
|
|
126
149
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
await this._partyProcessor.takeHints([{ type: KeyType.FEED, publicKey: writableFeed.key }]);
|
|
130
|
-
|
|
131
|
-
if (keyHints.length > 0) {
|
|
132
|
-
await this._partyProcessor.takeHints(keyHints);
|
|
150
|
+
if (feedHints.length > 0) {
|
|
151
|
+
await this._partyProcessor.takeHints(feedHints.map(publicKey => ({ publicKey, type: KeyType.FEED })));
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
//
|
|
@@ -138,31 +157,34 @@ export class PartyCore {
|
|
|
138
157
|
|
|
139
158
|
const iterator = await this._feedProvider.createIterator(
|
|
140
159
|
createMessageSelector(this._partyProcessor, this._timeframeClock),
|
|
141
|
-
this.
|
|
160
|
+
createFeedSelector(this._partyProcessor, feedHints),
|
|
161
|
+
initialTimeframe
|
|
142
162
|
);
|
|
143
163
|
|
|
144
|
-
this._pipeline = new
|
|
145
|
-
this._partyProcessor,
|
|
146
|
-
|
|
147
|
-
// TODO(burdon): Support read-only parties.
|
|
148
|
-
const [readStream, writeStream] = await this._pipeline.open();
|
|
164
|
+
this._pipeline = new FeedMuxer(
|
|
165
|
+
this._partyProcessor,
|
|
149
166
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
167
|
+
iterator,
|
|
168
|
+
this._timeframeClock,
|
|
169
|
+
createFeedWriter(writableFeed.feed),
|
|
170
|
+
this._options
|
|
171
|
+
);
|
|
154
172
|
|
|
155
173
|
//
|
|
156
174
|
// Database
|
|
157
175
|
//
|
|
158
176
|
|
|
177
|
+
const databaseBackend = new FeedDatabaseBackend(this._pipeline.outboundEchoStream, this._databaseSnapshot, { snapshots: true });
|
|
159
178
|
this._database = new Database(
|
|
160
179
|
this._modelFactory,
|
|
161
|
-
|
|
180
|
+
databaseBackend,
|
|
162
181
|
this._memberKey
|
|
163
182
|
);
|
|
164
183
|
|
|
184
|
+
// Open pipeline and connect it to the database.
|
|
165
185
|
await this._database.initialize();
|
|
186
|
+
this._pipeline.setEchoProcessor(databaseBackend.echoProcessor);
|
|
187
|
+
await this._pipeline.open();
|
|
166
188
|
|
|
167
189
|
// TODO(burdon): Propagate errors.
|
|
168
190
|
this._subscriptions.push(this._pipeline.errors.on(err => console.error(err)));
|
|
@@ -176,6 +198,10 @@ export class PartyCore {
|
|
|
176
198
|
);
|
|
177
199
|
}
|
|
178
200
|
|
|
201
|
+
if (targetTimeframe) {
|
|
202
|
+
await this._timeframeClock.waitUntilReached(targetTimeframe);
|
|
203
|
+
}
|
|
204
|
+
|
|
179
205
|
return this;
|
|
180
206
|
}
|
|
181
207
|
|
|
@@ -202,11 +228,6 @@ export class PartyCore {
|
|
|
202
228
|
return this;
|
|
203
229
|
}
|
|
204
230
|
|
|
205
|
-
writeCredentialsMessage (message: HaloMessage): Promise<WriteReceipt> {
|
|
206
|
-
assert(this._partyProcessor, 'Party not open');
|
|
207
|
-
return this._partyProcessor?.writeHaloMessage(message);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
231
|
/**
|
|
211
232
|
* Create a snapshot of the current state.
|
|
212
233
|
*/
|
|
@@ -234,3 +255,5 @@ export class PartyCore {
|
|
|
234
255
|
this._databaseSnapshot = snapshot.database;
|
|
235
256
|
}
|
|
236
257
|
}
|
|
258
|
+
|
|
259
|
+
const createFeedSelector = (partyProcessor: PartyProcessor, hints: PublicKey[]): FeedSelector => feed => hints.some(hint => hint.equals(feed.key)) || partyProcessor.isFeedAdmitted(feed.key);
|
|
@@ -16,15 +16,11 @@ import {
|
|
|
16
16
|
SignedMessage
|
|
17
17
|
} from '@dxos/credentials';
|
|
18
18
|
import { PublicKey } from '@dxos/crypto';
|
|
19
|
-
import { FeedKey,
|
|
19
|
+
import { FeedKey, IHaloStream, PartyKey, HaloStateSnapshot } from '@dxos/echo-protocol';
|
|
20
20
|
import { jsonReplacer } from '@dxos/util';
|
|
21
21
|
|
|
22
22
|
const log = debug('dxos:echo-db:party-processor');
|
|
23
23
|
|
|
24
|
-
export interface CredentialWriter {
|
|
25
|
-
writeHaloMessage (message: HaloMessage): Promise<WriteReceipt>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
export interface CredentialProcessor {
|
|
29
25
|
processMessage (message: IHaloStream): Promise<void>
|
|
30
26
|
}
|
|
@@ -47,11 +43,9 @@ export interface PartyStateProvider {
|
|
|
47
43
|
/**
|
|
48
44
|
* TODO(burdon): Wrapper/Bridge between HALO APIs.
|
|
49
45
|
*/
|
|
50
|
-
export class PartyProcessor implements
|
|
46
|
+
export class PartyProcessor implements CredentialProcessor, PartyStateProvider {
|
|
51
47
|
private readonly _state: PartyState;
|
|
52
48
|
|
|
53
|
-
private _outboundHaloStream: FeedWriter<HaloMessage> | undefined;
|
|
54
|
-
|
|
55
49
|
readonly feedAdded = new Event<FeedKey>()
|
|
56
50
|
|
|
57
51
|
public readonly keyOrInfoAdded = new Event<PublicKey>();
|
|
@@ -148,16 +142,6 @@ export class PartyProcessor implements CredentialWriter, CredentialProcessor, Pa
|
|
|
148
142
|
await this._state.processMessages([data]);
|
|
149
143
|
}
|
|
150
144
|
|
|
151
|
-
setOutboundStream (stream: FeedWriter<HaloMessage>) {
|
|
152
|
-
this._outboundHaloStream = stream;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async writeHaloMessage (message: HaloMessage): Promise<WriteReceipt> {
|
|
156
|
-
assert(this._outboundHaloStream, 'Party is closed or read-only');
|
|
157
|
-
// TODO(marik-d): Wait for the message to be processed?
|
|
158
|
-
return this._outboundHaloStream.write(message);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
145
|
makeSnapshot (): HaloStateSnapshot {
|
|
162
146
|
return {
|
|
163
147
|
messages: this._haloMessages
|
|
@@ -6,7 +6,6 @@ import expect from 'expect';
|
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
8
|
import { createAuthMessage, createKeyAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
9
|
-
import { MockFeedWriter } from '@dxos/echo-protocol';
|
|
10
9
|
|
|
11
10
|
import { PartyProcessor } from '../pipeline';
|
|
12
11
|
import { createAuthenticator } from './authenticator';
|
|
@@ -23,8 +22,6 @@ describe('authenticator', () => {
|
|
|
23
22
|
const signer = CredentialsSigner.createDirectDeviceSigner(keyring);
|
|
24
23
|
|
|
25
24
|
const partyProcessor = new PartyProcessor(partyKey.publicKey);
|
|
26
|
-
const feed = new MockFeedWriter();
|
|
27
|
-
partyProcessor.setOutboundStream(feed);
|
|
28
25
|
await partyProcessor.processMessage({
|
|
29
26
|
data: createPartyGenesisMessage(
|
|
30
27
|
keyring,
|
|
@@ -53,7 +50,7 @@ describe('authenticator', () => {
|
|
|
53
50
|
meta: {} as any
|
|
54
51
|
});
|
|
55
52
|
|
|
56
|
-
const authenticator = createAuthenticator(partyProcessor, signer);
|
|
53
|
+
const authenticator = createAuthenticator(partyProcessor, signer, null as any);
|
|
57
54
|
const credential = createAuthMessage(
|
|
58
55
|
keyring,
|
|
59
56
|
partyKey.publicKey,
|
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
|
|
7
|
-
import { Authenticator, codec, createAuthMessage, createEnvelopeMessage, createFeedAdmitMessage, PartyAuthenticator } from '@dxos/credentials';
|
|
8
|
-
import { FeedKey, PartyKey } from '@dxos/echo-protocol';
|
|
7
|
+
import { Message as HaloMessage, Authenticator, codec, createAuthMessage, createEnvelopeMessage, createFeedAdmitMessage, PartyAuthenticator } from '@dxos/credentials';
|
|
8
|
+
import { FeedKey, FeedWriter, PartyKey } from '@dxos/echo-protocol';
|
|
9
9
|
|
|
10
10
|
import { PartyProcessor } from '../pipeline';
|
|
11
11
|
import { CredentialsSigner } from './credentials-signer';
|
|
12
12
|
|
|
13
13
|
const log = debug('dxos:echo-db:authenticator');
|
|
14
14
|
|
|
15
|
-
export const createAuthenticator = (
|
|
15
|
+
export const createAuthenticator = (
|
|
16
|
+
partyProcessor: PartyProcessor,
|
|
17
|
+
credentialsSigner: CredentialsSigner,
|
|
18
|
+
credentialsWriter: FeedWriter<HaloMessage>
|
|
19
|
+
): Authenticator => new PartyAuthenticator(partyProcessor.state, async auth => {
|
|
16
20
|
if (auth.feedAdmit && auth.feedKey && !partyProcessor.isFeedAdmitted(auth.feedKey)) {
|
|
17
21
|
log(`Admitting feed of authenticated member: ${auth.feedKey}`);
|
|
18
|
-
await
|
|
22
|
+
await credentialsWriter.write(createEnvelopeMessage(
|
|
19
23
|
credentialsSigner.signer,
|
|
20
24
|
partyProcessor.partyKey,
|
|
21
25
|
auth.feedAdmit,
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
|
|
7
|
-
import { TimeframeClock } from '../database';
|
|
8
|
-
import {
|
|
7
|
+
import { TimeframeClock } from '../packlets/database';
|
|
8
|
+
import { PartyPipeline } from '../pipeline';
|
|
9
9
|
import { SnapshotStore } from './snapshot-store';
|
|
10
10
|
|
|
11
11
|
const log = debug('dxos:snapshot-generator');
|
|
12
12
|
|
|
13
|
-
export const createAutomaticSnapshots = (party:
|
|
13
|
+
export const createAutomaticSnapshots = (party: PartyPipeline, clock: TimeframeClock, store: SnapshotStore, interval: number) => clock.update.on(async timeframe => {
|
|
14
14
|
const totalMessages = timeframe.totalMessages();
|
|
15
15
|
if (totalMessages > 0 && totalMessages % interval === 0) {
|
|
16
16
|
log(`Saving snapshot of ${party.key.humanize()}...`);
|
|
@@ -12,7 +12,7 @@ import { schema, ItemID, MockFeedWriter, PartyKey } from '@dxos/echo-protocol';
|
|
|
12
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
13
|
import { ObjectModel, ValueUtil } from '@dxos/object-model';
|
|
14
14
|
|
|
15
|
-
import { ItemDemuxer, ItemManager } from '../database';
|
|
15
|
+
import { ItemDemuxer, ItemManager } from '../packlets/database';
|
|
16
16
|
import { createTestInstance } from '../testing';
|
|
17
17
|
|
|
18
18
|
const log = debug('dxos:snapshot:test');
|
|
@@ -8,8 +8,8 @@ import { Model } from '@dxos/model-factory';
|
|
|
8
8
|
import { ObjectModel } from '@dxos/object-model';
|
|
9
9
|
import { range } from '@dxos/util';
|
|
10
10
|
|
|
11
|
-
import { Item, CreateItemOption } from '../api';
|
|
12
11
|
import { ECHO } from '../echo';
|
|
12
|
+
import { CreateItemOption, Item } from '../packlets/database';
|
|
13
13
|
import { DataParty } from '../parties';
|
|
14
14
|
import { createTestInstance, inviteTestPeer } from './testing';
|
|
15
15
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/api/database.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAA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