@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
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import assert from 'node:assert';
|
|
6
|
-
import { v4 } from 'uuid';
|
|
7
|
-
|
|
8
|
-
import { latch } from '@dxos/async';
|
|
9
|
-
import { Stream } from '@dxos/codec-protobuf';
|
|
10
|
-
import { todo } from '@dxos/debug';
|
|
11
|
-
import {
|
|
12
|
-
AuthenticateInvitationRequest,
|
|
13
|
-
CreateInvitationRequest,
|
|
14
|
-
CreateSnapshotRequest,
|
|
15
|
-
GetPartyDetailsRequest,
|
|
16
|
-
InvitationRequest,
|
|
17
|
-
InvitationState,
|
|
18
|
-
Party,
|
|
19
|
-
PartyDetails,
|
|
20
|
-
PartyService as PartyServiceRpc,
|
|
21
|
-
RedeemedInvitation,
|
|
22
|
-
SetPartyStateRequest,
|
|
23
|
-
SubscribeMembersRequest,
|
|
24
|
-
SubscribeMembersResponse,
|
|
25
|
-
SubscribePartiesResponse,
|
|
26
|
-
SubscribePartyRequest,
|
|
27
|
-
SubscribePartyResponse
|
|
28
|
-
} from '@dxos/protocols/proto/dxos/client';
|
|
29
|
-
import { PartySnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
|
|
30
|
-
import { InvitationDescriptor } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
31
|
-
|
|
32
|
-
import { InvitationWrapper, InviteeInvitation, InviteeInvitations } from '../../invitations';
|
|
33
|
-
import { ServiceContext } from '../service-context';
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Party service implementation.
|
|
37
|
-
*/
|
|
38
|
-
// TODO(burdon): Rename Space.
|
|
39
|
-
export class PartyService implements PartyServiceRpc {
|
|
40
|
-
private inviteeInvitations: InviteeInvitations = new Map();
|
|
41
|
-
|
|
42
|
-
constructor(private readonly serviceContext: ServiceContext) {}
|
|
43
|
-
|
|
44
|
-
subscribeToParty(request: SubscribePartyRequest): Stream<SubscribePartyResponse> {
|
|
45
|
-
return new Stream(({ next }) => {
|
|
46
|
-
next({
|
|
47
|
-
party: {
|
|
48
|
-
publicKey: request.partyKey,
|
|
49
|
-
isOpen: true,
|
|
50
|
-
isActive: true,
|
|
51
|
-
members: []
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
// const update = (next: (message: SubscribePartyResponse) => void) => {
|
|
56
|
-
// try {
|
|
57
|
-
// const party = this.echo.getParty(request.party_key);
|
|
58
|
-
// next({
|
|
59
|
-
// party: party && {
|
|
60
|
-
// public_key: party.key,
|
|
61
|
-
// is_open: party.is_open,
|
|
62
|
-
// is_active: party.is_active,
|
|
63
|
-
// members: party.queryMembers().value
|
|
64
|
-
// }
|
|
65
|
-
// });
|
|
66
|
-
// } catch (err) {
|
|
67
|
-
// if (err instanceof InvalidStateError) {
|
|
68
|
-
// // Do nothing.
|
|
69
|
-
// } else {
|
|
70
|
-
// throw err;
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
73
|
-
// };
|
|
74
|
-
|
|
75
|
-
// const party = this.serviceContext.brane.getParty(request.party_key);
|
|
76
|
-
// if (party) {
|
|
77
|
-
// return new Stream(({ next }) => party.update.on(() => update(next)));
|
|
78
|
-
// } else {
|
|
79
|
-
// return new Stream(({ next }) => {
|
|
80
|
-
// let unsubscribeParty: () => void;
|
|
81
|
-
// const unsubscribeParties = this.echo.queryParties().subscribe((parties) => {
|
|
82
|
-
// const party = parties.find((party) => party.key.equals(request.party_key));
|
|
83
|
-
// if (party && !unsubscribeParty) {
|
|
84
|
-
// unsubscribeParty = party.update.on(() => update(next));
|
|
85
|
-
// }
|
|
86
|
-
// });
|
|
87
|
-
|
|
88
|
-
// update(next);
|
|
89
|
-
|
|
90
|
-
// return () => {
|
|
91
|
-
// unsubscribeParties();
|
|
92
|
-
// unsubscribeParty?.();
|
|
93
|
-
// };
|
|
94
|
-
// });
|
|
95
|
-
// }
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
subscribeParties() {
|
|
99
|
-
return new Stream<SubscribePartiesResponse>(({ next }) => {
|
|
100
|
-
const update = () => {
|
|
101
|
-
next({
|
|
102
|
-
parties: Array.from(this.serviceContext.spaceManager!.spaces.values()).map((space) => ({
|
|
103
|
-
publicKey: space.key,
|
|
104
|
-
isOpen: true,
|
|
105
|
-
isActive: true
|
|
106
|
-
}))
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
setTimeout(async () => {
|
|
111
|
-
if (!this.serviceContext.spaceManager) {
|
|
112
|
-
next({ parties: [] });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await this.serviceContext.initialized.wait();
|
|
116
|
-
|
|
117
|
-
update();
|
|
118
|
-
return this.serviceContext.spaceManager!.update.on(update);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async getPartyDetails(request: GetPartyDetailsRequest): Promise<PartyDetails> {
|
|
124
|
-
return todo();
|
|
125
|
-
// const party = this.echo.getParty(request.party_key) ?? raise(new SpaceNotFoundError(request.party_key));
|
|
126
|
-
// return {
|
|
127
|
-
// processedTimeframe: party.timeframe
|
|
128
|
-
// };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async createParty(): Promise<Party> {
|
|
132
|
-
await this.serviceContext.initialized.wait();
|
|
133
|
-
const space = await this.serviceContext.spaceManager!.createSpace();
|
|
134
|
-
return {
|
|
135
|
-
publicKey: space.key,
|
|
136
|
-
isOpen: true,
|
|
137
|
-
isActive: true
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async cloneParty(snapshot: PartySnapshot): Promise<Party> {
|
|
142
|
-
return todo();
|
|
143
|
-
// const party = await this.echo.cloneParty(snapshot);
|
|
144
|
-
// return {
|
|
145
|
-
// public_key: party.key,
|
|
146
|
-
// is_open: party.is_open,
|
|
147
|
-
// is_active: party.is_active
|
|
148
|
-
// };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async setPartyState(request: SetPartyStateRequest) {
|
|
152
|
-
return todo();
|
|
153
|
-
// const party = this.echo.getParty(request.party_key);
|
|
154
|
-
// if (!party) {
|
|
155
|
-
// throw new Error('Party not found');
|
|
156
|
-
// }
|
|
157
|
-
|
|
158
|
-
// if (request.open === true) {
|
|
159
|
-
// await party.open();
|
|
160
|
-
// } else if (request.open === false) {
|
|
161
|
-
// await party.close();
|
|
162
|
-
// } // Undefined preserves previous state.
|
|
163
|
-
|
|
164
|
-
// if (request.active_global === true) {
|
|
165
|
-
// await party.activate({ global: true });
|
|
166
|
-
// } else if (request.active_global === false) {
|
|
167
|
-
// await party.deactivate({ global: true });
|
|
168
|
-
// } // Undefined preserves previous state.
|
|
169
|
-
|
|
170
|
-
// if (request.active_device === true) {
|
|
171
|
-
// await party.activate({ device: true });
|
|
172
|
-
// } else if (request.active_device === false) {
|
|
173
|
-
// await party.deactivate({ device: true });
|
|
174
|
-
// } // Undefined preserves previous state.
|
|
175
|
-
// return {
|
|
176
|
-
// public_key: party.key,
|
|
177
|
-
// is_open: party.is_open,
|
|
178
|
-
// is_active: party.is_active
|
|
179
|
-
// };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
createInvitation(request: CreateInvitationRequest): Stream<InvitationRequest> {
|
|
183
|
-
return new Stream(({ next, close }) => {
|
|
184
|
-
setTimeout(async () => {
|
|
185
|
-
try {
|
|
186
|
-
let invitation: InvitationWrapper;
|
|
187
|
-
if (!request.inviteeKey) {
|
|
188
|
-
// const secret = Buffer.from(generatePasscode());
|
|
189
|
-
// const secretProvider = async () => {
|
|
190
|
-
// next({ state: InvitationState.CONNECTED });
|
|
191
|
-
// return Buffer.from(secret);
|
|
192
|
-
// };
|
|
193
|
-
invitation = await this.serviceContext.createInvitation(request.partyKey, () => {
|
|
194
|
-
next({ state: InvitationState.SUCCESS });
|
|
195
|
-
close();
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
assert(invitation.type === InvitationDescriptor.Type.INTERACTIVE);
|
|
199
|
-
// invitation.secret = Buffer.from(secret);
|
|
200
|
-
} else {
|
|
201
|
-
todo();
|
|
202
|
-
// invitation = await party.invitationManager.createOfflineInvitation(request.invitee_key);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// TODO(burdon): Change stream type.
|
|
206
|
-
next({
|
|
207
|
-
state: InvitationState.WAITING_FOR_CONNECTION,
|
|
208
|
-
descriptor: invitation!.toProto()
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// if (invitation.type === InvitationDescriptor.Type.OFFLINE) {
|
|
212
|
-
// close();
|
|
213
|
-
// }
|
|
214
|
-
} catch (err: any) {
|
|
215
|
-
next({ state: InvitationState.ERROR, error: err.message });
|
|
216
|
-
close();
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
acceptInvitation(request: InvitationDescriptor): Stream<RedeemedInvitation> {
|
|
223
|
-
return new Stream(({ next, close }) => {
|
|
224
|
-
const id = v4();
|
|
225
|
-
const [, secretTrigger] = latch();
|
|
226
|
-
const inviteeInvitation: InviteeInvitation = { secretTrigger };
|
|
227
|
-
|
|
228
|
-
// Secret will be provided separately (in AuthenticateInvitation).
|
|
229
|
-
// Process will continue when `secretLatch` resolves, triggered by `secretTrigger`.
|
|
230
|
-
// const secretProvider: SecretProvider = async () => {
|
|
231
|
-
// await secretLatch;
|
|
232
|
-
// const secret = inviteeInvitation.secret;
|
|
233
|
-
// if (!secret) {
|
|
234
|
-
// throw new Error('Secret not provided.');
|
|
235
|
-
// }
|
|
236
|
-
|
|
237
|
-
// return Buffer.from(secret);
|
|
238
|
-
// };
|
|
239
|
-
|
|
240
|
-
// Joining process is kicked off, and will await authentication with a secret.
|
|
241
|
-
const partyPromise = this.serviceContext.acceptInvitation(InvitationWrapper.fromProto(request));
|
|
242
|
-
this.inviteeInvitations.set(id, inviteeInvitation);
|
|
243
|
-
next({ id, state: InvitationState.CONNECTED });
|
|
244
|
-
|
|
245
|
-
partyPromise
|
|
246
|
-
.then((party) => {
|
|
247
|
-
next({ id, state: InvitationState.SUCCESS, partyKey: party.key });
|
|
248
|
-
})
|
|
249
|
-
.catch((err) => {
|
|
250
|
-
console.error(err);
|
|
251
|
-
next({ id, state: InvitationState.ERROR, error: String(err) });
|
|
252
|
-
})
|
|
253
|
-
.finally(() => {
|
|
254
|
-
close();
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async authenticateInvitation(request: AuthenticateInvitationRequest) {
|
|
260
|
-
assert(request.processId, 'Process ID is missing.');
|
|
261
|
-
const invitation = this.inviteeInvitations.get(request.processId);
|
|
262
|
-
assert(invitation, 'Invitation not found.');
|
|
263
|
-
assert(request.secret, 'Secret not provided.');
|
|
264
|
-
|
|
265
|
-
// Supply the secret, and move the internal invitation process by triggering the secretTrigger.
|
|
266
|
-
invitation.secret = request.secret;
|
|
267
|
-
invitation.secretTrigger?.();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
subscribeMembers(request: SubscribeMembersRequest): Stream<SubscribeMembersResponse> {
|
|
271
|
-
return new Stream(({ next }) => {
|
|
272
|
-
next({
|
|
273
|
-
members: []
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
// const party = this.echo.getParty(request.party_key);
|
|
277
|
-
// if (party) {
|
|
278
|
-
// return resultSetToStream(party.queryMembers(), (members): SubscribeMembersResponse => ({ members }));
|
|
279
|
-
// } else {
|
|
280
|
-
// return new Stream(({ next }) => {
|
|
281
|
-
// let unsubscribeMembers: () => void;
|
|
282
|
-
// const unsubscribeParties = this.echo.queryParties().subscribe((parties) => {
|
|
283
|
-
// const party = parties.find((party) => party.key.equals(request.party_key));
|
|
284
|
-
// if (!unsubscribeMembers && party) {
|
|
285
|
-
// const resultSet = party.queryMembers();
|
|
286
|
-
// next({ members: resultSet.value });
|
|
287
|
-
// unsubscribeMembers = resultSet.update.on(() => next({ members: resultSet.value }));
|
|
288
|
-
// }
|
|
289
|
-
// });
|
|
290
|
-
|
|
291
|
-
// return () => {
|
|
292
|
-
// unsubscribeParties();
|
|
293
|
-
// unsubscribeMembers();
|
|
294
|
-
// };
|
|
295
|
-
// });
|
|
296
|
-
// }
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
async createSnapshot(request: CreateSnapshotRequest): Promise<PartySnapshot> {
|
|
300
|
-
return todo();
|
|
301
|
-
// assert(request.party_key);
|
|
302
|
-
// const party = this.echo.getParty(request.party_key) ?? raise(new SpaceNotFoundError(request.party_key));
|
|
303
|
-
// return party.createSnapshot();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Config } from '@dxos/config';
|
|
6
|
-
import { NetworkManager } from '@dxos/network-manager';
|
|
7
|
-
|
|
8
|
-
import { DevtoolsHostEvents } from '../devtools';
|
|
9
|
-
import { HaloService, PartyService, ProfileService, SystemService, TracingService } from './impl';
|
|
10
|
-
import { DevtoolsService } from './impl/devtools';
|
|
11
|
-
import { ServiceContext } from './service-context';
|
|
12
|
-
import { ClientServices } from './services';
|
|
13
|
-
import { HaloSigner } from './signer';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Service factory.
|
|
17
|
-
*/
|
|
18
|
-
export const createServices = ({
|
|
19
|
-
config,
|
|
20
|
-
context, // TODO(burdon): Too big to pass into services.?
|
|
21
|
-
signer // TODO(burdon): Remove (legacy?)
|
|
22
|
-
}: {
|
|
23
|
-
config: Config;
|
|
24
|
-
context: ServiceContext;
|
|
25
|
-
networkManager: NetworkManager;
|
|
26
|
-
signer?: HaloSigner;
|
|
27
|
-
}): ClientServices => ({
|
|
28
|
-
DataService: context.dataService,
|
|
29
|
-
HaloService: new HaloService(null, signer), // TODO(burdon): Remove.
|
|
30
|
-
PartyService: new PartyService(context),
|
|
31
|
-
ProfileService: new ProfileService(context),
|
|
32
|
-
SystemService: new SystemService(config),
|
|
33
|
-
TracingService: new TracingService(config),
|
|
34
|
-
DevtoolsHost: new DevtoolsService({ events: new DevtoolsHostEvents(), config, context })
|
|
35
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { schema } from '@dxos/protocols';
|
|
6
|
-
import { PartyService, ProfileService, SystemService, HaloService } from '@dxos/protocols/proto/dxos/client';
|
|
7
|
-
import { DevtoolsHost, TracingService } from '@dxos/protocols/proto/dxos/devtools/host';
|
|
8
|
-
import { DataService } from '@dxos/protocols/proto/dxos/echo/service';
|
|
9
|
-
import { createServiceBundle } from '@dxos/rpc';
|
|
10
|
-
|
|
11
|
-
// TODO(burdon): Is there a way to mark TS (generics) so cast isn't required for result of stream?
|
|
12
|
-
export type ClientServices = {
|
|
13
|
-
DataService: DataService;
|
|
14
|
-
HaloService: HaloService;
|
|
15
|
-
PartyService: PartyService;
|
|
16
|
-
ProfileService: ProfileService;
|
|
17
|
-
SystemService: SystemService;
|
|
18
|
-
|
|
19
|
-
DevtoolsHost: DevtoolsHost;
|
|
20
|
-
TracingService: TracingService;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Rethink name/factory.
|
|
24
|
-
export const clientServiceBundle = createServiceBundle<ClientServices>({
|
|
25
|
-
DataService: schema.getService('dxos.echo.service.DataService'),
|
|
26
|
-
HaloService: schema.getService('dxos.client.HaloService'),
|
|
27
|
-
PartyService: schema.getService('dxos.client.PartyService'),
|
|
28
|
-
ProfileService: schema.getService('dxos.client.ProfileService'),
|
|
29
|
-
SystemService: schema.getService('dxos.client.SystemService'),
|
|
30
|
-
|
|
31
|
-
DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),
|
|
32
|
-
TracingService: schema.getService('dxos.devtools.host.TracingService')
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export interface ClientServiceProvider {
|
|
36
|
-
services: ClientServices;
|
|
37
|
-
open(onProgressCallback?: ((progress: any) => void) | undefined): Promise<void>;
|
|
38
|
-
close(): Promise<void>;
|
|
39
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
|
-
import { ObjectModel } from '@dxos/object-model';
|
|
9
|
-
import { afterTest } from '@dxos/testutils';
|
|
10
|
-
|
|
11
|
-
import { createServiceContext } from './testing';
|
|
12
|
-
|
|
13
|
-
describe('services/spaces', function () {
|
|
14
|
-
it('space genesis', async function () {
|
|
15
|
-
const peer = await createServiceContext();
|
|
16
|
-
await peer.open();
|
|
17
|
-
afterTest(() => peer.close());
|
|
18
|
-
|
|
19
|
-
await peer.createIdentity();
|
|
20
|
-
|
|
21
|
-
const space = await peer.spaceManager!.createSpace();
|
|
22
|
-
expect(space.database).not.to.be.undefined;
|
|
23
|
-
expect(peer.spaceManager!.spaces.has(space.key)).to.be.true;
|
|
24
|
-
await space.close();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('space genesis with database', async function () {
|
|
28
|
-
const peer = await createServiceContext();
|
|
29
|
-
await peer.open();
|
|
30
|
-
afterTest(() => peer.close());
|
|
31
|
-
|
|
32
|
-
await peer.createIdentity();
|
|
33
|
-
const space = await peer.spaceManager!.createSpace();
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
const item = await space.database!.createItem<ObjectModel>({ type: 'test' });
|
|
37
|
-
void item.model.set('name', 'test');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
const [item] = space.database!.select({ type: 'test' }).exec().entities;
|
|
42
|
-
expect(item.model.get('name')).to.eq('test');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
await space.close();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('create and accepts space invitations', async function () {
|
|
49
|
-
const signalContext = new MemorySignalManagerContext();
|
|
50
|
-
|
|
51
|
-
const peer1 = await createServiceContext({ signalContext });
|
|
52
|
-
const peer2 = await createServiceContext({ signalContext });
|
|
53
|
-
|
|
54
|
-
await peer1.open();
|
|
55
|
-
await peer2.open();
|
|
56
|
-
afterTest(() => peer1.close());
|
|
57
|
-
afterTest(() => peer2.close());
|
|
58
|
-
|
|
59
|
-
await peer1.createIdentity();
|
|
60
|
-
await peer2.createIdentity();
|
|
61
|
-
|
|
62
|
-
const space1 = await peer1.spaceManager!.createSpace();
|
|
63
|
-
const invitation = await peer1.createInvitation(space1.key);
|
|
64
|
-
|
|
65
|
-
const space2 = await peer2.acceptInvitation(invitation);
|
|
66
|
-
expect(space1.key).to.deep.eq(space2.key);
|
|
67
|
-
|
|
68
|
-
// TODO(burdon): Write multiple items.
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
// Check item replicated from 1 => 2.
|
|
72
|
-
const item1 = await space1.database!.createItem({ type: 'dxos.example.1' });
|
|
73
|
-
const item2 = await space2.database!.waitForItem({ type: 'dxos.example.1' });
|
|
74
|
-
expect(item1.id).to.eq(item2.id);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
// Check item replicated from 2 => 1.
|
|
79
|
-
const item1 = await space2.database!.createItem({ type: 'dxos.example.2' });
|
|
80
|
-
const item2 = await space1.database!.waitForItem({ type: 'dxos.example.2' });
|
|
81
|
-
expect(item1.id).to.eq(item2.id);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await space1.close();
|
|
85
|
-
await space2.close();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
6
|
-
import { ModelFactory } from '@dxos/model-factory';
|
|
7
|
-
import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
|
|
8
|
-
import { ObjectModel } from '@dxos/object-model';
|
|
9
|
-
import { createStorage, Storage, StorageType } from '@dxos/random-access-storage';
|
|
10
|
-
|
|
11
|
-
import { ServiceContext } from '../service-context';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Create test builder.
|
|
14
|
-
export const createServiceContext = async ({
|
|
15
|
-
signalContext = new MemorySignalManagerContext(),
|
|
16
|
-
storage = createStorage({ type: StorageType.RAM })
|
|
17
|
-
}: {
|
|
18
|
-
signalContext?: MemorySignalManagerContext;
|
|
19
|
-
storage?: Storage;
|
|
20
|
-
} = {}) => {
|
|
21
|
-
const networkManager = new NetworkManager({
|
|
22
|
-
signalManager: new MemorySignalManager(signalContext),
|
|
23
|
-
transportFactory: MemoryTransportFactory
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
27
|
-
return new ServiceContext(storage, networkManager, modelFactory);
|
|
28
|
-
};
|