@dxos/client-services 0.1.23 → 0.1.24
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-R2FEBB66.mjs +3865 -0
- package/dist/lib/browser/chunk-R2FEBB66.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +56 -3066
- 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 +198 -0
- package/dist/lib/browser/packlets/testing/index.mjs.map +7 -0
- package/dist/lib/node/index.cjs +1401 -645
- 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 +3688 -0
- package/dist/lib/node/packlets/testing/index.cjs.map +7 -0
- package/dist/types/src/packlets/deprecated/profile.d.ts +3 -1
- package/dist/types/src/packlets/deprecated/profile.d.ts.map +1 -1
- package/dist/types/src/packlets/deprecated/space.d.ts.map +1 -1
- package/dist/types/src/packlets/deprecated/system.d.ts +15 -9
- package/dist/types/src/packlets/deprecated/system.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +3 -3
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.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 +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -0
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts +11 -3
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations.d.ts +1 -1
- package/dist/types/src/packlets/invitations/invitations.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.test.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-definitions.d.ts +1 -1
- package/dist/types/src/packlets/services/service-definitions.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +9 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +4 -3
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +9 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +18 -4
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +50 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.test.d.ts +2 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.test.d.ts.map +1 -0
- 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/testing/credential-utils.d.ts +8 -0
- package/dist/types/src/packlets/testing/credential-utils.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/index.d.ts +2 -0
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +3 -0
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +28 -0
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/{iframe-runtime.d.ts → iframe-proxy-runtime.d.ts} +4 -4
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/index.d.ts +4 -1
- package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +19 -0
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -4
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +29 -29
- package/src/packlets/deprecated/profile.ts +20 -2
- package/src/packlets/deprecated/space.ts +41 -37
- package/src/packlets/deprecated/system.ts +26 -13
- package/src/packlets/devtools/devtools.ts +4 -4
- package/src/packlets/devtools/feeds.ts +11 -6
- package/src/packlets/devtools/network.ts +20 -9
- package/src/packlets/devtools/spaces.ts +7 -6
- package/src/packlets/identity/authenticator.ts +11 -6
- package/src/packlets/identity/identity-manager.test.ts +24 -15
- package/src/packlets/identity/identity-manager.ts +22 -8
- package/src/packlets/identity/identity.test.ts +21 -22
- package/src/packlets/identity/identity.ts +10 -5
- package/src/packlets/invitations/halo-invitations-handler.test.ts +4 -45
- package/src/packlets/invitations/halo-invitations-handler.ts +33 -17
- package/src/packlets/invitations/invitations.ts +2 -1
- package/src/packlets/invitations/space-invitations-handler.test.ts +43 -26
- package/src/packlets/invitations/space-invitations-handler.ts +8 -11
- package/src/packlets/services/service-context.test.ts +56 -0
- package/src/packlets/services/service-context.ts +60 -4
- package/src/packlets/services/service-definitions.ts +1 -1
- package/src/packlets/services/service-host.test.ts +74 -5
- package/src/packlets/services/service-host.ts +85 -23
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/services/service-registry.ts +5 -1
- package/src/packlets/spaces/data-space-manager.test.ts +71 -14
- package/src/packlets/spaces/data-space-manager.ts +49 -8
- package/src/packlets/spaces/data-space.ts +113 -14
- package/src/packlets/spaces/notarization-plugin.test.ts +81 -0
- package/src/packlets/spaces/notarization-plugin.ts +211 -0
- package/src/packlets/spaces/spaces-service.ts +9 -1
- package/src/packlets/testing/credential-utils.ts +28 -0
- package/src/packlets/testing/index.ts +2 -0
- package/src/packlets/testing/invitation-utils.ts +44 -0
- package/src/packlets/testing/test-builder.ts +14 -18
- package/src/packlets/vault/iframe-host-runtime.ts +112 -0
- package/src/packlets/vault/{iframe-runtime.ts → iframe-proxy-runtime.ts} +3 -3
- package/src/packlets/vault/index.ts +4 -1
- package/src/packlets/vault/vault-resource-lock.ts +76 -0
- package/src/packlets/vault/worker-runtime.ts +13 -3
- package/src/packlets/vault/worker-session.ts +17 -17
- package/dist/types/src/packlets/vault/iframe-runtime.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,EACL,aAAa,EACb,uBAAuB,EACxB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAEzE;;GAEG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,YAAY;IAElD,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;IAInC,WAAW,IAAI,MAAM,CAAC,KAAK,CAAC;IAI5B,YAAY,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAAC,oBAAoB,CAAC;IAItE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC;IAcrE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,uBAAuB;CAM1E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Signer } from '@dxos/crypto';
|
|
2
|
+
import { PublicKey } from '@dxos/keys';
|
|
3
|
+
import { Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
4
|
+
export declare const createMockCredential: ({ signer, issuer }: {
|
|
5
|
+
signer: Signer;
|
|
6
|
+
issuer: PublicKey;
|
|
7
|
+
}) => Promise<Credential>;
|
|
8
|
+
//# sourceMappingURL=credential-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-utils.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/credential-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAEzE,eAAO,MAAM,oBAAoB;YAIvB,MAAM;YACN,SAAS;MACf,QAAQ,UAAU,CAYlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-utils.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/invitation-utils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,6FA+B7B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from '@dxos/config';
|
|
2
|
-
import {
|
|
2
|
+
import { DataPipelineControllerImpl, MetadataStore, SigningContext, SnapshotStore, SpaceManager } from '@dxos/echo-db';
|
|
3
3
|
import { FeedStore } from '@dxos/feed-store';
|
|
4
4
|
import { Keyring } from '@dxos/keyring';
|
|
5
5
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -13,7 +13,7 @@ export declare const createServiceContext: ({ signalContext, storage }?: {
|
|
|
13
13
|
}) => ServiceContext;
|
|
14
14
|
export declare const createPeers: (numPeers: number) => Promise<ServiceContext[]>;
|
|
15
15
|
export declare const createIdentity: (peer: ServiceContext) => Promise<ServiceContext>;
|
|
16
|
-
export declare const syncItems: (
|
|
16
|
+
export declare const syncItems: (db1: DataPipelineControllerImpl, db2: DataPipelineControllerImpl) => Promise<void>;
|
|
17
17
|
export declare class TestBuilder {
|
|
18
18
|
readonly signalContext: MemorySignalManagerContext;
|
|
19
19
|
createPeer(): TestPeer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EAEb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAe,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAuB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAA0B,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAiB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAA6B,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM5F,eAAO,MAAM,iBAAiB,WAAY,MAAM,wBAAwB,0BAA0B,uBAUjG,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;oBAchC,CAAC;AAEF,eAAO,MAAM,WAAW,aAAoB,MAAM,8BAUjD,CAAC;AAEF,eAAO,MAAM,cAAc,SAAgB,cAAc,4BAGxD,CAAC;AAIF,eAAO,MAAM,SAAS,QAAe,0BAA0B,OAAO,0BAA0B,kBAG/F,CAAC;AAEF,qBAAa,WAAW;IACtB,SAAgB,aAAa,6BAAoC;IAEjE,UAAU,IAAI,QAAQ;CAGvB;AAED,oBAAY,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,qBAAa,QAAQ;IAGP,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,MAAM,CAAqB;gBAEN,aAAa,EAAE,0BAA0B;IAEtE,IAAI,OAAO,YAEV;IAED,IAAI,OAAO,YAEV;IAED,IAAI,SAAS,mBAUZ;IAED,IAAI,aAAa,kBAEhB;IAED,IAAI,aAAa,kBAEhB;IAED,IAAI,cAAc,mBAKjB;IAED,IAAI,YAAY,iBAKf;CACF;AAED,eAAO,MAAM,oBAAoB,YAAmB,OAAO,KAAG,QAAQ,cAAc,CAgBnF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Config } from '@dxos/config';
|
|
2
|
+
import { RpcPort } from '@dxos/rpc';
|
|
3
|
+
import { MaybePromise } from '@dxos/util';
|
|
4
|
+
export declare type IFrameHostRuntimeParams = {
|
|
5
|
+
configProvider: () => MaybePromise<Config>;
|
|
6
|
+
appPort: RpcPort;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Runs the client services in the main thread.
|
|
10
|
+
*
|
|
11
|
+
* Holds a lock over the client services such that only one instance can run at a time.
|
|
12
|
+
* This should only be used when SharedWorker is not available.
|
|
13
|
+
*/
|
|
14
|
+
export declare class IFrameHostRuntime {
|
|
15
|
+
private readonly _configProvider;
|
|
16
|
+
private readonly _transportFactory;
|
|
17
|
+
private readonly _ready;
|
|
18
|
+
private readonly _getService;
|
|
19
|
+
private readonly _appPort;
|
|
20
|
+
private _clientServices;
|
|
21
|
+
private _clientRpc;
|
|
22
|
+
private _config;
|
|
23
|
+
origin?: string;
|
|
24
|
+
constructor({ configProvider, appPort }: IFrameHostRuntimeParams);
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=iframe-host-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframe-host-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/iframe-host-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,EAAoC,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,oBAAY,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAkC;IACpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAEN;IAEtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,OAAO,CAAU;IAGlB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEX,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,uBAAuB;IAkB1D,KAAK;IA4CL,IAAI;CAMX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcPort } from '@dxos/rpc';
|
|
2
|
-
export declare type
|
|
2
|
+
export declare type IFrameProxyRuntimeParams = {
|
|
3
3
|
systemPort: RpcPort;
|
|
4
4
|
workerAppPort: RpcPort;
|
|
5
5
|
windowAppPort: RpcPort;
|
|
@@ -7,14 +7,14 @@ export declare type IframeRuntimeParams = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Manages the client connection to the shared worker.
|
|
9
9
|
*/
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class IFrameProxyRuntime {
|
|
11
11
|
private readonly _systemPort;
|
|
12
12
|
private readonly _windowAppPort;
|
|
13
13
|
private readonly _workerAppPort;
|
|
14
14
|
private readonly _systemRpc;
|
|
15
15
|
private readonly _transportService;
|
|
16
|
-
constructor({ systemPort, workerAppPort, windowAppPort }:
|
|
16
|
+
constructor({ systemPort, workerAppPort, windowAppPort }: IFrameProxyRuntimeParams);
|
|
17
17
|
open(origin: string): Promise<void>;
|
|
18
18
|
close(): Promise<void>;
|
|
19
19
|
}
|
|
20
|
-
//# sourceMappingURL=iframe-runtime.d.ts.map
|
|
20
|
+
//# sourceMappingURL=iframe-proxy-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframe-proxy-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/iframe-proxy-runtime.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoC,OAAO,EAAE,MAAM,WAAW,CAAC;AAKtE,oBAAY,wBAAwB,GAAG;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAC/D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgC;gBAEtD,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,EAAE,wBAAwB;IAwB5E,IAAI,CAAC,MAAM,EAAE,MAAM;IAKnB,KAAK;CAIZ"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * from './iframe-runtime';
|
|
1
|
+
export * from './iframe-host-runtime';
|
|
2
|
+
export * from './iframe-proxy-runtime';
|
|
3
|
+
export * from './services';
|
|
4
|
+
export * from './vault-resource-lock';
|
|
2
5
|
export * from './worker-runtime';
|
|
3
6
|
export * from './worker-session';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MaybePromise } from '@dxos/util';
|
|
2
|
+
export declare type VaultResourceLockOptions = {
|
|
3
|
+
lockKey: string;
|
|
4
|
+
onAcquire?: () => MaybePromise<void>;
|
|
5
|
+
onRelease?: () => MaybePromise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare class VaultResourceLock {
|
|
8
|
+
private readonly _broadcastChannel;
|
|
9
|
+
private readonly _lockKey;
|
|
10
|
+
private readonly _onAcquire;
|
|
11
|
+
private readonly _onRelease;
|
|
12
|
+
private _releaseTrigger;
|
|
13
|
+
constructor({ lockKey, onAcquire, onRelease }: VaultResourceLockOptions);
|
|
14
|
+
acquire(): Promise<void>;
|
|
15
|
+
release(): Promise<void>;
|
|
16
|
+
private _onMessage;
|
|
17
|
+
private _requestLock;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=vault-resource-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-resource-lock.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/vault-resource-lock.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,oBAAY,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+C;IACjF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwC;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwC;IACnE,OAAO,CAAC,eAAe,CAAiB;gBAE5B,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,wBAAwB;IAOjE,OAAO;IAYP,OAAO;IAIb,OAAO,CAAC,UAAU;YAMJ,YAAY;CAqB3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/worker-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-runtime.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/worker-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,oBAAY,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,aAAa;IAUtB,OAAO,CAAC,QAAQ,CAAC,eAAe;IATlC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IACvE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IACrD,OAAO,CAAC,qBAAqB,CAAC,CAAgB;IAC9C,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,OAAO,CAAU;gBAIN,eAAe,EAAE,MAAM,YAAY,CAAC,MAAM,CAAC;IAGxD,KAAK;IAyBL,IAAI;IAKV;;OAEG;IACG,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,mBAAmB;IAgChE;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAmBzB"}
|
|
@@ -2,9 +2,9 @@ import { Trigger } from '@dxos/async';
|
|
|
2
2
|
import { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
3
3
|
import { RpcPort } from '@dxos/rpc';
|
|
4
4
|
import { Callback } from '@dxos/util';
|
|
5
|
-
import {
|
|
5
|
+
import { ClientServices } from '../services';
|
|
6
6
|
export declare type WorkerSessionParams = {
|
|
7
|
-
|
|
7
|
+
getService: <Service>(find: (services: Partial<ClientServices>) => Service | undefined) => Promise<Service>;
|
|
8
8
|
systemPort: RpcPort;
|
|
9
9
|
appPort: RpcPort;
|
|
10
10
|
readySignal: Trigger<Error | undefined>;
|
|
@@ -19,13 +19,13 @@ export declare class WorkerSession {
|
|
|
19
19
|
private readonly _clientRpc;
|
|
20
20
|
private readonly _iframeRpc;
|
|
21
21
|
private readonly _startTrigger;
|
|
22
|
-
private readonly
|
|
22
|
+
private readonly _getService;
|
|
23
23
|
private readonly _options;
|
|
24
24
|
private _heartbeatTimer?;
|
|
25
25
|
readonly onClose: Callback<() => Promise<void>>;
|
|
26
26
|
origin?: string;
|
|
27
27
|
bridgeService?: BridgeService;
|
|
28
|
-
constructor({
|
|
28
|
+
constructor({ getService, systemPort, appPort, options }: WorkerSessionParams);
|
|
29
29
|
open(): Promise<void>;
|
|
30
30
|
close(): Promise<void>;
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-session.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/worker-session.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAoC,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,
|
|
1
|
+
{"version":3,"file":"worker-session.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/vault/worker-session.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAoC,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAuB,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlE,oBAAY,mBAAmB,GAAG;IAChC,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,OAAO,GAAG,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5G,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE;QACR,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAC/D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoC;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8C;IACvE,OAAO,CAAC,eAAe,CAAC,CAAiB;IAEzC,SAAgB,OAAO,iBAAsB,QAAQ,IAAI,CAAC,EAAI;IAGvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,aAAa,CAAC,EAAE,aAAa,CAAC;gBAEzB,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAEC,EACF,EAAE,mBAAmB;IAoDhB,IAAI;IAuBJ,KAAK;CAcZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"browser": {
|
|
11
11
|
"jsondown": false,
|
|
12
12
|
"./dist/lib/node/index.cjs": "./dist/lib/browser/index.mjs",
|
|
13
|
-
"./
|
|
13
|
+
"./testing.js": "./dist/lib/browser/packlets/testing/index.mjs"
|
|
14
14
|
},
|
|
15
15
|
"types": "dist/types/src/index.d.ts",
|
|
16
16
|
"files": [
|
|
@@ -21,36 +21,36 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"base-x": "~3.0.9",
|
|
24
|
-
"@dxos/async": "0.1.
|
|
25
|
-
"@dxos/codec-protobuf": "0.1.
|
|
26
|
-
"@dxos/config": "0.1.
|
|
27
|
-
"@dxos/context": "0.1.
|
|
28
|
-
"@dxos/credentials": "0.1.
|
|
29
|
-
"@dxos/crypto": "0.1.
|
|
30
|
-
"@dxos/debug": "0.1.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/protocols": "0.1.
|
|
43
|
-
"@dxos/random-access-storage": "0.1.
|
|
44
|
-
"@dxos/rpc": "0.1.
|
|
45
|
-
"@dxos/teleport": "0.1.
|
|
46
|
-
"@dxos/teleport-extension-presence": "0.1.
|
|
47
|
-
"@dxos/text-model": "0.1.
|
|
48
|
-
"@dxos/timeframe": "0.1.
|
|
49
|
-
"@dxos/util": "0.1.
|
|
24
|
+
"@dxos/async": "0.1.24",
|
|
25
|
+
"@dxos/codec-protobuf": "0.1.24",
|
|
26
|
+
"@dxos/config": "0.1.24",
|
|
27
|
+
"@dxos/context": "0.1.24",
|
|
28
|
+
"@dxos/credentials": "0.1.24",
|
|
29
|
+
"@dxos/crypto": "0.1.24",
|
|
30
|
+
"@dxos/debug": "0.1.24",
|
|
31
|
+
"@dxos/document-model": "0.1.24",
|
|
32
|
+
"@dxos/echo-db": "0.1.24",
|
|
33
|
+
"@dxos/errors": "0.1.24",
|
|
34
|
+
"@dxos/feed-store": "0.1.24",
|
|
35
|
+
"@dxos/keyring": "0.1.24",
|
|
36
|
+
"@dxos/keys": "0.1.24",
|
|
37
|
+
"@dxos/log": "0.1.24",
|
|
38
|
+
"@dxos/messaging": "0.1.24",
|
|
39
|
+
"@dxos/model-factory": "0.1.24",
|
|
40
|
+
"@dxos/network-manager": "0.1.24",
|
|
41
|
+
"@dxos/node-std": "0.1.24",
|
|
42
|
+
"@dxos/protocols": "0.1.24",
|
|
43
|
+
"@dxos/random-access-storage": "0.1.24",
|
|
44
|
+
"@dxos/rpc": "0.1.24",
|
|
45
|
+
"@dxos/teleport": "0.1.24",
|
|
46
|
+
"@dxos/teleport-extension-presence": "0.1.24",
|
|
47
|
+
"@dxos/text-model": "0.1.24",
|
|
48
|
+
"@dxos/timeframe": "0.1.24",
|
|
49
|
+
"@dxos/util": "0.1.24"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/readable-stream": "^2.3.9",
|
|
53
|
-
"@dxos/signal": "0.1.
|
|
53
|
+
"@dxos/signal": "0.1.24"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import assert from 'node:assert';
|
|
6
|
+
|
|
5
7
|
import { Stream } from '@dxos/codec-protobuf';
|
|
8
|
+
import { signPresentation } from '@dxos/credentials';
|
|
6
9
|
import { todo } from '@dxos/debug';
|
|
7
10
|
import {
|
|
8
11
|
CreateProfileRequest,
|
|
9
12
|
Profile,
|
|
10
13
|
ProfileService,
|
|
11
14
|
RecoverProfileRequest,
|
|
15
|
+
SignPresentationRequest,
|
|
12
16
|
SubscribeProfileResponse
|
|
13
17
|
} from '@dxos/protocols/proto/dxos/client';
|
|
18
|
+
import { Presentation } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
14
19
|
|
|
15
20
|
import { ServiceContext } from '../services';
|
|
16
21
|
import { InviteeInvitations } from './invitations';
|
|
@@ -32,7 +37,8 @@ export class ProfileServiceImpl implements ProfileService {
|
|
|
32
37
|
? {
|
|
33
38
|
identityKey: this.context.identityManager.identity.identityKey,
|
|
34
39
|
deviceKey: this.context.identityManager.identity.deviceKey,
|
|
35
|
-
displayName: this.context.identityManager.identity.profileDocument?.displayName
|
|
40
|
+
displayName: this.context.identityManager.identity.profileDocument?.displayName,
|
|
41
|
+
haloSpace: this.context.identityManager.identity.space.key
|
|
36
42
|
}
|
|
37
43
|
: undefined
|
|
38
44
|
});
|
|
@@ -49,7 +55,8 @@ export class ProfileServiceImpl implements ProfileService {
|
|
|
49
55
|
return {
|
|
50
56
|
identityKey: this.context.identityManager.identity!.identityKey,
|
|
51
57
|
deviceKey: this.context.identityManager.identity!.deviceKey,
|
|
52
|
-
displayName: this.context.identityManager.identity!.profileDocument?.displayName
|
|
58
|
+
displayName: this.context.identityManager.identity!.profileDocument?.displayName,
|
|
59
|
+
haloSpace: this.context.identityManager.identity!.space.key
|
|
53
60
|
};
|
|
54
61
|
}
|
|
55
62
|
|
|
@@ -64,4 +71,15 @@ export class ProfileServiceImpl implements ProfileService {
|
|
|
64
71
|
// assert(profile, 'Recovering profile failed.');
|
|
65
72
|
// return profile;
|
|
66
73
|
}
|
|
74
|
+
|
|
75
|
+
async signPresentation({ presentation, nonce }: SignPresentationRequest): Promise<Presentation> {
|
|
76
|
+
assert(this.context.identityManager.identity, 'Identity not initialized.');
|
|
77
|
+
return await signPresentation({
|
|
78
|
+
presentation,
|
|
79
|
+
signer: this.context.keyring,
|
|
80
|
+
signerKey: this.context.identityManager.identity.deviceKey,
|
|
81
|
+
chain: this.context.identityManager.identity.deviceCredentialChain,
|
|
82
|
+
nonce
|
|
83
|
+
});
|
|
84
|
+
}
|
|
67
85
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import assert from 'node:assert';
|
|
6
6
|
|
|
7
|
-
import { EventSubscriptions } from '@dxos/async';
|
|
8
7
|
import { Stream } from '@dxos/codec-protobuf';
|
|
9
8
|
import { todo } from '@dxos/debug';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
@@ -94,29 +93,29 @@ export class SpaceServiceImpl implements SpaceService {
|
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
subscribeSpaces() {
|
|
97
|
-
return new Stream<SubscribeSpacesResponse>(({ next }) => {
|
|
98
|
-
const subscriptions = new EventSubscriptions();
|
|
99
|
-
|
|
96
|
+
return new Stream<SubscribeSpacesResponse>(({ next, ctx }) => {
|
|
100
97
|
const onUpdate = () => {
|
|
101
|
-
const spaces = Array.from(this.serviceContext.dataSpaceManager!.spaces.values())
|
|
102
|
-
(space)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
const spaces = Array.from(this.serviceContext.dataSpaceManager!.spaces.values())
|
|
99
|
+
.filter((space) => this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) // Skip spaces without data service available.
|
|
100
|
+
.map(
|
|
101
|
+
(space): Space => ({
|
|
102
|
+
publicKey: space.key,
|
|
103
|
+
isOpen: true,
|
|
104
|
+
isActive: true,
|
|
105
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
109
106
|
identityKey: member.key,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
profile: {
|
|
108
|
+
identityKey: member.key,
|
|
109
|
+
displayName: member.assertion.profile?.displayName ?? humanize(member.key)
|
|
110
|
+
},
|
|
111
|
+
presence:
|
|
112
|
+
this.serviceContext.identityManager.identity?.identityKey.equals(member.key) ||
|
|
113
|
+
space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0
|
|
114
|
+
? SpaceMember.PresenceState.ONLINE
|
|
115
|
+
: SpaceMember.PresenceState.OFFLINE
|
|
116
|
+
}))
|
|
117
|
+
})
|
|
118
|
+
);
|
|
120
119
|
log('update', { spaces });
|
|
121
120
|
next({ spaces });
|
|
122
121
|
};
|
|
@@ -128,25 +127,27 @@ export class SpaceServiceImpl implements SpaceService {
|
|
|
128
127
|
|
|
129
128
|
await this.serviceContext.initialized.wait();
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
// TODO(dmaretskyi): Create a pattern for subscribing to a set of objects.
|
|
131
|
+
const subscribeSpaces = () => {
|
|
132
|
+
for (const space of this.serviceContext.dataSpaceManager!.spaces.values()) {
|
|
133
|
+
if (!this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) {
|
|
134
|
+
// Skip spaces without data service available.
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
space.stateUpdate.on(ctx, onUpdate);
|
|
139
|
+
space.presence.updated.on(ctx, onUpdate);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
this.serviceContext.dataSpaceManager!.updated.on(ctx, () => {
|
|
144
|
+
subscribeSpaces();
|
|
145
|
+
onUpdate();
|
|
144
146
|
});
|
|
145
147
|
|
|
148
|
+
subscribeSpaces();
|
|
146
149
|
onUpdate();
|
|
147
150
|
});
|
|
148
|
-
|
|
149
|
-
return () => subscriptions.clear();
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -159,6 +160,9 @@ export class SpaceServiceImpl implements SpaceService {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
async createSpace(): Promise<Space> {
|
|
163
|
+
if (!this.serviceContext.identityManager.identity) {
|
|
164
|
+
throw new Error('This device has no HALO identity available. See https://docs.dxos.org/guide/halo');
|
|
165
|
+
}
|
|
162
166
|
await this.serviceContext.initialized.wait();
|
|
163
167
|
const space = await this.serviceContext.dataSpaceManager!.createSpace();
|
|
164
168
|
return {
|
|
@@ -3,33 +3,46 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Config } from '@dxos/config';
|
|
6
|
-
import { SystemService } from '@dxos/protocols/proto/dxos/client';
|
|
6
|
+
import { StatusResponse, SystemService } from '@dxos/protocols/proto/dxos/client';
|
|
7
|
+
import { MaybePromise } from '@dxos/util';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
export type SystemServiceOptions = {
|
|
10
|
+
config: Config;
|
|
11
|
+
onInit: () => MaybePromise<void>;
|
|
12
|
+
onStatus: () => MaybePromise<StatusResponse>;
|
|
13
|
+
onReset: () => MaybePromise<void>;
|
|
14
|
+
};
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* @deprecated
|
|
12
18
|
*/
|
|
13
19
|
export class SystemServiceImpl implements SystemService {
|
|
14
|
-
|
|
20
|
+
private readonly _config: Config;
|
|
21
|
+
private readonly _onInit: () => MaybePromise<void>;
|
|
22
|
+
private readonly _onStatus: () => MaybePromise<StatusResponse>;
|
|
23
|
+
private readonly _onReset: () => MaybePromise<void>;
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
constructor({ config, onInit, onStatus, onReset }: SystemServiceOptions) {
|
|
26
|
+
this._config = config;
|
|
27
|
+
this._onInit = onInit;
|
|
28
|
+
this._onStatus = onStatus;
|
|
29
|
+
this._onReset = onReset;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
async getConfig(
|
|
32
|
+
async getConfig() {
|
|
22
33
|
return this._config.values;
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
// TODO(burdon): Connect to iframe RPC heartbeat for network status?
|
|
26
|
-
async getStatus(
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
async getStatus() {
|
|
38
|
+
return this._onStatus();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async initSession() {
|
|
42
|
+
await this._onInit();
|
|
30
43
|
}
|
|
31
44
|
|
|
32
|
-
async reset(
|
|
33
|
-
await this.
|
|
45
|
+
async reset() {
|
|
46
|
+
await this._onReset();
|
|
34
47
|
}
|
|
35
48
|
}
|
|
@@ -33,14 +33,14 @@ import {
|
|
|
33
33
|
SubscribeToSpacesRequest,
|
|
34
34
|
SubscribeToSpacesResponse,
|
|
35
35
|
SubscribeToSignalStatusResponse,
|
|
36
|
-
|
|
36
|
+
SignalResponse,
|
|
37
37
|
SubscribeToSwarmInfoResponse
|
|
38
38
|
} from '@dxos/protocols/proto/dxos/devtools/host';
|
|
39
39
|
|
|
40
40
|
import { ServiceContext } from '../services';
|
|
41
41
|
import { subscribeToFeedBlocks, subscribeToFeeds } from './feeds';
|
|
42
42
|
import { subscribeToKeyringKeys } from './keys';
|
|
43
|
-
import { subscribeToNetworkStatus,
|
|
43
|
+
import { subscribeToNetworkStatus, subscribeToSignal, subscribeToSwarmInfo } from './network';
|
|
44
44
|
import { subscribeToSpaces } from './spaces';
|
|
45
45
|
|
|
46
46
|
export class DevtoolsHostEvents {
|
|
@@ -133,8 +133,8 @@ export class DevtoolsServiceImpl implements DevtoolsHost {
|
|
|
133
133
|
return subscribeToNetworkStatus({ networkManager: this.params.context.networkManager });
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
return
|
|
136
|
+
subscribeToSignal(): Stream<SignalResponse> {
|
|
137
|
+
return subscribeToSignal({ networkManager: this.params.context.networkManager });
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
subscribeToSwarmInfo(): Stream<SubscribeToSwarmInfoResponse> {
|
|
@@ -18,17 +18,17 @@ import { ComplexMap } from '@dxos/util';
|
|
|
18
18
|
export const subscribeToFeeds = (
|
|
19
19
|
{ feedStore }: { feedStore: FeedStore<FeedMessage> },
|
|
20
20
|
{ feedKeys }: SubscribeToFeedsRequest
|
|
21
|
-
) =>
|
|
22
|
-
new Stream<SubscribeToFeedsResponse>(({ next }) => {
|
|
21
|
+
) => {
|
|
22
|
+
return new Stream<SubscribeToFeedsResponse>(({ next }) => {
|
|
23
23
|
if (feedKeys?.length === 0) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const feedMap = new ComplexMap<PublicKey, FeedWrapper<FeedMessage>>(PublicKey.hash);
|
|
28
27
|
const subscriptions = new EventSubscriptions();
|
|
28
|
+
const feedMap = new ComplexMap<PublicKey, FeedWrapper<FeedMessage>>(PublicKey.hash);
|
|
29
29
|
|
|
30
30
|
const update = () => {
|
|
31
|
-
const feeds = feedStore
|
|
31
|
+
const { feeds } = feedStore;
|
|
32
32
|
feeds
|
|
33
33
|
.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key)))
|
|
34
34
|
.forEach((feed) => {
|
|
@@ -38,6 +38,7 @@ export const subscribeToFeeds = (
|
|
|
38
38
|
subscriptions.add(feed.off('close', update));
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
+
|
|
41
42
|
next({
|
|
42
43
|
feeds: Array.from(feedMap.values()).map((feed) => ({ feedKey: feed.key, length: feed.properties.length }))
|
|
43
44
|
});
|
|
@@ -50,12 +51,13 @@ export const subscribeToFeeds = (
|
|
|
50
51
|
subscriptions.clear();
|
|
51
52
|
};
|
|
52
53
|
});
|
|
54
|
+
};
|
|
53
55
|
|
|
54
56
|
export const subscribeToFeedBlocks = (
|
|
55
57
|
{ feedStore }: { feedStore: FeedStore<FeedMessage> },
|
|
56
58
|
{ feedKey, maxBlocks = 10 }: SubscribeToFeedBlocksRequest
|
|
57
|
-
) =>
|
|
58
|
-
new Stream<SubscribeToFeedBlocksResponse>(({ next }) => {
|
|
59
|
+
) => {
|
|
60
|
+
return new Stream<SubscribeToFeedBlocksResponse>(({ next }) => {
|
|
59
61
|
if (!feedKey) {
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
@@ -77,9 +79,11 @@ export const subscribeToFeedBlocks = (
|
|
|
77
79
|
break;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
82
|
+
|
|
80
83
|
next({
|
|
81
84
|
blocks: blocks.slice(-maxBlocks)
|
|
82
85
|
});
|
|
86
|
+
|
|
83
87
|
await iterator.close();
|
|
84
88
|
};
|
|
85
89
|
|
|
@@ -96,3 +100,4 @@ export const subscribeToFeedBlocks = (
|
|
|
96
100
|
clearTimeout(timeout);
|
|
97
101
|
};
|
|
98
102
|
});
|
|
103
|
+
};
|