@dxos/client-services 0.5.8 → 0.5.9-main.0a0e87d
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-JECXTGZA.mjs → chunk-CMZ6YZOX.mjs} +1485 -1315
- package/dist/lib/browser/chunk-CMZ6YZOX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +55 -363
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +13 -12
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-OR7LRWDY.cjs → chunk-CA7UVCON.cjs} +1613 -1447
- package/dist/lib/node/chunk-CA7UVCON.cjs.map +7 -0
- package/dist/lib/node/index.cjs +93 -396
- 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 +18 -17
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +4 -4
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +4 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -2
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -5
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -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 +2 -0
- package/dist/types/src/packlets/spaces/data-space.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/testing/test-builder.d.ts +11 -9
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/index.d.ts +3 -0
- package/dist/types/src/packlets/worker/index.d.ts.map +1 -0
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/worker/worker-session.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 +36 -36
- package/src/index.ts +3 -3
- package/src/packlets/devtools/network.ts +4 -4
- package/src/packlets/identity/default-space-state-machine.ts +44 -0
- package/src/packlets/identity/identity-manager.test.ts +2 -2
- package/src/packlets/identity/identity-service.test.ts +35 -5
- package/src/packlets/identity/identity-service.ts +50 -8
- package/src/packlets/identity/identity.test.ts +8 -4
- package/src/packlets/identity/identity.ts +25 -2
- package/src/packlets/invitations/invitations-handler.ts +2 -2
- package/src/packlets/network/network-service.ts +2 -2
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +16 -44
- package/src/packlets/spaces/data-space-manager.test.ts +46 -1
- package/src/packlets/spaces/data-space-manager.ts +54 -25
- package/src/packlets/spaces/data-space.ts +35 -6
- package/src/packlets/spaces/spaces-service.ts +3 -2
- package/src/packlets/testing/test-builder.ts +15 -10
- package/src/packlets/worker/index.ts +6 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-JECXTGZA.mjs.map +0 -7
- package/dist/lib/node/chunk-OR7LRWDY.cjs.map +0 -7
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -37
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/index.d.ts +0 -6
- package/dist/types/src/packlets/vault/index.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +0 -36
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +0 -33
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +0 -1
- package/src/packlets/vault/iframe-host-runtime.ts +0 -130
- package/src/packlets/vault/index.ts +0 -9
- package/src/packlets/vault/shared-worker-connection.ts +0 -115
- package/src/packlets/vault/shell-runtime.ts +0 -111
- /package/dist/types/src/packlets/{vault → worker}/worker-runtime.d.ts +0 -0
- /package/dist/types/src/packlets/{vault → worker}/worker-session.d.ts +0 -0
- /package/src/packlets/{vault → worker}/worker-runtime.ts +0 -0
- /package/src/packlets/{vault → worker}/worker-session.ts +0 -0
|
@@ -19,7 +19,7 @@ export declare class SpacesServiceImpl implements SpacesService {
|
|
|
19
19
|
subscribeMessages({ spaceKey, channel }: SubscribeMessagesRequest): Stream<GossipMessage>;
|
|
20
20
|
queryCredentials({ spaceKey, noTail }: QueryCredentialsRequest): Stream<Credential>;
|
|
21
21
|
writeCredentials({ spaceKey, credentials }: WriteCredentialsRequest): Promise<void>;
|
|
22
|
-
createEpoch({ spaceKey, migration }: CreateEpochRequest): Promise<void>;
|
|
22
|
+
createEpoch({ spaceKey, migration, automergeRootUrl }: CreateEpochRequest): Promise<void>;
|
|
23
23
|
private _serializeSpace;
|
|
24
24
|
private _requireIdentity;
|
|
25
25
|
private _updateMetrics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.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AAE,YAAY,EAC3B,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAGtE,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;IAQ7B,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,kBAAkB;IAmBnD,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BvE,WAAW,IAAI,MAAM,CAAC,mBAAmB,CAAC;IAmDpC,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,kBAAkB;IAMpE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,wBAAwB;IAajE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC;IAmB7E,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,uBAAuB;IAmBnE,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,kBAAkB;IAM/E,OAAO,CAAC,eAAe;IA6CvB,OAAO,CAAC,gBAAgB;YASV,cAAc;CAS7B"}
|
|
@@ -5,16 +5,17 @@ import { FeedStore } from '@dxos/feed-store';
|
|
|
5
5
|
import { Keyring } from '@dxos/keyring';
|
|
6
6
|
import { type LevelDB } from '@dxos/kv-store';
|
|
7
7
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
|
-
import {
|
|
8
|
+
import { SwarmNetworkManager } from '@dxos/network-manager';
|
|
9
9
|
import { StorageType, type Storage } from '@dxos/random-access-storage';
|
|
10
10
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
11
11
|
import { InvitationsManager } from '../invitations';
|
|
12
|
-
import { ClientServicesHost, ServiceContext } from '../services';
|
|
13
|
-
import { DataSpaceManager, type SigningContext } from '../spaces';
|
|
12
|
+
import { ClientServicesHost, ServiceContext, type ServiceContextRuntimeParams } from '../services';
|
|
13
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
14
14
|
export declare const createServiceHost: (config: Config, signalManagerContext: MemorySignalManagerContext) => ClientServicesHost;
|
|
15
|
-
export declare const createServiceContext: ({ signalContext, storage, }?: {
|
|
15
|
+
export declare const createServiceContext: ({ signalContext, storage, runtimeParams, }?: {
|
|
16
16
|
signalContext?: MemorySignalManagerContext;
|
|
17
17
|
storage?: Storage;
|
|
18
|
+
runtimeParams?: ServiceContextRuntimeParams;
|
|
18
19
|
}) => Promise<ServiceContext>;
|
|
19
20
|
export declare const createPeers: (numPeers: number) => Promise<ServiceContext[]>;
|
|
20
21
|
export declare const createIdentity: (peer: ServiceContext) => Promise<ServiceContext>;
|
|
@@ -26,6 +27,7 @@ export declare class TestBuilder {
|
|
|
26
27
|
}
|
|
27
28
|
export type TestPeerOpts = {
|
|
28
29
|
dataStore?: StorageType;
|
|
30
|
+
dataSpaceParams?: DataSpaceManagerRuntimeParams;
|
|
29
31
|
};
|
|
30
32
|
export type TestPeerProps = {
|
|
31
33
|
storage?: Storage;
|
|
@@ -33,7 +35,7 @@ export type TestPeerProps = {
|
|
|
33
35
|
feedStore?: FeedStore<any>;
|
|
34
36
|
metadataStore?: MetadataStore;
|
|
35
37
|
keyring?: Keyring;
|
|
36
|
-
networkManager?:
|
|
38
|
+
networkManager?: SwarmNetworkManager;
|
|
37
39
|
spaceManager?: SpaceManager;
|
|
38
40
|
dataSpaceManager?: DataSpaceManager;
|
|
39
41
|
snapshotStore?: SnapshotStore;
|
|
@@ -43,10 +45,10 @@ export type TestPeerProps = {
|
|
|
43
45
|
invitationsManager?: InvitationsManager;
|
|
44
46
|
};
|
|
45
47
|
export declare class TestPeer {
|
|
46
|
-
private readonly
|
|
47
|
-
private readonly
|
|
48
|
+
private readonly _signalContext;
|
|
49
|
+
private readonly _opts;
|
|
48
50
|
private _props;
|
|
49
|
-
constructor(
|
|
51
|
+
constructor(_signalContext: MemorySignalManagerContext, _opts?: TestPeerOpts);
|
|
50
52
|
get props(): TestPeerProps;
|
|
51
53
|
get storage(): Storage;
|
|
52
54
|
get keyring(): Keyring;
|
|
@@ -55,7 +57,7 @@ export declare class TestPeer {
|
|
|
55
57
|
get metadataStore(): MetadataStore;
|
|
56
58
|
get blobStore(): BlobStore;
|
|
57
59
|
get snapshotStore(): SnapshotStore;
|
|
58
|
-
get networkManager():
|
|
60
|
+
get networkManager(): SwarmNetworkManager;
|
|
59
61
|
get spaceManager(): SpaceManager;
|
|
60
62
|
get identity(): SigningContext;
|
|
61
63
|
get echoHost(): EchoHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAe,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAuB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAA0B,
|
|
1
|
+
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAe,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"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/worker/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/worker/worker-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAW3C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,qBAAa,aAAa;IAatB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAZlC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAyC;IAC3E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsB;IACtD,OAAO,CAAC,qBAAqB,CAAC,CAAgB;IAC9C,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,mBAAmB,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;IAElD,SAAgB,OAAO,iBAAsB,QAAQ,IAAI,CAAC,EAAI;IAGvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAGjC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,aAAa,CAAC,EAAE,aAAa,CAAC;gBAEzB,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,mBAAmB;IAoEvF,IAAI;IAeJ,KAAK;YAYG,eAAe;IAQ7B,OAAO,CAAC,kBAAkB;CAO3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DXOS_VERSION = "0.5.
|
|
1
|
+
export declare const DXOS_VERSION = "0.5.9-main.0a0e87d";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9-main.0a0e87d",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -23,45 +23,45 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"platform": "^1.3.6",
|
|
26
|
-
"@dxos/
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/config": "0.5.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/crypto": "0.5.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo-
|
|
36
|
-
"@dxos/echo-
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/feed-store": "0.5.
|
|
39
|
-
"@dxos/echo-schema": "0.5.
|
|
40
|
-
"@dxos/indexing": "0.5.
|
|
41
|
-
"@dxos/invariant": "0.5.
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/protocols": "0.5.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/random-access-storage": "0.5.
|
|
52
|
-
"@dxos/rpc": "0.5.
|
|
53
|
-
"@dxos/teleport": "0.5.
|
|
54
|
-
"@dxos/teleport-extension-gossip": "0.5.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/timeframe": "0.5.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
26
|
+
"@dxos/async": "0.5.9-main.0a0e87d",
|
|
27
|
+
"@dxos/client-protocol": "0.5.9-main.0a0e87d",
|
|
28
|
+
"@dxos/automerge": "0.5.9-main.0a0e87d",
|
|
29
|
+
"@dxos/codec-protobuf": "0.5.9-main.0a0e87d",
|
|
30
|
+
"@dxos/config": "0.5.9-main.0a0e87d",
|
|
31
|
+
"@dxos/credentials": "0.5.9-main.0a0e87d",
|
|
32
|
+
"@dxos/crypto": "0.5.9-main.0a0e87d",
|
|
33
|
+
"@dxos/context": "0.5.9-main.0a0e87d",
|
|
34
|
+
"@dxos/echo-db": "0.5.9-main.0a0e87d",
|
|
35
|
+
"@dxos/echo-pipeline": "0.5.9-main.0a0e87d",
|
|
36
|
+
"@dxos/echo-protocol": "0.5.9-main.0a0e87d",
|
|
37
|
+
"@dxos/debug": "0.5.9-main.0a0e87d",
|
|
38
|
+
"@dxos/feed-store": "0.5.9-main.0a0e87d",
|
|
39
|
+
"@dxos/echo-schema": "0.5.9-main.0a0e87d",
|
|
40
|
+
"@dxos/indexing": "0.5.9-main.0a0e87d",
|
|
41
|
+
"@dxos/invariant": "0.5.9-main.0a0e87d",
|
|
42
|
+
"@dxos/kv-store": "0.5.9-main.0a0e87d",
|
|
43
|
+
"@dxos/lock-file": "0.5.9-main.0a0e87d",
|
|
44
|
+
"@dxos/keyring": "0.5.9-main.0a0e87d",
|
|
45
|
+
"@dxos/keys": "0.5.9-main.0a0e87d",
|
|
46
|
+
"@dxos/messaging": "0.5.9-main.0a0e87d",
|
|
47
|
+
"@dxos/node-std": "0.5.9-main.0a0e87d",
|
|
48
|
+
"@dxos/log": "0.5.9-main.0a0e87d",
|
|
49
|
+
"@dxos/protocols": "0.5.9-main.0a0e87d",
|
|
50
|
+
"@dxos/network-manager": "0.5.9-main.0a0e87d",
|
|
51
|
+
"@dxos/random-access-storage": "0.5.9-main.0a0e87d",
|
|
52
|
+
"@dxos/rpc": "0.5.9-main.0a0e87d",
|
|
53
|
+
"@dxos/teleport": "0.5.9-main.0a0e87d",
|
|
54
|
+
"@dxos/teleport-extension-gossip": "0.5.9-main.0a0e87d",
|
|
55
|
+
"@dxos/teleport-extension-object-sync": "0.5.9-main.0a0e87d",
|
|
56
|
+
"@dxos/timeframe": "0.5.9-main.0a0e87d",
|
|
57
|
+
"@dxos/tracing": "0.5.9-main.0a0e87d",
|
|
58
|
+
"@dxos/util": "0.5.9-main.0a0e87d",
|
|
59
|
+
"@dxos/websocket-rpc": "0.5.9-main.0a0e87d"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/platform": "^1.3.4",
|
|
63
63
|
"@types/readable-stream": "^2.3.9",
|
|
64
|
-
"@dxos/signal": "0.5.
|
|
64
|
+
"@dxos/signal": "0.5.9-main.0a0e87d"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from './packlets/devtools';
|
|
6
|
+
export * from './packlets/diagnostics';
|
|
6
7
|
export * from './packlets/identity';
|
|
7
8
|
export * from './packlets/invitations';
|
|
9
|
+
export * from './packlets/locks';
|
|
8
10
|
export * from './packlets/services';
|
|
9
11
|
export * from './packlets/spaces';
|
|
10
12
|
export * from './packlets/storage';
|
|
11
|
-
export * from './packlets/
|
|
12
|
-
export * from './packlets/locks';
|
|
13
|
-
export * from './packlets/diagnostics';
|
|
13
|
+
export * from './packlets/worker';
|
|
@@ -6,7 +6,7 @@ import { Stream } from '@dxos/codec-protobuf';
|
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { type SignalManager } from '@dxos/messaging';
|
|
9
|
-
import { type
|
|
9
|
+
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
10
10
|
import {
|
|
11
11
|
type GetNetworkPeersRequest,
|
|
12
12
|
type GetNetworkPeersResponse,
|
|
@@ -56,7 +56,7 @@ export const subscribeToSignal = ({ signalManager }: { signalManager: SignalMana
|
|
|
56
56
|
};
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
export const subscribeToNetworkTopics = ({ networkManager }: { networkManager:
|
|
59
|
+
export const subscribeToNetworkTopics = ({ networkManager }: { networkManager: SwarmNetworkManager }) =>
|
|
60
60
|
new Stream<SubscribeToNetworkTopicsResponse>(({ next, close }) => {
|
|
61
61
|
const update = () => {
|
|
62
62
|
try {
|
|
@@ -75,7 +75,7 @@ export const subscribeToNetworkTopics = ({ networkManager }: { networkManager: N
|
|
|
75
75
|
update();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
export const subscribeToSwarmInfo = ({ networkManager }: { networkManager:
|
|
78
|
+
export const subscribeToSwarmInfo = ({ networkManager }: { networkManager: SwarmNetworkManager }) =>
|
|
79
79
|
new Stream<SubscribeToSwarmInfoResponse>(({ next }) => {
|
|
80
80
|
const update = () => {
|
|
81
81
|
const info = networkManager.connectionLog?.swarms;
|
|
@@ -88,7 +88,7 @@ export const subscribeToSwarmInfo = ({ networkManager }: { networkManager: Netwo
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
export const getNetworkPeers = (
|
|
91
|
-
{ networkManager }: { networkManager:
|
|
91
|
+
{ networkManager }: { networkManager: SwarmNetworkManager },
|
|
92
92
|
request: GetNetworkPeersRequest,
|
|
93
93
|
): GetNetworkPeersResponse => {
|
|
94
94
|
if (!request.topic) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
6
|
+
import { SpaceId, type PublicKey } from '@dxos/keys';
|
|
7
|
+
import { log } from '@dxos/log';
|
|
8
|
+
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
|
+
|
|
10
|
+
type DefaultSpaceStateMachineParams = {
|
|
11
|
+
identityKey: PublicKey;
|
|
12
|
+
onUpdate?: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Processes device invitation credentials.
|
|
17
|
+
*/
|
|
18
|
+
export class DefaultSpaceStateMachine implements CredentialProcessor {
|
|
19
|
+
private _spaceId: SpaceId | undefined;
|
|
20
|
+
|
|
21
|
+
constructor(private readonly _params: DefaultSpaceStateMachineParams) {}
|
|
22
|
+
|
|
23
|
+
public get spaceId(): SpaceId | undefined {
|
|
24
|
+
return this._spaceId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async processCredential(credential: Credential) {
|
|
28
|
+
const assertion = getCredentialAssertion(credential);
|
|
29
|
+
switch (assertion['@type']) {
|
|
30
|
+
case 'dxos.halo.credentials.DefaultSpace': {
|
|
31
|
+
if (!credential.subject.id.equals(this._params.identityKey)) {
|
|
32
|
+
log.warn('Invalid default space credential', { expectedIdentity: this._params.identityKey, credential });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!SpaceId.isValid(assertion.spaceId)) {
|
|
36
|
+
log.warn('Invalid default space id', { id: assertion.spaceId });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this._spaceId = assertion.spaceId;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -9,7 +9,7 @@ import { valueEncoding, MetadataStore, SpaceManager, AuthStatus, SnapshotStore }
|
|
|
9
9
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
10
10
|
import { Keyring } from '@dxos/keyring';
|
|
11
11
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
12
|
-
import { MemoryTransportFactory,
|
|
12
|
+
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
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';
|
|
@@ -41,7 +41,7 @@ describe('identity/identity-manager', () => {
|
|
|
41
41
|
|
|
42
42
|
afterTest(() => feedStore.close());
|
|
43
43
|
|
|
44
|
-
const networkManager = new
|
|
44
|
+
const networkManager = new SwarmNetworkManager({
|
|
45
45
|
signalManager: new MemorySignalManager(signalContext),
|
|
46
46
|
transportFactory: MemoryTransportFactory,
|
|
47
47
|
});
|
|
@@ -24,11 +24,7 @@ describe('IdentityService', () => {
|
|
|
24
24
|
beforeEach(async () => {
|
|
25
25
|
serviceContext = await createServiceContext();
|
|
26
26
|
await serviceContext.open(new Context());
|
|
27
|
-
identityService =
|
|
28
|
-
(options) => serviceContext.createIdentity(options),
|
|
29
|
-
serviceContext.identityManager,
|
|
30
|
-
serviceContext.keyring,
|
|
31
|
-
);
|
|
27
|
+
identityService = createIdentityService(serviceContext);
|
|
32
28
|
});
|
|
33
29
|
|
|
34
30
|
afterEach(async () => {
|
|
@@ -95,3 +91,37 @@ describe('IdentityService', () => {
|
|
|
95
91
|
});
|
|
96
92
|
});
|
|
97
93
|
});
|
|
94
|
+
|
|
95
|
+
describe('open', () => {
|
|
96
|
+
test('identity without default space fixed', async () => {
|
|
97
|
+
const serviceContext = await createServiceContext();
|
|
98
|
+
await serviceContext.open(new Context());
|
|
99
|
+
const identity = await serviceContext.createIdentity();
|
|
100
|
+
const identityService = createIdentityService(serviceContext);
|
|
101
|
+
const getDataSpaces = () => [...(serviceContext.dataSpaceManager?.spaces?.values() ?? [])];
|
|
102
|
+
expect(getDataSpaces().length).to.eq(0);
|
|
103
|
+
expect(identity.defaultSpaceId).to.be.undefined;
|
|
104
|
+
await identityService.open();
|
|
105
|
+
expect(getDataSpaces()[0].id === identity.defaultSpaceId).to.be.true;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('identity without default space credential fixed', async () => {
|
|
109
|
+
const serviceContext = await createServiceContext();
|
|
110
|
+
await serviceContext.open(new Context());
|
|
111
|
+
const identity = await serviceContext.createIdentity();
|
|
112
|
+
const space = await serviceContext.dataSpaceManager!.createDefaultSpace();
|
|
113
|
+
const identityService = createIdentityService(serviceContext);
|
|
114
|
+
expect(identity.defaultSpaceId).to.be.undefined;
|
|
115
|
+
await identityService.open();
|
|
116
|
+
expect(identity.defaultSpaceId === space.id).to.be.true;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const createIdentityService = (serviceContext: ServiceContext) => {
|
|
121
|
+
return new IdentityServiceImpl(
|
|
122
|
+
serviceContext.identityManager,
|
|
123
|
+
serviceContext.keyring,
|
|
124
|
+
() => serviceContext.dataSpaceManager!,
|
|
125
|
+
(options) => serviceContext.createIdentity(options),
|
|
126
|
+
);
|
|
127
|
+
};
|
|
@@ -3,36 +3,59 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
|
+
import { Resource } from '@dxos/context';
|
|
6
7
|
import { signPresentation } from '@dxos/credentials';
|
|
7
8
|
import { todo } from '@dxos/debug';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
10
|
import { type Keyring } from '@dxos/keyring';
|
|
10
11
|
import {
|
|
11
12
|
type CreateIdentityRequest,
|
|
12
|
-
type Identity,
|
|
13
|
+
type Identity as IdentityProto,
|
|
13
14
|
type IdentityService,
|
|
14
15
|
type QueryIdentityResponse,
|
|
15
16
|
type RecoverIdentityRequest,
|
|
16
17
|
type SignPresentationRequest,
|
|
18
|
+
SpaceState,
|
|
17
19
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
18
20
|
import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
19
21
|
|
|
22
|
+
import { type Identity } from './identity';
|
|
20
23
|
import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
|
|
24
|
+
import { type DataSpaceManager } from '../spaces';
|
|
21
25
|
|
|
22
|
-
export class IdentityServiceImpl implements IdentityService {
|
|
26
|
+
export class IdentityServiceImpl extends Resource implements IdentityService {
|
|
23
27
|
constructor(
|
|
24
|
-
private readonly _createIdentity: (params: CreateIdentityOptions) => Promise<Identity>,
|
|
25
28
|
private readonly _identityManager: IdentityManager,
|
|
26
29
|
private readonly _keyring: Keyring,
|
|
30
|
+
private readonly _dataSpaceManagerProvider: () => DataSpaceManager,
|
|
31
|
+
private readonly _createIdentity: (params: CreateIdentityOptions) => Promise<Identity>,
|
|
27
32
|
private readonly _onProfileUpdate?: (profile: ProfileDocument | undefined) => Promise<void>,
|
|
28
|
-
) {
|
|
33
|
+
) {
|
|
34
|
+
super();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected override async _open() {
|
|
38
|
+
const identity = this._identityManager.identity;
|
|
39
|
+
if (identity && !identity.defaultSpaceId) {
|
|
40
|
+
await this._fixIdentityWithoutDefaultSpace(identity);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
29
43
|
|
|
30
|
-
async createIdentity(request: CreateIdentityRequest): Promise<
|
|
44
|
+
async createIdentity(request: CreateIdentityRequest): Promise<IdentityProto> {
|
|
31
45
|
await this._createIdentity({ displayName: request.profile?.displayName, deviceProfile: request.deviceProfile });
|
|
46
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
47
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
32
48
|
return this._getIdentity()!;
|
|
33
49
|
}
|
|
34
50
|
|
|
35
|
-
async
|
|
51
|
+
private async _createDefaultSpace(dataSpaceManager: DataSpaceManager) {
|
|
52
|
+
const space = await dataSpaceManager!.createDefaultSpace();
|
|
53
|
+
const identity = this._identityManager.identity;
|
|
54
|
+
invariant(identity);
|
|
55
|
+
await identity.updateDefaultSpace(space.id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async recoverIdentity(request: RecoverIdentityRequest): Promise<IdentityProto> {
|
|
36
59
|
return todo();
|
|
37
60
|
}
|
|
38
61
|
|
|
@@ -45,7 +68,7 @@ export class IdentityServiceImpl implements IdentityService {
|
|
|
45
68
|
});
|
|
46
69
|
}
|
|
47
70
|
|
|
48
|
-
private _getIdentity():
|
|
71
|
+
private _getIdentity(): IdentityProto | undefined {
|
|
49
72
|
if (!this._identityManager.identity) {
|
|
50
73
|
return undefined;
|
|
51
74
|
}
|
|
@@ -57,7 +80,7 @@ export class IdentityServiceImpl implements IdentityService {
|
|
|
57
80
|
};
|
|
58
81
|
}
|
|
59
82
|
|
|
60
|
-
async updateProfile(profile: ProfileDocument): Promise<
|
|
83
|
+
async updateProfile(profile: ProfileDocument): Promise<IdentityProto> {
|
|
61
84
|
invariant(this._identityManager.identity, 'Identity not initialized.');
|
|
62
85
|
await this._identityManager.updateProfile(profile);
|
|
63
86
|
await this._onProfileUpdate?.(this._identityManager.identity.profileDocument);
|
|
@@ -75,4 +98,23 @@ export class IdentityServiceImpl implements IdentityService {
|
|
|
75
98
|
nonce,
|
|
76
99
|
});
|
|
77
100
|
}
|
|
101
|
+
|
|
102
|
+
private async _fixIdentityWithoutDefaultSpace(identity: Identity) {
|
|
103
|
+
let hasDefaultSpace = false;
|
|
104
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
105
|
+
for (const space of dataSpaceManager.spaces.values()) {
|
|
106
|
+
if (space.state === SpaceState.CLOSED) {
|
|
107
|
+
await space.open();
|
|
108
|
+
await space.initializeDataPipeline();
|
|
109
|
+
}
|
|
110
|
+
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
111
|
+
await identity.updateDefaultSpace(space.id);
|
|
112
|
+
hasDefaultSpace = true;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!hasDefaultSpace) {
|
|
117
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
78
120
|
}
|
|
@@ -7,6 +7,7 @@ import expect from 'expect';
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { CredentialGenerator, verifyCredential } from '@dxos/credentials';
|
|
9
9
|
import {
|
|
10
|
+
createIdFromSpaceKey,
|
|
10
11
|
MetadataStore,
|
|
11
12
|
MOCK_AUTH_PROVIDER,
|
|
12
13
|
MOCK_AUTH_VERIFIER,
|
|
@@ -20,7 +21,7 @@ import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
|
20
21
|
import { Keyring } from '@dxos/keyring';
|
|
21
22
|
import { type PublicKey } from '@dxos/keys';
|
|
22
23
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
23
|
-
import { MemoryTransportFactory,
|
|
24
|
+
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
24
25
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
25
26
|
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
26
27
|
import { createStorage, StorageType } from '@dxos/random-access-storage';
|
|
@@ -78,7 +79,7 @@ describe('identity/identity', () => {
|
|
|
78
79
|
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
79
80
|
},
|
|
80
81
|
blobStore,
|
|
81
|
-
networkManager: new
|
|
82
|
+
networkManager: new SwarmNetworkManager({
|
|
82
83
|
signalManager: new MemorySignalManager(new MemorySignalManagerContext()),
|
|
83
84
|
transportFactory: MemoryTransportFactory,
|
|
84
85
|
}),
|
|
@@ -86,6 +87,7 @@ describe('identity/identity', () => {
|
|
|
86
87
|
|
|
87
88
|
await metadataStore.setIdentityRecord({ haloSpace: { key: spaceKey }, identityKey, deviceKey });
|
|
88
89
|
const space: Space = new Space({
|
|
90
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
89
91
|
spaceKey,
|
|
90
92
|
protocol,
|
|
91
93
|
genesisFeed: controlFeed,
|
|
@@ -193,7 +195,7 @@ describe('identity/identity', () => {
|
|
|
193
195
|
credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
|
|
194
196
|
},
|
|
195
197
|
blobStore,
|
|
196
|
-
networkManager: new
|
|
198
|
+
networkManager: new SwarmNetworkManager({
|
|
197
199
|
signalManager: new MemorySignalManager(signalContext),
|
|
198
200
|
transportFactory: MemoryTransportFactory,
|
|
199
201
|
}),
|
|
@@ -201,6 +203,7 @@ describe('identity/identity', () => {
|
|
|
201
203
|
|
|
202
204
|
await metadataStore.setIdentityRecord({ haloSpace: { key: spaceKey }, identityKey, deviceKey });
|
|
203
205
|
const space = new Space({
|
|
206
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
204
207
|
spaceKey,
|
|
205
208
|
protocol,
|
|
206
209
|
genesisFeed: controlFeed,
|
|
@@ -281,7 +284,7 @@ describe('identity/identity', () => {
|
|
|
281
284
|
credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
|
|
282
285
|
},
|
|
283
286
|
blobStore,
|
|
284
|
-
networkManager: new
|
|
287
|
+
networkManager: new SwarmNetworkManager({
|
|
285
288
|
signalManager: new MemorySignalManager(signalContext),
|
|
286
289
|
transportFactory: MemoryTransportFactory,
|
|
287
290
|
}),
|
|
@@ -293,6 +296,7 @@ describe('identity/identity', () => {
|
|
|
293
296
|
deviceKey,
|
|
294
297
|
});
|
|
295
298
|
const space = new Space({
|
|
299
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
296
300
|
spaceKey,
|
|
297
301
|
protocol,
|
|
298
302
|
genesisFeed: await feedStore.openFeed(genesisFeedKey),
|
|
@@ -16,7 +16,7 @@ import { type Signer } from '@dxos/crypto';
|
|
|
16
16
|
import { type Space } from '@dxos/echo-pipeline';
|
|
17
17
|
import { writeMessages } from '@dxos/feed-store';
|
|
18
18
|
import { invariant } from '@dxos/invariant';
|
|
19
|
-
import { PublicKey } from '@dxos/keys';
|
|
19
|
+
import { PublicKey, type SpaceId } from '@dxos/keys';
|
|
20
20
|
import { log } from '@dxos/log';
|
|
21
21
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
22
22
|
import {
|
|
@@ -26,10 +26,12 @@ import {
|
|
|
26
26
|
} from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
27
27
|
import { type DeviceAdmissionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
28
28
|
import { type Presence } from '@dxos/teleport-extension-gossip';
|
|
29
|
+
import { Timeframe } from '@dxos/timeframe';
|
|
29
30
|
import { trace } from '@dxos/tracing';
|
|
30
31
|
import { type ComplexMap, ComplexSet } from '@dxos/util';
|
|
31
32
|
|
|
32
33
|
import { TrustedKeySetAuthVerifier } from './authenticator';
|
|
34
|
+
import { DefaultSpaceStateMachine } from './default-space-state-machine';
|
|
33
35
|
|
|
34
36
|
export type IdentityParams = {
|
|
35
37
|
identityKey: PublicKey;
|
|
@@ -49,6 +51,7 @@ export class Identity {
|
|
|
49
51
|
private readonly _presence?: Presence;
|
|
50
52
|
private readonly _deviceStateMachine: DeviceStateMachine;
|
|
51
53
|
private readonly _profileStateMachine: ProfileStateMachine;
|
|
54
|
+
private readonly _defaultSpaceStateMachine: DefaultSpaceStateMachine;
|
|
52
55
|
public readonly authVerifier: TrustedKeySetAuthVerifier;
|
|
53
56
|
|
|
54
57
|
public readonly identityKey: PublicKey;
|
|
@@ -75,6 +78,10 @@ export class Identity {
|
|
|
75
78
|
identityKey: this.identityKey,
|
|
76
79
|
onUpdate: () => this.stateUpdate.emit(),
|
|
77
80
|
});
|
|
81
|
+
this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
|
|
82
|
+
identityKey: this.identityKey,
|
|
83
|
+
onUpdate: () => this.stateUpdate.emit(),
|
|
84
|
+
});
|
|
78
85
|
|
|
79
86
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
80
87
|
trustedKeysProvider: () => new ComplexSet(PublicKey.hash, this.authorizedDeviceKeys.keys()),
|
|
@@ -88,17 +95,24 @@ export class Identity {
|
|
|
88
95
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
89
96
|
}
|
|
90
97
|
|
|
98
|
+
get defaultSpaceId(): SpaceId | undefined {
|
|
99
|
+
return this._defaultSpaceStateMachine.spaceId;
|
|
100
|
+
}
|
|
101
|
+
|
|
91
102
|
@trace.span()
|
|
92
103
|
async open(ctx: Context) {
|
|
104
|
+
await this._presence?.open();
|
|
93
105
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
94
106
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
107
|
+
await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
|
|
95
108
|
await this.space.open(ctx);
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
@trace.span()
|
|
99
112
|
async close(ctx: Context) {
|
|
100
|
-
await this._presence?.
|
|
113
|
+
await this._presence?.close();
|
|
101
114
|
await this.authVerifier.close();
|
|
115
|
+
await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
|
|
102
116
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
103
117
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
104
118
|
await this.space.close();
|
|
@@ -157,6 +171,15 @@ export class Identity {
|
|
|
157
171
|
return createCredentialSignerWithKey(this._signer, this.deviceKey);
|
|
158
172
|
}
|
|
159
173
|
|
|
174
|
+
async updateDefaultSpace(spaceId: SpaceId) {
|
|
175
|
+
const credential = await this.getDeviceCredentialSigner().createCredential({
|
|
176
|
+
subject: this.identityKey,
|
|
177
|
+
assertion: { '@type': 'dxos.halo.credentials.DefaultSpace', spaceId },
|
|
178
|
+
});
|
|
179
|
+
const receipt = await this.controlPipeline.writer.write({ credential: { credential } });
|
|
180
|
+
await this.controlPipeline.state.waitUntilTimeframe(new Timeframe([[receipt.feedKey, receipt.seq]]));
|
|
181
|
+
}
|
|
182
|
+
|
|
160
183
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }: DeviceAdmissionRequest) {
|
|
161
184
|
log('Admitting device:', {
|
|
162
185
|
identityKey: this.identityKey,
|