@dxos/echo-db 2.33.8-dev.c77ba621 → 2.33.9-dev.2637427f
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/result-set.js +4 -4
- package/dist/src/api/result-set.js.map +1 -1
- package/dist/src/echo.js +2 -2
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +17 -17
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts +1 -1
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +17 -17
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +4 -6
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +12 -6
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.d.ts.map +1 -1
- package/dist/src/halo/halo.js +11 -10
- package/dist/src/halo/halo.js.map +1 -1
- package/dist/src/halo/halo.test.js +2 -3
- package/dist/src/halo/halo.test.js.map +1 -1
- package/dist/src/halo/identity-manager.d.ts.map +1 -1
- package/dist/src/halo/identity-manager.js +13 -7
- package/dist/src/halo/identity-manager.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.map +1 -1
- package/dist/src/halo/party-opener.js +2 -4
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +9 -12
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/halo/types.d.ts +1 -0
- package/dist/src/halo/types.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +5 -4
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +9 -10
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.js +2 -2
- package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts +4 -7
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +12 -26
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +8 -8
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +12 -12
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +2 -1
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/invitation-factory.js +6 -8
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +9 -9
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.js +8 -8
- package/dist/src/packlets/database/data-mirror.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.test.js +1 -1
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -1
- package/dist/src/packlets/database/data-service-host.js +3 -3
- package/dist/src/packlets/database/data-service-host.js.map +1 -1
- package/dist/src/packlets/database/data-service-router.js +5 -5
- package/dist/src/packlets/database/data-service-router.js.map +1 -1
- package/dist/src/packlets/database/database-backend.js +3 -3
- package/dist/src/packlets/database/database-backend.js.map +1 -1
- package/dist/src/packlets/database/database.js +2 -2
- package/dist/src/packlets/database/database.js.map +1 -1
- package/dist/src/packlets/database/item-demuxer.js +14 -14
- package/dist/src/packlets/database/item-demuxer.js.map +1 -1
- package/dist/src/packlets/database/item-demuxer.test.js +1 -1
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -1
- package/dist/src/packlets/database/item-manager.js +18 -18
- package/dist/src/packlets/database/item-manager.js.map +1 -1
- package/dist/src/packlets/database/link.js +3 -3
- package/dist/src/packlets/database/link.js.map +1 -1
- package/dist/src/packlets/database/selection/result.js +2 -2
- package/dist/src/packlets/database/selection/result.js.map +1 -1
- package/dist/src/packlets/database/testing.js +1 -1
- package/dist/src/packlets/database/testing.js.map +1 -1
- package/dist/src/packlets/database/timeframe-clock.d.ts +2 -1
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -1
- package/dist/src/packlets/database/timeframe-clock.js +15 -5
- package/dist/src/packlets/database/timeframe-clock.js.map +1 -1
- package/dist/src/parties/data-party.d.ts +4 -3
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +18 -14
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +12 -12
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +2 -4
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +18 -15
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts +1 -1
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +19 -19
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +22 -18
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/parties/party-preferences.js +2 -2
- package/dist/src/parties/party-preferences.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -1
- package/dist/src/pipeline/feed-muxer.js +5 -5
- package/dist/src/pipeline/feed-muxer.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.test.js +2 -2
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +1 -2
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +6 -33
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +7 -2
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +12 -3
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts +2 -2
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +5 -4
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.d.ts +5 -5
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/party-pipeline.js +19 -20
- package/dist/src/pipeline/party-pipeline.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.test.js +13 -18
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -1
- package/dist/src/pipeline/party-processor.js +3 -3
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/protocol/authenticator.test.js +53 -12
- package/dist/src/protocol/authenticator.test.js.map +1 -1
- package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +2 -2
- package/dist/src/protocol/identity-credentials.js.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js +1 -1
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/protocol/replicator-plugin.d.ts.map +1 -1
- package/dist/src/protocol/replicator-plugin.js +1 -2
- package/dist/src/protocol/replicator-plugin.js.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +2 -2
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +4 -4
- package/dist/src/snapshots/snapshot-store.js.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 +24 -20
- package/src/api/result-set.ts +1 -1
- package/src/echo.test.ts +6 -4
- package/src/echo.ts +1 -1
- package/src/halo/halo-factory.ts +9 -9
- package/src/halo/halo-party.ts +15 -7
- package/src/halo/halo.test.ts +3 -2
- package/src/halo/halo.ts +4 -2
- package/src/halo/identity-manager.ts +12 -3
- package/src/halo/identity.ts +1 -1
- package/src/halo/party-opener.ts +2 -4
- package/src/halo/preferences.ts +5 -9
- package/src/halo/types.ts +1 -0
- package/src/invitations/greeting-initiator.ts +11 -6
- package/src/invitations/greeting-protocol-provider.ts +2 -2
- package/src/invitations/greeting-responder.ts +12 -31
- package/src/invitations/halo-recovery-initiator.ts +4 -4
- package/src/invitations/invitation-descriptor.ts +6 -6
- package/src/invitations/invitation-factory.ts +3 -3
- package/src/invitations/offline-invitation-claimer.ts +4 -4
- package/src/packlets/database/data-mirror.test.ts +2 -2
- package/src/packlets/database/data-mirror.ts +1 -1
- package/src/packlets/database/data-service-host.ts +1 -1
- package/src/packlets/database/data-service-router.ts +1 -1
- package/src/packlets/database/database-backend.ts +1 -1
- package/src/packlets/database/database.ts +1 -1
- package/src/packlets/database/item-demuxer.test.ts +2 -2
- package/src/packlets/database/item-demuxer.ts +1 -1
- package/src/packlets/database/item-manager.ts +1 -1
- package/src/packlets/database/link.ts +1 -1
- package/src/packlets/database/selection/result.ts +1 -1
- package/src/packlets/database/testing.ts +2 -2
- package/src/packlets/database/timeframe-clock.ts +4 -1
- package/src/parties/data-party.test.ts +12 -12
- package/src/parties/data-party.ts +15 -7
- package/src/parties/party-factory.ts +21 -13
- package/src/parties/party-manager.test.ts +13 -9
- package/src/parties/party-manager.ts +15 -13
- package/src/parties/party-preferences.ts +1 -1
- package/src/pipeline/feed-muxer.test.ts +2 -2
- package/src/pipeline/feed-muxer.ts +5 -5
- package/src/pipeline/message-selector.ts +5 -36
- package/src/pipeline/metadata-store.ts +16 -3
- package/src/pipeline/party-feed-provider.ts +3 -3
- package/src/pipeline/party-pipeline.test.ts +13 -19
- package/src/pipeline/party-pipeline.ts +14 -13
- package/src/pipeline/party-processor.ts +1 -1
- package/src/protocol/authenticator.test.ts +102 -17
- package/src/protocol/identity-credentials.ts +5 -2
- package/src/protocol/party-protocol-factory.ts +2 -2
- package/src/protocol/replicator-plugin.ts +1 -2
- package/src/snapshots/snapshot-generator.ts +1 -1
- package/src/snapshots/snapshot-store.ts +3 -3
- package/src/testing/testing-factories.ts +1 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import base from 'base-x';
|
|
7
6
|
import stableStringify from 'json-stable-stringify';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { ripemd160 } from '@dxos/crypto';
|
|
10
10
|
import { SwarmKey } from '@dxos/echo-protocol';
|
|
11
11
|
import * as proto from '@dxos/echo-protocol';
|
|
12
12
|
import { PublicKey } from '@dxos/protocols';
|
|
@@ -46,8 +46,8 @@ export class InvitationDescriptor {
|
|
|
46
46
|
static fromQueryParameters (queryParameters: InvitationQueryParameters): InvitationDescriptor {
|
|
47
47
|
const { hash, swarmKey, invitation, identityKey, type } = queryParameters;
|
|
48
48
|
|
|
49
|
-
const descriptor = new InvitationDescriptor(parseInvitationType(type),
|
|
50
|
-
|
|
49
|
+
const descriptor = new InvitationDescriptor(parseInvitationType(type), PublicKey.bufferize(swarmKey),
|
|
50
|
+
PublicKey.bufferize(invitation), identityKey ? PublicKey.from(identityKey) : undefined);
|
|
51
51
|
|
|
52
52
|
if (hash !== descriptor.hash) {
|
|
53
53
|
throw new InvalidInvitationError();
|
|
@@ -104,8 +104,8 @@ export class InvitationDescriptor {
|
|
|
104
104
|
*/
|
|
105
105
|
toQueryParameters (): InvitationQueryParameters {
|
|
106
106
|
const query: Partial<InvitationQueryParameters> = {
|
|
107
|
-
swarmKey:
|
|
108
|
-
invitation:
|
|
107
|
+
swarmKey: PublicKey.stringify(this.swarmKey),
|
|
108
|
+
invitation: PublicKey.stringify(this.invitation),
|
|
109
109
|
type: stringifyInvitationType(this.type)
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
5
|
+
import assert from 'node:assert';
|
|
6
6
|
|
|
7
7
|
import { createPartyInvitationMessage, Message as HaloMessage } from '@dxos/credentials';
|
|
8
8
|
import { FeedWriter } from '@dxos/echo-protocol';
|
|
@@ -21,8 +21,7 @@ import { InvitationDescriptor, InvitationDescriptorType } from './invitation-des
|
|
|
21
21
|
export class InvitationFactory {
|
|
22
22
|
constructor (
|
|
23
23
|
private readonly _partyProcessor: PartyStateProvider,
|
|
24
|
-
|
|
25
|
-
// Then the identity would be changed after this is instantiated.
|
|
24
|
+
private readonly _genesisFeedKey: PublicKey,
|
|
26
25
|
private readonly _credentialsSigner: CredentialsSigner,
|
|
27
26
|
private readonly _credentialsWriter: FeedWriter<HaloMessage>,
|
|
28
27
|
private readonly _networkManager: NetworkManager
|
|
@@ -62,6 +61,7 @@ export class InvitationFactory {
|
|
|
62
61
|
const responder = new GreetingResponder(
|
|
63
62
|
this._networkManager,
|
|
64
63
|
this._partyProcessor,
|
|
64
|
+
this._genesisFeedKey,
|
|
65
65
|
this._credentialsSigner,
|
|
66
66
|
this._credentialsWriter
|
|
67
67
|
);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
6
|
+
import assert from 'node:assert';
|
|
7
7
|
|
|
8
8
|
import { waitForEvent } from '@dxos/async';
|
|
9
9
|
import {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
SignedMessage,
|
|
21
21
|
codec
|
|
22
22
|
} from '@dxos/credentials';
|
|
23
|
-
import {
|
|
23
|
+
import { randomBytes } from '@dxos/crypto';
|
|
24
24
|
import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
|
|
25
25
|
import { PublicKey } from '@dxos/protocols';
|
|
26
26
|
|
|
@@ -66,7 +66,7 @@ export class OfflineInvitationClaimer {
|
|
|
66
66
|
|
|
67
67
|
// This is a temporary connection, there is no need to any special or permanent ID.
|
|
68
68
|
const localPeerId = randomBytes();
|
|
69
|
-
log('Local PeerId:',
|
|
69
|
+
log('Local PeerId:', PublicKey.stringify(localPeerId));
|
|
70
70
|
|
|
71
71
|
this._greeterPlugin = new GreetingCommandPlugin(localPeerId, async () => false);
|
|
72
72
|
|
|
@@ -100,7 +100,7 @@ export class OfflineInvitationClaimer {
|
|
|
100
100
|
const { invitation: invitationID } = this._invitationDescriptor;
|
|
101
101
|
|
|
102
102
|
// Send to the first peer (any peer will do).
|
|
103
|
-
const responderPeerId =
|
|
103
|
+
const responderPeerId = PublicKey.bufferize(this._greeterPlugin.peers[0].getSession().peerId);
|
|
104
104
|
|
|
105
105
|
// We expect to receive a new swarm/rendezvousKey to use for the full Greeting process.
|
|
106
106
|
const claimResponse = await this._greeterPlugin.send(
|
|
@@ -6,10 +6,10 @@ import expect from 'expect';
|
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
|
-
import { EchoEnvelope, MockFeedWriter
|
|
9
|
+
import { EchoEnvelope, MockFeedWriter } from '@dxos/echo-protocol';
|
|
10
10
|
import { ModelFactory } from '@dxos/model-factory';
|
|
11
11
|
import { ObjectModel } from '@dxos/object-model';
|
|
12
|
-
import { PublicKey } from '@dxos/protocols';
|
|
12
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
13
13
|
|
|
14
14
|
import { DataMirror } from './data-mirror';
|
|
15
15
|
import { DataServiceHost } from './data-service-host';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
6
|
+
import assert from 'node:assert';
|
|
7
7
|
|
|
8
8
|
import { DatabaseSnapshot, DataService, EchoEnvelope, FeedWriter, PartyKey } from '@dxos/echo-protocol';
|
|
9
9
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -9,10 +9,10 @@ import { it as test } from 'mocha';
|
|
|
9
9
|
import { latch } from '@dxos/async';
|
|
10
10
|
import { createId } from '@dxos/crypto';
|
|
11
11
|
import { checkType } from '@dxos/debug';
|
|
12
|
-
import { EchoEnvelope, MockFeedWriter
|
|
12
|
+
import { EchoEnvelope, MockFeedWriter } from '@dxos/echo-protocol';
|
|
13
13
|
import { ModelFactory, TestModel } from '@dxos/model-factory';
|
|
14
14
|
import { ObjectModel } from '@dxos/object-model';
|
|
15
|
-
import { PublicKey } from '@dxos/protocols';
|
|
15
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
16
16
|
|
|
17
17
|
import { Item } from './item';
|
|
18
18
|
import { ItemDemuxer } from './item-demuxer';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { EchoEnvelope, MockFeedWriter
|
|
5
|
+
import { EchoEnvelope, MockFeedWriter } from '@dxos/echo-protocol';
|
|
6
6
|
import { ModelFactory } from '@dxos/model-factory';
|
|
7
|
-
import { PublicKey } from '@dxos/protocols';
|
|
7
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
8
8
|
|
|
9
9
|
import { DataServiceHost } from './data-service-host';
|
|
10
10
|
import { DataServiceRouter } from './data-service-router';
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { timed } from '@dxos/debug';
|
|
7
|
+
import { FeedKey } from '@dxos/echo-protocol';
|
|
8
|
+
import { Timeframe } from '@dxos/protocols';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Keeps state of the last timeframe that was processed by ECHO.
|
|
@@ -29,6 +31,7 @@ export class TimeframeClock {
|
|
|
29
31
|
return !gaps.isEmpty();
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
@timed(5_000)
|
|
32
35
|
async waitUntilReached (target: Timeframe) {
|
|
33
36
|
await this.update.waitForCondition(() => Timeframe.dependencies(target, this._timeframe).isEmpty());
|
|
34
37
|
}
|
|
@@ -22,7 +22,7 @@ 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,
|
|
25
|
+
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, genesisFeedKey?: PublicKey) => {
|
|
26
26
|
|
|
27
27
|
const storage = createStorage('', StorageType.RAM);
|
|
28
28
|
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
@@ -43,7 +43,7 @@ describe('DataParty', () => {
|
|
|
43
43
|
identity.preferences,
|
|
44
44
|
networkManager
|
|
45
45
|
);
|
|
46
|
-
party.
|
|
46
|
+
party._setGenesisFeedKey(genesisFeedKey ?? writableFeed.key);
|
|
47
47
|
return party;
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ describe('DataParty', () => {
|
|
|
51
51
|
const keyring = new Keyring();
|
|
52
52
|
const identity = await createTestIdentityCredentials(keyring);
|
|
53
53
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
54
|
-
const party = await createParty(identity, partyKey.publicKey
|
|
54
|
+
const party = await createParty(identity, partyKey.publicKey);
|
|
55
55
|
|
|
56
56
|
await party.open();
|
|
57
57
|
await party.close();
|
|
@@ -61,7 +61,7 @@ describe('DataParty', () => {
|
|
|
61
61
|
const keyring = new Keyring();
|
|
62
62
|
const identity = await createTestIdentityCredentials(keyring);
|
|
63
63
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
64
|
-
const party = await createParty(identity, partyKey.publicKey
|
|
64
|
+
const party = await createParty(identity, partyKey.publicKey);
|
|
65
65
|
await party.open();
|
|
66
66
|
|
|
67
67
|
const feed = await party.getWriteFeed();
|
|
@@ -81,7 +81,7 @@ describe('DataParty', () => {
|
|
|
81
81
|
const keyring = new Keyring();
|
|
82
82
|
const identity = await createTestIdentityCredentials(keyring);
|
|
83
83
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
84
|
-
const party = await createParty(identity, partyKey.publicKey
|
|
84
|
+
const party = await createParty(identity, partyKey.publicKey);
|
|
85
85
|
await party.open();
|
|
86
86
|
|
|
87
87
|
const feed = await party.getWriteFeed();
|
|
@@ -109,7 +109,7 @@ describe('DataParty', () => {
|
|
|
109
109
|
const identity = await createTestIdentityCredentials(keyring);
|
|
110
110
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
111
111
|
|
|
112
|
-
const party = await createParty(identity, partyKey.publicKey
|
|
112
|
+
const party = await createParty(identity, partyKey.publicKey);
|
|
113
113
|
await party.open();
|
|
114
114
|
const feed = await party.getWriteFeed();
|
|
115
115
|
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
@@ -134,7 +134,7 @@ describe('DataParty', () => {
|
|
|
134
134
|
const identityA = await createTestIdentityCredentials(keyring);
|
|
135
135
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
136
136
|
|
|
137
|
-
const party = await createParty(identityA, partyKey.publicKey
|
|
137
|
+
const party = await createParty(identityA, partyKey.publicKey);
|
|
138
138
|
await party.open();
|
|
139
139
|
const feed = await party.getWriteFeed();
|
|
140
140
|
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
@@ -161,7 +161,7 @@ describe('DataParty', () => {
|
|
|
161
161
|
const identityA = await createTestIdentityCredentials(keyring);
|
|
162
162
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
163
163
|
|
|
164
|
-
const partyA = await createParty(identityA, partyKey.publicKey
|
|
164
|
+
const partyA = await createParty(identityA, partyKey.publicKey);
|
|
165
165
|
await partyA.open();
|
|
166
166
|
const feedA = await partyA.getWriteFeed();
|
|
167
167
|
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
@@ -178,7 +178,7 @@ describe('DataParty', () => {
|
|
|
178
178
|
));
|
|
179
179
|
|
|
180
180
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
181
|
-
const partyB = await createParty(identityB, partyKey.publicKey,
|
|
181
|
+
const partyB = await createParty(identityB, partyKey.publicKey, feedA.key);
|
|
182
182
|
await partyB.open();
|
|
183
183
|
|
|
184
184
|
await partyA.database.createItem({ type: 'test:item-a' });
|
|
@@ -195,7 +195,7 @@ describe('DataParty', () => {
|
|
|
195
195
|
const identityA = await createTestIdentityCredentials(new Keyring());
|
|
196
196
|
const partyKeyA = await identityA.keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
197
197
|
|
|
198
|
-
const partyA = await createParty(identityA, partyKeyA.publicKey
|
|
198
|
+
const partyA = await createParty(identityA, partyKeyA.publicKey);
|
|
199
199
|
await partyA.open();
|
|
200
200
|
const feedA = await partyA.getWriteFeed();
|
|
201
201
|
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
@@ -226,9 +226,9 @@ describe('DataParty', () => {
|
|
|
226
226
|
);
|
|
227
227
|
|
|
228
228
|
await initiator.connect();
|
|
229
|
-
const { partyKey: partyKeyB,
|
|
229
|
+
const { partyKey: partyKeyB, genesisFeedKey } = await initiator.redeemInvitation(defaultSecretProvider);
|
|
230
230
|
expect(partyKeyB.equals(partyKeyA.publicKey));
|
|
231
|
-
const partyB = await createParty(identityB, partyKeyB,
|
|
231
|
+
const partyB = await createParty(identityB, partyKeyB, genesisFeedKey);
|
|
232
232
|
await partyB.open();
|
|
233
233
|
await initiator.destroy();
|
|
234
234
|
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
5
|
+
import assert from 'node:assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized, Event } from '@dxos/async';
|
|
8
8
|
import { timed } from '@dxos/debug';
|
|
9
|
-
import { PartyKey, PartySnapshot
|
|
9
|
+
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
10
10
|
import { FeedDescriptor } from '@dxos/feed-store';
|
|
11
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
12
12
|
import { NetworkManager } from '@dxos/network-manager';
|
|
13
13
|
import { ObjectModel } from '@dxos/object-model';
|
|
14
|
-
import { PublicKey } from '@dxos/protocols';
|
|
14
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
15
15
|
|
|
16
16
|
import { ResultSet } from '../api';
|
|
17
17
|
import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
|
|
@@ -46,7 +46,8 @@ export class DataParty {
|
|
|
46
46
|
private readonly _preferences?: PartyPreferences;
|
|
47
47
|
private _invitationManager?: InvitationFactory;
|
|
48
48
|
private _protocol?: PartyProtocolFactory;
|
|
49
|
-
|
|
49
|
+
|
|
50
|
+
private _genesisFeedKey?: PublicKey | undefined;
|
|
50
51
|
|
|
51
52
|
constructor (
|
|
52
53
|
partyKey: PartyKey,
|
|
@@ -141,11 +142,16 @@ export class DataParty {
|
|
|
141
142
|
await this._preferences?.setLastKnownTitle(title);
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
get genesisFeedKey () {
|
|
146
|
+
assert(this._genesisFeedKey);
|
|
147
|
+
return this._genesisFeedKey;
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
/**
|
|
145
151
|
* @internal
|
|
146
152
|
*/
|
|
147
|
-
|
|
148
|
-
this.
|
|
153
|
+
_setGenesisFeedKey (genesisFeedKey: PublicKey) {
|
|
154
|
+
this._genesisFeedKey = genesisFeedKey;
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
/**
|
|
@@ -161,8 +167,9 @@ export class DataParty {
|
|
|
161
167
|
// TODO(dmaretskyi): May be undefined in some tests.
|
|
162
168
|
const party = this._metadataStore.getParty(this._partyCore.key);
|
|
163
169
|
|
|
170
|
+
assert(this._genesisFeedKey);
|
|
164
171
|
await this._partyCore.open({
|
|
165
|
-
|
|
172
|
+
genesisFeedKey: this._genesisFeedKey,
|
|
166
173
|
initialTimeframe: this._initialTimeframe,
|
|
167
174
|
targetTimeframe: party?.latestTimeframe
|
|
168
175
|
});
|
|
@@ -175,6 +182,7 @@ export class DataParty {
|
|
|
175
182
|
|
|
176
183
|
this._invitationManager = new InvitationFactory(
|
|
177
184
|
this._partyCore.processor,
|
|
185
|
+
this._genesisFeedKey,
|
|
178
186
|
this._credentialsSigner,
|
|
179
187
|
this._partyCore.credentialsWriter,
|
|
180
188
|
this._networkManager
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
6
|
+
import assert from 'node:assert';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
createEnvelopeMessage,
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
SecretProvider,
|
|
14
14
|
wrapMessage
|
|
15
15
|
} from '@dxos/credentials';
|
|
16
|
-
import { humanize, keyToString } from '@dxos/crypto';
|
|
17
16
|
import { failUndefined, raise, timed } from '@dxos/debug';
|
|
18
|
-
import { createFeedWriter, FeedMessage, PartyKey, PartySnapshot
|
|
17
|
+
import { createFeedWriter, FeedMessage, PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
19
18
|
import { ModelFactory } from '@dxos/model-factory';
|
|
20
19
|
import { NetworkManager } from '@dxos/network-manager';
|
|
21
20
|
import { ObjectModel } from '@dxos/object-model';
|
|
22
|
-
import { PublicKey } from '@dxos/protocols';
|
|
21
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
22
|
+
import { humanize } from '@dxos/util';
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
25
|
createDataPartyAdmissionMessages,
|
|
@@ -59,8 +59,10 @@ export class PartyFactory {
|
|
|
59
59
|
const party = await this.constructParty(partyKey.publicKey);
|
|
60
60
|
|
|
61
61
|
const writableFeed = await party.getWriteFeed();
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
party._setGenesisFeedKey(writableFeed.key);
|
|
63
|
+
|
|
64
|
+
await this._metadataStore.addParty(partyKey.publicKey);
|
|
65
|
+
await this._metadataStore.setGenesisFeed(partyKey.publicKey, writableFeed.key);
|
|
64
66
|
|
|
65
67
|
// Connect the pipeline.
|
|
66
68
|
await party.open();
|
|
@@ -111,8 +113,6 @@ export class PartyFactory {
|
|
|
111
113
|
|
|
112
114
|
/**
|
|
113
115
|
* Constructs a party object from an existing set of feeds.
|
|
114
|
-
* @param partyKey
|
|
115
|
-
* @param hints
|
|
116
116
|
*/
|
|
117
117
|
async constructParty (partyKey: PartyKey, initialTimeframe?: Timeframe) {
|
|
118
118
|
const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
|
|
@@ -154,8 +154,8 @@ export class PartyFactory {
|
|
|
154
154
|
const invitationClaimer = new OfflineInvitationClaimer(this._networkManager, invitationDescriptor);
|
|
155
155
|
await invitationClaimer.connect();
|
|
156
156
|
invitationDescriptor = await invitationClaimer.claim();
|
|
157
|
-
log(`Party invitation ${
|
|
158
|
-
`at ${
|
|
157
|
+
log(`Party invitation ${PublicKey.stringify(originalInvitation.invitation)} triggered interactive Greeting`,
|
|
158
|
+
`at ${PublicKey.stringify(invitationDescriptor.invitation)}`);
|
|
159
159
|
await invitationClaimer.destroy();
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -172,9 +172,14 @@ export class PartyFactory {
|
|
|
172
172
|
);
|
|
173
173
|
|
|
174
174
|
await initiator.connect();
|
|
175
|
-
const { partyKey,
|
|
175
|
+
const { partyKey, genesisFeedKey } = await initiator.redeemInvitation(secretProvider);
|
|
176
176
|
const party = await this.constructParty(partyKey);
|
|
177
|
-
|
|
177
|
+
|
|
178
|
+
await this._metadataStore.addParty(partyKey);
|
|
179
|
+
await this._metadataStore.setGenesisFeed(partyKey, genesisFeedKey);
|
|
180
|
+
|
|
181
|
+
party._setGenesisFeedKey(genesisFeedKey);
|
|
182
|
+
|
|
178
183
|
await party.open();
|
|
179
184
|
await initiator.destroy();
|
|
180
185
|
|
|
@@ -201,7 +206,10 @@ export class PartyFactory {
|
|
|
201
206
|
|
|
202
207
|
const writableFeed = await party.getWriteFeed();
|
|
203
208
|
// Hint at the newly created writable feed so that we can start replicating from it.
|
|
204
|
-
party.
|
|
209
|
+
party._setGenesisFeedKey(writableFeed.key);
|
|
210
|
+
|
|
211
|
+
await this._metadataStore.addParty(partyKey.publicKey);
|
|
212
|
+
await this._metadataStore.setGenesisFeed(partyKey.publicKey, writableFeed.key);
|
|
205
213
|
|
|
206
214
|
// Connect the pipeline.
|
|
207
215
|
await party.open();
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable jest/no-conditional-expect */
|
|
6
6
|
|
|
7
|
-
import assert from 'assert';
|
|
8
7
|
import debug from 'debug';
|
|
9
8
|
import expect from 'expect';
|
|
10
9
|
import { it as test } from 'mocha';
|
|
10
|
+
import assert from 'node:assert';
|
|
11
11
|
|
|
12
12
|
import { latch } from '@dxos/async';
|
|
13
13
|
import {
|
|
@@ -19,20 +19,21 @@ import {
|
|
|
19
19
|
} from '@dxos/credentials';
|
|
20
20
|
import {
|
|
21
21
|
createKeyPair,
|
|
22
|
-
humanize,
|
|
23
22
|
randomBytes,
|
|
24
23
|
sign,
|
|
25
|
-
SIGNATURE_LENGTH,
|
|
24
|
+
SIGNATURE_LENGTH,
|
|
25
|
+
verify
|
|
26
26
|
} from '@dxos/crypto';
|
|
27
27
|
import { checkType } from '@dxos/debug';
|
|
28
|
-
import { codec, EchoEnvelope
|
|
28
|
+
import { codec, EchoEnvelope } from '@dxos/echo-protocol';
|
|
29
29
|
import { createWritableFeedStream, FeedStore } from '@dxos/feed-store';
|
|
30
30
|
import { ModelFactory } from '@dxos/model-factory';
|
|
31
31
|
import { NetworkManager } from '@dxos/network-manager';
|
|
32
32
|
import { ObjectModel } from '@dxos/object-model';
|
|
33
|
-
import { PublicKey } from '@dxos/protocols';
|
|
33
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
34
34
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
35
35
|
import { afterTest, testTimeout } from '@dxos/testutils';
|
|
36
|
+
import { humanize } from '@dxos/util';
|
|
36
37
|
|
|
37
38
|
import { defaultInvitationAuthenticator, OfflineInvitationClaimer } from '../invitations';
|
|
38
39
|
import { Item } from '../packlets/database';
|
|
@@ -133,17 +134,19 @@ describe('Party manager', () => {
|
|
|
133
134
|
|
|
134
135
|
// TODO(burdon): Create multiple feeds.
|
|
135
136
|
const { publicKey, secretKey } = createKeyPair();
|
|
136
|
-
const
|
|
137
|
+
const feed = await feedStore.openReadWriteFeed(PublicKey.from(publicKey), secretKey);
|
|
137
138
|
const feedKey = await keyring.addKeyRecord({
|
|
138
139
|
publicKey: PublicKey.from(feed.key),
|
|
139
140
|
secretKey: feed.secretKey,
|
|
140
141
|
type: KeyType.FEED
|
|
141
142
|
});
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
await feed.append({
|
|
145
|
+
timeframe: new Timeframe(),
|
|
146
|
+
halo: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey)
|
|
147
|
+
});
|
|
145
148
|
|
|
146
|
-
await partyManager.addParty(partyKey.publicKey,
|
|
149
|
+
await partyManager.addParty(partyKey.publicKey, feed.key);
|
|
147
150
|
|
|
148
151
|
await update;
|
|
149
152
|
});
|
|
@@ -184,6 +187,7 @@ describe('Party manager', () => {
|
|
|
184
187
|
assert(keyRecord, 'Key is not found in keyring');
|
|
185
188
|
assert(keyRecord.secretKey, 'Missing secret key');
|
|
186
189
|
await metadataStore.addPartyFeed(partyKey.publicKey, keyRecord.publicKey);
|
|
190
|
+
await metadataStore.setGenesisFeed(partyKey.publicKey, keyRecord.publicKey);
|
|
187
191
|
|
|
188
192
|
// TODO(burdon): Create multiple feeds.
|
|
189
193
|
const { feed } = await feedStore.openReadWriteFeed(keyRecord.publicKey, keyRecord.secretKey);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
7
6
|
import unionWith from 'lodash.unionwith';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
8
|
|
|
9
9
|
import { Event, synchronized } from '@dxos/async';
|
|
10
|
-
import {
|
|
10
|
+
import { SecretProvider } from '@dxos/credentials';
|
|
11
11
|
import { failUndefined, timed } from '@dxos/debug';
|
|
12
12
|
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
13
13
|
import { PublicKey } from '@dxos/protocols';
|
|
@@ -96,11 +96,15 @@ export class PartyManager {
|
|
|
96
96
|
const snapshot = await this._snapshotStore.load(partyKey);
|
|
97
97
|
|
|
98
98
|
const metadata = this._metadataStore.getParty(partyKey) ?? failUndefined();
|
|
99
|
+
if (!metadata.genesisFeedKey) {
|
|
100
|
+
log(`Skipping loading party with missing genesis feed key: ${partyKey}`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
99
103
|
|
|
100
104
|
const party = snapshot
|
|
101
105
|
? await this._partyFactory.constructPartyFromSnapshot(snapshot)
|
|
102
106
|
: await this._partyFactory.constructParty(partyKey);
|
|
103
|
-
party.
|
|
107
|
+
party._setGenesisFeedKey(metadata.genesisFeedKey);
|
|
104
108
|
|
|
105
109
|
const isActive = identity?.preferences?.isPartyActive(partyKey) ?? true;
|
|
106
110
|
if (isActive) {
|
|
@@ -163,7 +167,7 @@ export class PartyManager {
|
|
|
163
167
|
* Construct a party object and start replicating with the remote peer that created that party.
|
|
164
168
|
*/
|
|
165
169
|
@synchronized
|
|
166
|
-
async addParty (partyKey: PartyKey,
|
|
170
|
+
async addParty (partyKey: PartyKey, genesisFeedKey: PublicKey) {
|
|
167
171
|
assert(this._open, 'PartyManager is not open.');
|
|
168
172
|
|
|
169
173
|
/*
|
|
@@ -176,11 +180,14 @@ export class PartyManager {
|
|
|
176
180
|
return this._parties.get(partyKey);
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
log(`Adding party partyKey=${partyKey.toHex()}
|
|
183
|
+
log(`Adding party partyKey=${partyKey.toHex()}`);
|
|
180
184
|
const party = await this._partyFactory.constructParty(partyKey);
|
|
181
|
-
party.
|
|
182
|
-
|
|
185
|
+
party._setGenesisFeedKey(genesisFeedKey);
|
|
186
|
+
|
|
183
187
|
await this._metadataStore.addParty(party.key);
|
|
188
|
+
await this._metadataStore.setGenesisFeed(party.key, genesisFeedKey);
|
|
189
|
+
|
|
190
|
+
await party.open();
|
|
184
191
|
this._setParty(party);
|
|
185
192
|
return party;
|
|
186
193
|
}
|
|
@@ -327,14 +334,9 @@ export class PartyManager {
|
|
|
327
334
|
return;
|
|
328
335
|
}
|
|
329
336
|
|
|
330
|
-
const keyHints: KeyHint[] = [
|
|
331
|
-
...party.processor.memberKeys.map(publicKey => ({ publicKey: publicKey, type: KeyType.UNKNOWN })),
|
|
332
|
-
...party.processor.feedKeys.map(publicKey => ({ publicKey: publicKey, type: KeyType.FEED }))
|
|
333
|
-
];
|
|
334
|
-
|
|
335
337
|
await identity.preferences.recordPartyJoining({
|
|
336
338
|
partyKey: party.key,
|
|
337
|
-
|
|
339
|
+
genesisFeed: party.genesisFeedKey
|
|
338
340
|
});
|
|
339
341
|
}
|
|
340
342
|
}
|