@dxos/client-services 0.1.41 → 0.1.45-next.45667d4
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-T73F4MV4.mjs → chunk-IHSMRQ3L.mjs} +985 -867
- package/dist/lib/browser/chunk-IHSMRQ3L.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +121 -297
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +589 -469
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +688 -740
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +4 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +5 -4
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +1 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +6 -4
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -2
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +16 -9
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +12 -7
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +15 -10
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +5 -0
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +4 -4
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/index.d.ts +0 -1
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +13 -7
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +35 -32
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +5 -2
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -7
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +30 -31
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.ts +5 -5
- package/src/packlets/devtools/devtools.ts +25 -4
- package/src/packlets/devtools/feeds.ts +10 -10
- package/src/packlets/devtools/keys.ts +6 -6
- package/src/packlets/devtools/network.ts +14 -13
- package/src/packlets/devtools/spaces.ts +4 -4
- package/src/packlets/identity/authenticator.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +17 -13
- package/src/packlets/identity/identity-manager.ts +21 -22
- package/src/packlets/identity/identity-service.ts +3 -3
- package/src/packlets/identity/identity.test.ts +65 -36
- package/src/packlets/identity/identity.ts +17 -17
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +7 -7
- package/src/packlets/invitations/invitation-extension.ts +16 -27
- package/src/packlets/invitations/invitations-handler.ts +17 -25
- package/src/packlets/invitations/invitations-service.ts +11 -11
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -12
- package/src/packlets/logging/logging-service.ts +8 -3
- package/src/packlets/network/network-service.test.ts +8 -8
- package/src/packlets/network/network-service.ts +20 -8
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/local-client-services.ts +1 -1
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +26 -24
- package/src/packlets/services/service-host.test.ts +6 -6
- package/src/packlets/services/service-host.ts +57 -31
- package/src/packlets/services/service-registry.test.ts +20 -38
- package/src/packlets/spaces/data-space-manager.test.ts +17 -29
- package/src/packlets/spaces/data-space-manager.ts +29 -35
- package/src/packlets/spaces/data-space.ts +73 -47
- package/src/packlets/spaces/genesis.ts +81 -0
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +12 -12
- package/src/packlets/spaces/spaces-service.test.ts +2 -2
- package/src/packlets/spaces/spaces-service.ts +21 -10
- package/src/packlets/storage/storage.ts +3 -3
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/credential-utils.ts +4 -4
- package/src/packlets/testing/index.ts +0 -1
- package/src/packlets/testing/invitation-utils.ts +28 -33
- package/src/packlets/testing/test-builder.ts +132 -168
- package/src/packlets/vault/iframe-host-runtime.ts +8 -11
- package/src/packlets/vault/iframe-proxy-runtime.ts +25 -9
- package/src/packlets/vault/shell-runtime.ts +4 -4
- package/src/packlets/vault/vault-resource-lock.ts +2 -2
- package/src/packlets/vault/worker-runtime.ts +7 -9
- package/src/packlets/vault/worker-session.ts +24 -45
- package/dist/lib/browser/chunk-T73F4MV4.mjs.map +0 -7
- package/dist/types/src/packlets/services/utils.d.ts +0 -7
- package/dist/types/src/packlets/services/utils.d.ts.map +0 -1
- package/dist/types/src/packlets/testing/host-test-builder.d.ts +0 -43
- package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client-services.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client-services.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/text.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/text.test.d.ts.map +0 -1
- package/src/packlets/services/utils.ts +0 -53
- package/src/packlets/testing/host-test-builder.ts +0 -163
- package/src/packlets/tests/client-services.test.ts +0 -222
- package/src/packlets/tests/client.test.ts +0 -140
- package/src/packlets/tests/halo-credentials.test.ts +0 -94
- package/src/packlets/tests/halo-persistent.test.ts +0 -53
- package/src/packlets/tests/halo-profile.test.ts +0 -48
- package/src/packlets/tests/invitations.test.ts +0 -389
- package/src/packlets/tests/shared-worker.test.ts +0 -92
- package/src/packlets/tests/spaces-invitations.test.ts +0 -46
- package/src/packlets/tests/spaces.test.ts +0 -147
- package/src/packlets/tests/text.test.ts +0 -206
|
@@ -10,20 +10,16 @@ import {
|
|
|
10
10
|
SubscribeToFeedsRequest,
|
|
11
11
|
SubscribeToFeedsResponse,
|
|
12
12
|
SubscribeToFeedBlocksRequest,
|
|
13
|
-
SubscribeToFeedBlocksResponse
|
|
13
|
+
SubscribeToFeedBlocksResponse,
|
|
14
14
|
} from '@dxos/protocols/proto/dxos/devtools/host';
|
|
15
15
|
import { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
16
16
|
import { ComplexMap } from '@dxos/util';
|
|
17
17
|
|
|
18
18
|
export const subscribeToFeeds = (
|
|
19
19
|
{ feedStore }: { feedStore: FeedStore<FeedMessage> },
|
|
20
|
-
{ feedKeys }: SubscribeToFeedsRequest
|
|
20
|
+
{ feedKeys }: SubscribeToFeedsRequest,
|
|
21
21
|
) => {
|
|
22
22
|
return new Stream<SubscribeToFeedsResponse>(({ next }) => {
|
|
23
|
-
if (feedKeys?.length === 0) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
23
|
const subscriptions = new EventSubscriptions();
|
|
28
24
|
const feedMap = new ComplexMap<PublicKey, FeedWrapper<FeedMessage>>(PublicKey.hash);
|
|
29
25
|
|
|
@@ -35,12 +31,16 @@ export const subscribeToFeeds = (
|
|
|
35
31
|
if (!feedMap.has(feed.key)) {
|
|
36
32
|
feedMap.set(feed.key, feed);
|
|
37
33
|
feed.on('close', update);
|
|
38
|
-
subscriptions.add(feed.off('close', update));
|
|
34
|
+
subscriptions.add(() => feed.off('close', update));
|
|
39
35
|
}
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
next({
|
|
43
|
-
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
39
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
40
|
+
feedKey: feed.key,
|
|
41
|
+
length: feed.properties.length,
|
|
42
|
+
diskUsage: feed.core.byteLength,
|
|
43
|
+
})),
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -55,7 +55,7 @@ export const subscribeToFeeds = (
|
|
|
55
55
|
|
|
56
56
|
export const subscribeToFeedBlocks = (
|
|
57
57
|
{ feedStore }: { feedStore: FeedStore<FeedMessage> },
|
|
58
|
-
{ feedKey, maxBlocks = 10 }: SubscribeToFeedBlocksRequest
|
|
58
|
+
{ feedKey, maxBlocks = 10 }: SubscribeToFeedBlocksRequest,
|
|
59
59
|
) => {
|
|
60
60
|
return new Stream<SubscribeToFeedBlocksResponse>(({ next }) => {
|
|
61
61
|
if (!feedKey) {
|
|
@@ -81,7 +81,7 @@ export const subscribeToFeedBlocks = (
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
next({
|
|
84
|
-
blocks: blocks.slice(-maxBlocks)
|
|
84
|
+
blocks: blocks.slice(-maxBlocks),
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
await iterator.close();
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { scheduleTask } from '@dxos/async';
|
|
5
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
7
|
import { Keyring } from '@dxos/keyring';
|
|
7
8
|
import { SubscribeToKeyringKeysResponse } from '@dxos/protocols/proto/dxos/devtools/host';
|
|
8
9
|
|
|
9
10
|
export const subscribeToKeyringKeys = ({ keyring }: { keyring: Keyring }) =>
|
|
10
|
-
new Stream<SubscribeToKeyringKeysResponse>(({ next }) => {
|
|
11
|
-
const update = () => {
|
|
11
|
+
new Stream<SubscribeToKeyringKeysResponse>(({ next, ctx }) => {
|
|
12
|
+
const update = async () => {
|
|
12
13
|
next({
|
|
13
|
-
keys: keyring.list()
|
|
14
|
+
keys: await keyring.list(),
|
|
14
15
|
});
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
update
|
|
18
|
-
return unsubscribe;
|
|
17
|
+
keyring.keysUpdate.on(ctx, update);
|
|
18
|
+
scheduleTask(ctx, update);
|
|
19
19
|
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
|
+
import { SignalManager } from '@dxos/messaging';
|
|
8
9
|
import { NetworkManager } from '@dxos/network-manager';
|
|
9
10
|
import {
|
|
10
11
|
GetNetworkPeersRequest,
|
|
@@ -12,38 +13,38 @@ import {
|
|
|
12
13
|
SubscribeToNetworkTopicsResponse,
|
|
13
14
|
SubscribeToSignalStatusResponse,
|
|
14
15
|
SignalResponse,
|
|
15
|
-
SubscribeToSwarmInfoResponse
|
|
16
|
+
SubscribeToSwarmInfoResponse,
|
|
16
17
|
} from '@dxos/protocols/proto/dxos/devtools/host';
|
|
17
18
|
|
|
18
|
-
export const subscribeToNetworkStatus = ({
|
|
19
|
+
export const subscribeToNetworkStatus = ({ signalManager }: { signalManager: SignalManager }) =>
|
|
19
20
|
new Stream<SubscribeToSignalStatusResponse>(({ next, close }) => {
|
|
20
21
|
const update = () => {
|
|
21
22
|
try {
|
|
22
|
-
const status =
|
|
23
|
+
const status = signalManager.getStatus();
|
|
23
24
|
next({ servers: status });
|
|
24
25
|
} catch (err: any) {
|
|
25
26
|
close(err);
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
signalManager.statusChanged.on(() => update());
|
|
30
31
|
update();
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
export const subscribeToSignal = ({
|
|
34
|
+
export const subscribeToSignal = ({ signalManager }: { signalManager: SignalManager }) =>
|
|
34
35
|
new Stream<SignalResponse>(({ next }) => {
|
|
35
36
|
const ctx = new Context();
|
|
36
|
-
|
|
37
|
+
signalManager.onMessage.on(ctx, (message) => {
|
|
37
38
|
next({
|
|
38
39
|
message: {
|
|
39
40
|
author: message.author.asUint8Array(),
|
|
40
41
|
recipient: message.recipient.asUint8Array(),
|
|
41
|
-
payload: message.payload
|
|
42
|
+
payload: message.payload,
|
|
42
43
|
},
|
|
43
|
-
receivedAt: new Date()
|
|
44
|
+
receivedAt: new Date(),
|
|
44
45
|
});
|
|
45
46
|
});
|
|
46
|
-
|
|
47
|
+
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
47
48
|
next({ swarmEvent: swarmEvent.swarmEvent, receivedAt: new Date() });
|
|
48
49
|
});
|
|
49
50
|
return () => {
|
|
@@ -58,7 +59,7 @@ export const subscribeToNetworkTopics = ({ networkManager }: { networkManager: N
|
|
|
58
59
|
const topics = networkManager.topics;
|
|
59
60
|
const labeledTopics = topics.map((topic) => ({
|
|
60
61
|
topic,
|
|
61
|
-
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
62
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex(),
|
|
62
63
|
}));
|
|
63
64
|
next({ topics: labeledTopics });
|
|
64
65
|
} catch (err: any) {
|
|
@@ -84,7 +85,7 @@ export const subscribeToSwarmInfo = ({ networkManager }: { networkManager: Netwo
|
|
|
84
85
|
|
|
85
86
|
export const getNetworkPeers = (
|
|
86
87
|
{ networkManager }: { networkManager: NetworkManager },
|
|
87
|
-
request: GetNetworkPeersRequest
|
|
88
|
+
request: GetNetworkPeersRequest,
|
|
88
89
|
): GetNetworkPeersResponse => {
|
|
89
90
|
if (!request.topic) {
|
|
90
91
|
throw new Error('Expected a network topic');
|
|
@@ -94,7 +95,7 @@ export const getNetworkPeers = (
|
|
|
94
95
|
return {
|
|
95
96
|
peers: map?.peers.map((peer) => ({
|
|
96
97
|
...peer,
|
|
97
|
-
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
98
|
-
}))
|
|
98
|
+
connections: peer.connections.map((connection) => connection.asUint8Array()),
|
|
99
|
+
})),
|
|
99
100
|
};
|
|
100
101
|
};
|
|
@@ -16,13 +16,13 @@ export const subscribeToSpaces = (context: ServiceContext, { spaceKeys = [] }: S
|
|
|
16
16
|
const update = async () => {
|
|
17
17
|
const spaces: Space[] = [...context.spaceManager!.spaces.values()];
|
|
18
18
|
const filteredSpaces = spaces.filter(
|
|
19
|
-
(space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key))
|
|
19
|
+
(space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)),
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
next({
|
|
23
23
|
spaces: filteredSpaces.map((space): SubscribeToSpacesResponse.SpaceInfo => {
|
|
24
24
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata: SpaceMetadata) =>
|
|
25
|
-
spaceMetadata.key.equals(space.key)
|
|
25
|
+
spaceMetadata.key.equals(space.key),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
return {
|
|
@@ -31,9 +31,9 @@ export const subscribeToSpaces = (context: ServiceContext, { spaceKeys = [] }: S
|
|
|
31
31
|
timeframe: spaceMetadata?.dataTimeframe,
|
|
32
32
|
genesisFeed: space.genesisFeedKey,
|
|
33
33
|
controlFeed: space.controlFeedKey!, // TODO(dmaretskyi): Those keys may be missing.
|
|
34
|
-
dataFeed: space.dataFeedKey
|
|
34
|
+
dataFeed: space.dataFeedKey!,
|
|
35
35
|
};
|
|
36
|
-
})
|
|
36
|
+
}),
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -23,7 +23,7 @@ describe('identity/authenticator', () => {
|
|
|
23
23
|
const authVerifier = new TrustedKeySetAuthVerifier({
|
|
24
24
|
trustedKeysProvider: () => new ComplexSet(PublicKey.hash, [deviceKey]),
|
|
25
25
|
update: new Event(),
|
|
26
|
-
authTimeout: 10
|
|
26
|
+
authTimeout: 10,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const nonce = new Uint8Array([2, 1, 3, 7]);
|
|
@@ -16,10 +16,10 @@ export const createAuthProvider =
|
|
|
16
16
|
async (nonce) => {
|
|
17
17
|
const credential = await signer.createCredential({
|
|
18
18
|
assertion: {
|
|
19
|
-
'@type': 'dxos.halo.credentials.Auth'
|
|
19
|
+
'@type': 'dxos.halo.credentials.Auth',
|
|
20
20
|
},
|
|
21
21
|
subject: signer.getIssuer(),
|
|
22
|
-
nonce
|
|
22
|
+
nonce,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
return schema.getCodecForType('dxos.halo.credentials.Credential').encode(credential);
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { createDefaultModelFactory } from '@dxos/client-protocol';
|
|
8
|
+
import { valueEncoding, MetadataStore, SpaceManager, AuthStatus, SnapshotStore } from '@dxos/echo-pipeline';
|
|
8
9
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
9
10
|
import { Keyring } from '@dxos/keyring';
|
|
10
11
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -18,7 +19,7 @@ import { IdentityManager } from './identity-manager';
|
|
|
18
19
|
describe('identity/identity-manager', () => {
|
|
19
20
|
const setupPeer = async ({
|
|
20
21
|
signalContext = new MemorySignalManagerContext(),
|
|
21
|
-
storage = createStorage({ type: StorageType.RAM })
|
|
22
|
+
storage = createStorage({ type: StorageType.RAM }),
|
|
22
23
|
}: {
|
|
23
24
|
signalContext?: MemorySignalManagerContext;
|
|
24
25
|
storage?: Storage;
|
|
@@ -31,27 +32,30 @@ describe('identity/identity-manager', () => {
|
|
|
31
32
|
root: storage.createDirectory('feeds'),
|
|
32
33
|
signer: keyring,
|
|
33
34
|
hypercore: {
|
|
34
|
-
valueEncoding
|
|
35
|
-
}
|
|
36
|
-
})
|
|
35
|
+
valueEncoding,
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
afterTest(() => feedStore.close());
|
|
40
41
|
|
|
41
42
|
const networkManager = new NetworkManager({
|
|
42
43
|
signalManager: new MemorySignalManager(signalContext),
|
|
43
|
-
transportFactory: MemoryTransportFactory
|
|
44
|
+
transportFactory: MemoryTransportFactory,
|
|
44
45
|
});
|
|
45
46
|
const spaceManager = new SpaceManager({
|
|
46
47
|
feedStore,
|
|
47
|
-
networkManager
|
|
48
|
+
networkManager,
|
|
49
|
+
modelFactory: createDefaultModelFactory(),
|
|
50
|
+
metadataStore: new MetadataStore(storage.createDirectory('metadata')),
|
|
51
|
+
snapshotStore: new SnapshotStore(storage.createDirectory('snapshots')),
|
|
48
52
|
});
|
|
49
53
|
const identityManager = new IdentityManager(metadataStore, keyring, feedStore, spaceManager);
|
|
50
54
|
|
|
51
55
|
return {
|
|
52
56
|
identityManager,
|
|
53
57
|
feedStore,
|
|
54
|
-
keyring
|
|
58
|
+
keyring,
|
|
55
59
|
};
|
|
56
60
|
};
|
|
57
61
|
|
|
@@ -102,10 +106,10 @@ describe('identity/identity-manager', () => {
|
|
|
102
106
|
assertion: {
|
|
103
107
|
'@type': 'dxos.halo.credentials.AuthorizedDevice',
|
|
104
108
|
identityKey: identity1.identityKey,
|
|
105
|
-
deviceKey
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
+
deviceKey,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
109
113
|
});
|
|
110
114
|
|
|
111
115
|
// Identity2 is not yet ready at this point. Peer1 needs to admit peer2 device key and feed keys.
|
|
@@ -115,7 +119,7 @@ describe('identity/identity-manager', () => {
|
|
|
115
119
|
haloSpaceKey: identity1.haloSpaceKey,
|
|
116
120
|
haloGenesisFeedKey: identity1.haloGenesisFeedKey,
|
|
117
121
|
controlFeedKey,
|
|
118
|
-
dataFeedKey
|
|
122
|
+
dataFeedKey,
|
|
119
123
|
});
|
|
120
124
|
|
|
121
125
|
// TODO(dmaretskyi): We'd also need to admit device2's feeds otherwise messages from them won't be processed by the pipeline.
|
|
@@ -52,16 +52,13 @@ export class IdentityManager {
|
|
|
52
52
|
|
|
53
53
|
private _identity?: Identity;
|
|
54
54
|
|
|
55
|
-
private readonly _instanceId = PublicKey.random().toHex();
|
|
56
|
-
public _traceParent?: string;
|
|
57
|
-
|
|
58
55
|
// TODO(burdon): IdentityManagerParams.
|
|
59
56
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
60
57
|
constructor(
|
|
61
58
|
private readonly _metadataStore: MetadataStore,
|
|
62
59
|
private readonly _keyring: Keyring,
|
|
63
60
|
private readonly _feedStore: FeedStore<FeedMessage>,
|
|
64
|
-
private readonly _spaceManager: SpaceManager
|
|
61
|
+
private readonly _spaceManager: SpaceManager,
|
|
65
62
|
) {}
|
|
66
63
|
|
|
67
64
|
get identity() {
|
|
@@ -69,7 +66,8 @@ export class IdentityManager {
|
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
async open() {
|
|
72
|
-
|
|
69
|
+
const traceId = PublicKey.random().toHex();
|
|
70
|
+
log.trace('dxos.halo.identity-manager.open', trace.begin({ id: traceId }));
|
|
73
71
|
await this._metadataStore.load();
|
|
74
72
|
|
|
75
73
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
@@ -80,15 +78,15 @@ export class IdentityManager {
|
|
|
80
78
|
await this._identity.ready();
|
|
81
79
|
log.trace('dxos.halo.identity', {
|
|
82
80
|
identityKey: identityRecord.identityKey,
|
|
83
|
-
displayName: this._identity.profileDocument?.displayName
|
|
81
|
+
displayName: this._identity.profileDocument?.displayName,
|
|
84
82
|
});
|
|
85
83
|
this.stateUpdate.emit();
|
|
86
84
|
}
|
|
85
|
+
log.trace('dxos.halo.identity-manager.open', trace.end({ id: traceId }));
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
async close() {
|
|
90
89
|
await this._identity?.close();
|
|
91
|
-
log.trace('dxos.halo.identity-manager', trace.end({ id: this._instanceId }));
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
async createIdentity({ displayName }: CreateIdentityOptions = {}) {
|
|
@@ -103,8 +101,8 @@ export class IdentityManager {
|
|
|
103
101
|
key: await this._keyring.createKey(),
|
|
104
102
|
genesisFeedKey: controlFeedKey,
|
|
105
103
|
controlFeedKey,
|
|
106
|
-
dataFeedKey: await this._keyring.createKey()
|
|
107
|
-
}
|
|
104
|
+
dataFeedKey: await this._keyring.createKey(),
|
|
105
|
+
},
|
|
108
106
|
};
|
|
109
107
|
|
|
110
108
|
const identity = await this._constructIdentity(identityRecord);
|
|
@@ -122,8 +120,8 @@ export class IdentityManager {
|
|
|
122
120
|
await generator.createFeedAdmission(
|
|
123
121
|
identityRecord.haloSpace.key,
|
|
124
122
|
identityRecord.haloSpace.dataFeedKey,
|
|
125
|
-
AdmittedFeed.Designation.DATA
|
|
126
|
-
)
|
|
123
|
+
AdmittedFeed.Designation.DATA,
|
|
124
|
+
),
|
|
127
125
|
];
|
|
128
126
|
|
|
129
127
|
if (displayName) {
|
|
@@ -136,7 +134,7 @@ export class IdentityManager {
|
|
|
136
134
|
|
|
137
135
|
for (const credential of credentials) {
|
|
138
136
|
await identity.controlPipeline.writer.write({
|
|
139
|
-
credential: { credential }
|
|
137
|
+
credential: { credential },
|
|
140
138
|
});
|
|
141
139
|
}
|
|
142
140
|
}
|
|
@@ -150,7 +148,7 @@ export class IdentityManager {
|
|
|
150
148
|
await this._identity.ready();
|
|
151
149
|
log.trace('dxos.halo.identity', {
|
|
152
150
|
identityKey: identityRecord.identityKey,
|
|
153
|
-
displayName: this._identity.profileDocument?.displayName
|
|
151
|
+
displayName: this._identity.profileDocument?.displayName,
|
|
154
152
|
});
|
|
155
153
|
this.stateUpdate.emit();
|
|
156
154
|
|
|
@@ -173,8 +171,8 @@ export class IdentityManager {
|
|
|
173
171
|
genesisFeedKey: params.haloGenesisFeedKey,
|
|
174
172
|
controlFeedKey: params.controlFeedKey,
|
|
175
173
|
dataFeedKey: params.dataFeedKey,
|
|
176
|
-
controlTimeframe: params.controlTimeframe
|
|
177
|
-
}
|
|
174
|
+
controlTimeframe: params.controlTimeframe,
|
|
175
|
+
},
|
|
178
176
|
};
|
|
179
177
|
const identity = await this._constructIdentity(identityRecord);
|
|
180
178
|
|
|
@@ -184,7 +182,7 @@ export class IdentityManager {
|
|
|
184
182
|
await this._identity.ready();
|
|
185
183
|
log.trace('dxos.halo.identity', {
|
|
186
184
|
identityKey: identityRecord.identityKey,
|
|
187
|
-
displayName: this._identity.profileDocument?.displayName
|
|
185
|
+
displayName: this._identity.profileDocument?.displayName,
|
|
188
186
|
});
|
|
189
187
|
|
|
190
188
|
this.stateUpdate.emit();
|
|
@@ -199,7 +197,7 @@ export class IdentityManager {
|
|
|
199
197
|
// Must be created before the space so the feeds are writable.
|
|
200
198
|
assert(identityRecord.haloSpace.controlFeedKey);
|
|
201
199
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
202
|
-
writable: true
|
|
200
|
+
writable: true,
|
|
203
201
|
});
|
|
204
202
|
assert(identityRecord.haloSpace.dataFeedKey);
|
|
205
203
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, { writable: true });
|
|
@@ -209,9 +207,9 @@ export class IdentityManager {
|
|
|
209
207
|
swarmIdentity: {
|
|
210
208
|
peerKey: identityRecord.deviceKey,
|
|
211
209
|
credentialProvider: createAuthProvider(createCredentialSignerWithKey(this._keyring, identityRecord.deviceKey)),
|
|
212
|
-
credentialAuthenticator: deferFunction(() => identity.authVerifier.verifier)
|
|
210
|
+
credentialAuthenticator: deferFunction(() => identity.authVerifier.verifier),
|
|
213
211
|
},
|
|
214
|
-
identityKey: identityRecord.identityKey
|
|
212
|
+
identityKey: identityRecord.identityKey,
|
|
215
213
|
});
|
|
216
214
|
space.setControlFeed(controlFeed);
|
|
217
215
|
space.setDataFeed(dataFeed);
|
|
@@ -220,7 +218,7 @@ export class IdentityManager {
|
|
|
220
218
|
space,
|
|
221
219
|
signer: this._keyring,
|
|
222
220
|
identityKey: identityRecord.identityKey,
|
|
223
|
-
deviceKey: identityRecord.deviceKey
|
|
221
|
+
deviceKey: identityRecord.deviceKey,
|
|
224
222
|
});
|
|
225
223
|
log('done', { identityKey: identityRecord.identityKey });
|
|
226
224
|
|
|
@@ -236,10 +234,11 @@ export class IdentityManager {
|
|
|
236
234
|
return this._spaceManager.constructSpace({
|
|
237
235
|
metadata: {
|
|
238
236
|
key: spaceRecord.key,
|
|
239
|
-
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
237
|
+
genesisFeedKey: spaceRecord.genesisFeedKey,
|
|
240
238
|
},
|
|
241
239
|
swarmIdentity,
|
|
242
|
-
onNetworkConnection: () => {}
|
|
240
|
+
onNetworkConnection: () => {},
|
|
241
|
+
memberKey: identityKey,
|
|
243
242
|
});
|
|
244
243
|
}
|
|
245
244
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
IdentityService,
|
|
13
13
|
QueryIdentityResponse,
|
|
14
14
|
RecoverIdentityRequest,
|
|
15
|
-
SignPresentationRequest
|
|
15
|
+
SignPresentationRequest,
|
|
16
16
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
17
17
|
import { Presentation, ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
18
18
|
|
|
@@ -49,7 +49,7 @@ export class IdentityServiceImpl implements IdentityService {
|
|
|
49
49
|
return {
|
|
50
50
|
identityKey: this._serviceContext.identityManager.identity.identityKey,
|
|
51
51
|
spaceKey: this._serviceContext.identityManager.identity.space.key,
|
|
52
|
-
profile: this._serviceContext.identityManager.identity.profileDocument
|
|
52
|
+
profile: this._serviceContext.identityManager.identity.profileDocument,
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -61,7 +61,7 @@ export class IdentityServiceImpl implements IdentityService {
|
|
|
61
61
|
signer: this._serviceContext.keyring,
|
|
62
62
|
signerKey: this._serviceContext.identityManager.identity.deviceKey,
|
|
63
63
|
chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
|
|
64
|
-
nonce
|
|
64
|
+
nonce,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
}
|