@dxos/client-services 0.1.2 → 0.1.3
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/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/packlets/deprecated/index.d.ts +5 -0
- package/dist/src/packlets/deprecated/index.d.ts.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/index.js +1 -3
- package/dist/src/packlets/deprecated/index.js.map +1 -0
- package/dist/src/packlets/{invitations/common.d.ts → deprecated/invitations.d.ts} +14 -2
- package/dist/src/packlets/deprecated/invitations.d.ts.map +1 -0
- package/dist/src/packlets/{invitations/common.js → deprecated/invitations.js} +1 -1
- package/dist/src/packlets/deprecated/invitations.js.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/profile.d.ts +5 -5
- package/dist/src/packlets/deprecated/profile.d.ts.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/profile.js +10 -10
- package/dist/src/packlets/deprecated/profile.js.map +1 -0
- package/dist/src/packlets/deprecated/space.d.ts +23 -0
- package/dist/src/packlets/deprecated/space.d.ts.map +1 -0
- package/dist/src/packlets/deprecated/space.js +206 -0
- package/dist/src/packlets/deprecated/space.js.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/system.d.ts +2 -2
- package/dist/src/packlets/deprecated/system.d.ts.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/system.js +3 -3
- package/dist/src/packlets/deprecated/system.js.map +1 -0
- package/dist/src/packlets/deprecated/tracing.d.ts +12 -0
- package/dist/src/packlets/deprecated/tracing.d.ts.map +1 -0
- package/dist/src/packlets/{services/impl → deprecated}/tracing.js +3 -3
- package/dist/src/packlets/deprecated/tracing.js.map +1 -0
- package/dist/src/packlets/{services/impl → devtools}/devtools.d.ts +11 -7
- package/dist/src/packlets/devtools/devtools.d.ts.map +1 -0
- package/dist/src/packlets/devtools/devtools.js +86 -0
- package/dist/src/packlets/devtools/devtools.js.map +1 -0
- package/dist/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/src/packlets/devtools/feeds.js +28 -26
- package/dist/src/packlets/devtools/feeds.js.map +1 -1
- package/dist/src/packlets/devtools/index.d.ts +1 -1
- package/dist/src/packlets/devtools/index.d.ts.map +1 -1
- package/dist/src/packlets/devtools/index.js +1 -1
- package/dist/src/packlets/devtools/index.js.map +1 -1
- package/dist/src/packlets/devtools/spaces.d.ts +2 -2
- package/dist/src/packlets/devtools/spaces.d.ts.map +1 -1
- package/dist/src/packlets/devtools/spaces.js +13 -13
- package/dist/src/packlets/devtools/spaces.js.map +1 -1
- package/dist/src/packlets/identity/devices-service-impl.d.ts +10 -0
- package/dist/src/packlets/identity/devices-service-impl.d.ts.map +1 -0
- package/dist/src/packlets/identity/devices-service-impl.js +47 -0
- package/dist/src/packlets/identity/devices-service-impl.js.map +1 -0
- package/dist/src/packlets/identity/identity-manager.test.js +7 -11
- package/dist/src/packlets/identity/identity-manager.test.js.map +1 -1
- package/dist/src/packlets/identity/identity.d.ts +2 -0
- package/dist/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/src/packlets/identity/identity.js +4 -1
- package/dist/src/packlets/identity/identity.js.map +1 -1
- package/dist/src/packlets/identity/identity.test.js +2 -3
- package/dist/src/packlets/identity/identity.test.js.map +1 -1
- package/dist/src/packlets/invitations/encoder.d.ts +9 -0
- package/dist/src/packlets/invitations/encoder.d.ts.map +1 -0
- package/dist/src/packlets/invitations/encoder.js +27 -0
- package/dist/src/packlets/invitations/encoder.js.map +1 -0
- package/dist/src/packlets/invitations/encoder.test.d.ts +2 -0
- package/dist/src/packlets/invitations/encoder.test.d.ts.map +1 -0
- package/dist/src/packlets/invitations/encoder.test.js +19 -0
- package/dist/src/packlets/invitations/encoder.test.js.map +1 -0
- package/dist/src/packlets/invitations/halo-invitations.d.ts +3 -3
- package/dist/src/packlets/invitations/halo-invitations.d.ts.map +1 -1
- package/dist/src/packlets/invitations/halo-invitations.js +14 -10
- package/dist/src/packlets/invitations/halo-invitations.js.map +1 -1
- package/dist/src/packlets/invitations/halo-invitations.test.d.ts +2 -0
- package/dist/src/packlets/invitations/halo-invitations.test.d.ts.map +1 -0
- package/dist/src/packlets/{services/testing/halo.test.js → invitations/halo-invitations.test.js} +6 -6
- package/dist/src/packlets/invitations/halo-invitations.test.js.map +1 -0
- package/dist/src/packlets/invitations/index.d.ts +6 -3
- package/dist/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/src/packlets/invitations/index.js +6 -3
- package/dist/src/packlets/invitations/index.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-proxy.d.ts +14 -0
- package/dist/src/packlets/invitations/invitations-proxy.d.ts.map +1 -0
- package/dist/src/packlets/invitations/invitations-proxy.js +126 -0
- package/dist/src/packlets/invitations/invitations-proxy.js.map +1 -0
- package/dist/src/packlets/invitations/invitations.d.ts +90 -0
- package/dist/src/packlets/invitations/invitations.d.ts.map +1 -0
- package/dist/src/packlets/invitations/invitations.js +55 -0
- package/dist/src/packlets/invitations/invitations.js.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-handler.d.ts +24 -0
- package/dist/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-handler.js +232 -0
- package/dist/src/packlets/invitations/space-invitations-handler.js.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-handler.test.d.ts +2 -0
- package/dist/src/packlets/invitations/space-invitations-handler.test.d.ts.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-handler.test.js +131 -0
- package/dist/src/packlets/invitations/space-invitations-handler.test.js.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-proxy.d.ts +11 -0
- package/dist/src/packlets/invitations/space-invitations-proxy.d.ts.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-proxy.js +17 -0
- package/dist/src/packlets/invitations/space-invitations-proxy.js.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-service.d.ts +22 -0
- package/dist/src/packlets/invitations/space-invitations-service.d.ts.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-service.js +189 -0
- package/dist/src/packlets/invitations/space-invitations-service.js.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-service.test.d.ts +2 -0
- package/dist/src/packlets/invitations/space-invitations-service.test.d.ts.map +1 -0
- package/dist/src/packlets/invitations/space-invitations-service.test.js +100 -0
- package/dist/src/packlets/invitations/space-invitations-service.test.js.map +1 -0
- package/dist/src/packlets/services/index.d.ts +3 -2
- package/dist/src/packlets/services/index.d.ts.map +1 -1
- package/dist/src/packlets/services/index.js +3 -2
- package/dist/src/packlets/services/index.js.map +1 -1
- package/dist/src/packlets/services/service-context.d.ts +4 -7
- package/dist/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/src/packlets/services/service-context.js +9 -25
- package/dist/src/packlets/services/service-context.js.map +1 -1
- package/dist/src/packlets/services/service-definitions.d.ts +30 -0
- package/dist/src/packlets/services/service-definitions.d.ts.map +1 -0
- package/dist/src/packlets/services/{services.js → service-definitions.js} +9 -5
- package/dist/src/packlets/services/service-definitions.js.map +1 -0
- package/dist/src/packlets/services/service-host.d.ts +9 -12
- package/dist/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/src/packlets/services/service-host.js +55 -54
- package/dist/src/packlets/services/service-host.js.map +1 -1
- package/dist/src/packlets/services/service-host.test.js +7 -17
- package/dist/src/packlets/services/service-host.test.js.map +1 -1
- package/dist/src/packlets/services/service-proxy.d.ts +17 -0
- package/dist/src/packlets/services/service-proxy.d.ts.map +1 -0
- package/dist/src/packlets/services/service-proxy.js +48 -0
- package/dist/src/packlets/services/service-proxy.js.map +1 -0
- package/dist/src/packlets/services/service-registry.d.ts +12 -0
- package/dist/src/packlets/services/service-registry.d.ts.map +1 -0
- package/dist/src/packlets/services/service-registry.js +24 -0
- package/dist/src/packlets/services/service-registry.js.map +1 -0
- package/dist/src/packlets/services/service-registry.test.d.ts +2 -0
- package/dist/src/packlets/services/service-registry.test.d.ts.map +1 -0
- package/dist/src/packlets/services/service-registry.test.js +75 -0
- package/dist/src/packlets/services/service-registry.test.js.map +1 -0
- package/dist/src/packlets/services/signer.d.ts +0 -3
- package/dist/src/packlets/services/signer.d.ts.map +1 -1
- package/dist/src/packlets/spaces/index.d.ts +2 -0
- package/dist/src/packlets/spaces/index.d.ts.map +1 -0
- package/dist/src/packlets/spaces/index.js +21 -0
- package/dist/src/packlets/spaces/index.js.map +1 -0
- package/dist/src/packlets/spaces/spaces-service.d.ts +11 -0
- package/dist/src/packlets/spaces/spaces-service.d.ts.map +1 -0
- package/dist/src/packlets/spaces/spaces-service.js +22 -0
- package/dist/src/packlets/spaces/spaces-service.js.map +1 -0
- package/dist/src/packlets/storage/storage.js +1 -1
- package/dist/src/packlets/storage/storage.js.map +1 -1
- package/dist/src/packlets/testing/index.d.ts +2 -0
- package/dist/src/packlets/testing/index.d.ts.map +1 -0
- package/dist/src/packlets/testing/index.js +21 -0
- package/dist/src/packlets/testing/index.js.map +1 -0
- package/dist/src/packlets/testing/test-builder.d.ts +14 -0
- package/dist/src/packlets/testing/test-builder.d.ts.map +1 -0
- package/dist/src/packlets/testing/test-builder.js +65 -0
- package/dist/src/packlets/testing/test-builder.js.map +1 -0
- package/dist/src/packlets/vault/iframe-runtime.d.ts +19 -0
- package/dist/src/packlets/vault/iframe-runtime.d.ts.map +1 -0
- package/dist/src/packlets/vault/iframe-runtime.js +54 -0
- package/dist/src/packlets/vault/iframe-runtime.js.map +1 -0
- package/dist/src/packlets/vault/index.d.ts +4 -0
- package/dist/src/packlets/vault/index.d.ts.map +1 -0
- package/dist/src/packlets/vault/index.js +23 -0
- package/dist/src/packlets/vault/index.js.map +1 -0
- package/dist/src/packlets/vault/services.d.ts +13 -0
- package/dist/src/packlets/vault/services.d.ts.map +1 -0
- package/dist/src/packlets/vault/services.js +15 -0
- package/dist/src/packlets/vault/services.js.map +1 -0
- package/dist/src/packlets/vault/worker-runtime.d.ts +32 -0
- package/dist/src/packlets/vault/worker-runtime.d.ts.map +1 -0
- package/dist/src/packlets/vault/worker-runtime.js +94 -0
- package/dist/src/packlets/vault/worker-runtime.js.map +1 -0
- package/dist/src/packlets/vault/worker-session.d.ts +29 -0
- package/dist/src/packlets/vault/worker-session.d.ts.map +1 -0
- package/dist/src/packlets/vault/worker-session.js +84 -0
- package/dist/src/packlets/vault/worker-session.js.map +1 -0
- package/package.json +26 -26
- package/src/index.ts +5 -2
- package/src/packlets/{services/impl → deprecated}/index.ts +1 -4
- package/src/packlets/{invitations/common.ts → deprecated/invitations.ts} +18 -3
- package/src/packlets/{services/impl → deprecated}/profile.ts +13 -13
- package/src/packlets/deprecated/space.ts +245 -0
- package/src/packlets/{services/impl → deprecated}/system.ts +2 -2
- package/src/packlets/{services/impl → deprecated}/tracing.ts +2 -2
- package/src/packlets/{services/impl → devtools}/devtools.ts +33 -34
- package/src/packlets/devtools/feeds.ts +31 -27
- package/src/packlets/devtools/index.ts +1 -1
- package/src/packlets/devtools/spaces.ts +19 -18
- package/src/packlets/identity/devices-service-impl.ts +54 -0
- package/src/packlets/identity/identity-manager.test.ts +7 -8
- package/src/packlets/identity/identity.test.ts +2 -3
- package/src/packlets/identity/identity.ts +5 -1
- package/src/packlets/invitations/encoder.test.ts +22 -0
- package/src/packlets/invitations/encoder.ts +26 -0
- package/src/packlets/{services/testing/halo.test.ts → invitations/halo-invitations.test.ts} +5 -5
- package/src/packlets/invitations/halo-invitations.ts +12 -10
- package/src/packlets/invitations/index.ts +6 -3
- package/src/packlets/invitations/invitations-proxy.ts +157 -0
- package/src/packlets/invitations/invitations.ts +149 -0
- package/src/packlets/invitations/space-invitations-handler.test.ts +154 -0
- package/src/packlets/invitations/space-invitations-handler.ts +266 -0
- package/src/packlets/invitations/space-invitations-proxy.ts +16 -0
- package/src/packlets/invitations/space-invitations-service.test.ts +129 -0
- package/src/packlets/invitations/space-invitations-service.ts +196 -0
- package/src/packlets/services/index.ts +3 -2
- package/src/packlets/services/service-context.ts +9 -31
- package/src/packlets/services/service-definitions.ts +54 -0
- package/src/packlets/services/service-host.test.ts +12 -24
- package/src/packlets/services/service-host.ts +64 -64
- package/src/packlets/services/service-proxy.ts +54 -0
- package/src/packlets/services/service-registry.test.ts +95 -0
- package/src/packlets/services/service-registry.ts +24 -0
- package/src/packlets/services/signer.ts +1 -3
- package/src/packlets/spaces/index.ts +5 -0
- package/src/packlets/spaces/spaces-service.ts +28 -0
- package/src/packlets/storage/storage.ts +1 -1
- package/src/packlets/testing/index.ts +5 -0
- package/src/packlets/testing/test-builder.ts +79 -0
- package/src/packlets/vault/iframe-runtime.ts +68 -0
- package/src/packlets/vault/index.ts +7 -0
- package/src/packlets/vault/services.ts +26 -0
- package/src/packlets/vault/worker-runtime.ts +111 -0
- package/src/packlets/vault/worker-session.ts +113 -0
- package/dist/src/packlets/devtools/devtools-host-events.d.ts +0 -5
- package/dist/src/packlets/devtools/devtools-host-events.d.ts.map +0 -1
- package/dist/src/packlets/devtools/devtools-host-events.js +0 -14
- package/dist/src/packlets/devtools/devtools-host-events.js.map +0 -1
- package/dist/src/packlets/invitations/common.d.ts.map +0 -1
- package/dist/src/packlets/invitations/common.js.map +0 -1
- package/dist/src/packlets/invitations/invitation-wrapper.d.ts +0 -36
- package/dist/src/packlets/invitations/invitation-wrapper.d.ts.map +0 -1
- package/dist/src/packlets/invitations/invitation-wrapper.js +0 -104
- package/dist/src/packlets/invitations/invitation-wrapper.js.map +0 -1
- package/dist/src/packlets/invitations/space-invitations.d.ts +0 -25
- package/dist/src/packlets/invitations/space-invitations.d.ts.map +0 -1
- package/dist/src/packlets/invitations/space-invitations.js +0 -136
- package/dist/src/packlets/invitations/space-invitations.js.map +0 -1
- package/dist/src/packlets/services/impl/devtools.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/devtools.js +0 -77
- package/dist/src/packlets/services/impl/devtools.js.map +0 -1
- package/dist/src/packlets/services/impl/halo.d.ts +0 -20
- package/dist/src/packlets/services/impl/halo.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/halo.js +0 -93
- package/dist/src/packlets/services/impl/halo.js.map +0 -1
- package/dist/src/packlets/services/impl/index.d.ts +0 -6
- package/dist/src/packlets/services/impl/index.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/index.js.map +0 -1
- package/dist/src/packlets/services/impl/party.d.ts +0 -25
- package/dist/src/packlets/services/impl/party.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/party.js +0 -265
- package/dist/src/packlets/services/impl/party.js.map +0 -1
- package/dist/src/packlets/services/impl/profile.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/profile.js.map +0 -1
- package/dist/src/packlets/services/impl/system.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/system.js.map +0 -1
- package/dist/src/packlets/services/impl/tracing.d.ts +0 -12
- package/dist/src/packlets/services/impl/tracing.d.ts.map +0 -1
- package/dist/src/packlets/services/impl/tracing.js.map +0 -1
- package/dist/src/packlets/services/service-factory.d.ts +0 -15
- package/dist/src/packlets/services/service-factory.d.ts.map +0 -1
- package/dist/src/packlets/services/service-factory.js +0 -25
- package/dist/src/packlets/services/service-factory.js.map +0 -1
- package/dist/src/packlets/services/services.d.ts +0 -19
- package/dist/src/packlets/services/services.d.ts.map +0 -1
- package/dist/src/packlets/services/services.js.map +0 -1
- package/dist/src/packlets/services/testing/halo.test.d.ts +0 -2
- package/dist/src/packlets/services/testing/halo.test.d.ts.map +0 -1
- package/dist/src/packlets/services/testing/halo.test.js.map +0 -1
- package/dist/src/packlets/services/testing/spaces.test.d.ts +0 -2
- package/dist/src/packlets/services/testing/spaces.test.d.ts.map +0 -1
- package/dist/src/packlets/services/testing/spaces.test.js +0 -68
- package/dist/src/packlets/services/testing/spaces.test.js.map +0 -1
- package/dist/src/packlets/services/testing/testing.d.ts +0 -8
- package/dist/src/packlets/services/testing/testing.d.ts.map +0 -1
- package/dist/src/packlets/services/testing/testing.js +0 -23
- package/dist/src/packlets/services/testing/testing.js.map +0 -1
- package/src/packlets/devtools/devtools-host-events.ts +0 -8
- package/src/packlets/invitations/invitation-wrapper.ts +0 -140
- package/src/packlets/invitations/space-invitations.ts +0 -159
- package/src/packlets/services/impl/halo.ts +0 -107
- package/src/packlets/services/impl/party.ts +0 -305
- package/src/packlets/services/service-factory.ts +0 -35
- package/src/packlets/services/services.ts +0 -39
- package/src/packlets/services/testing/spaces.test.ts +0 -87
- package/src/packlets/services/testing/testing.ts +0 -28
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import assert from 'assert';
|
|
6
|
+
import { expect } from 'chai';
|
|
7
|
+
|
|
8
|
+
import { asyncChain, Trigger } from '@dxos/async';
|
|
9
|
+
import { raise } from '@dxos/debug';
|
|
10
|
+
import { Invitation, InvitationsService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
+
import { afterTest } from '@dxos/testutils';
|
|
12
|
+
|
|
13
|
+
import { ServiceContext } from '../services';
|
|
14
|
+
import { createIdentity, createPeers } from '../testing';
|
|
15
|
+
import { SpaceInvitationsProxy } from './space-invitations-proxy';
|
|
16
|
+
import { SpaceInvitationsServiceImpl } from './space-invitations-service';
|
|
17
|
+
|
|
18
|
+
const closeAfterTest = async (peer: ServiceContext) => {
|
|
19
|
+
afterTest(() => peer.close());
|
|
20
|
+
return peer;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('services/space-invitation-service', function () {
|
|
24
|
+
it('creates space and invites peer', async function () {
|
|
25
|
+
const [host, guest] = await asyncChain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
26
|
+
|
|
27
|
+
assert(host.spaceManager);
|
|
28
|
+
assert(host.spaceInvitations);
|
|
29
|
+
const service1: InvitationsService = new SpaceInvitationsServiceImpl(
|
|
30
|
+
host.identityManager,
|
|
31
|
+
() => host.spaceManager!,
|
|
32
|
+
() => host.spaceInvitations!
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
assert(guest.spaceManager);
|
|
36
|
+
assert(guest.spaceInvitations);
|
|
37
|
+
const service2: InvitationsService = new SpaceInvitationsServiceImpl(
|
|
38
|
+
guest.identityManager,
|
|
39
|
+
() => guest.spaceManager!,
|
|
40
|
+
() => guest.spaceInvitations!
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const space1 = await host.spaceManager.createSpace();
|
|
44
|
+
|
|
45
|
+
const success1 = new Trigger<Invitation>();
|
|
46
|
+
const success2 = new Trigger<Invitation>();
|
|
47
|
+
|
|
48
|
+
const authenticationCode = new Trigger<string>();
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
const proxy1 = new SpaceInvitationsProxy(service1);
|
|
52
|
+
const observable1 = proxy1.createInvitation(space1.key);
|
|
53
|
+
observable1.subscribe({
|
|
54
|
+
onConnecting: (invitation: Invitation) => {
|
|
55
|
+
const proxy2 = new SpaceInvitationsProxy(service2);
|
|
56
|
+
const observable2 = proxy2.acceptInvitation(invitation);
|
|
57
|
+
observable2.subscribe({
|
|
58
|
+
onAuthenticating: async (invitation2: Invitation) => {
|
|
59
|
+
await observable2.authenticate(await authenticationCode.wait());
|
|
60
|
+
},
|
|
61
|
+
onSuccess: (invitation: Invitation) => {
|
|
62
|
+
success2.wake(invitation);
|
|
63
|
+
},
|
|
64
|
+
onError: (err: Error) => raise(new Error(err.message))
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onConnected: (invitation: Invitation) => {
|
|
68
|
+
assert(invitation.authenticationCode);
|
|
69
|
+
authenticationCode.wake(invitation.authenticationCode);
|
|
70
|
+
},
|
|
71
|
+
onSuccess: (invitation: Invitation) => {
|
|
72
|
+
success1.wake(invitation);
|
|
73
|
+
},
|
|
74
|
+
onCancelled: () => raise(new Error()),
|
|
75
|
+
onTimeout: (err: Error) => raise(new Error(err.message)),
|
|
76
|
+
onError: (err: Error) => raise(new Error(err.message))
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const [invitation1, invitation2] = await Promise.all([success1.wait(), success2.wait()]);
|
|
81
|
+
expect(invitation1.spaceKey).to.deep.eq(invitation2.spaceKey);
|
|
82
|
+
expect(invitation1.state).to.eq(Invitation.State.SUCCESS);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('creates space and cancels invitation', async function () {
|
|
86
|
+
const [host, guest] = await asyncChain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
87
|
+
|
|
88
|
+
assert(host.spaceManager);
|
|
89
|
+
assert(host.spaceInvitations);
|
|
90
|
+
const service1: InvitationsService = new SpaceInvitationsServiceImpl(
|
|
91
|
+
host.identityManager,
|
|
92
|
+
() => host.spaceManager!,
|
|
93
|
+
() => host.spaceInvitations!
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
assert(guest.spaceManager);
|
|
97
|
+
assert(guest.spaceInvitations);
|
|
98
|
+
const service2: InvitationsService = new SpaceInvitationsServiceImpl(
|
|
99
|
+
guest.identityManager,
|
|
100
|
+
() => guest.spaceManager!,
|
|
101
|
+
() => guest.spaceInvitations!
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const space1 = await host.spaceManager.createSpace();
|
|
105
|
+
const cancelled = new Trigger();
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
const proxy = new SpaceInvitationsProxy(service1);
|
|
109
|
+
const observable = proxy.createInvitation(space1.key);
|
|
110
|
+
observable.subscribe({
|
|
111
|
+
onConnecting: (invitation: Invitation) => {
|
|
112
|
+
const proxy2 = new SpaceInvitationsProxy(service2);
|
|
113
|
+
proxy2.acceptInvitation(invitation);
|
|
114
|
+
},
|
|
115
|
+
onConnected: (invitation: Invitation) => {
|
|
116
|
+
void observable.cancel();
|
|
117
|
+
},
|
|
118
|
+
onCancelled: () => {
|
|
119
|
+
cancelled.wake();
|
|
120
|
+
},
|
|
121
|
+
onSuccess: () => raise(new Error()),
|
|
122
|
+
onTimeout: (err: Error) => raise(new Error(err.message)),
|
|
123
|
+
onError: (err: Error) => raise(new Error(err.message))
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
await cancelled.wait();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import assert from 'assert';
|
|
6
|
+
|
|
7
|
+
import { TimeoutError } from '@dxos/async';
|
|
8
|
+
import { Stream } from '@dxos/codec-protobuf';
|
|
9
|
+
import { SpaceManager } from '@dxos/echo-db';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import { AuthenticationRequest, Invitation, InvitationsService } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
+
import { Provider } from '@dxos/util';
|
|
13
|
+
|
|
14
|
+
import { IdentityManager } from '../identity';
|
|
15
|
+
import { AuthenticatingInvitationObservable, CancellableInvitationObservable } from './invitations';
|
|
16
|
+
import { SpaceInvitationsHandler } from './space-invitations-handler';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Adapts invitation service observable to client/service stream.
|
|
20
|
+
*/
|
|
21
|
+
export class SpaceInvitationsServiceImpl implements InvitationsService {
|
|
22
|
+
private readonly _createInvitations = new Map<string, CancellableInvitationObservable>();
|
|
23
|
+
private readonly _acceptInvitations = new Map<string, AuthenticatingInvitationObservable>();
|
|
24
|
+
|
|
25
|
+
// prettier-ignore
|
|
26
|
+
constructor (
|
|
27
|
+
private readonly _identityManager: IdentityManager,
|
|
28
|
+
private readonly _getSpaceManager: Provider<SpaceManager>,
|
|
29
|
+
private readonly _getSpaceInvitations: Provider<SpaceInvitationsHandler>
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
createInvitation(invitation: Invitation): Stream<Invitation> {
|
|
33
|
+
return new Stream<Invitation>(({ next, close }) => {
|
|
34
|
+
const spaceManager = this._getSpaceManager();
|
|
35
|
+
const spaceInvitations = this._getSpaceInvitations();
|
|
36
|
+
|
|
37
|
+
assert(invitation.spaceKey);
|
|
38
|
+
log('stream opened', {
|
|
39
|
+
host: this._identityManager.identity?.deviceKey,
|
|
40
|
+
spaceKey: invitation.spaceKey
|
|
41
|
+
});
|
|
42
|
+
const space = spaceManager.spaces.get(invitation.spaceKey!);
|
|
43
|
+
assert(space);
|
|
44
|
+
|
|
45
|
+
let invitationId: string;
|
|
46
|
+
const { type } = invitation;
|
|
47
|
+
const observable = spaceInvitations.createInvitation(space, { type });
|
|
48
|
+
observable.subscribe({
|
|
49
|
+
onConnecting: (invitation) => {
|
|
50
|
+
assert(invitation.invitationId);
|
|
51
|
+
invitationId = invitation.invitationId;
|
|
52
|
+
this._createInvitations.set(invitation.invitationId, observable);
|
|
53
|
+
invitation.state = Invitation.State.CONNECTING;
|
|
54
|
+
next(invitation);
|
|
55
|
+
},
|
|
56
|
+
onConnected: (invitation) => {
|
|
57
|
+
assert(invitation.invitationId);
|
|
58
|
+
invitation.state = Invitation.State.CONNECTED;
|
|
59
|
+
next(invitation);
|
|
60
|
+
},
|
|
61
|
+
onAuthenticating: (invitation) => {
|
|
62
|
+
assert(invitation.invitationId);
|
|
63
|
+
invitation.state = Invitation.State.AUTHENTICATING;
|
|
64
|
+
next(invitation);
|
|
65
|
+
},
|
|
66
|
+
onSuccess: (invitation) => {
|
|
67
|
+
assert(invitation.invitationId);
|
|
68
|
+
invitation.state = Invitation.State.SUCCESS;
|
|
69
|
+
next(invitation);
|
|
70
|
+
close();
|
|
71
|
+
},
|
|
72
|
+
onCancelled: () => {
|
|
73
|
+
assert(invitationId);
|
|
74
|
+
invitation.invitationId = invitationId;
|
|
75
|
+
invitation.state = Invitation.State.CANCELLED;
|
|
76
|
+
next(invitation);
|
|
77
|
+
close();
|
|
78
|
+
},
|
|
79
|
+
onTimeout: (err: TimeoutError) => {
|
|
80
|
+
invitation.state = Invitation.State.TIMEOUT;
|
|
81
|
+
close(err);
|
|
82
|
+
},
|
|
83
|
+
onError: (err: any) => {
|
|
84
|
+
invitation.state = Invitation.State.ERROR;
|
|
85
|
+
close(err);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return (err?: Error) => {
|
|
90
|
+
const context = {
|
|
91
|
+
guest: this._identityManager.identity?.deviceKey,
|
|
92
|
+
spaceKey: invitation.spaceKey
|
|
93
|
+
};
|
|
94
|
+
if (err) {
|
|
95
|
+
log.warn('stream closed', { ...context, err });
|
|
96
|
+
} else {
|
|
97
|
+
log('stream closed', context);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this._createInvitations.delete(invitation.invitationId!);
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
acceptInvitation(invitation: Invitation): Stream<Invitation> {
|
|
106
|
+
return new Stream<Invitation>(({ next, close }) => {
|
|
107
|
+
const spaceInvitations = this._getSpaceInvitations();
|
|
108
|
+
|
|
109
|
+
assert(invitation.spaceKey);
|
|
110
|
+
log('stream opened', {
|
|
111
|
+
guest: this._identityManager.identity?.deviceKey,
|
|
112
|
+
spaceKey: invitation.spaceKey
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
let invitationId: string;
|
|
116
|
+
const observable = spaceInvitations.acceptInvitation(invitation);
|
|
117
|
+
observable.subscribe({
|
|
118
|
+
onConnecting: (invitation) => {
|
|
119
|
+
assert(invitation.invitationId);
|
|
120
|
+
invitationId = invitation.invitationId;
|
|
121
|
+
this._acceptInvitations.set(invitation.invitationId, observable);
|
|
122
|
+
invitation.state = Invitation.State.CONNECTING;
|
|
123
|
+
next(invitation);
|
|
124
|
+
},
|
|
125
|
+
onConnected: (invitation) => {
|
|
126
|
+
assert(invitation.invitationId);
|
|
127
|
+
invitation.state = Invitation.State.CONNECTED;
|
|
128
|
+
next(invitation);
|
|
129
|
+
},
|
|
130
|
+
onAuthenticating: (invitation) => {
|
|
131
|
+
assert(invitation.invitationId);
|
|
132
|
+
invitation.state = Invitation.State.AUTHENTICATING;
|
|
133
|
+
next(invitation);
|
|
134
|
+
},
|
|
135
|
+
onSuccess: (invitation) => {
|
|
136
|
+
assert(invitation.spaceKey);
|
|
137
|
+
invitation.state = Invitation.State.SUCCESS;
|
|
138
|
+
next(invitation);
|
|
139
|
+
close();
|
|
140
|
+
},
|
|
141
|
+
onCancelled: () => {
|
|
142
|
+
assert(invitationId);
|
|
143
|
+
invitation.invitationId = invitationId;
|
|
144
|
+
invitation.state = Invitation.State.CANCELLED;
|
|
145
|
+
next(invitation);
|
|
146
|
+
close();
|
|
147
|
+
},
|
|
148
|
+
onTimeout: (err: TimeoutError) => {
|
|
149
|
+
invitation.state = Invitation.State.TIMEOUT;
|
|
150
|
+
close(err);
|
|
151
|
+
},
|
|
152
|
+
onError: (err: any) => {
|
|
153
|
+
invitation.state = Invitation.State.ERROR;
|
|
154
|
+
close(err);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
return (err?: Error) => {
|
|
159
|
+
const context = {
|
|
160
|
+
guest: this._identityManager.identity?.deviceKey,
|
|
161
|
+
spaceKey: invitation.spaceKey
|
|
162
|
+
};
|
|
163
|
+
if (err) {
|
|
164
|
+
log.warn('stream closed', { ...context, err });
|
|
165
|
+
} else {
|
|
166
|
+
log('stream closed', context);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this._acceptInvitations.delete(invitation.invitationId!);
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async authenticate({ invitationId, authenticationCode }: AuthenticationRequest): Promise<void> {
|
|
175
|
+
log('authenticating...');
|
|
176
|
+
assert(invitationId);
|
|
177
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
178
|
+
if (!observable) {
|
|
179
|
+
log.warn('invalid invitation', { invitationId });
|
|
180
|
+
} else {
|
|
181
|
+
await observable.authenticate(authenticationCode);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async cancelInvitation(invitation: Invitation): Promise<void> {
|
|
186
|
+
log('cancelling...');
|
|
187
|
+
assert(invitation.invitationId);
|
|
188
|
+
const observable =
|
|
189
|
+
this._createInvitations.get(invitation.invitationId) ?? this._acceptInvitations.get(invitation.invitationId);
|
|
190
|
+
if (!observable) {
|
|
191
|
+
log.warn('invalid invitation', { invitationId: invitation.invitationId });
|
|
192
|
+
} else {
|
|
193
|
+
await observable?.cancel();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from './service-context';
|
|
6
|
-
export * from './service-
|
|
6
|
+
export * from './service-definitions';
|
|
7
7
|
export * from './service-host';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './service-proxy';
|
|
9
|
+
export * from './service-registry';
|
|
9
10
|
export * from './signer';
|
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'node:assert';
|
|
6
|
-
|
|
7
5
|
import { Trigger } from '@dxos/async';
|
|
8
|
-
import { failUndefined
|
|
6
|
+
import { failUndefined } from '@dxos/debug';
|
|
9
7
|
import {
|
|
10
8
|
MOCK_AUTH_PROVIDER,
|
|
11
9
|
MOCK_AUTH_VERIFIER,
|
|
12
10
|
valueEncoding,
|
|
13
|
-
|
|
11
|
+
DataServiceSubscriptions,
|
|
14
12
|
MetadataStore,
|
|
15
13
|
SpaceManager,
|
|
16
14
|
SigningContext
|
|
17
15
|
} from '@dxos/echo-db';
|
|
18
16
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
19
17
|
import { Keyring } from '@dxos/keyring';
|
|
20
|
-
import { PublicKey } from '@dxos/keys';
|
|
21
18
|
import { log } from '@dxos/log';
|
|
22
19
|
import { ModelFactory } from '@dxos/model-factory';
|
|
23
20
|
import { NetworkManager } from '@dxos/network-manager';
|
|
@@ -25,7 +22,7 @@ import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
25
22
|
import { Storage } from '@dxos/random-access-storage';
|
|
26
23
|
|
|
27
24
|
import { IdentityManager } from '../identity';
|
|
28
|
-
import { HaloInvitations,
|
|
25
|
+
import { HaloInvitations, SpaceInvitationsHandler } from '../invitations';
|
|
29
26
|
|
|
30
27
|
/**
|
|
31
28
|
* Shared backend for all client services.
|
|
@@ -33,10 +30,7 @@ import { HaloInvitations, InvitationWrapper, SpaceInvitations } from '../invitat
|
|
|
33
30
|
// TODO(burdon): Rename/break-up into smaller components. And/or make members private.
|
|
34
31
|
export class ServiceContext {
|
|
35
32
|
public readonly initialized = new Trigger();
|
|
36
|
-
|
|
37
|
-
// TODO(burdon): Factor out with other services.
|
|
38
|
-
public readonly dataService = new DataService();
|
|
39
|
-
|
|
33
|
+
public readonly dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
40
34
|
public readonly metadataStore: MetadataStore;
|
|
41
35
|
public readonly feedStore: FeedStore<FeedMessage>;
|
|
42
36
|
public readonly keyring: Keyring;
|
|
@@ -45,7 +39,7 @@ export class ServiceContext {
|
|
|
45
39
|
|
|
46
40
|
// Initialized after identity is initialized.
|
|
47
41
|
public spaceManager?: SpaceManager;
|
|
48
|
-
public spaceInvitations?:
|
|
42
|
+
public spaceInvitations?: SpaceInvitationsHandler;
|
|
49
43
|
|
|
50
44
|
// prettier-ignore
|
|
51
45
|
constructor(
|
|
@@ -95,31 +89,17 @@ export class ServiceContext {
|
|
|
95
89
|
await this.spaceManager?.close();
|
|
96
90
|
await this.feedStore.close();
|
|
97
91
|
await this.networkManager.destroy(); // TODO(burdon): Close.
|
|
92
|
+
this.dataServiceSubscriptions.clear();
|
|
98
93
|
log('closed');
|
|
99
94
|
}
|
|
100
95
|
|
|
101
96
|
async createIdentity() {
|
|
102
97
|
const identity = await this.identityManager.createIdentity();
|
|
103
|
-
this.
|
|
98
|
+
this.dataServiceSubscriptions.registerSpace(identity.haloSpaceKey, identity.haloDatabase.createDataServiceHost());
|
|
104
99
|
await this._initialize();
|
|
105
100
|
return identity;
|
|
106
101
|
}
|
|
107
102
|
|
|
108
|
-
async createInvitation(spaceKey: PublicKey, onFinish?: () => void): Promise<InvitationWrapper> {
|
|
109
|
-
assert(this.spaceManager);
|
|
110
|
-
assert(this.spaceInvitations);
|
|
111
|
-
|
|
112
|
-
const space = this.spaceManager.spaces.get(spaceKey) ?? raise(new Error('Space not found.'));
|
|
113
|
-
const invitation = await this.spaceInvitations.createInvitation(space, { onFinish });
|
|
114
|
-
return InvitationWrapper.fromProto(invitation);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async acceptInvitation(invitationDescriptor: InvitationWrapper) {
|
|
118
|
-
assert(this.spaceInvitations);
|
|
119
|
-
|
|
120
|
-
return this.spaceInvitations.acceptInvitation(invitationDescriptor.toProto());
|
|
121
|
-
}
|
|
122
|
-
|
|
123
103
|
private async _initialize() {
|
|
124
104
|
const identity = this.identityManager.identity ?? failUndefined();
|
|
125
105
|
const signingContext: SigningContext = {
|
|
@@ -136,16 +116,14 @@ export class ServiceContext {
|
|
|
136
116
|
feedStore: this.feedStore,
|
|
137
117
|
networkManager: this.networkManager,
|
|
138
118
|
keyring: this.keyring,
|
|
139
|
-
|
|
119
|
+
dataServiceSubscriptions: this.dataServiceSubscriptions,
|
|
140
120
|
modelFactory: this.modelFactory,
|
|
141
121
|
signingContext
|
|
142
122
|
});
|
|
143
123
|
|
|
144
124
|
await spaceManager.open();
|
|
145
|
-
|
|
146
125
|
this.spaceManager = spaceManager;
|
|
147
|
-
this.spaceInvitations = new
|
|
148
|
-
|
|
126
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.spaceManager, this.networkManager, signingContext);
|
|
149
127
|
this.initialized.wake();
|
|
150
128
|
}
|
|
151
129
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2020 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { schema } from '@dxos/protocols';
|
|
6
|
+
import { ProfileService, SystemService, SpaceService } from '@dxos/protocols/proto/dxos/client';
|
|
7
|
+
import { SpacesService, InvitationsService, DevicesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
|
+
import { DevtoolsHost, TracingService } from '@dxos/protocols/proto/dxos/devtools/host';
|
|
9
|
+
import { DataService } from '@dxos/protocols/proto/dxos/echo/service';
|
|
10
|
+
import { createServiceBundle, ServiceBundle } from '@dxos/rpc';
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// NOTE: Should contain client/proxy dependencies only.
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
export type ClientServices = {
|
|
17
|
+
SpaceService: SpaceService;
|
|
18
|
+
DataService: DataService;
|
|
19
|
+
ProfileService: ProfileService;
|
|
20
|
+
SystemService: SystemService;
|
|
21
|
+
DevtoolsHost: DevtoolsHost;
|
|
22
|
+
TracingService: TracingService;
|
|
23
|
+
|
|
24
|
+
SpacesService: SpacesService;
|
|
25
|
+
SpaceInvitationsService: InvitationsService;
|
|
26
|
+
DevicesService: DevicesService;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Provide access to client services definitions and service handler.
|
|
31
|
+
*/
|
|
32
|
+
export interface ClientServicesProvider {
|
|
33
|
+
descriptors: ServiceBundle<ClientServices>;
|
|
34
|
+
services: ClientServices;
|
|
35
|
+
|
|
36
|
+
open(): Promise<void>;
|
|
37
|
+
close(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Services supported by host.
|
|
42
|
+
*/
|
|
43
|
+
export const clientServiceBundle = createServiceBundle<ClientServices>({
|
|
44
|
+
SpaceService: schema.getService('dxos.client.SpaceService'),
|
|
45
|
+
DataService: schema.getService('dxos.echo.service.DataService'),
|
|
46
|
+
ProfileService: schema.getService('dxos.client.ProfileService'),
|
|
47
|
+
SystemService: schema.getService('dxos.client.SystemService'),
|
|
48
|
+
DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),
|
|
49
|
+
TracingService: schema.getService('dxos.devtools.host.TracingService'),
|
|
50
|
+
|
|
51
|
+
SpacesService: schema.getService('dxos.client.services.SpacesService'),
|
|
52
|
+
SpaceInvitationsService: schema.getService('dxos.client.services.InvitationsService'),
|
|
53
|
+
DevicesService: schema.getService('dxos.client.services.DevicesService')
|
|
54
|
+
});
|
|
@@ -6,13 +6,12 @@ import { expect } from 'chai';
|
|
|
6
6
|
|
|
7
7
|
import { latch, Trigger } from '@dxos/async';
|
|
8
8
|
import { Config, ConfigProto } from '@dxos/config';
|
|
9
|
-
import {
|
|
10
|
-
import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
|
|
9
|
+
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
11
10
|
import { InvitationState } from '@dxos/protocols/proto/dxos/client';
|
|
12
|
-
import {
|
|
11
|
+
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
13
12
|
import { afterTest } from '@dxos/testutils';
|
|
14
13
|
|
|
15
|
-
import {
|
|
14
|
+
import { createServiceHost } from '../testing';
|
|
16
15
|
|
|
17
16
|
const defaultTestingConfig: ConfigProto = {
|
|
18
17
|
version: 1
|
|
@@ -26,34 +25,23 @@ const defaultTestingConfig: ConfigProto = {
|
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
describe('services/service-host', function () {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const networkManager = new NetworkManager({
|
|
32
|
-
signalManager: new MemorySignalManager(signalManagerContext),
|
|
33
|
-
transportFactory: MemoryTransportFactory
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return new ClientServiceHost({
|
|
37
|
-
config: new Config(defaultTestingConfig),
|
|
38
|
-
networkManager
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
it('process device invitation', async function () {
|
|
28
|
+
it.skip('process device invitation', async function () {
|
|
29
|
+
const config = new Config(defaultTestingConfig);
|
|
43
30
|
const signalManagerContext = new MemorySignalManagerContext();
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
const
|
|
32
|
+
// TODO(burdon): Use builder.
|
|
33
|
+
const peer1 = createServiceHost(config, signalManagerContext);
|
|
34
|
+
const peer2 = createServiceHost(config, signalManagerContext);
|
|
47
35
|
await peer1.open();
|
|
48
36
|
await peer2.open();
|
|
49
37
|
afterTest(() => peer1.close());
|
|
50
38
|
afterTest(() => peer2.close());
|
|
51
39
|
|
|
52
|
-
const invitationTrigger = new Trigger<
|
|
40
|
+
const invitationTrigger = new Trigger<Invitation>();
|
|
53
41
|
{
|
|
54
42
|
await peer1.services.ProfileService.createProfile({});
|
|
55
43
|
const stream = peer1.services.ProfileService.createInvitation();
|
|
56
|
-
stream.subscribe((msg) => {
|
|
44
|
+
stream.subscribe((msg: any) => {
|
|
57
45
|
switch (msg.state) {
|
|
58
46
|
case InvitationState.WAITING_FOR_CONNECTION: {
|
|
59
47
|
invitationTrigger.wake(msg.descriptor!);
|
|
@@ -67,7 +55,7 @@ describe('services/service-host', function () {
|
|
|
67
55
|
{
|
|
68
56
|
const invitation = await invitationTrigger.wait();
|
|
69
57
|
const stream = peer2.services.ProfileService.acceptInvitation(invitation);
|
|
70
|
-
stream.subscribe((msg) => {
|
|
58
|
+
stream.subscribe((msg: any) => {
|
|
71
59
|
switch (msg.state) {
|
|
72
60
|
case InvitationState.CONNECTED: {
|
|
73
61
|
setAck();
|
|
@@ -75,7 +63,7 @@ describe('services/service-host', function () {
|
|
|
75
63
|
}
|
|
76
64
|
|
|
77
65
|
case InvitationState.SUCCESS: {
|
|
78
|
-
expect(msg.
|
|
66
|
+
expect(msg.spaceKey).not.to.be.undefined;
|
|
79
67
|
setAck();
|
|
80
68
|
break;
|
|
81
69
|
}
|