@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
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { defaultSecretProvider, defaultSecretValidator, SecretProvider, SecretValidator } from '@dxos/credentials';
|
|
6
6
|
|
|
7
|
+
//
|
|
8
|
+
// TODO(burdon): Deprecated pending new invitations.
|
|
9
|
+
//
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* Defines a way for peers to authenticate each other through a side channel.
|
|
9
13
|
*/
|
|
@@ -18,7 +22,7 @@ export const defaultInvitationAuthenticator: Required<InvitationAuthenticator> =
|
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
25
|
+
* @deprecated
|
|
22
26
|
*/
|
|
23
27
|
export interface InvitationOptions {
|
|
24
28
|
/**
|
|
@@ -32,17 +36,28 @@ export interface InvitationOptions {
|
|
|
32
36
|
expiration?: number;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
36
42
|
export type InviterInvitation = {
|
|
37
43
|
invitationCode: string;
|
|
38
44
|
secret: Uint8Array | undefined;
|
|
39
45
|
};
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
42
50
|
export type InviteeInvitation = {
|
|
43
51
|
secret?: Uint8Array | undefined; // Can be undefined initially, then set after receiving secret from the inviter.
|
|
44
52
|
secretTrigger?: () => void; // Is triggered after supplying the secret.
|
|
45
53
|
};
|
|
46
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
*/
|
|
47
58
|
export type InviterInvitations = InviterInvitation[];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated
|
|
62
|
+
*/
|
|
48
63
|
export type InviteeInvitations = Map<string, InviteeInvitation>;
|
|
@@ -15,20 +15,20 @@ import {
|
|
|
15
15
|
InvitationRequest,
|
|
16
16
|
InvitationState,
|
|
17
17
|
Profile,
|
|
18
|
-
ProfileService
|
|
18
|
+
ProfileService,
|
|
19
19
|
RecoverProfileRequest,
|
|
20
20
|
RedeemedInvitation,
|
|
21
21
|
SubscribeProfileResponse
|
|
22
22
|
} from '@dxos/protocols/proto/dxos/client';
|
|
23
|
-
import {
|
|
23
|
+
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
24
24
|
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import { ServiceContext } from '../services';
|
|
26
|
+
import { InviteeInvitation, InviteeInvitations } from './invitations';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Profile service implementation.
|
|
30
30
|
*/
|
|
31
|
-
export class
|
|
31
|
+
export class ProfileServiceImpl implements ProfileService {
|
|
32
32
|
private inviteeInvitations: InviteeInvitations = new Map();
|
|
33
33
|
|
|
34
34
|
constructor(private readonly context: ServiceContext) {}
|
|
@@ -39,7 +39,7 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
39
39
|
next({
|
|
40
40
|
profile: this.context.identityManager.identity
|
|
41
41
|
? {
|
|
42
|
-
|
|
42
|
+
identityKey: this.context.identityManager.identity.identityKey
|
|
43
43
|
}
|
|
44
44
|
: undefined
|
|
45
45
|
});
|
|
@@ -51,7 +51,7 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
51
51
|
|
|
52
52
|
async createProfile(request: CreateProfileRequest): Promise<Profile> {
|
|
53
53
|
await this.context.createIdentity();
|
|
54
|
-
return {
|
|
54
|
+
return { identityKey: this.context.identityManager.identity!.identityKey };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
async recoverProfile(request: RecoverProfileRequest): Promise<Profile> {
|
|
@@ -69,7 +69,7 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
69
69
|
createInvitation(): Stream<InvitationRequest> {
|
|
70
70
|
return new Stream(({ next, close }) => {
|
|
71
71
|
setTimeout(async () => {
|
|
72
|
-
const
|
|
72
|
+
const authenticationCode = generatePasscode();
|
|
73
73
|
// TODO(burdon): Not used.
|
|
74
74
|
// const secretProvider = async () => {
|
|
75
75
|
// next({ descriptor: invitation.toProto(), state: InvitationState.CONNECTED });
|
|
@@ -82,7 +82,7 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
82
82
|
close();
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
invitation.
|
|
85
|
+
invitation.authenticationCode = authenticationCode;
|
|
86
86
|
|
|
87
87
|
next({
|
|
88
88
|
state: InvitationState.WAITING_FOR_CONNECTION,
|
|
@@ -92,7 +92,7 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
acceptInvitation(invitation:
|
|
95
|
+
acceptInvitation(invitation: Invitation): Stream<RedeemedInvitation> {
|
|
96
96
|
return new Stream(({ next, close }) => {
|
|
97
97
|
const id = v4();
|
|
98
98
|
const [, secretTrigger] = latch();
|
|
@@ -110,16 +110,16 @@ export class ProfileService implements ProfileServiceRpc {
|
|
|
110
110
|
// };
|
|
111
111
|
|
|
112
112
|
// Joining process is kicked off, and will await authentication with a secret.
|
|
113
|
-
const
|
|
113
|
+
const haloSpacePromise = this.context.haloInvitations.acceptInvitation(invitation);
|
|
114
114
|
this.inviteeInvitations.set(id, inviteeInvitation);
|
|
115
115
|
next({ id, state: InvitationState.CONNECTED });
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
haloSpacePromise
|
|
118
118
|
.then((identity) => {
|
|
119
119
|
next({
|
|
120
120
|
id,
|
|
121
121
|
state: InvitationState.SUCCESS,
|
|
122
|
-
|
|
122
|
+
spaceKey: identity.identityKey
|
|
123
123
|
});
|
|
124
124
|
})
|
|
125
125
|
.catch((err) => {
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import assert from 'node:assert';
|
|
6
|
+
|
|
7
|
+
import { EventSubscriptions } from '@dxos/async';
|
|
8
|
+
import { Stream } from '@dxos/codec-protobuf';
|
|
9
|
+
import { todo } from '@dxos/debug';
|
|
10
|
+
import {
|
|
11
|
+
AuthenticateInvitationRequest,
|
|
12
|
+
CreateSnapshotRequest,
|
|
13
|
+
GetSpaceDetailsRequest,
|
|
14
|
+
Space,
|
|
15
|
+
SpaceDetails,
|
|
16
|
+
SpaceService,
|
|
17
|
+
SetSpaceStateRequest,
|
|
18
|
+
SubscribeMembersRequest,
|
|
19
|
+
SubscribeMembersResponse,
|
|
20
|
+
SubscribeSpacesResponse,
|
|
21
|
+
SubscribeSpaceRequest,
|
|
22
|
+
SubscribeSpaceResponse
|
|
23
|
+
} from '@dxos/protocols/proto/dxos/client';
|
|
24
|
+
import { SpaceSnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
|
|
25
|
+
import { humanize } from '@dxos/util';
|
|
26
|
+
|
|
27
|
+
import { ServiceContext } from '../services';
|
|
28
|
+
import { InviteeInvitations } from './invitations';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Space service implementation.
|
|
32
|
+
* @deprecated
|
|
33
|
+
*/
|
|
34
|
+
export class SpaceServiceImpl implements SpaceService {
|
|
35
|
+
private inviteeInvitations: InviteeInvitations = new Map();
|
|
36
|
+
|
|
37
|
+
constructor(private readonly serviceContext: ServiceContext) {}
|
|
38
|
+
|
|
39
|
+
subscribeToSpace(request: SubscribeSpaceRequest): Stream<SubscribeSpaceResponse> {
|
|
40
|
+
return new Stream(({ next }) => {
|
|
41
|
+
next({
|
|
42
|
+
space: {
|
|
43
|
+
publicKey: request.spaceKey,
|
|
44
|
+
isOpen: true,
|
|
45
|
+
isActive: true,
|
|
46
|
+
members: []
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// const update = (next: (message: SubscribeSpaceResponse) => void) => {
|
|
52
|
+
// try {
|
|
53
|
+
// const space = this.echo.getSpace(request.space_key);
|
|
54
|
+
// next({
|
|
55
|
+
// space: space && {
|
|
56
|
+
// public_key: space.key,
|
|
57
|
+
// is_open: space.is_open,
|
|
58
|
+
// is_active: space.is_active,
|
|
59
|
+
// members: space.queryMembers().value
|
|
60
|
+
// }
|
|
61
|
+
// });
|
|
62
|
+
// } catch (err) {
|
|
63
|
+
// if (err instanceof InvalidStateError) {
|
|
64
|
+
// // Do nothing.
|
|
65
|
+
// } else {
|
|
66
|
+
// throw err;
|
|
67
|
+
// }
|
|
68
|
+
// }
|
|
69
|
+
// };
|
|
70
|
+
|
|
71
|
+
// const space = this.serviceContext.brane.getSpace(request.space_key);
|
|
72
|
+
// if (space) {
|
|
73
|
+
// return new Stream(({ next }) => space.update.on(() => update(next)));
|
|
74
|
+
// } else {
|
|
75
|
+
// return new Stream(({ next }) => {
|
|
76
|
+
// let unsubscribeSpace: () => void;
|
|
77
|
+
// const unsubscribeSpaces = this.echo.querySpaces().subscribe((spaces) => {
|
|
78
|
+
// const space = spaces.find((space) => space.key.equals(request.space_key));
|
|
79
|
+
// if (space && !unsubscribeSpace) {
|
|
80
|
+
// unsubscribeSpace = space.update.on(() => update(next));
|
|
81
|
+
// }
|
|
82
|
+
// });
|
|
83
|
+
|
|
84
|
+
// update(next);
|
|
85
|
+
|
|
86
|
+
// return () => {
|
|
87
|
+
// unsubscribeSpaces();
|
|
88
|
+
// unsubscribeSpace?.();
|
|
89
|
+
// };
|
|
90
|
+
// });
|
|
91
|
+
// }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
subscribeSpaces() {
|
|
95
|
+
return new Stream<SubscribeSpacesResponse>(({ next }) => {
|
|
96
|
+
const subscriptions = new EventSubscriptions();
|
|
97
|
+
|
|
98
|
+
const onUpdate = () => {
|
|
99
|
+
next({
|
|
100
|
+
spaces: Array.from(this.serviceContext.spaceManager!.spaces.values()).map(
|
|
101
|
+
(space): Space => ({
|
|
102
|
+
publicKey: space.key,
|
|
103
|
+
isOpen: true,
|
|
104
|
+
isActive: true,
|
|
105
|
+
members: Array.from(space.spaceState.members.values()).map((member) => ({
|
|
106
|
+
identityKey: member.key,
|
|
107
|
+
profile: {
|
|
108
|
+
identityKey: member.key,
|
|
109
|
+
displayName: humanize(member.key)
|
|
110
|
+
}
|
|
111
|
+
}))
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
setTimeout(async () => {
|
|
118
|
+
if (!this.serviceContext.spaceManager) {
|
|
119
|
+
next({ spaces: [] });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await this.serviceContext.initialized.wait();
|
|
123
|
+
|
|
124
|
+
subscriptions.add(
|
|
125
|
+
this.serviceContext.spaceManager!.updated.on(() => {
|
|
126
|
+
this.serviceContext.spaceManager!.spaces.forEach((space) => {
|
|
127
|
+
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
128
|
+
});
|
|
129
|
+
onUpdate();
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
onUpdate();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return () => subscriptions.clear();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async getSpaceDetails(request: GetSpaceDetailsRequest): Promise<SpaceDetails> {
|
|
141
|
+
return todo();
|
|
142
|
+
// const space = this.echo.getSpace(request.space_key) ?? raise(new SpaceNotFoundError(request.space_key));
|
|
143
|
+
// return {
|
|
144
|
+
// processedTimeframe: space.timeframe
|
|
145
|
+
// };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async createSpace(): Promise<Space> {
|
|
149
|
+
await this.serviceContext.initialized.wait();
|
|
150
|
+
const space = await this.serviceContext.spaceManager!.createSpace();
|
|
151
|
+
return {
|
|
152
|
+
publicKey: space.key,
|
|
153
|
+
isOpen: true,
|
|
154
|
+
isActive: true
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async cloneSpace(snapshot: SpaceSnapshot): Promise<Space> {
|
|
159
|
+
return todo();
|
|
160
|
+
// const space = await this.echo.cloneSpace(snapshot);
|
|
161
|
+
// return {
|
|
162
|
+
// public_key: space.key,
|
|
163
|
+
// is_open: space.is_open,
|
|
164
|
+
// is_active: space.is_active
|
|
165
|
+
// };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async setSpaceState(request: SetSpaceStateRequest) {
|
|
169
|
+
return todo();
|
|
170
|
+
// const space = this.echo.getSpace(request.space_key);
|
|
171
|
+
// if (!space) {
|
|
172
|
+
// throw new Error('Space not found');
|
|
173
|
+
// }
|
|
174
|
+
|
|
175
|
+
// if (request.open === true) {
|
|
176
|
+
// await space.open();
|
|
177
|
+
// } else if (request.open === false) {
|
|
178
|
+
// await space.close();
|
|
179
|
+
// } // Undefined preserves previous state.
|
|
180
|
+
|
|
181
|
+
// if (request.active_global === true) {
|
|
182
|
+
// await space.activate({ global: true });
|
|
183
|
+
// } else if (request.active_global === false) {
|
|
184
|
+
// await space.deactivate({ global: true });
|
|
185
|
+
// } // Undefined preserves previous state.
|
|
186
|
+
|
|
187
|
+
// if (request.active_device === true) {
|
|
188
|
+
// await space.activate({ device: true });
|
|
189
|
+
// } else if (request.active_device === false) {
|
|
190
|
+
// await space.deactivate({ device: true });
|
|
191
|
+
// } // Undefined preserves previous state.
|
|
192
|
+
// return {
|
|
193
|
+
// public_key: space.key,
|
|
194
|
+
// is_open: space.is_open,
|
|
195
|
+
// is_active: space.is_active
|
|
196
|
+
// };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async authenticateInvitation(request: AuthenticateInvitationRequest) {
|
|
200
|
+
assert(request.processId, 'Process ID is missing.');
|
|
201
|
+
const invitation = this.inviteeInvitations.get(request.processId);
|
|
202
|
+
assert(invitation, 'Invitation not found.');
|
|
203
|
+
assert(request.secret, 'Secret not provided.');
|
|
204
|
+
|
|
205
|
+
// Supply the secret, and move the internal invitation process by triggering the secretTrigger.
|
|
206
|
+
invitation.secret = request.secret;
|
|
207
|
+
invitation.secretTrigger?.();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
subscribeMembers(request: SubscribeMembersRequest): Stream<SubscribeMembersResponse> {
|
|
211
|
+
return new Stream(({ next }) => {
|
|
212
|
+
next({
|
|
213
|
+
members: []
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
// const space = this.echo.getSpace(request.space_key);
|
|
217
|
+
// if (space) {
|
|
218
|
+
// return resultSetToStream(space.queryMembers(), (members): SubscribeMembersResponse => ({ members }));
|
|
219
|
+
// } else {
|
|
220
|
+
// return new Stream(({ next }) => {
|
|
221
|
+
// let unsubscribeMembers: () => void;
|
|
222
|
+
// const unsubscribeSpaces = this.echo.querySpaces().subscribe((spaces) => {
|
|
223
|
+
// const space = spaces.find((space) => space.key.equals(request.space_key));
|
|
224
|
+
// if (!unsubscribeMembers && space) {
|
|
225
|
+
// const resultSet = space.queryMembers();
|
|
226
|
+
// next({ members: resultSet.value });
|
|
227
|
+
// unsubscribeMembers = resultSet.update.on(() => next({ members: resultSet.value }));
|
|
228
|
+
// }
|
|
229
|
+
// });
|
|
230
|
+
|
|
231
|
+
// return () => {
|
|
232
|
+
// unsubscribeSpaces();
|
|
233
|
+
// unsubscribeMembers();
|
|
234
|
+
// };
|
|
235
|
+
// });
|
|
236
|
+
// }
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async createSnapshot(request: CreateSnapshotRequest): Promise<SpaceSnapshot> {
|
|
240
|
+
return todo();
|
|
241
|
+
// assert(request.space_key);
|
|
242
|
+
// const space = this.echo.getSpace(request.space_key) ?? raise(new SpaceNotFoundError(request.space_key));
|
|
243
|
+
// return space.createSnapshot();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { Config } from '@dxos/config';
|
|
6
6
|
import { todo } from '@dxos/debug';
|
|
7
|
-
import { SystemService
|
|
7
|
+
import { SystemService } from '@dxos/protocols/proto/dxos/client';
|
|
8
8
|
|
|
9
|
-
export class
|
|
9
|
+
export class SystemServiceImpl implements SystemService {
|
|
10
10
|
constructor(private readonly _config: Config) {}
|
|
11
11
|
|
|
12
12
|
async getConfig(request: void) {
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Config } from '@dxos/config';
|
|
6
|
-
import { TracingService
|
|
6
|
+
import { TracingService } from '@dxos/protocols/proto/dxos/devtools/host';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
export class
|
|
11
|
+
export class TracingServiceImpl implements TracingService {
|
|
12
12
|
constructor(private readonly _config: Config) {}
|
|
13
13
|
|
|
14
14
|
async setTracingOptions() {
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Event as AsyncEvent } from '@dxos/async';
|
|
5
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
7
|
import { Config } from '@dxos/config';
|
|
7
|
-
import { todo } from '@dxos/debug';
|
|
8
8
|
import {
|
|
9
9
|
ClearSnapshotsRequest,
|
|
10
|
-
DevtoolsHost,
|
|
10
|
+
DevtoolsHost, // TODO(burdon): Rename DevtoolsService
|
|
11
11
|
EnableDebugLoggingRequest,
|
|
12
12
|
EnableDebugLoggingResponse,
|
|
13
13
|
Event,
|
|
14
14
|
GetConfigResponse,
|
|
15
15
|
GetNetworkPeersRequest,
|
|
16
16
|
GetNetworkPeersResponse,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
GetSpaceSnapshotRequest,
|
|
18
|
+
GetSpaceSnapshotResponse,
|
|
19
19
|
ResetStorageRequest,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
SaveSpaceSnapshotRequest,
|
|
21
|
+
SaveSpaceSnapshotResponse,
|
|
22
22
|
SubscribeToCredentialMessagesRequest,
|
|
23
23
|
SubscribeToCredentialMessagesResponse,
|
|
24
24
|
SubscribeToFeedBlocksRequest,
|
|
@@ -30,23 +30,22 @@ import {
|
|
|
30
30
|
SubscribeToKeyringKeysRequest,
|
|
31
31
|
SubscribeToKeyringKeysResponse,
|
|
32
32
|
SubscribeToNetworkTopicsResponse,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
SubscribeToSpacesRequest,
|
|
34
|
+
SubscribeToSpacesResponse,
|
|
35
35
|
SubscribeToSignalStatusResponse,
|
|
36
36
|
SubscribeToSignalTraceResponse,
|
|
37
37
|
SubscribeToSwarmInfoResponse
|
|
38
38
|
} from '@dxos/protocols/proto/dxos/devtools/host';
|
|
39
39
|
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
import { ServiceContext } from '../service-context';
|
|
40
|
+
import { ServiceContext } from '../services';
|
|
41
|
+
import { subscribeToFeedBlocks, subscribeToFeeds } from './feeds';
|
|
42
|
+
import { subscribeToNetworkStatus, subscribeToSignalTrace, subscribeToSwarmInfo } from './network';
|
|
43
|
+
import { subscribeToSpaces } from './spaces';
|
|
44
|
+
|
|
45
|
+
// TODO(burdon): Remove?
|
|
46
|
+
export class DevtoolsHostEvents {
|
|
47
|
+
readonly ready = new AsyncEvent();
|
|
48
|
+
}
|
|
50
49
|
|
|
51
50
|
export type DevtoolsServiceParams = {
|
|
52
51
|
events: DevtoolsHostEvents;
|
|
@@ -54,7 +53,7 @@ export type DevtoolsServiceParams = {
|
|
|
54
53
|
context: ServiceContext;
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
export class
|
|
56
|
+
export class DevtoolsServiceImpl implements DevtoolsHost {
|
|
58
57
|
constructor(private readonly params: DevtoolsServiceParams) {}
|
|
59
58
|
|
|
60
59
|
events(request: void): Stream<Event> {
|
|
@@ -66,37 +65,37 @@ export class DevtoolsService implements DevtoolsHost {
|
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
getConfig(request: void): Promise<GetConfigResponse> {
|
|
69
|
-
|
|
68
|
+
throw new Error();
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
resetStorage(request: ResetStorageRequest): Promise<void> {
|
|
73
|
-
|
|
72
|
+
throw new Error();
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
enableDebugLogging(request: EnableDebugLoggingRequest): Promise<EnableDebugLoggingResponse> {
|
|
77
|
-
|
|
76
|
+
throw new Error();
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
disableDebugLogging(request: EnableDebugLoggingRequest): Promise<EnableDebugLoggingResponse> {
|
|
81
|
-
|
|
80
|
+
throw new Error();
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
subscribeToKeyringKeys(request: SubscribeToKeyringKeysRequest): Stream<SubscribeToKeyringKeysResponse> {
|
|
85
|
-
|
|
84
|
+
throw new Error();
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
subscribeToCredentialMessages(
|
|
89
88
|
request: SubscribeToCredentialMessagesRequest
|
|
90
89
|
): Stream<SubscribeToCredentialMessagesResponse> {
|
|
91
|
-
|
|
90
|
+
throw new Error();
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
|
|
93
|
+
subscribeToSpaces(request: SubscribeToSpacesRequest): Stream<SubscribeToSpacesResponse> {
|
|
95
94
|
return subscribeToSpaces(this.params.context, request);
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
subscribeToItems(request: SubscribeToItemsRequest): Stream<SubscribeToItemsResponse> {
|
|
99
|
-
|
|
98
|
+
throw new Error();
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
subscribeToFeeds(request: SubscribeToFeedsRequest): Stream<SubscribeToFeedsResponse> {
|
|
@@ -107,24 +106,24 @@ export class DevtoolsService implements DevtoolsHost {
|
|
|
107
106
|
return subscribeToFeedBlocks({ feedStore: this.params.context.feedStore }, request);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
getSpaceSnapshot(request: GetSpaceSnapshotRequest): Promise<GetSpaceSnapshotResponse> {
|
|
110
|
+
throw new Error();
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
saveSpaceSnapshot(request: SaveSpaceSnapshotRequest): Promise<SaveSpaceSnapshotResponse> {
|
|
114
|
+
throw new Error();
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
clearSnapshots(request: ClearSnapshotsRequest): Promise<void> {
|
|
119
|
-
|
|
118
|
+
throw new Error();
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
getNetworkPeers(request: GetNetworkPeersRequest): Promise<GetNetworkPeersResponse> {
|
|
123
|
-
|
|
122
|
+
throw new Error();
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
subscribeToNetworkTopics(request: void): Stream<SubscribeToNetworkTopicsResponse> {
|
|
127
|
-
|
|
126
|
+
throw new Error();
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
subscribeToSignalStatus(request: void): Stream<SubscribeToSignalStatusResponse> {
|
|
@@ -27,14 +27,15 @@ export const subscribeToFeeds = (
|
|
|
27
27
|
const feedMap = new ComplexMap<PublicKey, FeedWrapper<FeedMessage>>(PublicKey.hash);
|
|
28
28
|
const subscriptions = new EventSubscriptions();
|
|
29
29
|
|
|
30
|
-
const update =
|
|
31
|
-
const feeds =
|
|
30
|
+
const update = () => {
|
|
31
|
+
const feeds = feedStore.feeds;
|
|
32
32
|
feeds
|
|
33
33
|
.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key)))
|
|
34
34
|
.forEach((feed) => {
|
|
35
35
|
if (!feedMap.has(feed.key)) {
|
|
36
36
|
feedMap.set(feed.key, feed);
|
|
37
|
-
feed.on('close', update);
|
|
37
|
+
feed.on('close', update);
|
|
38
|
+
subscriptions.add(feed.off('close', update));
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
next({
|
|
@@ -42,10 +43,8 @@ export const subscribeToFeeds = (
|
|
|
42
43
|
});
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
await update();
|
|
48
|
-
});
|
|
46
|
+
subscriptions.add(feedStore.feedOpened.on(update));
|
|
47
|
+
update();
|
|
49
48
|
|
|
50
49
|
return () => {
|
|
51
50
|
subscriptions.clear();
|
|
@@ -60,31 +59,36 @@ export const subscribeToFeedBlocks = (
|
|
|
60
59
|
if (!feedKey) {
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
const update = async (feed: FeedWrapper<FeedMessage>) => {
|
|
65
|
-
const iterator = new FeedIterator(feed);
|
|
66
|
-
await iterator.open();
|
|
67
|
-
const blocks = [];
|
|
68
|
-
for await (const block of iterator) {
|
|
69
|
-
blocks.push(block);
|
|
70
|
-
if (blocks.length >= feed.properties.length) {
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
next({
|
|
75
|
-
blocks: blocks.slice(-maxBlocks)
|
|
76
|
-
});
|
|
77
|
-
await iterator.close();
|
|
78
|
-
};
|
|
62
|
+
const subscriptions = new EventSubscriptions();
|
|
79
63
|
|
|
80
64
|
setImmediate(async () => {
|
|
81
|
-
const feed =
|
|
65
|
+
const feed = feedStore.getFeed(feedKey);
|
|
82
66
|
if (!feed) {
|
|
83
67
|
return;
|
|
84
68
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
|
|
70
|
+
const update = async () => {
|
|
71
|
+
const iterator = new FeedIterator(feed);
|
|
72
|
+
await iterator.open();
|
|
73
|
+
const blocks = [];
|
|
74
|
+
for await (const block of iterator) {
|
|
75
|
+
blocks.push(block);
|
|
76
|
+
if (blocks.length >= feed.properties.length) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
next({
|
|
81
|
+
blocks: blocks.slice(-maxBlocks)
|
|
82
|
+
});
|
|
83
|
+
await iterator.close();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
feed.on('append', update);
|
|
87
|
+
subscriptions.add(feed.off('append', update));
|
|
88
|
+
|
|
89
|
+
feed.on('truncate', update);
|
|
90
|
+
subscriptions.add(feed.off('truncate', update));
|
|
91
|
+
await update();
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
return () => {};
|