@dxos/client-services 0.1.5 → 0.1.7
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/LICENSE +5 -18
- package/README.md +14 -10
- package/README.yml +5 -0
- package/dist/src/packlets/deprecated/profile.d.ts +2 -5
- package/dist/src/packlets/deprecated/profile.d.ts.map +1 -1
- package/dist/src/packlets/deprecated/profile.js +1 -73
- package/dist/src/packlets/deprecated/profile.js.map +1 -1
- package/dist/src/packlets/deprecated/system.d.ts +4 -0
- package/dist/src/packlets/deprecated/system.d.ts.map +1 -1
- package/dist/src/packlets/deprecated/system.js +6 -0
- package/dist/src/packlets/deprecated/system.js.map +1 -1
- package/dist/src/packlets/deprecated/tracing.d.ts +1 -1
- package/dist/src/packlets/deprecated/tracing.js +1 -1
- package/dist/src/packlets/devtools/devtools.d.ts +3 -0
- package/dist/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/src/packlets/devtools/devtools.js +3 -1
- package/dist/src/packlets/devtools/devtools.js.map +1 -1
- package/dist/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/src/packlets/devtools/feeds.js +5 -3
- package/dist/src/packlets/devtools/feeds.js.map +1 -1
- package/dist/src/packlets/identity/devices-service-impl.d.ts.map +1 -1
- package/dist/src/packlets/identity/devices-service-impl.js.map +1 -1
- package/dist/src/packlets/identity/identity-manager.d.ts +2 -2
- package/dist/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/src/packlets/identity/identity-manager.js +44 -43
- package/dist/src/packlets/identity/identity-manager.js.map +1 -1
- package/dist/src/packlets/identity/identity.d.ts +3 -0
- package/dist/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/src/packlets/identity/identity.js +51 -1
- package/dist/src/packlets/identity/identity.js.map +1 -1
- package/dist/src/packlets/invitations/halo-invitations-handler.d.ts +23 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.d.ts.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.js +231 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.js.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.test.d.ts +2 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.test.d.ts.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.test.js +69 -0
- package/dist/src/packlets/invitations/halo-invitations-handler.test.js.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-proxy.d.ts +8 -0
- package/dist/src/packlets/invitations/halo-invitations-proxy.d.ts.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-proxy.js +17 -0
- package/dist/src/packlets/invitations/halo-invitations-proxy.js.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-service.d.ts +13 -0
- package/dist/src/packlets/invitations/halo-invitations-service.d.ts.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-service.js +20 -0
- package/dist/src/packlets/invitations/halo-invitations-service.js.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-service.test.d.ts +2 -0
- package/dist/src/packlets/invitations/halo-invitations-service.test.d.ts.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations-service.test.js +83 -0
- package/dist/src/packlets/invitations/halo-invitations-service.test.js.map +1 -0
- package/dist/src/packlets/invitations/index.d.ts +5 -1
- package/dist/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/src/packlets/invitations/index.js +5 -1
- package/dist/src/packlets/invitations/index.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-handler.d.ts +48 -0
- package/dist/src/packlets/invitations/invitations-handler.d.ts.map +1 -0
- package/dist/src/packlets/invitations/invitations-handler.js +18 -0
- package/dist/src/packlets/invitations/invitations-handler.js.map +1 -0
- package/dist/src/packlets/invitations/invitations-proxy.d.ts +11 -7
- package/dist/src/packlets/invitations/invitations-proxy.d.ts.map +1 -1
- package/dist/src/packlets/invitations/invitations-proxy.js +5 -10
- package/dist/src/packlets/invitations/invitations-proxy.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-service.d.ts +25 -0
- package/dist/src/packlets/invitations/invitations-service.d.ts.map +1 -0
- package/dist/src/packlets/invitations/invitations-service.js +174 -0
- package/dist/src/packlets/invitations/invitations-service.js.map +1 -0
- package/dist/src/packlets/invitations/invitations.d.ts +10 -42
- package/dist/src/packlets/invitations/invitations.d.ts.map +1 -1
- package/dist/src/packlets/invitations/invitations.js +5 -2
- package/dist/src/packlets/invitations/invitations.js.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-handler.d.ts +6 -6
- package/dist/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-handler.js +18 -19
- package/dist/src/packlets/invitations/space-invitations-handler.js.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-handler.test.js +5 -5
- package/dist/src/packlets/invitations/space-invitations-handler.test.js.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-proxy.d.ts +1 -1
- package/dist/src/packlets/invitations/space-invitations-proxy.d.ts.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-proxy.js +2 -2
- package/dist/src/packlets/invitations/space-invitations-proxy.js.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-service.d.ts +8 -14
- package/dist/src/packlets/invitations/space-invitations-service.d.ts.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-service.js +11 -169
- package/dist/src/packlets/invitations/space-invitations-service.js.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-service.test.js +4 -4
- package/dist/src/packlets/invitations/space-invitations-service.test.js.map +1 -1
- package/dist/src/packlets/services/service-context.d.ts +2 -2
- package/dist/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/src/packlets/services/service-context.js +8 -8
- package/dist/src/packlets/services/service-context.js.map +1 -1
- package/dist/src/packlets/services/service-definitions.d.ts +5 -4
- package/dist/src/packlets/services/service-definitions.d.ts.map +1 -1
- package/dist/src/packlets/services/service-definitions.js +6 -4
- package/dist/src/packlets/services/service-definitions.js.map +1 -1
- package/dist/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/src/packlets/services/service-host.js +10 -8
- package/dist/src/packlets/services/service-host.js.map +1 -1
- package/dist/src/packlets/services/service-proxy.js +1 -1
- package/dist/src/packlets/services/service-registry.test.js +2 -2
- package/dist/src/packlets/services/service-registry.test.js.map +1 -1
- package/dist/src/packlets/vault/iframe-runtime.d.ts +5 -4
- package/dist/src/packlets/vault/iframe-runtime.d.ts.map +1 -1
- package/dist/src/packlets/vault/iframe-runtime.js +4 -12
- package/dist/src/packlets/vault/iframe-runtime.js.map +1 -1
- package/dist/src/packlets/vault/worker-runtime.d.ts +4 -3
- package/dist/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/src/packlets/vault/worker-runtime.js +29 -24
- package/dist/src/packlets/vault/worker-runtime.js.map +1 -1
- package/dist/src/packlets/vault/worker-session.d.ts +5 -2
- package/dist/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/src/packlets/vault/worker-session.js +23 -10
- package/dist/src/packlets/vault/worker-session.js.map +1 -1
- package/package.json +26 -26
- package/src/packlets/deprecated/profile.ts +2 -84
- package/src/packlets/deprecated/system.ts +7 -0
- package/src/packlets/deprecated/tracing.ts +1 -1
- package/src/packlets/devtools/devtools.ts +3 -1
- package/src/packlets/devtools/feeds.ts +5 -3
- package/src/packlets/identity/devices-service-impl.ts +0 -1
- package/src/packlets/identity/identity-manager.ts +50 -49
- package/src/packlets/identity/identity.ts +58 -1
- package/src/packlets/invitations/halo-invitations-handler.test.ts +79 -0
- package/src/packlets/invitations/halo-invitations-handler.ts +255 -0
- package/src/packlets/invitations/halo-invitations-proxy.ts +14 -0
- package/src/packlets/invitations/halo-invitations-service.test.ts +96 -0
- package/src/packlets/invitations/halo-invitations-service.ts +24 -0
- package/src/packlets/invitations/index.ts +5 -1
- package/src/packlets/invitations/invitations-handler.ts +59 -0
- package/src/packlets/invitations/invitations-proxy.ts +15 -13
- package/src/packlets/invitations/invitations-service.ts +184 -0
- package/src/packlets/invitations/invitations.ts +14 -46
- package/src/packlets/invitations/space-invitations-handler.test.ts +6 -6
- package/src/packlets/invitations/space-invitations-handler.ts +16 -16
- package/src/packlets/invitations/space-invitations-proxy.ts +2 -2
- package/src/packlets/invitations/space-invitations-service.test.ts +13 -13
- package/src/packlets/invitations/space-invitations-service.ts +16 -177
- package/src/packlets/services/service-context.ts +6 -6
- package/src/packlets/services/service-definitions.ts +20 -10
- package/src/packlets/services/service-host.ts +15 -7
- package/src/packlets/services/service-proxy.ts +1 -1
- package/src/packlets/services/service-registry.test.ts +5 -5
- package/src/packlets/vault/iframe-runtime.ts +8 -15
- package/src/packlets/vault/worker-runtime.ts +36 -30
- package/src/packlets/vault/worker-session.ts +20 -6
- package/dist/src/packlets/invitations/halo-invitations.d.ts +0 -23
- package/dist/src/packlets/invitations/halo-invitations.d.ts.map +0 -1
- package/dist/src/packlets/invitations/halo-invitations.js +0 -154
- package/dist/src/packlets/invitations/halo-invitations.js.map +0 -1
- package/dist/src/packlets/invitations/halo-invitations.test.d.ts +0 -2
- package/dist/src/packlets/invitations/halo-invitations.test.d.ts.map +0 -1
- package/dist/src/packlets/invitations/halo-invitations.test.js +0 -34
- package/dist/src/packlets/invitations/halo-invitations.test.js.map +0 -1
- package/dist/src/packlets/services/iframe-service-proxy.d.ts +0 -23
- package/dist/src/packlets/services/iframe-service-proxy.d.ts.map +0 -1
- package/dist/src/packlets/services/iframe-service-proxy.js +0 -53
- package/dist/src/packlets/services/iframe-service-proxy.js.map +0 -1
- package/dist/src/packlets/services/service-host.test.d.ts +0 -2
- package/dist/src/packlets/services/service-host.test.d.ts.map +0 -1
- package/dist/src/packlets/services/service-host.test.js +0 -68
- package/dist/src/packlets/services/service-host.test.js.map +0 -1
- package/src/packlets/invitations/halo-invitations.test.ts +0 -40
- package/src/packlets/invitations/halo-invitations.ts +0 -164
- package/src/packlets/services/iframe-service-proxy.ts +0 -71
- package/src/packlets/services/service-host.test.ts +0 -76
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2022 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const chai_1 = require("chai");
|
|
7
|
-
const messaging_1 = require("@dxos/messaging");
|
|
8
|
-
const testutils_1 = require("@dxos/testutils");
|
|
9
|
-
const testing_1 = require("../testing");
|
|
10
|
-
describe('services/halo', function () {
|
|
11
|
-
it('creates identity', async function () {
|
|
12
|
-
const peer = (0, testing_1.createServiceContext)();
|
|
13
|
-
await peer.open();
|
|
14
|
-
(0, testutils_1.afterTest)(() => peer.close());
|
|
15
|
-
const identity = await peer.createIdentity();
|
|
16
|
-
(0, chai_1.expect)(identity).not.to.be.undefined;
|
|
17
|
-
});
|
|
18
|
-
it('invitations', async function () {
|
|
19
|
-
const signalContext = new messaging_1.MemorySignalManagerContext();
|
|
20
|
-
const peer1 = (0, testing_1.createServiceContext)({ signalContext });
|
|
21
|
-
const peer2 = (0, testing_1.createServiceContext)({ signalContext });
|
|
22
|
-
await peer1.open();
|
|
23
|
-
await peer2.open();
|
|
24
|
-
(0, testutils_1.afterTest)(() => peer1.close());
|
|
25
|
-
(0, testutils_1.afterTest)(() => peer2.close());
|
|
26
|
-
const identity1 = await peer1.createIdentity();
|
|
27
|
-
(0, chai_1.expect)(peer1.identityManager.identity).to.eq(identity1);
|
|
28
|
-
(0, chai_1.expect)(peer2.identityManager.identity).to.be.undefined;
|
|
29
|
-
const invitation = await peer1.haloInvitations.createInvitation();
|
|
30
|
-
const identity2 = await peer2.haloInvitations.acceptInvitation(invitation);
|
|
31
|
-
(0, chai_1.expect)(identity2.identityKey).to.deep.eq(identity1.identityKey);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=halo-invitations.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"halo-invitations.test.js","sourceRoot":"","sources":["../../../../src/packlets/invitations/halo-invitations.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;AAEF,+BAA8B;AAE9B,+CAA6D;AAC7D,+CAA4C;AAE5C,wCAAkD;AAElD,QAAQ,CAAC,eAAe,EAAE;IACxB,EAAE,CAAC,kBAAkB,EAAE,KAAK;QAC1B,MAAM,IAAI,GAAG,IAAA,8BAAoB,GAAE,CAAC;QACpC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAE9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,EAAE,KAAK;QACrB,MAAM,aAAa,GAAG,IAAI,sCAA0B,EAAE,CAAC;QAEvD,MAAM,KAAK,GAAG,IAAA,8BAAoB,EAAC,EAAE,aAAa,EAAE,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,IAAA,8BAAoB,EAAC,EAAE,aAAa,EAAE,CAAC,CAAC;QACtD,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/B,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC/C,IAAA,aAAM,EAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QACxD,IAAA,aAAM,EAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QAEvD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;QAClE,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC3E,IAAA,aAAM,EAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Config, ConfigProto } from '@dxos/config';
|
|
2
|
-
import { ClientServicesProvider } from './service-definitions';
|
|
3
|
-
export declare const DEFAULT_CLIENT_ORIGIN = "https://halo.dxos.org/headless.html";
|
|
4
|
-
export declare const DEFAULT_CONFIG_CHANNEL = "dxos:app";
|
|
5
|
-
export declare type ClientIFrameServiceProxyParams = {
|
|
6
|
-
config: Config | ConfigProto;
|
|
7
|
-
channel?: string;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
};
|
|
10
|
-
/** */
|
|
11
|
-
export declare class ClientIFrameServiceProxy implements ClientServicesProvider {
|
|
12
|
-
private _iframeId?;
|
|
13
|
-
private _clientServicesProxy?;
|
|
14
|
-
private readonly params;
|
|
15
|
-
constructor({ config, channel, timeout }: ClientIFrameServiceProxyParams);
|
|
16
|
-
get proxy(): import("@dxos/rpc").ProtoRpcPeer<import("./service-definitions").ClientServices>;
|
|
17
|
-
get descriptors(): import("@dxos/rpc").ServiceBundle<import("./service-definitions").ClientServices>;
|
|
18
|
-
get services(): import("./service-definitions").ClientServices;
|
|
19
|
-
open(): Promise<void>;
|
|
20
|
-
close(): Promise<void>;
|
|
21
|
-
private _getIFramePort;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=iframe-service-proxy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-service-proxy.d.ts","sourceRoot":"","sources":["../../../../src/packlets/services/iframe-service-proxy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAc,MAAM,cAAc,CAAC;AAK/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAI/D,eAAO,MAAM,qBAAqB,wCAAwC,CAAC;AAC3E,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD,oBAAY,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM;AACN,qBAAa,wBAAyB,YAAW,sBAAsB;IACrE,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAsB;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAEZ,EAAE,MAAM,EAAE,OAAgC,EAAE,OAAc,EAAE,EAAE,8BAA8B;IAKxG,IAAI,KAAK,qFAER;IAED,IAAI,WAAW,sFAEd;IAED,IAAI,QAAQ,mDAEX;IAEK,IAAI;IAOJ,KAAK;IASX,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2021 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ClientIFrameServiceProxy = exports.DEFAULT_CONFIG_CHANNEL = exports.DEFAULT_CLIENT_ORIGIN = void 0;
|
|
7
|
-
const config_1 = require("@dxos/config");
|
|
8
|
-
const keys_1 = require("@dxos/keys");
|
|
9
|
-
const rpc_tunnel_1 = require("@dxos/rpc-tunnel");
|
|
10
|
-
const service_proxy_1 = require("./service-proxy");
|
|
11
|
-
// TODO(mykola): Remove copy-paste from client/config.ts
|
|
12
|
-
exports.DEFAULT_CLIENT_ORIGIN = 'https://halo.dxos.org/headless.html';
|
|
13
|
-
exports.DEFAULT_CONFIG_CHANNEL = 'dxos:app';
|
|
14
|
-
/** */
|
|
15
|
-
class ClientIFrameServiceProxy {
|
|
16
|
-
constructor({ config, channel = exports.DEFAULT_CONFIG_CHANNEL, timeout = 1000 }) {
|
|
17
|
-
this.params = { config, channel, timeout };
|
|
18
|
-
this._clientServicesProxy = new service_proxy_1.ClientServicesProxy(this._getIFramePort());
|
|
19
|
-
}
|
|
20
|
-
get proxy() {
|
|
21
|
-
return this._clientServicesProxy.proxy;
|
|
22
|
-
}
|
|
23
|
-
get descriptors() {
|
|
24
|
-
return this._clientServicesProxy.descriptors;
|
|
25
|
-
}
|
|
26
|
-
get services() {
|
|
27
|
-
return this._clientServicesProxy.services;
|
|
28
|
-
}
|
|
29
|
-
async open() {
|
|
30
|
-
if (!this._clientServicesProxy) {
|
|
31
|
-
this._clientServicesProxy = new service_proxy_1.ClientServicesProxy(this._getIFramePort());
|
|
32
|
-
}
|
|
33
|
-
return this._clientServicesProxy.open();
|
|
34
|
-
}
|
|
35
|
-
async close() {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
await ((_a = this._clientServicesProxy) === null || _a === void 0 ? void 0 : _a.close());
|
|
38
|
-
this._clientServicesProxy = undefined;
|
|
39
|
-
if (this._iframeId) {
|
|
40
|
-
(_b = document.getElementById(this._iframeId)) === null || _b === void 0 ? void 0 : _b.remove();
|
|
41
|
-
this._iframeId = undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
_getIFramePort() {
|
|
45
|
-
var _a;
|
|
46
|
-
this._iframeId = `__DXOS_CLIENT_${keys_1.PublicKey.random().toHex()}__`;
|
|
47
|
-
const source = new URL((_a = (0, config_1.fromConfig)(this.params.config).get('runtime.client.remoteSource')) !== null && _a !== void 0 ? _a : exports.DEFAULT_CLIENT_ORIGIN, window.location.origin);
|
|
48
|
-
const iframe = (0, rpc_tunnel_1.createIFrame)(source.toString(), this._iframeId);
|
|
49
|
-
return (0, rpc_tunnel_1.createIFramePort)({ origin: source.origin, iframe, channel: this.params.channel });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.ClientIFrameServiceProxy = ClientIFrameServiceProxy;
|
|
53
|
-
//# sourceMappingURL=iframe-service-proxy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-service-proxy.js","sourceRoot":"","sources":["../../../../src/packlets/services/iframe-service-proxy.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,yCAA+D;AAC/D,qCAAuC;AAEvC,iDAAkE;AAGlE,mDAAsD;AAEtD,wDAAwD;AAC3C,QAAA,qBAAqB,GAAG,qCAAqC,CAAC;AAC9D,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAQjD,MAAM;AACN,MAAa,wBAAwB;IAKnC,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,8BAAsB,EAAE,OAAO,GAAG,IAAI,EAAkC;QACtG,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,oBAAoB,GAAG,IAAI,mCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,oBAAqB,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,oBAAqB,CAAC,WAAW,CAAC;IAChD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,oBAAqB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,IAAI,CAAC,oBAAoB,GAAG,IAAI,mCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;SAC5E;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,KAAK;;QACT,MAAM,CAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,KAAK,EAAE,CAAA,CAAC;QACzC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,MAAA,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,MAAM,EAAE,CAAC;YAClD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;SAC5B;IACH,CAAC;IAEO,cAAc;;QACpB,IAAI,CAAC,SAAS,GAAG,iBAAiB,gBAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACjE,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,MAAA,IAAA,mBAAU,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,mCAAI,6BAAqB,EAC1F,MAAM,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/D,OAAO,IAAA,6BAAgB,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC;CACF;AA/CD,4DA+CC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-host.test.d.ts","sourceRoot":"","sources":["../../../../src/packlets/services/service-host.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2022 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const chai_1 = require("chai");
|
|
7
|
-
const async_1 = require("@dxos/async");
|
|
8
|
-
const config_1 = require("@dxos/config");
|
|
9
|
-
const messaging_1 = require("@dxos/messaging");
|
|
10
|
-
const client_1 = require("@dxos/protocols/proto/dxos/client");
|
|
11
|
-
const testutils_1 = require("@dxos/testutils");
|
|
12
|
-
const testing_1 = require("../testing");
|
|
13
|
-
const defaultTestingConfig = {
|
|
14
|
-
version: 1
|
|
15
|
-
// runtime: {
|
|
16
|
-
// services: {
|
|
17
|
-
// signal: {
|
|
18
|
-
// server: 'ws://localhost:4000/.well-known/dx/signal'
|
|
19
|
-
// }
|
|
20
|
-
// }
|
|
21
|
-
// }
|
|
22
|
-
};
|
|
23
|
-
describe('services/service-host', function () {
|
|
24
|
-
it.skip('process device invitation', async function () {
|
|
25
|
-
const config = new config_1.Config(defaultTestingConfig);
|
|
26
|
-
const signalManagerContext = new messaging_1.MemorySignalManagerContext();
|
|
27
|
-
// TODO(burdon): Use builder.
|
|
28
|
-
const peer1 = (0, testing_1.createServiceHost)(config, signalManagerContext);
|
|
29
|
-
const peer2 = (0, testing_1.createServiceHost)(config, signalManagerContext);
|
|
30
|
-
await peer1.open();
|
|
31
|
-
await peer2.open();
|
|
32
|
-
(0, testutils_1.afterTest)(() => peer1.close());
|
|
33
|
-
(0, testutils_1.afterTest)(() => peer2.close());
|
|
34
|
-
const invitationTrigger = new async_1.Trigger();
|
|
35
|
-
{
|
|
36
|
-
await peer1.services.ProfileService.createProfile({});
|
|
37
|
-
const stream = peer1.services.ProfileService.createInvitation();
|
|
38
|
-
stream.subscribe((msg) => {
|
|
39
|
-
switch (msg.state) {
|
|
40
|
-
case client_1.InvitationState.WAITING_FOR_CONNECTION: {
|
|
41
|
-
invitationTrigger.wake(msg.descriptor);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const [done, setAck] = (0, async_1.latch)({ count: 2 });
|
|
48
|
-
{
|
|
49
|
-
const invitation = await invitationTrigger.wait();
|
|
50
|
-
const stream = peer2.services.ProfileService.acceptInvitation(invitation);
|
|
51
|
-
stream.subscribe((msg) => {
|
|
52
|
-
switch (msg.state) {
|
|
53
|
-
case client_1.InvitationState.CONNECTED: {
|
|
54
|
-
setAck();
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
case client_1.InvitationState.SUCCESS: {
|
|
58
|
-
(0, chai_1.expect)(msg.spaceKey).not.to.be.undefined;
|
|
59
|
-
setAck();
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
await done();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=service-host.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-host.test.js","sourceRoot":"","sources":["../../../../src/packlets/services/service-host.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;AAEF,+BAA8B;AAE9B,uCAA6C;AAC7C,yCAAmD;AACnD,+CAA6D;AAC7D,8DAAoE;AAEpE,+CAA4C;AAE5C,wCAA+C;AAE/C,MAAM,oBAAoB,GAAgB;IACxC,OAAO,EAAE,CAAC;IACV,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,4DAA4D;IAC5D,QAAQ;IACR,MAAM;IACN,IAAI;CACL,CAAC;AAEF,QAAQ,CAAC,uBAAuB,EAAE;IAChC,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK;QACxC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,oBAAoB,CAAC,CAAC;QAChD,MAAM,oBAAoB,GAAG,IAAI,sCAA0B,EAAE,CAAC;QAE9D,6BAA6B;QAC7B,MAAM,KAAK,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAC9D,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/B,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,MAAM,iBAAiB,GAAG,IAAI,eAAO,EAAc,CAAC;QACpD;YACE,MAAM,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YACtD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,CAAC,SAAS,CAAC,CAAC,GAAQ,EAAE,EAAE;gBAC5B,QAAQ,GAAG,CAAC,KAAK,EAAE;oBACjB,KAAK,wBAAe,CAAC,sBAAsB,CAAC,CAAC;wBAC3C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,UAAW,CAAC,CAAC;wBACxC,MAAM;qBACP;iBACF;YACH,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3C;YACE,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,CAAC;YAClD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAC1E,MAAM,CAAC,SAAS,CAAC,CAAC,GAAQ,EAAE,EAAE;gBAC5B,QAAQ,GAAG,CAAC,KAAK,EAAE;oBACjB,KAAK,wBAAe,CAAC,SAAS,CAAC,CAAC;wBAC9B,MAAM,EAAE,CAAC;wBACT,MAAM;qBACP;oBAED,KAAK,wBAAe,CAAC,OAAO,CAAC,CAAC;wBAC5B,IAAA,aAAM,EAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;wBACzC,MAAM,EAAE,CAAC;wBACT,MAAM;qBACP;iBACF;YACH,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
|
-
import { afterTest } from '@dxos/testutils';
|
|
9
|
-
|
|
10
|
-
import { createServiceContext } from '../testing';
|
|
11
|
-
|
|
12
|
-
describe('services/halo', function () {
|
|
13
|
-
it('creates identity', async function () {
|
|
14
|
-
const peer = createServiceContext();
|
|
15
|
-
await peer.open();
|
|
16
|
-
afterTest(() => peer.close());
|
|
17
|
-
|
|
18
|
-
const identity = await peer.createIdentity();
|
|
19
|
-
expect(identity).not.to.be.undefined;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('invitations', async function () {
|
|
23
|
-
const signalContext = new MemorySignalManagerContext();
|
|
24
|
-
|
|
25
|
-
const peer1 = createServiceContext({ signalContext });
|
|
26
|
-
const peer2 = createServiceContext({ signalContext });
|
|
27
|
-
await peer1.open();
|
|
28
|
-
await peer2.open();
|
|
29
|
-
afterTest(() => peer1.close());
|
|
30
|
-
afterTest(() => peer2.close());
|
|
31
|
-
|
|
32
|
-
const identity1 = await peer1.createIdentity();
|
|
33
|
-
expect(peer1.identityManager.identity).to.eq(identity1);
|
|
34
|
-
expect(peer2.identityManager.identity).to.be.undefined;
|
|
35
|
-
|
|
36
|
-
const invitation = await peer1.haloInvitations.createInvitation();
|
|
37
|
-
const identity2 = await peer2.haloInvitations.acceptInvitation(invitation);
|
|
38
|
-
expect(identity2.identityKey).to.deep.eq(identity1.identityKey);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import assert from 'assert';
|
|
6
|
-
|
|
7
|
-
import { Trigger } from '@dxos/async';
|
|
8
|
-
import { failUndefined } from '@dxos/debug';
|
|
9
|
-
import { PublicKey } from '@dxos/keys';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
|
-
import { createProtocolFactory, NetworkManager, StarTopology } from '@dxos/network-manager';
|
|
12
|
-
import { createRpcPlugin } from '@dxos/protocol-plugin-rpc';
|
|
13
|
-
import { schema } from '@dxos/protocols';
|
|
14
|
-
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
15
|
-
import { createProtoRpcPeer } from '@dxos/rpc';
|
|
16
|
-
|
|
17
|
-
import { Identity, IdentityManager } from '../identity';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates and processes Halo invitations between devices.
|
|
21
|
-
*/
|
|
22
|
-
export class HaloInvitations {
|
|
23
|
-
constructor(
|
|
24
|
-
private readonly _identityManager: IdentityManager,
|
|
25
|
-
private readonly _networkManager: NetworkManager,
|
|
26
|
-
private readonly _onInitialize: () => Promise<void> // TODO(burdon): ???
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Sends a HALO admission offer and waits for guest to accept.
|
|
31
|
-
*/
|
|
32
|
-
async createInvitation({ onFinish }: { onFinish?: () => void } = {}): Promise<Invitation> {
|
|
33
|
-
const identity = this._identityManager.identity ?? failUndefined();
|
|
34
|
-
|
|
35
|
-
const plugin = createRpcPlugin(async (port) => {
|
|
36
|
-
const peer = createProtoRpcPeer({
|
|
37
|
-
requested: {
|
|
38
|
-
HaloGuestService: schema.getService('dxos.halo.invitations.HaloGuestService')
|
|
39
|
-
},
|
|
40
|
-
exposed: {
|
|
41
|
-
HaloHostService: schema.getService('dxos.halo.invitations.HaloHostService')
|
|
42
|
-
},
|
|
43
|
-
handlers: {
|
|
44
|
-
HaloHostService: {
|
|
45
|
-
presentAdmissionCredentials: async ({ deviceKey, controlFeedKey, dataFeedKey }) => {
|
|
46
|
-
log('processing admission request', { identityKey: identity.identityKey, deviceKey });
|
|
47
|
-
|
|
48
|
-
// TODO(burdon): Use CredentialGenerator.
|
|
49
|
-
const signer = identity.getIdentityCredentialSigner();
|
|
50
|
-
await identity.controlPipeline.writer.write({
|
|
51
|
-
'@type': 'dxos.echo.feed.CredentialsMessage',
|
|
52
|
-
credential: await signer.createCredential({
|
|
53
|
-
subject: deviceKey,
|
|
54
|
-
assertion: {
|
|
55
|
-
'@type': 'dxos.halo.credentials.AuthorizedDevice',
|
|
56
|
-
identityKey: identity.identityKey,
|
|
57
|
-
deviceKey
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// TODO(dmaretskyi): Admit guest's feeds otherwise messages from them won't be processed by the pipeline.
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
port
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
await peer.open();
|
|
70
|
-
{
|
|
71
|
-
log('sending admission offer', { identityKey: identity.identityKey });
|
|
72
|
-
await peer.rpc.HaloGuestService.presentAdmissionOffer({
|
|
73
|
-
identityKey: identity.identityKey,
|
|
74
|
-
haloSpaceKey: identity.haloSpaceKey,
|
|
75
|
-
genesisFeedKey: identity.haloGenesisFeedKey
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
onFinish?.();
|
|
79
|
-
}
|
|
80
|
-
await peer.close();
|
|
81
|
-
await connection.close();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const topic = PublicKey.random();
|
|
85
|
-
const peerId = PublicKey.random(); // TODO(burdon): Fails if using the actual peer key.
|
|
86
|
-
const connection = await this._networkManager.openSwarmConnection({
|
|
87
|
-
topic,
|
|
88
|
-
peerId: topic, // TODO(burdon): Why???
|
|
89
|
-
// peerId,
|
|
90
|
-
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
91
|
-
topology: new StarTopology(topic)
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
type: Invitation.Type.INTERACTIVE,
|
|
96
|
-
swarmKey: topic
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Joins an existing identity HALO by invitation.
|
|
102
|
-
*/
|
|
103
|
-
async acceptInvitation(invitation: Invitation): Promise<Identity> {
|
|
104
|
-
const admitted = new Trigger<Identity>(); // TODO(burdon): Must not share across multiple connections.
|
|
105
|
-
|
|
106
|
-
const plugin = createRpcPlugin(async (port) => {
|
|
107
|
-
const peer = createProtoRpcPeer({
|
|
108
|
-
requested: {
|
|
109
|
-
// TODO(burdon): Rename in-bound.
|
|
110
|
-
HaloHostService: schema.getService('dxos.halo.invitations.HaloHostService')
|
|
111
|
-
},
|
|
112
|
-
exposed: {
|
|
113
|
-
// TODO(burdon): Rename out-bound?
|
|
114
|
-
HaloGuestService: schema.getService('dxos.halo.invitations.HaloGuestService')
|
|
115
|
-
},
|
|
116
|
-
handlers: {
|
|
117
|
-
// TODO(burdon): Factory to create handlers and open/close handlers.
|
|
118
|
-
HaloGuestService: {
|
|
119
|
-
presentAdmissionOffer: async ({ identityKey, haloSpaceKey, genesisFeedKey }) => {
|
|
120
|
-
log('processing admission offer', { identityKey });
|
|
121
|
-
const identity = await this._identityManager.acceptIdentity({
|
|
122
|
-
identityKey,
|
|
123
|
-
haloSpaceKey,
|
|
124
|
-
haloGenesisFeedKey: genesisFeedKey
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
log('sending admission request', { identityKey: invitation.identityKey });
|
|
128
|
-
await peer.rpc.HaloHostService.presentAdmissionCredentials({
|
|
129
|
-
deviceKey: identity.deviceKey,
|
|
130
|
-
controlFeedKey: PublicKey.random(),
|
|
131
|
-
dataFeedKey: PublicKey.random()
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// TODO(burdon): Document.
|
|
135
|
-
await identity.ready();
|
|
136
|
-
admitted.wake(identity);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
port
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
await peer.open();
|
|
144
|
-
await admitted.wait();
|
|
145
|
-
await peer.close();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
assert(invitation.swarmKey);
|
|
149
|
-
const topic = PublicKey.from(invitation.swarmKey);
|
|
150
|
-
const peerId = PublicKey.random(); // TODO(burdon): Fails if using the actual peer key.
|
|
151
|
-
const connection = await this._networkManager.openSwarmConnection({
|
|
152
|
-
topic,
|
|
153
|
-
peerId: PublicKey.random(),
|
|
154
|
-
// peerId,
|
|
155
|
-
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
156
|
-
topology: new StarTopology(topic)
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const identity = await admitted.wait();
|
|
160
|
-
await this._onInitialize();
|
|
161
|
-
await connection.close();
|
|
162
|
-
return identity;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2021 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Config, ConfigProto, fromConfig } from '@dxos/config';
|
|
6
|
-
import { PublicKey } from '@dxos/keys';
|
|
7
|
-
import { RpcPort } from '@dxos/rpc';
|
|
8
|
-
import { createIFrame, createIFramePort } from '@dxos/rpc-tunnel';
|
|
9
|
-
|
|
10
|
-
import { ClientServicesProvider } from './service-definitions';
|
|
11
|
-
import { ClientServicesProxy } from './service-proxy';
|
|
12
|
-
|
|
13
|
-
// TODO(mykola): Remove copy-paste from client/config.ts
|
|
14
|
-
export const DEFAULT_CLIENT_ORIGIN = 'https://halo.dxos.org/headless.html';
|
|
15
|
-
export const DEFAULT_CONFIG_CHANNEL = 'dxos:app';
|
|
16
|
-
|
|
17
|
-
export type ClientIFrameServiceProxyParams = {
|
|
18
|
-
config: Config | ConfigProto;
|
|
19
|
-
channel?: string;
|
|
20
|
-
timeout?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/** */
|
|
24
|
-
export class ClientIFrameServiceProxy implements ClientServicesProvider {
|
|
25
|
-
private _iframeId?: string;
|
|
26
|
-
private _clientServicesProxy?: ClientServicesProxy;
|
|
27
|
-
private readonly params;
|
|
28
|
-
|
|
29
|
-
constructor({ config, channel = DEFAULT_CONFIG_CHANNEL, timeout = 1000 }: ClientIFrameServiceProxyParams) {
|
|
30
|
-
this.params = { config, channel, timeout };
|
|
31
|
-
this._clientServicesProxy = new ClientServicesProxy(this._getIFramePort());
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get proxy() {
|
|
35
|
-
return this._clientServicesProxy!.proxy;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get descriptors() {
|
|
39
|
-
return this._clientServicesProxy!.descriptors;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get services() {
|
|
43
|
-
return this._clientServicesProxy!.services;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async open() {
|
|
47
|
-
if (!this._clientServicesProxy) {
|
|
48
|
-
this._clientServicesProxy = new ClientServicesProxy(this._getIFramePort());
|
|
49
|
-
}
|
|
50
|
-
return this._clientServicesProxy.open();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async close() {
|
|
54
|
-
await this._clientServicesProxy?.close();
|
|
55
|
-
this._clientServicesProxy = undefined;
|
|
56
|
-
if (this._iframeId) {
|
|
57
|
-
document.getElementById(this._iframeId)?.remove();
|
|
58
|
-
this._iframeId = undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private _getIFramePort(): RpcPort {
|
|
63
|
-
this._iframeId = `__DXOS_CLIENT_${PublicKey.random().toHex()}__`;
|
|
64
|
-
const source = new URL(
|
|
65
|
-
fromConfig(this.params.config).get('runtime.client.remoteSource') ?? DEFAULT_CLIENT_ORIGIN,
|
|
66
|
-
window.location.origin
|
|
67
|
-
);
|
|
68
|
-
const iframe = createIFrame(source.toString(), this._iframeId);
|
|
69
|
-
return createIFramePort({ origin: source.origin, iframe, channel: this.params.channel });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { latch, Trigger } from '@dxos/async';
|
|
8
|
-
import { Config, ConfigProto } from '@dxos/config';
|
|
9
|
-
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
10
|
-
import { InvitationState } from '@dxos/protocols/proto/dxos/client';
|
|
11
|
-
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
-
import { afterTest } from '@dxos/testutils';
|
|
13
|
-
|
|
14
|
-
import { createServiceHost } from '../testing';
|
|
15
|
-
|
|
16
|
-
const defaultTestingConfig: ConfigProto = {
|
|
17
|
-
version: 1
|
|
18
|
-
// runtime: {
|
|
19
|
-
// services: {
|
|
20
|
-
// signal: {
|
|
21
|
-
// server: 'ws://localhost:4000/.well-known/dx/signal'
|
|
22
|
-
// }
|
|
23
|
-
// }
|
|
24
|
-
// }
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe('services/service-host', function () {
|
|
28
|
-
it.skip('process device invitation', async function () {
|
|
29
|
-
const config = new Config(defaultTestingConfig);
|
|
30
|
-
const signalManagerContext = new MemorySignalManagerContext();
|
|
31
|
-
|
|
32
|
-
// TODO(burdon): Use builder.
|
|
33
|
-
const peer1 = createServiceHost(config, signalManagerContext);
|
|
34
|
-
const peer2 = createServiceHost(config, signalManagerContext);
|
|
35
|
-
await peer1.open();
|
|
36
|
-
await peer2.open();
|
|
37
|
-
afterTest(() => peer1.close());
|
|
38
|
-
afterTest(() => peer2.close());
|
|
39
|
-
|
|
40
|
-
const invitationTrigger = new Trigger<Invitation>();
|
|
41
|
-
{
|
|
42
|
-
await peer1.services.ProfileService.createProfile({});
|
|
43
|
-
const stream = peer1.services.ProfileService.createInvitation();
|
|
44
|
-
stream.subscribe((msg: any) => {
|
|
45
|
-
switch (msg.state) {
|
|
46
|
-
case InvitationState.WAITING_FOR_CONNECTION: {
|
|
47
|
-
invitationTrigger.wake(msg.descriptor!);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const [done, setAck] = latch({ count: 2 });
|
|
55
|
-
{
|
|
56
|
-
const invitation = await invitationTrigger.wait();
|
|
57
|
-
const stream = peer2.services.ProfileService.acceptInvitation(invitation);
|
|
58
|
-
stream.subscribe((msg: any) => {
|
|
59
|
-
switch (msg.state) {
|
|
60
|
-
case InvitationState.CONNECTED: {
|
|
61
|
-
setAck();
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
case InvitationState.SUCCESS: {
|
|
66
|
-
expect(msg.spaceKey).not.to.be.undefined;
|
|
67
|
-
setAck();
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
await done();
|
|
75
|
-
});
|
|
76
|
-
});
|