@dxos/echo-db 2.33.6 → 2.33.7-dev.40cf0994
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/echo.d.ts +20 -17
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +33 -20
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +9 -9
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/contact-manager.d.ts.map +1 -1
- package/dist/src/halo/contact-manager.js +2 -2
- package/dist/src/halo/contact-manager.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 +2 -1
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +1 -1
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.d.ts +1 -1
- package/dist/src/halo/halo.d.ts.map +1 -1
- package/dist/src/halo/halo.js +3 -2
- package/dist/src/halo/halo.js.map +1 -1
- package/dist/src/halo/halo.test.js +7 -6
- package/dist/src/halo/halo.test.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 +3 -3
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +5 -4
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +4 -3
- 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 +4 -3
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.d.ts +1 -1
- package/dist/src/invitations/invitation-descriptor.d.ts.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +4 -3
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +1 -1
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +4 -3
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.d.ts +1 -1
- package/dist/src/packlets/database/data-mirror.d.ts.map +1 -1
- package/dist/src/packlets/database/data-mirror.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.test.js +5 -5
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -1
- package/dist/src/packlets/database/data-service-host.d.ts.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/database.d.ts +1 -1
- package/dist/src/packlets/database/database.d.ts.map +1 -1
- package/dist/src/packlets/database/database.js.map +1 -1
- package/dist/src/packlets/database/item-demuxer.test.js +7 -6
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -1
- package/dist/src/packlets/database/item-manager.d.ts +1 -1
- package/dist/src/packlets/database/item-manager.d.ts.map +1 -1
- package/dist/src/packlets/database/item-manager.js.map +1 -1
- package/dist/src/packlets/database/item-manager.test.js +11 -10
- package/dist/src/packlets/database/item-manager.test.js.map +1 -1
- package/dist/src/packlets/database/selection/selection.test.js +2 -2
- package/dist/src/packlets/database/selection/selection.test.js.map +1 -1
- package/dist/src/packlets/database/testing.d.ts.map +1 -1
- package/dist/src/packlets/database/testing.js +5 -5
- package/dist/src/packlets/database/testing.js.map +1 -1
- package/dist/src/packlets/errors/errors.d.ts +22 -0
- package/dist/src/packlets/errors/errors.d.ts.map +1 -0
- package/dist/src/packlets/errors/errors.js +44 -0
- package/dist/src/packlets/errors/errors.js.map +1 -0
- package/dist/src/packlets/errors/index.d.ts +1 -21
- package/dist/src/packlets/errors/index.d.ts.map +1 -1
- package/dist/src/packlets/errors/index.js +16 -39
- package/dist/src/packlets/errors/index.js.map +1 -1
- package/dist/src/parties/data-party.d.ts +1 -1
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +1 -1
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +2 -1
- 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 +2 -2
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +10 -9
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -1
- package/dist/src/pipeline/feed-muxer.js +3 -2
- package/dist/src/pipeline/feed-muxer.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.test.js +5 -4
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +3 -3
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +1 -1
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +26 -0
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/metadata-store.test.js +24 -10
- package/dist/src/pipeline/metadata-store.test.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.d.ts +1 -1
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/party-pipeline.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.test.js +5 -4
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -1
- package/dist/src/pipeline/party-processor.d.ts +1 -1
- package/dist/src/pipeline/party-processor.d.ts.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.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/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +2 -1
- 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/party-protocol-factory.d.ts +1 -1
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +2 -1
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.test.js +2 -1
- package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
- package/dist/src/snapshots/snapshot.test.js +4 -4
- package/dist/src/snapshots/snapshot.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/echo.test.ts +10 -10
- package/src/echo.ts +41 -25
- package/src/halo/contact-manager.ts +1 -1
- package/src/halo/halo-factory.ts +2 -1
- package/src/halo/halo-party.ts +1 -1
- package/src/halo/halo.test.ts +7 -6
- package/src/halo/halo.ts +3 -2
- package/src/halo/preferences.ts +1 -1
- package/src/invitations/greeting-initiator.ts +2 -1
- package/src/invitations/greeting-responder.ts +2 -1
- package/src/invitations/halo-recovery-initiator.ts +2 -1
- package/src/invitations/invitation-descriptor.ts +2 -1
- package/src/invitations/invitation-factory.ts +1 -1
- package/src/invitations/offline-invitation-claimer.ts +2 -1
- package/src/packlets/database/data-mirror.test.ts +1 -1
- package/src/packlets/database/data-mirror.ts +1 -1
- package/src/packlets/database/data-service-host.ts +1 -1
- package/src/packlets/database/database.ts +1 -1
- package/src/packlets/database/item-demuxer.test.ts +2 -1
- package/src/packlets/database/item-manager.test.ts +2 -1
- package/src/packlets/database/item-manager.ts +2 -1
- package/src/packlets/database/selection/selection.test.ts +1 -1
- package/src/packlets/database/testing.ts +1 -1
- package/src/packlets/errors/errors.ts +43 -0
- package/src/packlets/errors/index.ts +2 -40
- package/src/parties/data-party.test.ts +1 -1
- package/src/parties/data-party.ts +2 -2
- package/src/parties/party-factory.ts +2 -1
- package/src/parties/party-manager.test.ts +9 -7
- package/src/parties/party-manager.ts +1 -1
- package/src/pipeline/feed-muxer.test.ts +2 -1
- package/src/pipeline/feed-muxer.ts +2 -1
- package/src/pipeline/message-selector.ts +1 -1
- package/src/pipeline/metadata-store.test.ts +18 -1
- package/src/pipeline/metadata-store.ts +19 -1
- package/src/pipeline/party-feed-provider.ts +1 -1
- package/src/pipeline/party-pipeline.test.ts +2 -1
- package/src/pipeline/party-pipeline.ts +1 -1
- package/src/pipeline/party-processor.ts +1 -1
- package/src/protocol/auth-plugin.ts +1 -1
- package/src/protocol/halo-recovery-plugin.ts +1 -1
- package/src/protocol/identity-credentials.ts +2 -1
- package/src/protocol/offline-invitation-plugin.ts +1 -1
- package/src/protocol/party-protocol-factory.ts +2 -1
- package/src/snapshots/snapshot-generator.ts +3 -1
- package/src/snapshots/snapshot-store.test.ts +2 -1
- package/src/snapshots/snapshot.test.ts +1 -1
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import { DXOSError } from '@dxos/debug';
|
|
7
|
-
import { ItemID } from '@dxos/echo-protocol';
|
|
8
|
-
|
|
9
|
-
export class PartyNotFoundError extends DXOSError {
|
|
10
|
-
constructor (partyKey: PublicKey) {
|
|
11
|
-
super('PARTY_NOT_FOUND', `Party with key not found: ${partyKey}`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class EntityNotFoundError extends DXOSError {
|
|
16
|
-
constructor (entityId: ItemID) {
|
|
17
|
-
super('ENTITY_NOT_FOUND', `Entitiy not found: ${entityId}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class UnknownModelError extends DXOSError {
|
|
22
|
-
constructor (model: string) {
|
|
23
|
-
super('UNKNOWN_MODEL', `Unknown model ${model}.`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class IdentityNotInitializedError extends DXOSError {
|
|
28
|
-
constructor () {
|
|
29
|
-
super('IDENTITY_NOT_INITIALIZED', 'Identity not initialized.');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class InvalidInvitationError extends DXOSError {
|
|
34
|
-
constructor () {
|
|
35
|
-
super('INVALID_INVITATION', 'Invitation is invalid.');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class InvalidStorageVersionError extends DXOSError {
|
|
40
|
-
constructor (expected: number, actual: number) {
|
|
41
|
-
super('INVALID_STORAGE_VERSION', `Invalid storage version: Expected ${expected}, actual ${actual}.`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
5
|
+
export * from './errors';
|
|
@@ -6,12 +6,12 @@ import expect from 'expect';
|
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
8
|
import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider, Keyring, KeyType, codec as haloCodec } from '@dxos/credentials';
|
|
9
|
-
import { PublicKey } from '@dxos/crypto';
|
|
10
9
|
import { codec } from '@dxos/echo-protocol';
|
|
11
10
|
import { FeedStore } from '@dxos/feed-store';
|
|
12
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
12
|
import { NetworkManager } from '@dxos/network-manager';
|
|
14
13
|
import { ObjectModel } from '@dxos/object-model';
|
|
14
|
+
import { PublicKey } from '@dxos/protocols';
|
|
15
15
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
16
16
|
|
|
17
17
|
import { createDataPartyAdmissionMessages, defaultInvitationAuthenticator, GreetingInitiator } from '../invitations';
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized, Event } from '@dxos/async';
|
|
8
|
-
import { PublicKey } from '@dxos/crypto';
|
|
9
8
|
import { timed } from '@dxos/debug';
|
|
10
9
|
import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
11
10
|
import { FeedDescriptor } from '@dxos/feed-store';
|
|
12
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
12
|
import { NetworkManager } from '@dxos/network-manager';
|
|
14
13
|
import { ObjectModel } from '@dxos/object-model';
|
|
14
|
+
import { PublicKey } from '@dxos/protocols';
|
|
15
15
|
|
|
16
16
|
import { ResultSet } from '../api';
|
|
17
17
|
import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
|
|
@@ -81,7 +81,7 @@ export class DataParty {
|
|
|
81
81
|
key: this.key.toHex(),
|
|
82
82
|
isOpen: this.isOpen,
|
|
83
83
|
isActive: this.isActive,
|
|
84
|
-
feedKeys: this._feedProvider.getFeeds().length,
|
|
84
|
+
feedKeys: this._feedProvider.getFeeds().length, // TODO(burdon): feeds.
|
|
85
85
|
timeframe: this.isOpen ? this._partyCore.timeframe : undefined,
|
|
86
86
|
properties: this.isOpen ? this.getPropertiesSet().expectOne().model.toObject() : undefined
|
|
87
87
|
};
|
|
@@ -13,12 +13,13 @@ import {
|
|
|
13
13
|
SecretProvider,
|
|
14
14
|
wrapMessage
|
|
15
15
|
} from '@dxos/credentials';
|
|
16
|
-
import { humanize, keyToString
|
|
16
|
+
import { humanize, keyToString } from '@dxos/crypto';
|
|
17
17
|
import { failUndefined, raise, timed } from '@dxos/debug';
|
|
18
18
|
import { createFeedWriter, FeedMessage, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
19
19
|
import { ModelFactory } from '@dxos/model-factory';
|
|
20
20
|
import { NetworkManager } from '@dxos/network-manager';
|
|
21
21
|
import { ObjectModel } from '@dxos/object-model';
|
|
22
|
+
import { PublicKey } from '@dxos/protocols';
|
|
22
23
|
|
|
23
24
|
import {
|
|
24
25
|
createDataPartyAdmissionMessages,
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
SecretValidator
|
|
19
19
|
} from '@dxos/credentials';
|
|
20
20
|
import {
|
|
21
|
-
createKeyPair,
|
|
21
|
+
createKeyPair,
|
|
22
|
+
humanize,
|
|
22
23
|
randomBytes,
|
|
23
24
|
sign,
|
|
24
25
|
SIGNATURE_LENGTH, verify
|
|
@@ -29,6 +30,7 @@ import { createWritableFeedStream, FeedStore } from '@dxos/feed-store';
|
|
|
29
30
|
import { ModelFactory } from '@dxos/model-factory';
|
|
30
31
|
import { NetworkManager } from '@dxos/network-manager';
|
|
31
32
|
import { ObjectModel } from '@dxos/object-model';
|
|
33
|
+
import { PublicKey } from '@dxos/protocols';
|
|
32
34
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
33
35
|
import { afterTest, testTimeout } from '@dxos/testutils';
|
|
34
36
|
|
|
@@ -318,11 +320,11 @@ describe('Party manager', () => {
|
|
|
318
320
|
expect(members.length).toBe(2);
|
|
319
321
|
for (const member of members) {
|
|
320
322
|
if (identityA.identityKey!.publicKey.equals(member.publicKey)) {
|
|
321
|
-
expect(member.displayName).toEqual(identityA.identityKey!.publicKey
|
|
323
|
+
expect(member.displayName).toEqual(humanize(identityA.identityKey!.publicKey));
|
|
322
324
|
expect(member.displayName).toEqual(identityA.displayName);
|
|
323
325
|
}
|
|
324
326
|
if (identityB.identityKey!.publicKey.equals(member.publicKey)) {
|
|
325
|
-
expect(member.displayName).toEqual(identityB.identityKey!.publicKey
|
|
327
|
+
expect(member.displayName).toEqual(humanize(identityB.identityKey!.publicKey));
|
|
326
328
|
expect(member.displayName).toEqual(identityB.displayName);
|
|
327
329
|
}
|
|
328
330
|
}
|
|
@@ -399,10 +401,10 @@ describe('Party manager', () => {
|
|
|
399
401
|
expect(members.length).toBe(2);
|
|
400
402
|
for (const member of members) {
|
|
401
403
|
if (identityA.identityKey!.publicKey.equals(member.publicKey)) {
|
|
402
|
-
expect(member.displayName).toEqual(identityA.identityKey!.publicKey
|
|
404
|
+
expect(member.displayName).toEqual(humanize(identityA.identityKey!.publicKey));
|
|
403
405
|
}
|
|
404
406
|
if (identityB.identityKey!.publicKey.equals(member.publicKey)) {
|
|
405
|
-
expect(member.displayName).toEqual(identityB.identityKey!.publicKey
|
|
407
|
+
expect(member.displayName).toEqual(humanize(identityB.identityKey!.publicKey));
|
|
406
408
|
}
|
|
407
409
|
}
|
|
408
410
|
}
|
|
@@ -456,11 +458,11 @@ describe('Party manager', () => {
|
|
|
456
458
|
expect(members.length).toBe(2);
|
|
457
459
|
for (const member of members) {
|
|
458
460
|
if (identityA.identityKey!.publicKey.equals(member.publicKey)) {
|
|
459
|
-
expect(member.displayName).toEqual(identityA.identityKey!.publicKey
|
|
461
|
+
expect(member.displayName).toEqual(humanize(identityA.identityKey!.publicKey));
|
|
460
462
|
expect(member.displayName).toEqual(identityA.displayName);
|
|
461
463
|
}
|
|
462
464
|
if (identityB.identityKey!.publicKey.equals(member.publicKey)) {
|
|
463
|
-
expect(member.displayName).toEqual(identityB.identityKey!.publicKey
|
|
465
|
+
expect(member.displayName).toEqual(humanize(identityB.identityKey!.publicKey));
|
|
464
466
|
expect(member.displayName).toEqual(identityB.displayName);
|
|
465
467
|
}
|
|
466
468
|
}
|
|
@@ -8,9 +8,9 @@ import unionWith from 'lodash.unionwith';
|
|
|
8
8
|
|
|
9
9
|
import { Event, synchronized } from '@dxos/async';
|
|
10
10
|
import { KeyHint, KeyType, SecretProvider } from '@dxos/credentials';
|
|
11
|
-
import { PublicKey } from '@dxos/crypto';
|
|
12
11
|
import { failUndefined, timed } from '@dxos/debug';
|
|
13
12
|
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
13
|
+
import { PublicKey } from '@dxos/protocols';
|
|
14
14
|
import { ComplexMap, boolGuard } from '@dxos/util';
|
|
15
15
|
|
|
16
16
|
import { InvitationDescriptor } from '../invitations';
|
|
@@ -8,10 +8,11 @@ import { it as test } from 'mocha';
|
|
|
8
8
|
|
|
9
9
|
import { waitForCondition, latch } from '@dxos/async';
|
|
10
10
|
import { createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
11
|
-
import { createId, createKeyPair
|
|
11
|
+
import { createId, createKeyPair } from '@dxos/crypto';
|
|
12
12
|
import { codec, createFeedWriter, FeedSelector, FeedStoreIterator, IEchoStream, Timeframe } from '@dxos/echo-protocol';
|
|
13
13
|
import { FeedStore, createWritableFeedStream } from '@dxos/feed-store';
|
|
14
14
|
import { createSetPropertyMutation } from '@dxos/model-factory';
|
|
15
|
+
import { PublicKey } from '@dxos/protocols';
|
|
15
16
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
16
17
|
import { jsonReplacer } from '@dxos/util';
|
|
17
18
|
|
|
@@ -7,11 +7,12 @@ import debug from 'debug';
|
|
|
7
7
|
|
|
8
8
|
import { Event } from '@dxos/async';
|
|
9
9
|
import { Message as HaloMessage } from '@dxos/credentials';
|
|
10
|
-
import { keyToString
|
|
10
|
+
import { keyToString } from '@dxos/crypto';
|
|
11
11
|
import { checkType } from '@dxos/debug';
|
|
12
12
|
import {
|
|
13
13
|
createFeedMeta, EchoEnvelope, FeedMessage, FeedStoreIterator, FeedWriter, IEchoStream, mapFeedWriter, Timeframe
|
|
14
14
|
} from '@dxos/echo-protocol';
|
|
15
|
+
import { PublicKey } from '@dxos/protocols';
|
|
15
16
|
import { jsonReplacer } from '@dxos/util';
|
|
16
17
|
|
|
17
18
|
import { EchoProcessor, TimeframeClock } from '../packlets/database';
|
|
@@ -6,8 +6,8 @@ import assert from 'assert';
|
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
|
|
8
8
|
import { getPartyCredentialMessageType, PartyCredential } from '@dxos/credentials';
|
|
9
|
-
import { PublicKey } from '@dxos/crypto';
|
|
10
9
|
import { MessageSelector } from '@dxos/echo-protocol';
|
|
10
|
+
import { PublicKey } from '@dxos/protocols';
|
|
11
11
|
|
|
12
12
|
import { TimeframeClock } from '../packlets/database';
|
|
13
13
|
import { PartyStateProvider } from './party-processor';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
|
|
7
|
-
import { PublicKey } from '@dxos/
|
|
7
|
+
import { PublicKey } from '@dxos/protocols';
|
|
8
8
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
9
9
|
|
|
10
10
|
import { MetadataStore } from './metadata-store';
|
|
@@ -76,4 +76,21 @@ describe('MetadataStore in-memory', () => {
|
|
|
76
76
|
await store.clear();
|
|
77
77
|
expect(store.parties?.length).toEqual(0);
|
|
78
78
|
});
|
|
79
|
+
|
|
80
|
+
it('not corrupted', async () => {
|
|
81
|
+
const storage = createStorage('', StorageType.RAM);
|
|
82
|
+
const dir = storage.directory('metadata');
|
|
83
|
+
const metadataStore = new MetadataStore(dir);
|
|
84
|
+
|
|
85
|
+
// writing something in metadataStore to save.
|
|
86
|
+
await metadataStore.setDataFeed(PublicKey.random(), PublicKey.random());
|
|
87
|
+
await metadataStore.setDataFeed(PublicKey.random(), PublicKey.random());
|
|
88
|
+
await metadataStore.setDataFeed(PublicKey.random(), PublicKey.random());
|
|
89
|
+
|
|
90
|
+
// using same directory to test if truncates.
|
|
91
|
+
const metadataStore2 = new MetadataStore(dir);
|
|
92
|
+
// should owerride previous data.
|
|
93
|
+
await metadataStore2.setDataFeed(PublicKey.random(), PublicKey.random());
|
|
94
|
+
await metadataStore2.load();
|
|
95
|
+
});
|
|
79
96
|
});
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { synchronized } from '@dxos/async';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
10
10
|
import { EchoMetadata, PartyMetadata, schema, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { PublicKey } from '@dxos/protocols';
|
|
11
12
|
import { Directory } from '@dxos/random-access-multi-storage';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -46,6 +47,7 @@ export class MetadataStore {
|
|
|
46
47
|
/**
|
|
47
48
|
* Loads metadata from persistent storage.
|
|
48
49
|
*/
|
|
50
|
+
@synchronized
|
|
49
51
|
async load (): Promise<void> {
|
|
50
52
|
const file = this._directory.createOrOpen('EchoMetadata');
|
|
51
53
|
try {
|
|
@@ -67,6 +69,7 @@ export class MetadataStore {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
@synchronized
|
|
70
73
|
private async _save (): Promise<void> {
|
|
71
74
|
const data: EchoMetadata = {
|
|
72
75
|
...this._metadata,
|
|
@@ -80,6 +83,21 @@ export class MetadataStore {
|
|
|
80
83
|
try {
|
|
81
84
|
const encoded = Buffer.from(schema.getCodecForType('dxos.echo.metadata.EchoMetadata').encode(data));
|
|
82
85
|
await file.write(0, encoded);
|
|
86
|
+
|
|
87
|
+
// Truncate the rest of the file.
|
|
88
|
+
{
|
|
89
|
+
const { size } = await file.stat();
|
|
90
|
+
if (size > encoded.length) {
|
|
91
|
+
await file.truncate(encoded.length, size);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Sanity check.
|
|
96
|
+
const { size } = await file.stat();
|
|
97
|
+
if (size !== encoded.length) {
|
|
98
|
+
console.log('SANITY!');
|
|
99
|
+
}
|
|
100
|
+
assert(size === encoded.length);
|
|
83
101
|
} finally {
|
|
84
102
|
await file.close();
|
|
85
103
|
}
|
|
@@ -7,9 +7,9 @@ import debug from 'debug';
|
|
|
7
7
|
|
|
8
8
|
import { Event, synchronized } from '@dxos/async';
|
|
9
9
|
import { Keyring, KeyType } from '@dxos/credentials';
|
|
10
|
-
import { PublicKey } from '@dxos/crypto';
|
|
11
10
|
import { FeedSelector, FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
12
11
|
import { FeedDescriptor, FeedStore } from '@dxos/feed-store';
|
|
12
|
+
import { PublicKey } from '@dxos/protocols';
|
|
13
13
|
import { ComplexMap } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { MetadataStore } from './metadata-store';
|
|
@@ -7,13 +7,14 @@ import { it as test } from 'mocha';
|
|
|
7
7
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
|
-
import { createId
|
|
10
|
+
import { createId } from '@dxos/crypto';
|
|
11
11
|
import { checkType } from '@dxos/debug';
|
|
12
12
|
import { codec, FeedMessage, Timeframe } from '@dxos/echo-protocol';
|
|
13
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
14
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
15
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
16
16
|
import { ObjectModel } from '@dxos/object-model';
|
|
17
|
+
import { PublicKey } from '@dxos/protocols';
|
|
17
18
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
18
19
|
import { afterTest } from '@dxos/testutils';
|
|
19
20
|
|
|
@@ -6,10 +6,10 @@ import assert from 'assert';
|
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
8
|
import { KeyType, Message as HaloMessage } from '@dxos/credentials';
|
|
9
|
-
import { PublicKey } from '@dxos/crypto';
|
|
10
9
|
import { timed } from '@dxos/debug';
|
|
11
10
|
import { createFeedWriter, DatabaseSnapshot, FeedSelector, FeedWriter, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
12
|
+
import { PublicKey } from '@dxos/protocols';
|
|
13
13
|
import { SubscriptionGroup } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { createMessageSelector, PartyProcessor, PartyFeedProvider, FeedMuxer } from '.';
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
PartyEventType,
|
|
16
16
|
SignedMessage
|
|
17
17
|
} from '@dxos/credentials';
|
|
18
|
-
import { PublicKey } from '@dxos/crypto';
|
|
19
18
|
import { FeedKey, IHaloStream, PartyKey, HaloStateSnapshot } from '@dxos/echo-protocol';
|
|
19
|
+
import { PublicKey } from '@dxos/protocols';
|
|
20
20
|
import { jsonReplacer } from '@dxos/util';
|
|
21
21
|
|
|
22
22
|
const log = debug('dxos:echo-db:party-processor');
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Authenticator, AuthPlugin } from '@dxos/credentials';
|
|
6
|
-
import { PublicKey } from '@dxos/crypto';
|
|
7
6
|
import { Replicator } from '@dxos/protocol-plugin-replicator';
|
|
7
|
+
import { PublicKey } from '@dxos/protocols';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates authenticator network-protocol plugin that guards access to the replicator.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createIdentityInfoMessage, createKeyAdmitMessage, createPartyGenesisMessage, KeyChain, KeyRecord, Keyring, KeyType, SignedMessage } from '@dxos/credentials';
|
|
6
|
+
import { humanize } from '@dxos/crypto';
|
|
6
7
|
|
|
7
8
|
import { ContactManager, Preferences } from '../halo';
|
|
8
9
|
import { CredentialsSigner } from './credentials-signer';
|
|
@@ -38,7 +39,7 @@ export const createTestIdentityCredentials = async (keyring: Keyring): Promise<I
|
|
|
38
39
|
messageMap.set(deviceKey.publicKey.toHex(), partyGenesis);
|
|
39
40
|
const deviceKeyChain = Keyring.buildKeyChain(deviceKey.publicKey, messageMap, [feedKey.publicKey]);
|
|
40
41
|
|
|
41
|
-
const displayName = identityKey.publicKey
|
|
42
|
+
const displayName = humanize(identityKey.publicKey);
|
|
42
43
|
const identityInfo = createIdentityInfoMessage(keyring, displayName, identityKey);
|
|
43
44
|
|
|
44
45
|
return {
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
|
|
7
|
-
import { discoveryKey, keyToString
|
|
7
|
+
import { discoveryKey, keyToString } from '@dxos/crypto';
|
|
8
8
|
import { PartyKey } from '@dxos/echo-protocol';
|
|
9
9
|
import { Protocol } from '@dxos/mesh-protocol';
|
|
10
10
|
import { MMSTTopology, NetworkManager, Plugin } from '@dxos/network-manager';
|
|
11
11
|
import { PresencePlugin } from '@dxos/protocol-plugin-presence';
|
|
12
|
+
import { PublicKey } from '@dxos/protocols';
|
|
12
13
|
|
|
13
14
|
import { CredentialsProvider } from '.';
|
|
14
15
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
|
|
7
|
+
import { humanize } from '@dxos/crypto';
|
|
8
|
+
|
|
7
9
|
import { TimeframeClock } from '../packlets/database';
|
|
8
10
|
import { PartyPipeline } from '../pipeline';
|
|
9
11
|
import { SnapshotStore } from './snapshot-store';
|
|
@@ -13,7 +15,7 @@ const log = debug('dxos:snapshot-generator');
|
|
|
13
15
|
export const createAutomaticSnapshots = (party: PartyPipeline, clock: TimeframeClock, store: SnapshotStore, interval: number) => clock.update.on(async timeframe => {
|
|
14
16
|
const totalMessages = timeframe.totalMessages();
|
|
15
17
|
if (totalMessages > 0 && totalMessages % interval === 0) {
|
|
16
|
-
log(`Saving snapshot of ${party.key
|
|
18
|
+
log(`Saving snapshot of ${humanize(party.key)}...`);
|
|
17
19
|
try {
|
|
18
20
|
const snapshot = party.createSnapshot();
|
|
19
21
|
await store.save(snapshot);
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
|
-
import { createId, createKeyPair
|
|
8
|
+
import { createId, createKeyPair } from '@dxos/crypto';
|
|
9
9
|
import { PartySnapshot } from '@dxos/echo-protocol';
|
|
10
|
+
import { PublicKey } from '@dxos/protocols';
|
|
10
11
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
11
12
|
|
|
12
13
|
import { SnapshotStore } from './snapshot-store';
|
|
@@ -7,10 +7,10 @@ import expect from 'expect';
|
|
|
7
7
|
import { it as test } from 'mocha';
|
|
8
8
|
|
|
9
9
|
import { waitForCondition } from '@dxos/async';
|
|
10
|
-
import { PublicKey } from '@dxos/crypto';
|
|
11
10
|
import { schema, ItemID, MockFeedWriter, PartyKey } from '@dxos/echo-protocol';
|
|
12
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
12
|
import { ObjectModel, ValueUtil } from '@dxos/object-model';
|
|
13
|
+
import { PublicKey } from '@dxos/protocols';
|
|
14
14
|
|
|
15
15
|
import { ItemDemuxer, ItemManager } from '../packlets/database';
|
|
16
16
|
import { createTestInstance } from '../testing';
|