@dxos/echo-db 2.33.9-dev.e605934d → 2.33.9-dev.eb69ac10
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 +3 -3
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/halo-factory.js +8 -8
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.js +3 -3
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.js +9 -9
- package/dist/src/halo/halo.js.map +1 -1
- package/dist/src/halo/identity-manager.js +6 -6
- 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/preferences.js +6 -6
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +6 -6
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-responder.js +5 -5
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +6 -6
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +9 -9
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.js +3 -3
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +7 -7
- 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-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-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/parties/data-party.js +11 -11
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/party-factory.js +4 -4
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.js +6 -6
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +6 -6
- 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.js +3 -3
- package/dist/src/pipeline/feed-muxer.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.test.js +4 -2
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.js +2 -2
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +35 -32
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +3 -3
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.js +13 -13
- package/dist/src/pipeline/party-pipeline.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/snapshots/snapshot-store.js +2 -2
- package/dist/src/snapshots/snapshot-store.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.test.js +5 -1
- package/dist/src/snapshots/snapshot-store.test.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 +21 -17
- package/src/api/result-set.ts +1 -1
- package/src/echo.test.ts +2 -2
- package/src/echo.ts +1 -1
- package/src/halo/halo-factory.ts +1 -1
- package/src/halo/halo-party.ts +1 -1
- package/src/halo/halo.ts +1 -1
- package/src/halo/identity-manager.ts +1 -1
- package/src/halo/identity.ts +1 -1
- package/src/halo/preferences.ts +1 -1
- package/src/invitations/greeting-initiator.ts +1 -1
- package/src/invitations/greeting-responder.ts +1 -1
- package/src/invitations/halo-recovery-initiator.ts +1 -1
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +1 -1
- package/src/invitations/offline-invitation-claimer.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/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.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/parties/data-party.ts +1 -1
- package/src/parties/party-factory.ts +1 -1
- package/src/parties/party-manager.test.ts +1 -1
- package/src/parties/party-manager.ts +1 -1
- package/src/parties/party-preferences.ts +1 -1
- package/src/pipeline/feed-muxer.test.ts +4 -2
- package/src/pipeline/feed-muxer.ts +1 -1
- package/src/pipeline/message-selector.ts +1 -1
- package/src/pipeline/metadata-store.ts +38 -29
- package/src/pipeline/party-feed-provider.ts +1 -1
- package/src/pipeline/party-pipeline.ts +1 -1
- package/src/pipeline/party-processor.ts +1 -1
- package/src/protocol/authenticator.test.ts +102 -17
- package/src/snapshots/snapshot-store.test.ts +5 -1
- package/src/snapshots/snapshot-store.ts +1 -1
- package/src/testing/testing-factories.ts +1 -1
package/package.json
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-db",
|
|
3
|
-
"version": "2.33.9-dev.
|
|
3
|
+
"version": "2.33.9-dev.eb69ac10",
|
|
4
4
|
"description": "ECHO database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|
|
8
|
+
"browser": {
|
|
9
|
+
"node:assert": "assert"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
12
|
"dist",
|
|
10
13
|
"src"
|
|
11
14
|
],
|
|
12
15
|
"dependencies": {
|
|
13
|
-
"@dxos/async": "2.33.9-dev.
|
|
14
|
-
"@dxos/codec-protobuf": "2.33.9-dev.
|
|
15
|
-
"@dxos/credentials": "2.33.9-dev.
|
|
16
|
-
"@dxos/crypto": "2.33.9-dev.
|
|
17
|
-
"@dxos/debug": "2.33.9-dev.
|
|
18
|
-
"@dxos/echo-protocol": "2.33.9-dev.
|
|
19
|
-
"@dxos/feed-store": "2.33.9-dev.
|
|
20
|
-
"@dxos/mesh-protocol": "2.33.9-dev.
|
|
21
|
-
"@dxos/model-factory": "2.33.9-dev.
|
|
22
|
-
"@dxos/network-manager": "2.33.9-dev.
|
|
23
|
-
"@dxos/object-model": "2.33.9-dev.
|
|
24
|
-
"@dxos/protocol-plugin-presence": "2.33.9-dev.
|
|
25
|
-
"@dxos/protocol-plugin-replicator": "2.33.9-dev.
|
|
26
|
-
"@dxos/protocols": "2.33.9-dev.
|
|
27
|
-
"@dxos/random-access-multi-storage": "2.33.9-dev.
|
|
28
|
-
"@dxos/util": "2.33.9-dev.
|
|
16
|
+
"@dxos/async": "2.33.9-dev.eb69ac10",
|
|
17
|
+
"@dxos/codec-protobuf": "2.33.9-dev.eb69ac10",
|
|
18
|
+
"@dxos/credentials": "2.33.9-dev.eb69ac10",
|
|
19
|
+
"@dxos/crypto": "2.33.9-dev.eb69ac10",
|
|
20
|
+
"@dxos/debug": "2.33.9-dev.eb69ac10",
|
|
21
|
+
"@dxos/echo-protocol": "2.33.9-dev.eb69ac10",
|
|
22
|
+
"@dxos/feed-store": "2.33.9-dev.eb69ac10",
|
|
23
|
+
"@dxos/mesh-protocol": "2.33.9-dev.eb69ac10",
|
|
24
|
+
"@dxos/model-factory": "2.33.9-dev.eb69ac10",
|
|
25
|
+
"@dxos/network-manager": "2.33.9-dev.eb69ac10",
|
|
26
|
+
"@dxos/object-model": "2.33.9-dev.eb69ac10",
|
|
27
|
+
"@dxos/protocol-plugin-presence": "2.33.9-dev.eb69ac10",
|
|
28
|
+
"@dxos/protocol-plugin-replicator": "2.33.9-dev.eb69ac10",
|
|
29
|
+
"@dxos/protocols": "2.33.9-dev.eb69ac10",
|
|
30
|
+
"@dxos/random-access-multi-storage": "2.33.9-dev.eb69ac10",
|
|
31
|
+
"@dxos/util": "2.33.9-dev.eb69ac10",
|
|
32
|
+
"assert": "^2.0.0",
|
|
29
33
|
"base-x": "~3.0.9",
|
|
30
34
|
"buffer-json-encoding": "^1.0.2",
|
|
31
35
|
"debug": "^4.3.3",
|
package/src/api/result-set.ts
CHANGED
package/src/echo.test.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
7
6
|
import expect from 'expect';
|
|
8
7
|
import { it as test } from 'mocha';
|
|
8
|
+
import assert from 'node:assert';
|
|
9
9
|
|
|
10
10
|
import { latch, promiseTimeout, waitForCondition } from '@dxos/async';
|
|
11
11
|
import {
|
|
@@ -374,7 +374,7 @@ describe('ECHO', () => {
|
|
|
374
374
|
|
|
375
375
|
}).timeout(10_000);
|
|
376
376
|
|
|
377
|
-
test
|
|
377
|
+
test('3 devices', async () => {
|
|
378
378
|
const a = await setup({ createProfile: true });
|
|
379
379
|
const b = await setup();
|
|
380
380
|
|
package/src/echo.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import debug from 'debug';
|
|
7
6
|
import memdown from 'memdown';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
8
|
|
|
9
9
|
import { synchronized } from '@dxos/async';
|
|
10
10
|
import { Keyring, KeyStore, SecretProvider } from '@dxos/credentials';
|
package/src/halo/halo-factory.ts
CHANGED
package/src/halo/halo-party.ts
CHANGED
package/src/halo/halo.ts
CHANGED
|
@@ -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 { Event, synchronized, waitForCondition } from '@dxos/async';
|
|
9
9
|
import { Filter, KeyRecord, Keyring, KeyType, SecretProvider } from '@dxos/credentials';
|
package/src/halo/identity.ts
CHANGED
|
@@ -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 { Filter, KeyChain, KeyRecord, Keyring, KeyType, SignedMessage, Signer } from '@dxos/credentials';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
package/src/halo/preferences.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
6
5
|
import stableStringify from 'json-stable-stringify';
|
|
7
6
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
8
|
|
|
9
9
|
import { Event } from '@dxos/async';
|
|
10
10
|
import { raise } from '@dxos/debug';
|
|
@@ -2,9 +2,9 @@
|
|
|
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
9
|
import { ripemd160 } from '@dxos/crypto';
|
|
10
10
|
import { SwarmKey } from '@dxos/echo-protocol';
|
|
@@ -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';
|
|
@@ -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 {
|
|
@@ -2,9 +2,9 @@
|
|
|
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
10
|
import { SecretProvider } from '@dxos/credentials';
|
|
@@ -128,7 +128,8 @@ describe('FeedMuxer', () => {
|
|
|
128
128
|
await pipeline.outboundEchoStream!.write({
|
|
129
129
|
itemId: '123',
|
|
130
130
|
genesis: {
|
|
131
|
-
itemType: 'foo'
|
|
131
|
+
itemType: 'foo',
|
|
132
|
+
modelType: 'bar'
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
135
|
|
|
@@ -138,7 +139,8 @@ describe('FeedMuxer', () => {
|
|
|
138
139
|
expect((echoMessages[0] as any).data).toEqual({
|
|
139
140
|
itemId: '123',
|
|
140
141
|
genesis: {
|
|
141
|
-
itemType: 'foo'
|
|
142
|
+
itemType: 'foo',
|
|
143
|
+
modelType: 'bar'
|
|
142
144
|
}
|
|
143
145
|
});
|
|
144
146
|
});
|
|
@@ -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 { synchronized } from '@dxos/async';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
@@ -25,13 +25,15 @@ export interface AddPartyOptions {
|
|
|
25
25
|
genesisFeed: PublicKey
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const emptyEchoMetadata = (): EchoMetadata => ({
|
|
29
|
+
version: STORAGE_VERSION,
|
|
30
|
+
parties: [],
|
|
31
|
+
created: new Date(),
|
|
32
|
+
updated: new Date()
|
|
33
|
+
});
|
|
34
|
+
|
|
28
35
|
export class MetadataStore {
|
|
29
|
-
private _metadata: EchoMetadata =
|
|
30
|
-
version: STORAGE_VERSION,
|
|
31
|
-
parties: [],
|
|
32
|
-
created: new Date(),
|
|
33
|
-
updated: new Date()
|
|
34
|
-
};
|
|
36
|
+
private _metadata: EchoMetadata = emptyEchoMetadata();
|
|
35
37
|
|
|
36
38
|
constructor (
|
|
37
39
|
private readonly _directory: Directory
|
|
@@ -56,19 +58,26 @@ export class MetadataStore {
|
|
|
56
58
|
async load (): Promise<void> {
|
|
57
59
|
const file = this._directory.createOrOpen('EchoMetadata');
|
|
58
60
|
try {
|
|
59
|
-
const { size } = await file.stat();
|
|
60
|
-
if (
|
|
61
|
+
const { size: fileLength } = await file.stat();
|
|
62
|
+
if (fileLength < 4) {
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
65
|
+
// Loading file size from first 4 bytes.
|
|
66
|
+
const dataSize = fromBytesInt32(await file.read(0, 4));
|
|
67
|
+
log(`Load: data size ${dataSize}`);
|
|
68
|
+
|
|
69
|
+
// Sanity check.
|
|
70
|
+
{
|
|
71
|
+
if (fileLength < dataSize + 4) {
|
|
72
|
+
throw new Error('Metadata storage is corrupted');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
63
75
|
|
|
64
|
-
const data = await file.read(
|
|
76
|
+
const data = await file.read(4, dataSize);
|
|
65
77
|
this._metadata = schema.getCodecForType('dxos.echo.metadata.EchoMetadata').decode(data);
|
|
66
78
|
} catch (err: any) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} else {
|
|
70
|
-
throw err;
|
|
71
|
-
}
|
|
79
|
+
log(`Error loading metadata: ${err}`);
|
|
80
|
+
this._metadata = emptyEchoMetadata();
|
|
72
81
|
} finally {
|
|
73
82
|
await file.close();
|
|
74
83
|
}
|
|
@@ -87,22 +96,14 @@ export class MetadataStore {
|
|
|
87
96
|
|
|
88
97
|
try {
|
|
89
98
|
const encoded = Buffer.from(schema.getCodecForType('dxos.echo.metadata.EchoMetadata').encode(data));
|
|
90
|
-
await file.write(0, encoded);
|
|
91
99
|
|
|
92
|
-
//
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
100
|
+
// Saving file size at first 4 bytes.
|
|
101
|
+
log(`Save: data size ${encoded.length}`);
|
|
102
|
+
await file.write(0, toBytesInt32(encoded.length));
|
|
103
|
+
|
|
104
|
+
// Saving data.
|
|
105
|
+
await file.write(4, encoded);
|
|
99
106
|
|
|
100
|
-
// Sanity check.
|
|
101
|
-
const { size } = await file.stat();
|
|
102
|
-
if (size !== encoded.length) {
|
|
103
|
-
console.log('SANITY!');
|
|
104
|
-
}
|
|
105
|
-
assert(size === encoded.length);
|
|
106
107
|
} finally {
|
|
107
108
|
await file.close();
|
|
108
109
|
}
|
|
@@ -196,3 +197,11 @@ export class MetadataStore {
|
|
|
196
197
|
await this._save();
|
|
197
198
|
}
|
|
198
199
|
}
|
|
200
|
+
|
|
201
|
+
const toBytesInt32 = (num: number) => {
|
|
202
|
+
const buf = Buffer.alloc(4);
|
|
203
|
+
buf.writeInt32LE(num, 0);
|
|
204
|
+
return buf;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const fromBytesInt32 = (buf: Buffer) => buf.readInt32LE(0);
|