@dxos/client-services 0.6.12 → 0.6.13-main.548ca8d
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/lib/browser/{chunk-TOAILL4T.mjs → chunk-UEQIHAL2.mjs} +5838 -5151
- package/dist/lib/browser/chunk-UEQIHAL2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +8 -7
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-H6C4XY6B.cjs → chunk-MA5EWTRH.cjs} +5858 -5175
- package/dist/lib/node/chunk-MA5EWTRH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +46 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +14 -13
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/chunk-AIBLDI4U.mjs +8403 -0
- package/dist/lib/node-esm/chunk-AIBLDI4U.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +416 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/testing/index.mjs +420 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts +2 -0
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +19 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +8 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +30 -0
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +2 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts +2 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts +19 -0
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -8
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +9 -9
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +6 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +3 -0
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.test.d.ts +2 -0
- package/dist/types/src/packlets/spaces/edge-feed-replicator.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +31 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/testing/setup.d.ts +3 -0
- package/dist/types/src/testing/setup.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +43 -39
- package/src/packlets/devices/devices-service.test.ts +4 -5
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -0
- package/src/packlets/identity/{authenticator.test.ts → authenticator.node.test.ts} +2 -3
- package/src/packlets/identity/authenticator.ts +5 -2
- package/src/packlets/identity/contacts-service.ts +1 -1
- package/src/packlets/identity/identity-manager.test.ts +5 -6
- package/src/packlets/identity/identity-manager.ts +35 -19
- package/src/packlets/identity/identity-service.test.ts +4 -8
- package/src/packlets/identity/identity.test.ts +128 -239
- package/src/packlets/identity/identity.ts +42 -8
- package/src/packlets/invitations/device-invitation-protocol.test.ts +7 -4
- package/src/packlets/invitations/edge-invitation-handler.ts +184 -0
- package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -4
- package/src/packlets/invitations/invitation-host-extension.ts +8 -7
- package/src/packlets/invitations/invitation-state.ts +111 -0
- package/src/packlets/invitations/invitations-handler.test.ts +16 -9
- package/src/packlets/invitations/invitations-handler.ts +23 -92
- package/src/packlets/invitations/space-invitation-protocol.test.ts +4 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +4 -0
- package/src/packlets/logging/logging.test.ts +1 -2
- package/src/packlets/network/network-service.test.ts +2 -3
- package/src/packlets/services/service-context.test.ts +3 -1
- package/src/packlets/services/service-context.ts +68 -31
- package/src/packlets/services/service-host.test.ts +8 -12
- package/src/packlets/services/service-host.ts +8 -6
- package/src/packlets/services/service-registry.test.ts +1 -2
- package/src/packlets/spaces/data-space-manager.test.ts +2 -2
- package/src/packlets/spaces/data-space-manager.ts +40 -5
- package/src/packlets/spaces/data-space.ts +34 -6
- package/src/packlets/spaces/edge-feed-replicator.test.ts +253 -0
- package/src/packlets/spaces/edge-feed-replicator.ts +80 -22
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +10 -7
- package/src/packlets/spaces/notarization-plugin.ts +169 -29
- package/src/packlets/spaces/spaces-service.test.ts +5 -9
- package/src/packlets/spaces/spaces-service.ts +6 -1
- package/src/packlets/storage/storage.ts +0 -1
- package/src/packlets/system/system-service.test.ts +1 -2
- package/src/packlets/testing/test-builder.ts +3 -4
- package/src/packlets/worker/worker-runtime.ts +2 -2
- package/src/testing/setup.ts +11 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-TOAILL4T.mjs.map +0 -7
- package/dist/lib/node/chunk-H6C4XY6B.cjs.map +0 -7
- package/dist/types/src/packlets/identity/authenticator.test.d.ts +0 -2
- package/dist/types/src/packlets/identity/authenticator.test.d.ts.map +0 -1
- package/dist/types/src/packlets/services/automerge-host.test.d.ts +0 -2
- package/dist/types/src/packlets/services/automerge-host.test.d.ts.map +0 -1
- package/src/packlets/services/automerge-host.test.ts +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13-main.548ca8d",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,14 +10,16 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
12
|
"node": {
|
|
13
|
-
"
|
|
13
|
+
"require": "./dist/lib/node/index.cjs",
|
|
14
|
+
"default": "./dist/lib/node-esm/index.mjs"
|
|
14
15
|
},
|
|
15
16
|
"types": "./dist/types/src/index.d.ts"
|
|
16
17
|
},
|
|
17
18
|
"./testing": {
|
|
18
19
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
19
20
|
"node": {
|
|
20
|
-
"
|
|
21
|
+
"require": "./dist/lib/node/testing/index.cjs",
|
|
22
|
+
"default": "./dist/lib/node-esm/testing/index.mjs"
|
|
21
23
|
},
|
|
22
24
|
"types": "./dist/types/src/testing/index.d.ts"
|
|
23
25
|
}
|
|
@@ -45,46 +47,48 @@
|
|
|
45
47
|
"dependencies": {
|
|
46
48
|
"cbor-x": "^1.5.4",
|
|
47
49
|
"platform": "^1.3.6",
|
|
48
|
-
"@dxos/async": "0.6.
|
|
49
|
-
"@dxos/automerge": "0.6.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/echo-db": "0.6.
|
|
58
|
-
"@dxos/echo-pipeline": "0.6.
|
|
59
|
-
"@dxos/echo-
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/indexing": "0.6.
|
|
64
|
-
"@dxos/invariant": "0.6.
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/kv-store": "0.6.
|
|
68
|
-
"@dxos/lock-file": "0.6.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/protocols": "0.6.
|
|
74
|
-
"@dxos/rpc": "0.6.
|
|
75
|
-
"@dxos/random-access-storage": "0.6.
|
|
76
|
-
"@dxos/teleport": "0.6.
|
|
77
|
-
"@dxos/teleport-extension-gossip": "0.6.
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/tracing": "0.6.
|
|
81
|
-
"@dxos/util": "0.6.
|
|
82
|
-
"@dxos/websocket-rpc": "0.6.
|
|
50
|
+
"@dxos/async": "0.6.13-main.548ca8d",
|
|
51
|
+
"@dxos/automerge": "0.6.13-main.548ca8d",
|
|
52
|
+
"@dxos/client-protocol": "0.6.13-main.548ca8d",
|
|
53
|
+
"@dxos/codec-protobuf": "0.6.13-main.548ca8d",
|
|
54
|
+
"@dxos/config": "0.6.13-main.548ca8d",
|
|
55
|
+
"@dxos/credentials": "0.6.13-main.548ca8d",
|
|
56
|
+
"@dxos/crypto": "0.6.13-main.548ca8d",
|
|
57
|
+
"@dxos/context": "0.6.13-main.548ca8d",
|
|
58
|
+
"@dxos/debug": "0.6.13-main.548ca8d",
|
|
59
|
+
"@dxos/echo-db": "0.6.13-main.548ca8d",
|
|
60
|
+
"@dxos/echo-pipeline": "0.6.13-main.548ca8d",
|
|
61
|
+
"@dxos/echo-schema": "0.6.13-main.548ca8d",
|
|
62
|
+
"@dxos/edge-client": "0.6.13-main.548ca8d",
|
|
63
|
+
"@dxos/feed-store": "0.6.13-main.548ca8d",
|
|
64
|
+
"@dxos/echo-protocol": "0.6.13-main.548ca8d",
|
|
65
|
+
"@dxos/indexing": "0.6.13-main.548ca8d",
|
|
66
|
+
"@dxos/invariant": "0.6.13-main.548ca8d",
|
|
67
|
+
"@dxos/keys": "0.6.13-main.548ca8d",
|
|
68
|
+
"@dxos/keyring": "0.6.13-main.548ca8d",
|
|
69
|
+
"@dxos/kv-store": "0.6.13-main.548ca8d",
|
|
70
|
+
"@dxos/lock-file": "0.6.13-main.548ca8d",
|
|
71
|
+
"@dxos/log": "0.6.13-main.548ca8d",
|
|
72
|
+
"@dxos/messaging": "0.6.13-main.548ca8d",
|
|
73
|
+
"@dxos/node-std": "0.6.13-main.548ca8d",
|
|
74
|
+
"@dxos/network-manager": "0.6.13-main.548ca8d",
|
|
75
|
+
"@dxos/protocols": "0.6.13-main.548ca8d",
|
|
76
|
+
"@dxos/rpc": "0.6.13-main.548ca8d",
|
|
77
|
+
"@dxos/random-access-storage": "0.6.13-main.548ca8d",
|
|
78
|
+
"@dxos/teleport": "0.6.13-main.548ca8d",
|
|
79
|
+
"@dxos/teleport-extension-gossip": "0.6.13-main.548ca8d",
|
|
80
|
+
"@dxos/teleport-extension-object-sync": "0.6.13-main.548ca8d",
|
|
81
|
+
"@dxos/timeframe": "0.6.13-main.548ca8d",
|
|
82
|
+
"@dxos/tracing": "0.6.13-main.548ca8d",
|
|
83
|
+
"@dxos/util": "0.6.13-main.548ca8d",
|
|
84
|
+
"@dxos/websocket-rpc": "0.6.13-main.548ca8d"
|
|
83
85
|
},
|
|
84
86
|
"devDependencies": {
|
|
85
87
|
"@types/platform": "^1.3.4",
|
|
86
88
|
"@types/readable-stream": "^2.3.9",
|
|
87
|
-
"
|
|
89
|
+
"get-port-please": "^3.1.1",
|
|
90
|
+
"@dxos/test-utils": "0.6.13-main.548ca8d",
|
|
91
|
+
"@dxos/signal": "0.6.13-main.548ca8d"
|
|
88
92
|
},
|
|
89
93
|
"publishConfig": {
|
|
90
94
|
"access": "public"
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { type DevicesService, type Device } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
12
11
|
|
|
13
12
|
import { DevicesServiceImpl } from './devices-service';
|
|
14
13
|
import { type ServiceContext } from '../services';
|
|
@@ -36,7 +35,7 @@ describe('DevicesService', () => {
|
|
|
36
35
|
query.subscribe(({ devices }) => {
|
|
37
36
|
result.wake(devices);
|
|
38
37
|
});
|
|
39
|
-
|
|
38
|
+
onTestFinished(() => query.close());
|
|
40
39
|
expect(device.profile?.label).to.equal('test-device');
|
|
41
40
|
});
|
|
42
41
|
});
|
|
@@ -51,7 +50,7 @@ describe('DevicesService', () => {
|
|
|
51
50
|
},
|
|
52
51
|
(err) => log.catch(err),
|
|
53
52
|
);
|
|
54
|
-
|
|
53
|
+
onTestFinished(() => query.close().catch((err) => log.catch(err)));
|
|
55
54
|
expect(await result.wait()).to.be.length(0);
|
|
56
55
|
});
|
|
57
56
|
|
|
@@ -61,7 +60,7 @@ describe('DevicesService', () => {
|
|
|
61
60
|
query.subscribe(({ devices }) => {
|
|
62
61
|
result.wake(devices);
|
|
63
62
|
});
|
|
64
|
-
|
|
63
|
+
onTestFinished(() => query.close());
|
|
65
64
|
expect(await result.wait()).to.be.length(0);
|
|
66
65
|
|
|
67
66
|
result = new Trigger<Device[] | undefined>();
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import expect from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { createCredentialSignerWithKey } from '@dxos/credentials';
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { Keyring } from '@dxos/keyring';
|
|
11
11
|
import { PublicKey } from '@dxos/keys';
|
|
12
|
-
import { describe, test } from '@dxos/test';
|
|
13
12
|
import { ComplexSet } from '@dxos/util';
|
|
14
13
|
|
|
15
14
|
import { createAuthProvider, TrustedKeySetAuthVerifier } from './authenticator';
|
|
@@ -30,5 +29,5 @@ describe('identity/authenticator', () => {
|
|
|
30
29
|
const credential = await authProvider(nonce);
|
|
31
30
|
invariant(credential);
|
|
32
31
|
expect(await authVerifier.verifier(nonce, credential)).toBeTruthy();
|
|
33
|
-
})
|
|
32
|
+
});
|
|
34
33
|
});
|
|
@@ -67,7 +67,7 @@ export class TrustedKeySetAuthVerifier {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (this._isTrustedKey(credential.issuer)) {
|
|
70
|
-
log('key is
|
|
70
|
+
log('key is trusted -- auth success', { key: credential.issuer });
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -81,7 +81,10 @@ export class TrustedKeySetAuthVerifier {
|
|
|
81
81
|
log('auth success', { key: credential.issuer });
|
|
82
82
|
trigger.wake(true);
|
|
83
83
|
} else {
|
|
84
|
-
log('key is not currently in trusted set, waiting...', {
|
|
84
|
+
log('key is not currently in trusted set, waiting...', {
|
|
85
|
+
key: credential.issuer,
|
|
86
|
+
trusted: [...this._params.trustedKeysProvider()],
|
|
87
|
+
});
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { EventSubscriptions, scheduleTask, UpdateScheduler } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { type MemberInfo } from '@dxos/credentials';
|
|
8
|
-
import type
|
|
8
|
+
import { type SpaceManager } from '@dxos/echo-pipeline';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { type Contact, type ContactBook, type ContactsService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
11
|
import { ComplexMap, ComplexSet } from '@dxos/util';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test, onTestFinished } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { valueEncoding, MetadataStore, SpaceManager, AuthStatus } from '@dxos/echo-pipeline';
|
|
@@ -13,7 +13,6 @@ import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manag
|
|
|
13
13
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
14
14
|
import { createStorage, type Storage, StorageType } from '@dxos/random-access-storage';
|
|
15
15
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
16
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
17
16
|
|
|
18
17
|
import { IdentityManager } from './identity-manager';
|
|
19
18
|
|
|
@@ -39,7 +38,7 @@ describe('identity/identity-manager', () => {
|
|
|
39
38
|
}),
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
onTestFinished(() => feedStore.close());
|
|
43
42
|
|
|
44
43
|
const networkManager = new SwarmNetworkManager({
|
|
45
44
|
signalManager: new MemorySignalManager(signalContext),
|
|
@@ -51,7 +50,7 @@ describe('identity/identity-manager', () => {
|
|
|
51
50
|
blobStore,
|
|
52
51
|
metadataStore,
|
|
53
52
|
});
|
|
54
|
-
const identityManager = new IdentityManager(metadataStore, keyring, feedStore, spaceManager);
|
|
53
|
+
const identityManager = new IdentityManager({ metadataStore, keyring, feedStore, spaceManager });
|
|
55
54
|
|
|
56
55
|
return {
|
|
57
56
|
metadataStore,
|
|
@@ -64,7 +63,7 @@ describe('identity/identity-manager', () => {
|
|
|
64
63
|
test('creates identity', async () => {
|
|
65
64
|
const { identityManager } = await setupPeer();
|
|
66
65
|
await identityManager.open(new Context());
|
|
67
|
-
|
|
66
|
+
onTestFinished(() => identityManager.close());
|
|
68
67
|
|
|
69
68
|
const identity = await identityManager.createIdentity();
|
|
70
69
|
expect(identity).to.exist;
|
|
@@ -95,7 +94,7 @@ describe('identity/identity-manager', () => {
|
|
|
95
94
|
test('update profile', async () => {
|
|
96
95
|
const { identityManager } = await setupPeer();
|
|
97
96
|
await identityManager.open(new Context());
|
|
98
|
-
|
|
97
|
+
onTestFinished(() => identityManager.close());
|
|
99
98
|
|
|
100
99
|
const identity = await identityManager.createIdentity();
|
|
101
100
|
expect(identity.profileDocument?.displayName).to.be.undefined;
|
|
@@ -7,6 +7,7 @@ import { Event } from '@dxos/async';
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { createCredentialSignerWithKey, CredentialGenerator } from '@dxos/credentials';
|
|
9
9
|
import { type MetadataStore, type SpaceManager, type SwarmIdentity } from '@dxos/echo-pipeline';
|
|
10
|
+
import { type EdgeConnection } from '@dxos/edge-client';
|
|
10
11
|
import { type FeedStore } from '@dxos/feed-store';
|
|
11
12
|
import { invariant } from '@dxos/invariant';
|
|
12
13
|
import { type Keyring } from '@dxos/keyring';
|
|
@@ -14,6 +15,7 @@ import { PublicKey } from '@dxos/keys';
|
|
|
14
15
|
import { log } from '@dxos/log';
|
|
15
16
|
import { trace } from '@dxos/protocols';
|
|
16
17
|
import { Device, DeviceKind } from '@dxos/protocols/proto/dxos/client/services';
|
|
18
|
+
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
17
19
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
18
20
|
import { type IdentityRecord, type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
19
21
|
import {
|
|
@@ -63,9 +65,20 @@ export type CreateIdentityOptions = {
|
|
|
63
65
|
deviceProfile?: DeviceProfileDocument;
|
|
64
66
|
};
|
|
65
67
|
|
|
66
|
-
export type
|
|
68
|
+
export type IdentityManagerCallbacks = {
|
|
69
|
+
onIdentityConstruction?: (identity: Identity) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type IdentityManagerParams = {
|
|
73
|
+
metadataStore: MetadataStore;
|
|
74
|
+
keyring: Keyring;
|
|
75
|
+
feedStore: FeedStore<FeedMessage>;
|
|
76
|
+
spaceManager: SpaceManager;
|
|
77
|
+
edgeConnection?: EdgeConnection;
|
|
78
|
+
edgeFeatures?: Runtime.Client.EdgeFeatures;
|
|
67
79
|
devicePresenceAnnounceInterval?: number;
|
|
68
80
|
devicePresenceOfflineTimeout?: number;
|
|
81
|
+
callbacks?: IdentityManagerCallbacks;
|
|
69
82
|
};
|
|
70
83
|
|
|
71
84
|
// TODO(dmaretskyi): Rename: represents the peer's state machine.
|
|
@@ -73,28 +86,29 @@ export type IdentityManagerRuntimeParams = {
|
|
|
73
86
|
export class IdentityManager {
|
|
74
87
|
readonly stateUpdate = new Event();
|
|
75
88
|
|
|
76
|
-
private
|
|
89
|
+
private readonly _metadataStore: MetadataStore;
|
|
90
|
+
private readonly _keyring: Keyring;
|
|
91
|
+
private readonly _feedStore: FeedStore<FeedMessage>;
|
|
92
|
+
private readonly _spaceManager: SpaceManager;
|
|
77
93
|
private readonly _devicePresenceAnnounceInterval: number;
|
|
78
94
|
private readonly _devicePresenceOfflineTimeout: number;
|
|
95
|
+
private readonly _edgeConnection: EdgeConnection | undefined;
|
|
96
|
+
private readonly _edgeFeatures: Runtime.Client.EdgeFeatures | undefined;
|
|
97
|
+
private readonly _callbacks: IdentityManagerCallbacks | undefined;
|
|
98
|
+
|
|
99
|
+
private _identity?: Identity;
|
|
79
100
|
|
|
80
|
-
// TODO(burdon): IdentityManagerParams.
|
|
81
101
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
82
|
-
constructor(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
params
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const {
|
|
93
|
-
devicePresenceAnnounceInterval = DEVICE_PRESENCE_ANNOUNCE_INTERVAL,
|
|
94
|
-
devicePresenceOfflineTimeout = DEVICE_PRESENCE_OFFLINE_TIMEOUT,
|
|
95
|
-
} = params ?? {};
|
|
96
|
-
this._devicePresenceAnnounceInterval = devicePresenceAnnounceInterval;
|
|
97
|
-
this._devicePresenceOfflineTimeout = devicePresenceOfflineTimeout;
|
|
102
|
+
constructor(params: IdentityManagerParams) {
|
|
103
|
+
this._metadataStore = params.metadataStore;
|
|
104
|
+
this._keyring = params.keyring;
|
|
105
|
+
this._feedStore = params.feedStore;
|
|
106
|
+
this._spaceManager = params.spaceManager;
|
|
107
|
+
this._edgeConnection = params.edgeConnection;
|
|
108
|
+
this._edgeFeatures = params.edgeFeatures;
|
|
109
|
+
this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
|
|
110
|
+
this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
|
|
111
|
+
this._callbacks = params.callbacks;
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
get identity() {
|
|
@@ -360,6 +374,8 @@ export class IdentityManager {
|
|
|
360
374
|
signer: this._keyring,
|
|
361
375
|
identityKey: identityRecord.identityKey,
|
|
362
376
|
deviceKey: identityRecord.deviceKey,
|
|
377
|
+
edgeConnection: this._edgeConnection,
|
|
378
|
+
edgeFeatures: this._edgeFeatures,
|
|
363
379
|
});
|
|
364
380
|
log('done', { identityKey: identityRecord.identityKey });
|
|
365
381
|
this._callbacks?.onIdentityConstruction?.(identity);
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { Trigger } from '@dxos/async';
|
|
9
8
|
import { Context } from '@dxos/context';
|
|
10
9
|
import { PublicKey } from '@dxos/keys';
|
|
11
10
|
import { type Identity, type IdentityService } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
13
11
|
|
|
14
12
|
import { IdentityServiceImpl } from './identity-service';
|
|
15
13
|
import { type ServiceContext } from '../services';
|
|
16
14
|
import { createServiceContext } from '../testing';
|
|
17
15
|
|
|
18
|
-
chai.use(chaiAsPromised);
|
|
19
|
-
|
|
20
16
|
describe('IdentityService', () => {
|
|
21
17
|
let serviceContext: ServiceContext;
|
|
22
18
|
let identityService: IdentityService;
|
|
@@ -49,7 +45,7 @@ describe('IdentityService', () => {
|
|
|
49
45
|
|
|
50
46
|
test('fails to create identity if one already exists', async () => {
|
|
51
47
|
await identityService.createIdentity({});
|
|
52
|
-
await expect(identityService.createIdentity({})).
|
|
48
|
+
await expect(identityService.createIdentity({})).rejects.toThrowError('Identity already exists');
|
|
53
49
|
});
|
|
54
50
|
});
|
|
55
51
|
|
|
@@ -72,7 +68,7 @@ describe('IdentityService', () => {
|
|
|
72
68
|
query.subscribe(({ identity }) => {
|
|
73
69
|
result.wake(identity);
|
|
74
70
|
});
|
|
75
|
-
|
|
71
|
+
onTestFinished(() => query.close());
|
|
76
72
|
expect(await result.wait()).to.be.undefined;
|
|
77
73
|
});
|
|
78
74
|
|
|
@@ -82,7 +78,7 @@ describe('IdentityService', () => {
|
|
|
82
78
|
query.subscribe(({ identity }) => {
|
|
83
79
|
result.wake(identity);
|
|
84
80
|
});
|
|
85
|
-
|
|
81
|
+
onTestFinished(() => query.close());
|
|
86
82
|
expect(await result.wait()).to.be.undefined;
|
|
87
83
|
|
|
88
84
|
result = new Trigger<Identity | undefined>();
|