@dxos/echo-db 2.33.5-dev.4dcc5349 → 2.33.5-dev.8e90a74f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/index.d.ts +0 -5
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +0 -5
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/schema.test.js +1 -1
- package/dist/src/api/schema.test.js.map +1 -1
- package/dist/src/echo.d.ts +1 -0
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +9 -20
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +12 -0
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/contact-manager.d.ts +2 -1
- package/dist/src/halo/contact-manager.d.ts.map +1 -1
- package/dist/src/halo/contact-manager.js +1 -1
- package/dist/src/halo/contact-manager.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts +2 -2
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +7 -13
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +4 -3
- 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.test.js +4 -3
- package/dist/src/halo/halo.test.js.map +1 -1
- package/dist/src/halo/identity.js +2 -2
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +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 +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +2 -2
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +2 -1
- 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.js +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +1 -1
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +5 -2
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/invitation-factory.js +4 -3
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +6 -8
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
- package/dist/src/packlets/database/data-mirror.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.js +0 -0
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
- package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
- package/dist/src/packlets/database/data-service-host.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
- package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
- package/dist/src/packlets/database/data-service-router.js.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.d.ts +0 -0
- package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.js +0 -0
- package/dist/src/packlets/database/database-backend.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.d.ts +2 -1
- package/dist/src/packlets/database/database.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.js +2 -2
- package/dist/src/packlets/database/database.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
- package/dist/src/packlets/database/database.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.js +3 -3
- package/dist/src/packlets/database/database.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
- package/dist/src/packlets/database/entity.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/entity.js +0 -0
- package/dist/src/packlets/database/entity.js.map +1 -0
- package/dist/src/{database → packlets/database}/index.d.ts +5 -0
- package/dist/src/packlets/database/index.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/index.js +5 -0
- package/dist/src/packlets/database/index.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.d.ts +3 -2
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +3 -5
- package/dist/src/packlets/database/item-demuxer.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
- package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.js +2 -2
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
- package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.js +13 -12
- package/dist/src/packlets/database/item-manager.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
- package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
- package/dist/src/packlets/database/item-manager.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/item.d.ts +1 -1
- package/dist/src/packlets/database/item.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/item.js +0 -0
- package/dist/src/packlets/database/item.js.map +1 -0
- package/dist/src/{api → packlets/database}/link.d.ts +1 -1
- package/dist/src/packlets/database/link.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/link.js +0 -0
- package/dist/src/packlets/database/link.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
- package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.js +0 -0
- package/dist/src/packlets/database/selection/index.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
- package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
- package/dist/src/packlets/database/selection/queries.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
- package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.js +0 -0
- package/dist/src/packlets/database/selection/result.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
- package/dist/src/packlets/database/selection/selection.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
- package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
- package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.js +0 -0
- package/dist/src/packlets/database/selection/util.js.map +1 -0
- package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
- package/dist/src/packlets/database/testing.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/testing.js +4 -4
- package/dist/src/packlets/database/testing.js.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +0 -0
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.js +0 -0
- package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
- package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
- package/dist/src/packlets/errors/index.d.ts.map +1 -0
- package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
- package/dist/src/packlets/errors/index.js.map +1 -0
- package/dist/src/parties/data-party.d.ts +11 -8
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +21 -14
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +23 -22
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +2 -8
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +22 -50
- 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 +4 -5
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +14 -13
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +3 -3
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +30 -29
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +3 -3
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +5 -5
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/metadata-store.test.js +8 -4
- package/dist/src/pipeline/metadata-store.test.js.map +1 -1
- package/dist/src/pipeline/party-core.d.ts +21 -6
- package/dist/src/pipeline/party-core.d.ts.map +1 -1
- package/dist/src/pipeline/party-core.js +14 -17
- package/dist/src/pipeline/party-core.js.map +1 -1
- package/dist/src/pipeline/party-core.test.js +34 -33
- package/dist/src/pipeline/party-core.test.js.map +1 -1
- package/dist/src/pipeline/party-processor.d.ts +21 -9
- package/dist/src/pipeline/party-processor.d.ts.map +1 -1
- package/dist/src/pipeline/party-processor.js +0 -8
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/pipeline/pipeline.d.ts +3 -5
- package/dist/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/pipeline.js +8 -11
- package/dist/src/pipeline/pipeline.js.map +1 -1
- package/dist/src/pipeline/pipeline.test.js +4 -5
- package/dist/src/pipeline/pipeline.test.js.map +1 -1
- package/dist/src/protocol/auth-plugin.d.ts +1 -1
- package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
- package/dist/src/protocol/auth-plugin.js +1 -3
- package/dist/src/protocol/auth-plugin.js.map +1 -1
- package/dist/src/protocol/authenticator.d.ts +4 -4
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +12 -16
- package/dist/src/protocol/authenticator.js.map +1 -1
- package/dist/src/protocol/authenticator.test.js +1 -4
- package/dist/src/protocol/authenticator.test.js.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.js +1 -3
- package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
- package/dist/src/protocol/identity-credentials.d.ts +2 -2
- package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +4 -4
- package/dist/src/protocol/identity-credentials.js.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.js +1 -3
- package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
- package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js +2 -55
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/protocol/replicator-plugin.d.ts +7 -0
- package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
- package/dist/src/protocol/replicator-plugin.js +36 -0
- package/dist/src/protocol/replicator-plugin.js.map +1 -0
- package/dist/src/snapshots/snapshot-generator.d.ts +2 -2
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +13 -15
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.d.ts +3 -3
- package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +5 -5
- package/dist/src/snapshots/snapshot-store.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.test.js +1 -1
- package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
- package/dist/src/snapshots/snapshot.test.js +1 -1
- package/dist/src/snapshots/snapshot.test.js.map +1 -1
- package/dist/src/testing/benchmark.test.d.ts +2 -0
- package/dist/src/testing/benchmark.test.d.ts.map +1 -0
- package/dist/src/testing/benchmark.test.js +25 -0
- package/dist/src/testing/benchmark.test.js.map +1 -0
- package/dist/src/testing/testing-factories.d.ts +1 -1
- package/dist/src/testing/testing-factories.d.ts.map +1 -1
- package/dist/src/testing/testing-factories.js +2 -2
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/api/index.ts +0 -5
- package/src/api/schema.test.ts +1 -2
- package/src/echo.test.ts +16 -1
- package/src/echo.ts +10 -20
- package/src/halo/contact-manager.ts +3 -2
- package/src/halo/halo-factory.ts +8 -21
- package/src/halo/halo-party.ts +18 -10
- package/src/halo/halo.test.ts +4 -3
- 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 +5 -4
- package/src/invitations/greeting-protocol-provider.ts +5 -9
- package/src/invitations/greeting-responder.ts +15 -17
- package/src/invitations/halo-recovery-initiator.ts +1 -1
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +8 -5
- package/src/invitations/offline-invitation-claimer.ts +6 -8
- package/src/{database → packlets/database}/data-mirror.test.ts +1 -1
- package/src/{database → packlets/database}/data-mirror.ts +1 -1
- package/src/{database → packlets/database}/data-service-host.ts +2 -1
- package/src/{database → packlets/database}/data-service-router.ts +0 -0
- package/src/{database → packlets/database}/database-backend.ts +0 -0
- package/src/{api → packlets/database}/database.test.ts +2 -1
- package/src/{api → packlets/database}/database.ts +3 -1
- package/src/{api → packlets/database}/entity.ts +1 -1
- package/src/{database → packlets/database}/index.ts +5 -0
- package/src/{database → packlets/database}/item-demuxer.test.ts +1 -1
- package/src/{database → packlets/database}/item-demuxer.ts +5 -5
- package/src/{database → packlets/database}/item-manager.test.ts +0 -0
- package/src/{database → packlets/database}/item-manager.ts +5 -3
- package/src/{api → packlets/database}/item.ts +2 -2
- package/src/{api → packlets/database}/link.ts +1 -1
- package/src/{api → packlets/database}/selection/index.ts +0 -0
- package/src/{api → packlets/database}/selection/queries.ts +14 -18
- package/src/{api → packlets/database}/selection/result.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
- package/src/{api → packlets/database}/selection/selection.ts +1 -7
- package/src/{api → packlets/database}/selection/util.ts +0 -0
- package/src/{database → packlets/database}/testing.ts +2 -2
- package/src/{database → packlets/database}/timeframe-clock.ts +0 -0
- package/src/{errors.ts → packlets/errors/index.ts} +0 -0
- package/src/parties/data-party.test.ts +26 -23
- package/src/parties/data-party.ts +23 -16
- package/src/parties/party-factory.ts +28 -75
- package/src/parties/party-manager.test.ts +21 -14
- package/src/parties/party-manager.ts +4 -5
- package/src/pipeline/message-selector.ts +32 -35
- package/src/pipeline/metadata-store.test.ts +8 -4
- package/src/pipeline/metadata-store.ts +5 -5
- package/src/pipeline/party-core.test.ts +37 -40
- package/src/pipeline/party-core.ts +34 -19
- package/src/pipeline/party-processor.ts +23 -15
- package/src/pipeline/pipeline.test.ts +4 -5
- package/src/pipeline/pipeline.ts +12 -15
- package/src/protocol/auth-plugin.ts +1 -3
- package/src/protocol/authenticator.test.ts +1 -4
- package/src/protocol/authenticator.ts +33 -33
- package/src/protocol/halo-recovery-plugin.ts +4 -6
- package/src/protocol/identity-credentials.ts +4 -4
- package/src/protocol/offline-invitation-plugin.ts +4 -6
- package/src/protocol/party-protocol-factory.ts +3 -56
- package/src/protocol/replicator-plugin.ts +37 -0
- package/src/snapshots/snapshot-generator.ts +13 -17
- package/src/snapshots/snapshot-store.test.ts +1 -1
- package/src/snapshots/snapshot-store.ts +5 -6
- package/src/snapshots/snapshot.test.ts +1 -1
- package/src/testing/benchmark.test.ts +30 -0
- package/src/testing/testing-factories.ts +3 -3
- package/dist/src/api/database.d.ts.map +0 -1
- package/dist/src/api/database.js.map +0 -1
- package/dist/src/api/database.test.d.ts.map +0 -1
- package/dist/src/api/database.test.js.map +0 -1
- package/dist/src/api/entity.d.ts.map +0 -1
- package/dist/src/api/entity.js.map +0 -1
- package/dist/src/api/item.d.ts.map +0 -1
- package/dist/src/api/item.js.map +0 -1
- package/dist/src/api/link.d.ts.map +0 -1
- package/dist/src/api/link.js.map +0 -1
- package/dist/src/api/selection/index.d.ts.map +0 -1
- package/dist/src/api/selection/index.js.map +0 -1
- package/dist/src/api/selection/queries.d.ts.map +0 -1
- package/dist/src/api/selection/queries.js.map +0 -1
- package/dist/src/api/selection/result.d.ts.map +0 -1
- package/dist/src/api/selection/result.js.map +0 -1
- package/dist/src/api/selection/selection.d.ts.map +0 -1
- package/dist/src/api/selection/selection.js.map +0 -1
- package/dist/src/api/selection/selection.test.d.ts.map +0 -1
- package/dist/src/api/selection/selection.test.js.map +0 -1
- package/dist/src/api/selection/util.d.ts.map +0 -1
- package/dist/src/api/selection/util.js.map +0 -1
- package/dist/src/database/data-mirror.d.ts.map +0 -1
- package/dist/src/database/data-mirror.js.map +0 -1
- package/dist/src/database/data-mirror.test.d.ts.map +0 -1
- package/dist/src/database/data-mirror.test.js.map +0 -1
- package/dist/src/database/data-service-host.d.ts.map +0 -1
- package/dist/src/database/data-service-host.js.map +0 -1
- package/dist/src/database/data-service-router.d.ts.map +0 -1
- package/dist/src/database/data-service-router.js.map +0 -1
- package/dist/src/database/database-backend.d.ts.map +0 -1
- package/dist/src/database/database-backend.js.map +0 -1
- package/dist/src/database/index.d.ts.map +0 -1
- package/dist/src/database/index.js.map +0 -1
- package/dist/src/database/item-demuxer.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.js.map +0 -1
- package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.test.js.map +0 -1
- package/dist/src/database/item-manager.d.ts.map +0 -1
- package/dist/src/database/item-manager.js.map +0 -1
- package/dist/src/database/item-manager.test.d.ts.map +0 -1
- package/dist/src/database/item-manager.test.js.map +0 -1
- package/dist/src/database/testing.d.ts.map +0 -1
- package/dist/src/database/testing.js.map +0 -1
- package/dist/src/database/timeframe-clock.d.ts.map +0 -1
- package/dist/src/database/timeframe-clock.js.map +0 -1
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js.map +0 -1
|
@@ -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,11 +20,11 @@ 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';
|
|
27
|
+
import { IdentityNotInitializedError } from '../packlets/errors';
|
|
29
28
|
import { PartyFeedProvider, PartyOptions } from '../pipeline';
|
|
30
29
|
import { IdentityCredentialsProvider } from '../protocol/identity-credentials';
|
|
31
30
|
import { SnapshotStore } from '../snapshots';
|
|
@@ -60,10 +59,10 @@ export class PartyFactory {
|
|
|
60
59
|
// Connect the pipeline.
|
|
61
60
|
await party.open();
|
|
62
61
|
|
|
63
|
-
const writableFeed = await party.
|
|
62
|
+
const writableFeed = await party.getWriteFeed();
|
|
64
63
|
|
|
65
64
|
// PartyGenesis (self-signed by Party).
|
|
66
|
-
await party.
|
|
65
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
67
66
|
identity.keyring,
|
|
68
67
|
partyKey,
|
|
69
68
|
writableFeed.key,
|
|
@@ -71,7 +70,7 @@ export class PartyFactory {
|
|
|
71
70
|
);
|
|
72
71
|
|
|
73
72
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
74
|
-
await party.
|
|
73
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
75
74
|
identity.keyring,
|
|
76
75
|
partyKey.publicKey,
|
|
77
76
|
wrapMessage(identity.identityGenesis),
|
|
@@ -80,7 +79,7 @@ export class PartyFactory {
|
|
|
80
79
|
|
|
81
80
|
// FeedAdmit (signed by the Device KeyChain).
|
|
82
81
|
// TODO(dmaretskyi): Is this really needed since a feed is already admitted by party genesis message.
|
|
83
|
-
await party.
|
|
82
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
84
83
|
identity.keyring,
|
|
85
84
|
partyKey.publicKey,
|
|
86
85
|
writableFeed.key,
|
|
@@ -89,7 +88,7 @@ export class PartyFactory {
|
|
|
89
88
|
|
|
90
89
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
91
90
|
if (identity.identityInfo) {
|
|
92
|
-
await party.
|
|
91
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
93
92
|
identity.keyring,
|
|
94
93
|
partyKey.publicKey,
|
|
95
94
|
wrapMessage(identity.identityInfo),
|
|
@@ -106,56 +105,12 @@ export class PartyFactory {
|
|
|
106
105
|
return party;
|
|
107
106
|
}
|
|
108
107
|
|
|
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
108
|
/**
|
|
154
109
|
* Constructs a party object from an existing set of feeds.
|
|
155
110
|
* @param partyKey
|
|
156
111
|
* @param hints
|
|
157
112
|
*/
|
|
158
|
-
async constructParty (partyKey: PartyKey,
|
|
113
|
+
async constructParty (partyKey: PartyKey, feedHints: PublicKey[] = [], initialTimeframe?: Timeframe) {
|
|
159
114
|
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
160
115
|
|
|
161
116
|
// TODO(marik-d): Support read-only parties if this feed doesn't exist?
|
|
@@ -172,7 +127,7 @@ export class PartyFactory {
|
|
|
172
127
|
identity.createCredentialsSigner(),
|
|
173
128
|
identity.preferences,
|
|
174
129
|
this._networkManager,
|
|
175
|
-
|
|
130
|
+
feedHints,
|
|
176
131
|
initialTimeframe,
|
|
177
132
|
this._options
|
|
178
133
|
);
|
|
@@ -190,7 +145,6 @@ export class PartyFactory {
|
|
|
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,18 @@ 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, hints);
|
|
176
|
+
await party.open();
|
|
222
177
|
await initiator.destroy();
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
));
|
|
233
|
-
}
|
|
178
|
+
|
|
179
|
+
// Copy our signed IdentityInfo into the new Party.
|
|
180
|
+
if (identity.identityInfo) {
|
|
181
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
182
|
+
identity.keyring,
|
|
183
|
+
partyKey,
|
|
184
|
+
wrapMessage(identity.identityInfo),
|
|
185
|
+
[identity.deviceKeyChain]
|
|
186
|
+
));
|
|
234
187
|
}
|
|
235
188
|
|
|
236
189
|
return party;
|
|
@@ -247,10 +200,10 @@ export class PartyFactory {
|
|
|
247
200
|
// Connect the pipeline.
|
|
248
201
|
await party.open();
|
|
249
202
|
|
|
250
|
-
const writableFeed = await party.
|
|
203
|
+
const writableFeed = await party.getWriteFeed();
|
|
251
204
|
|
|
252
205
|
// PartyGenesis (self-signed by Party).
|
|
253
|
-
await party.
|
|
206
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
254
207
|
identity.keyring,
|
|
255
208
|
partyKey,
|
|
256
209
|
writableFeed.key,
|
|
@@ -258,7 +211,7 @@ export class PartyFactory {
|
|
|
258
211
|
);
|
|
259
212
|
|
|
260
213
|
// KeyAdmit (IdentityGenesis in an Envelope signed by Party).
|
|
261
|
-
await party.
|
|
214
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
262
215
|
identity.keyring,
|
|
263
216
|
partyKey.publicKey,
|
|
264
217
|
wrapMessage(identity.identityGenesis),
|
|
@@ -266,7 +219,7 @@ export class PartyFactory {
|
|
|
266
219
|
));
|
|
267
220
|
|
|
268
221
|
// FeedAdmit (signed by the Device KeyChain).
|
|
269
|
-
await party.
|
|
222
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
270
223
|
identity.keyring,
|
|
271
224
|
partyKey.publicKey,
|
|
272
225
|
writableFeed.key,
|
|
@@ -275,7 +228,7 @@ export class PartyFactory {
|
|
|
275
228
|
|
|
276
229
|
// IdentityInfo in an Envelope signed by the Device KeyChain.
|
|
277
230
|
if (identity.identityInfo) {
|
|
278
|
-
await party.
|
|
231
|
+
await party.credentialsWriter.write(createEnvelopeMessage(
|
|
279
232
|
identity.keyring,
|
|
280
233
|
partyKey.publicKey,
|
|
281
234
|
wrapMessage(identity.identityInfo),
|
|
@@ -285,7 +238,7 @@ export class PartyFactory {
|
|
|
285
238
|
|
|
286
239
|
// const keyAdmitMessage = snapshot.halo?.messages?.[1];
|
|
287
240
|
// assert(keyAdmitMessage);
|
|
288
|
-
// await party.
|
|
241
|
+
// await party.writeCredentialsMessage(createEnvelopeMessage(
|
|
289
242
|
// identity.signer,
|
|
290
243
|
// partyKey.publicKey,
|
|
291
244
|
// keyAdmitMessage,
|
|
@@ -293,13 +246,14 @@ export class PartyFactory {
|
|
|
293
246
|
// ));
|
|
294
247
|
|
|
295
248
|
// for(const message of snapshot.halo?.messages?.slice(2) || []) {
|
|
296
|
-
// await party.
|
|
249
|
+
// await party.writeCredentialsMessage(message);
|
|
297
250
|
// }
|
|
298
251
|
|
|
299
252
|
// Write messages to create ECHO items.
|
|
300
253
|
const feedWriter = createFeedWriter(writableFeed.feed);
|
|
301
254
|
for (const item of snapshot.database?.items || []) {
|
|
302
255
|
const message: FeedMessage = {
|
|
256
|
+
timeframe: new Timeframe(),
|
|
303
257
|
echo: {
|
|
304
258
|
itemId: item.itemId ?? failUndefined(),
|
|
305
259
|
genesis: {
|
|
@@ -310,8 +264,7 @@ export class PartyFactory {
|
|
|
310
264
|
itemMutation: {
|
|
311
265
|
parentId: item.parentId
|
|
312
266
|
},
|
|
313
|
-
snapshot: item.model
|
|
314
|
-
timeframe: new Timeframe()
|
|
267
|
+
snapshot: item.model
|
|
315
268
|
}
|
|
316
269
|
};
|
|
317
270
|
await feedWriter.write(message);
|
|
@@ -32,8 +32,8 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
32
32
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
33
33
|
import { afterTest, testTimeout } from '@dxos/testutils';
|
|
34
34
|
|
|
35
|
-
import { Item } from '../api';
|
|
36
35
|
import { defaultInvitationAuthenticator, OfflineInvitationClaimer } from '../invitations';
|
|
36
|
+
import { Item } from '../packlets/database';
|
|
37
37
|
import { MetadataStore, PartyFeedProvider } from '../pipeline';
|
|
38
38
|
import { createTestIdentityCredentials } from '../protocol/identity-credentials';
|
|
39
39
|
import { SnapshotStore } from '../snapshots';
|
|
@@ -55,9 +55,11 @@ const log = debug('dxos:echo:parties:party-manager:test');
|
|
|
55
55
|
*/
|
|
56
56
|
const setup = async () => {
|
|
57
57
|
const keyring = new Keyring();
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const snapshotStore = new SnapshotStore(
|
|
58
|
+
|
|
59
|
+
const storage = createStorage('', StorageType.RAM);
|
|
60
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
61
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
62
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
61
63
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
62
64
|
const networkManager = new NetworkManager();
|
|
63
65
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
@@ -138,21 +140,18 @@ describe('Party manager', () => {
|
|
|
138
140
|
const feedStream = createWritableFeedStream(feed);
|
|
139
141
|
feedStream.write(createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey));
|
|
140
142
|
|
|
141
|
-
await partyManager.addParty(partyKey.publicKey, [
|
|
142
|
-
type: KeyType.FEED,
|
|
143
|
-
publicKey: PublicKey.from(feed.key)
|
|
144
|
-
}]);
|
|
143
|
+
await partyManager.addParty(partyKey.publicKey, [PublicKey.from(feed.key)]);
|
|
145
144
|
|
|
146
145
|
await update;
|
|
147
146
|
});
|
|
148
147
|
|
|
149
148
|
test('Create from cold start', async () => {
|
|
150
149
|
const storage = createStorage('', StorageType.RAM);
|
|
151
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
150
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
152
151
|
const keyring = new Keyring();
|
|
153
|
-
const
|
|
152
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
153
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
154
154
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
155
|
-
const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
|
|
156
155
|
const networkManager = new NetworkManager();
|
|
157
156
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
158
157
|
|
|
@@ -188,15 +187,23 @@ describe('Party manager', () => {
|
|
|
188
187
|
assert(feedKey);
|
|
189
188
|
|
|
190
189
|
const feedStream = createWritableFeedStream(feed);
|
|
191
|
-
feedStream.write({ halo: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identity.identityKey) });
|
|
192
190
|
feedStream.write({
|
|
191
|
+
timeframe: new Timeframe(),
|
|
192
|
+
halo: createPartyGenesisMessage(
|
|
193
|
+
keyring,
|
|
194
|
+
partyKey,
|
|
195
|
+
feedKey.publicKey,
|
|
196
|
+
identity.identityKey
|
|
197
|
+
)
|
|
198
|
+
});
|
|
199
|
+
feedStream.write({
|
|
200
|
+
timeframe: new Timeframe(),
|
|
193
201
|
echo: checkType<EchoEnvelope>({
|
|
194
202
|
itemId: 'foo',
|
|
195
203
|
genesis: {
|
|
196
204
|
itemType: PARTY_ITEM_TYPE,
|
|
197
205
|
modelType: ObjectModel.meta.type
|
|
198
|
-
}
|
|
199
|
-
timeframe: new Timeframe()
|
|
206
|
+
}
|
|
200
207
|
})
|
|
201
208
|
});
|
|
202
209
|
}
|
|
@@ -157,11 +157,9 @@ export class PartyManager {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Construct a party object and start replicating with the remote peer that created that party.
|
|
160
|
-
* @param partyKey
|
|
161
|
-
* @param hints
|
|
162
160
|
*/
|
|
163
161
|
@synchronized
|
|
164
|
-
async addParty (partyKey: PartyKey,
|
|
162
|
+
async addParty (partyKey: PartyKey, feedHints: PublicKey[] = []) {
|
|
165
163
|
assert(this._open, 'PartyManager is not open.');
|
|
166
164
|
|
|
167
165
|
/*
|
|
@@ -174,8 +172,9 @@ export class PartyManager {
|
|
|
174
172
|
return this._parties.get(partyKey);
|
|
175
173
|
}
|
|
176
174
|
|
|
177
|
-
log(`Adding party partyKey=${partyKey.toHex()} hints=${
|
|
178
|
-
const party = await this._partyFactory.
|
|
175
|
+
log(`Adding party partyKey=${partyKey.toHex()} hints=${feedHints.length}`);
|
|
176
|
+
const party = await this._partyFactory.constructParty(partyKey, feedHints);
|
|
177
|
+
await party.open();
|
|
179
178
|
await this._metadataStore.addParty(party.key);
|
|
180
179
|
this._setParty(party);
|
|
181
180
|
return party;
|
|
@@ -9,8 +9,8 @@ import { getPartyCredentialMessageType, PartyCredential } from '@dxos/credential
|
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { MessageSelector } from '@dxos/echo-protocol';
|
|
11
11
|
|
|
12
|
-
import { TimeframeClock } from '../database';
|
|
13
|
-
import {
|
|
12
|
+
import { TimeframeClock } from '../packlets/database';
|
|
13
|
+
import { PartyStateProvider } from './party-processor';
|
|
14
14
|
|
|
15
15
|
const log = debug('dxos:echo-db:message-selector');
|
|
16
16
|
|
|
@@ -23,47 +23,44 @@ const log = debug('dxos:echo-db:message-selector');
|
|
|
23
23
|
* @param partyProcessor
|
|
24
24
|
* @param timeframeClock
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const { data: { echo } } = candidates[i];
|
|
35
|
-
const feedKey = PublicKey.from(candidates[i].key);
|
|
36
|
-
if (!echo) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
26
|
+
export const createMessageSelector = (partyProcessor: PartyStateProvider, timeframeClock: TimeframeClock): MessageSelector => candidates => {
|
|
27
|
+
// Check ECHO message candidates first since they are less expensive than HALO cancidates.
|
|
28
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
29
|
+
const { data: { timeframe, echo } } = candidates[i];
|
|
30
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
31
|
+
if (!echo) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
35
|
+
assert(timeframe);
|
|
36
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
37
|
+
return i;
|
|
44
38
|
}
|
|
39
|
+
}
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
// Check HALO message candidates.
|
|
42
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
43
|
+
const { data: { timeframe, halo } } = candidates[i];
|
|
44
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
45
|
+
if (!halo) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
assert(timeframe);
|
|
50
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
if (partyProcessor.genesisRequired) {
|
|
55
|
+
try { // TODO(dmaretskyi): Get getPartyCredentialMessageType crashes for some reason.
|
|
59
56
|
// TODO(telackey): Add check that this is for the right Party.
|
|
60
57
|
if (getPartyCredentialMessageType(halo) === PartyCredential.Type.PARTY_GENESIS) {
|
|
61
58
|
return i;
|
|
62
59
|
}
|
|
63
|
-
}
|
|
60
|
+
} catch { }
|
|
64
61
|
}
|
|
62
|
+
}
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
64
|
+
// Not ready for this message yet.
|
|
65
|
+
log('Skipping...');
|
|
66
|
+
};
|
|
@@ -11,7 +11,8 @@ import { MetadataStore } from './metadata-store';
|
|
|
11
11
|
|
|
12
12
|
describe('MetadataStore in-memory', () => {
|
|
13
13
|
it('Creates party and adds feeds to it', async () => {
|
|
14
|
-
const
|
|
14
|
+
const storage = createStorage('', StorageType.RAM);
|
|
15
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
15
16
|
await store.load();
|
|
16
17
|
expect(store.parties?.length).toBe(0);
|
|
17
18
|
|
|
@@ -33,7 +34,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
it('Creates party when adding feed', async () => {
|
|
36
|
-
const
|
|
37
|
+
const storage = createStorage('', StorageType.RAM);
|
|
38
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
37
39
|
await store.load();
|
|
38
40
|
|
|
39
41
|
const partyKey = PublicKey.random();
|
|
@@ -45,7 +47,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
it('Doesn\'t add same feed twice', async () => {
|
|
48
|
-
const
|
|
50
|
+
const storage = createStorage('', StorageType.RAM);
|
|
51
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
49
52
|
await store.load();
|
|
50
53
|
|
|
51
54
|
const partyKey = PublicKey.random();
|
|
@@ -60,7 +63,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
60
63
|
|
|
61
64
|
// TODO(yivlad): Doesn't work for now.
|
|
62
65
|
it.skip('Resets storage', async () => {
|
|
63
|
-
const
|
|
66
|
+
const storage = createStorage('snapshots', StorageType.RAM);
|
|
67
|
+
const store = new MetadataStore(storage.directory(''));
|
|
64
68
|
|
|
65
69
|
const partyKey = PublicKey.random();
|
|
66
70
|
const feedKey = PublicKey.random();
|
|
@@ -8,7 +8,7 @@ import debug from 'debug';
|
|
|
8
8
|
import { PublicKey } from '@dxos/crypto';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
10
10
|
import { EchoMetadata, PartyMetadata, schema } from '@dxos/echo-protocol';
|
|
11
|
-
import {
|
|
11
|
+
import { Directory } from '@dxos/random-access-multi-storage';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
|
|
@@ -28,7 +28,7 @@ export class MetadataStore {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
constructor (
|
|
31
|
-
private readonly
|
|
31
|
+
private readonly _directory: Directory
|
|
32
32
|
) {}
|
|
33
33
|
|
|
34
34
|
get version (): number {
|
|
@@ -47,7 +47,7 @@ export class MetadataStore {
|
|
|
47
47
|
* Loads metadata from persistent storage.
|
|
48
48
|
*/
|
|
49
49
|
async load (): Promise<void> {
|
|
50
|
-
const file = this.
|
|
50
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
51
51
|
try {
|
|
52
52
|
const { size } = await file.stat();
|
|
53
53
|
if (size === 0) {
|
|
@@ -75,7 +75,7 @@ export class MetadataStore {
|
|
|
75
75
|
updated: new Date()
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const file = this.
|
|
78
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
79
79
|
|
|
80
80
|
try {
|
|
81
81
|
const encoded = Buffer.from(schema.getCodecForType('dxos.echo.metadata.EchoMetadata').encode(data));
|
|
@@ -90,7 +90,7 @@ export class MetadataStore {
|
|
|
90
90
|
*/
|
|
91
91
|
async clear (): Promise<void> {
|
|
92
92
|
log('Clearing all echo metadata...');
|
|
93
|
-
await this.
|
|
93
|
+
await this._directory.delete();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|