@dxos/client-services 0.8.3 → 0.8.4-main.03d5cd7b56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-LBG3C332.mjs → chunk-LWIXGESH.mjs} +3826 -5125
- package/dist/lib/browser/chunk-LWIXGESH.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs +22 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +454 -148
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +88 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +86 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +48 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +40 -41
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +22 -0
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SKGQLRKS.mjs → chunk-LOVO5YB5.mjs} +3226 -4393
- package/dist/lib/node-esm/chunk-LOVO5YB5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +454 -148
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +88 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +86 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +48 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +40 -41
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +3 -2
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts +3 -2
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +20 -20
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +3 -4
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +8 -7
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +6 -10
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +9 -12
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +6 -5
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +2 -2
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +8 -5
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +5 -4
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/browser.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +2 -2
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +5 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +7 -6
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +5 -5
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +14 -10
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +21 -8
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/archive-format.d.ts +9 -0
- package/dist/types/src/packlets/space-export/archive-format.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/index.d.ts +4 -1
- package/dist/types/src/packlets/space-export/index.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +23 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts +36 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +8 -2
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +29 -18
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +30 -13
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +2 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -9
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +11 -8
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +2 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +8 -7
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +41 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -4
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/testing/setup.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +72 -55
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +10 -7
- package/src/packlets/agents/edge-agent-service.ts +17 -5
- package/src/packlets/devices/devices-service.test.ts +3 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +29 -29
- package/src/packlets/devtools/feeds.ts +2 -2
- package/src/packlets/devtools/network.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
- package/src/packlets/diagnostics/diagnostics.ts +2 -3
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.node.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +3 -3
- package/src/packlets/identity/contacts-service.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +8 -8
- package/src/packlets/identity/identity-manager.ts +25 -24
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +8 -28
- package/src/packlets/identity/identity-service.ts +13 -80
- package/src/packlets/identity/identity.test.ts +11 -11
- package/src/packlets/identity/identity.ts +17 -39
- package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +8 -6
- package/src/packlets/invitations/edge-invitation-handler.ts +10 -6
- package/src/packlets/invitations/index.ts +1 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
- package/src/packlets/invitations/invitation-host-extension.ts +15 -16
- package/src/packlets/invitations/invitation-protocol.ts +8 -5
- package/src/packlets/invitations/invitation-state.ts +1 -15
- package/src/packlets/invitations/invitations-handler.test.ts +301 -292
- package/src/packlets/invitations/invitations-handler.ts +77 -25
- package/src/packlets/invitations/invitations-manager.ts +43 -18
- package/src/packlets/invitations/invitations-service.ts +10 -10
- package/src/packlets/invitations/space-invitation-protocol.test.ts +26 -25
- package/src/packlets/invitations/space-invitation-protocol.ts +13 -17
- package/src/packlets/invitations/utils.ts +1 -1
- package/src/packlets/locks/browser.ts +1 -1
- package/src/packlets/locks/index.ts +2 -2
- package/src/packlets/logging/logging-service.ts +22 -17
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +3 -3
- package/src/packlets/network/network-service.ts +12 -10
- package/src/packlets/services/client-rpc-server.ts +20 -17
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +377 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +4 -3
- package/src/packlets/services/service-context.ts +148 -64
- package/src/packlets/services/service-host.test.ts +10 -9
- package/src/packlets/services/service-host.ts +88 -49
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/space-export/archive-format.ts +42 -0
- package/src/packlets/space-export/index.ts +4 -1
- package/src/packlets/space-export/serialized-space-reader.ts +111 -0
- package/src/packlets/space-export/serialized-space-writer.ts +252 -0
- package/src/packlets/space-export/space-archive-reader.ts +65 -4
- package/src/packlets/space-export/space-archive-writer.ts +44 -6
- package/src/packlets/space-export/space-archive.test.ts +461 -0
- package/src/packlets/space-export/tar.test.ts +1 -1
- package/src/packlets/spaces/automerge-space-state.ts +1 -1
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +129 -125
- package/src/packlets/spaces/data-space.ts +65 -40
- package/src/packlets/spaces/edge-feed-replicator.test.ts +4 -4
- package/src/packlets/spaces/edge-feed-replicator.ts +13 -11
- package/src/packlets/spaces/epoch-migrations.ts +5 -5
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +13 -12
- package/src/packlets/spaces/spaces-service.test.ts +20 -12
- package/src/packlets/spaces/spaces-service.ts +138 -38
- package/src/packlets/storage/profile-archive.ts +1 -1
- package/src/packlets/storage/storage.ts +7 -8
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +11 -7
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +189 -17
- package/src/packlets/worker/worker-session.ts +15 -21
- package/src/version.ts +1 -5
- package/README.yml +0 -5
- package/dist/lib/browser/chunk-LBG3C332.mjs.map +0 -7
- package/dist/lib/node/chunk-LMGLGOUU.cjs +0 -9311
- package/dist/lib/node/chunk-LMGLGOUU.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -437
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -452
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SKGQLRKS.mjs.map +0 -7
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +0 -19
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +0 -1
- package/src/packlets/identity/default-space-state-machine.ts +0 -44
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Context } from '@dxos/context';
|
|
5
6
|
import {
|
|
6
7
|
createCancelDelegatedSpaceInvitationCredential,
|
|
7
8
|
createDelegatedSpaceInvitationCredential,
|
|
@@ -12,24 +13,18 @@ import { invariant } from '@dxos/invariant';
|
|
|
12
13
|
import { type Keyring } from '@dxos/keyring';
|
|
13
14
|
import { type PublicKey } from '@dxos/keys';
|
|
14
15
|
import { log } from '@dxos/log';
|
|
15
|
-
import {
|
|
16
|
-
AlreadyJoinedError,
|
|
17
|
-
type ApiError,
|
|
18
|
-
AuthorizationError,
|
|
19
|
-
InvalidInvitationError,
|
|
20
|
-
SpaceNotFoundError,
|
|
21
|
-
} from '@dxos/protocols';
|
|
16
|
+
import { AlreadyJoinedError, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from '@dxos/protocols';
|
|
22
17
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
|
-
import {
|
|
18
|
+
import { type ProfileDocument, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
24
19
|
import {
|
|
25
20
|
type AdmissionRequest,
|
|
26
21
|
type AdmissionResponse,
|
|
27
22
|
type IntroductionRequest,
|
|
28
23
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
29
24
|
|
|
25
|
+
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
30
26
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
31
27
|
import { computeExpirationTime } from './utils';
|
|
32
|
-
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
33
28
|
|
|
34
29
|
export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
35
30
|
constructor(
|
|
@@ -47,16 +42,16 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
checkCanInviteNewMembers():
|
|
45
|
+
checkCanInviteNewMembers(): Error | undefined {
|
|
51
46
|
if (this._spaceKey == null) {
|
|
52
|
-
return new InvalidInvitationError('No spaceKey was provided for a space invitation.');
|
|
47
|
+
return new InvalidInvitationError({ message: 'No spaceKey was provided for a space invitation.' });
|
|
53
48
|
}
|
|
54
49
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
55
50
|
if (space == null) {
|
|
56
51
|
return new SpaceNotFoundError(this._spaceKey);
|
|
57
52
|
}
|
|
58
53
|
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
59
|
-
return new AuthorizationError('No member management permission.');
|
|
54
|
+
return new AuthorizationError({ message: 'No member management permission.' });
|
|
60
55
|
}
|
|
61
56
|
return undefined;
|
|
62
57
|
}
|
|
@@ -147,10 +142,10 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
147
142
|
|
|
148
143
|
checkInvitation(invitation: Partial<Invitation>): InvalidInvitationError | AlreadyJoinedError | undefined {
|
|
149
144
|
if (invitation.spaceKey == null) {
|
|
150
|
-
return new InvalidInvitationError('No spaceKey was provided for a space invitation.');
|
|
145
|
+
return new InvalidInvitationError({ message: 'No spaceKey was provided for a space invitation.' });
|
|
151
146
|
}
|
|
152
147
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
153
|
-
return new AlreadyJoinedError('Already joined space.');
|
|
148
|
+
return new AlreadyJoinedError({ message: 'Already joined space.' });
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
|
|
@@ -175,7 +170,7 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
175
170
|
};
|
|
176
171
|
}
|
|
177
172
|
|
|
178
|
-
async accept(response: AdmissionResponse): Promise<Partial<Invitation>> {
|
|
173
|
+
async accept(ctx: Context, response: AdmissionResponse): Promise<Partial<Invitation>> {
|
|
179
174
|
invariant(response.space);
|
|
180
175
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
181
176
|
const assertion = getCredentialAssertion(credential);
|
|
@@ -183,15 +178,16 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
183
178
|
invariant(credential.subject.id.equals(this._signingContext.identityKey));
|
|
184
179
|
|
|
185
180
|
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
186
|
-
throw new AlreadyJoinedError('Already joined space.');
|
|
181
|
+
throw new AlreadyJoinedError({ message: 'Already joined space.' });
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
// Create local space.
|
|
190
|
-
await this._spaceManager.acceptSpace({
|
|
185
|
+
await this._spaceManager.acceptSpace(ctx, {
|
|
191
186
|
spaceKey: assertion.spaceKey,
|
|
192
187
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
193
188
|
controlTimeframe,
|
|
194
189
|
dataTimeframe,
|
|
190
|
+
tags: assertion.tags,
|
|
195
191
|
});
|
|
196
192
|
|
|
197
193
|
await this._signingContext.recordCredential(credential);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Mutex, type MutexGuard } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
8
|
|
|
9
9
|
export const stateToString = (state: Invitation.State): string => {
|
|
@@ -5,27 +5,25 @@
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
|
+
import { type LogLevel, type LogProcessor, type LogEntry as NaturalLogEntry, log } from '@dxos/log';
|
|
8
9
|
import {
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type LogEntry as NaturalLogEntry,
|
|
12
|
-
getContextFromEntry,
|
|
13
|
-
log,
|
|
14
|
-
} from '@dxos/log';
|
|
15
|
-
import {
|
|
10
|
+
type ControlMetricsRequest,
|
|
11
|
+
type ControlMetricsResponse,
|
|
16
12
|
type LogEntry,
|
|
17
13
|
type LoggingService,
|
|
18
14
|
type Metrics,
|
|
19
15
|
QueryLogsRequest,
|
|
20
|
-
type ControlMetricsRequest,
|
|
21
|
-
type ControlMetricsResponse,
|
|
22
16
|
type QueryMetricsRequest,
|
|
23
17
|
type QueryMetricsResponse,
|
|
24
18
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
25
|
-
import {
|
|
19
|
+
import { numericalValues, tracer } from '@dxos/util';
|
|
26
20
|
|
|
27
21
|
/**
|
|
28
22
|
* Logging service used to spy on logs of the host.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated This was created so that logs from the shared worker (WorkerClientServices) could be
|
|
25
|
+
* seen in the main window console without opening the shared worker DevTools. Shared worker client
|
|
26
|
+
* services is deprecated; dedicated worker logs already show in the main window console.
|
|
29
27
|
*/
|
|
30
28
|
export class LoggingServiceImpl implements LoggingService {
|
|
31
29
|
private readonly _logs = new Event<NaturalLogEntry>();
|
|
@@ -37,7 +35,7 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
async close(): Promise<void> {
|
|
40
|
-
const index = log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
38
|
+
const index = log.runtimeConfig.processors.findIndex((processor: LogProcessor) => processor === this._logProcessor);
|
|
41
39
|
log.runtimeConfig.processors.splice(index, 1);
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -110,18 +108,25 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
110
|
|
|
111
|
+
const { filename, line, context: scopeName } = entry.computedMeta;
|
|
112
|
+
const recordContext: Record<string, any> = { ...entry.computedContext };
|
|
113
|
+
if (entry.computedError !== undefined) {
|
|
114
|
+
recordContext.error = entry.computedError;
|
|
115
|
+
}
|
|
116
|
+
|
|
113
117
|
const record: LogEntry = {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
level: entry.level,
|
|
119
|
+
message: entry.message ?? entry.computedError ?? '',
|
|
120
|
+
context: recordContext,
|
|
121
|
+
timestamp: new Date(entry.timestamp),
|
|
117
122
|
meta: {
|
|
118
123
|
// TODO(dmaretskyi): Fix proto.
|
|
119
|
-
file:
|
|
120
|
-
line:
|
|
124
|
+
file: filename ?? '',
|
|
125
|
+
line: line ?? 0,
|
|
121
126
|
scope: {
|
|
122
127
|
hostSessionId: this._sessionId,
|
|
123
128
|
uptimeSeconds: (Date.now() - this._started) / 1000,
|
|
124
|
-
name:
|
|
129
|
+
name: scopeName ?? '',
|
|
125
130
|
},
|
|
126
131
|
},
|
|
127
132
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
|
-
import {
|
|
8
|
+
import { LogLevel, log } from '@dxos/log';
|
|
9
9
|
import { type LogEntry } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
11
|
import { LoggingServiceImpl } from './logging-service';
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterEach,
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { type NetworkService
|
|
9
|
+
import { ConnectionState, type NetworkService } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
|
-
import { NetworkServiceImpl } from './network-service';
|
|
12
11
|
import { type ServiceContext } from '../services';
|
|
13
12
|
import { createServiceContext } from '../testing';
|
|
13
|
+
import { NetworkServiceImpl } from './network-service';
|
|
14
14
|
|
|
15
15
|
describe('NetworkService', () => {
|
|
16
16
|
let serviceContext: ServiceContext;
|
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type RequestOptions } from '@dxos/codec-protobuf';
|
|
5
6
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
6
8
|
import { type EdgeConnection } from '@dxos/edge-client';
|
|
7
9
|
import { type SignalManager } from '@dxos/messaging';
|
|
8
10
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
9
11
|
import {
|
|
10
|
-
type SubscribeSwarmStateRequest,
|
|
11
12
|
type NetworkService,
|
|
12
13
|
type NetworkStatus,
|
|
14
|
+
type SubscribeSwarmStateRequest,
|
|
13
15
|
type UpdateConfigRequest,
|
|
14
16
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
15
17
|
import { type Peer, type SwarmResponse } from '@dxos/protocols/proto/dxos/edge/messenger';
|
|
16
18
|
import {
|
|
17
|
-
type LeaveRequest,
|
|
18
19
|
type JoinRequest,
|
|
20
|
+
type LeaveRequest,
|
|
19
21
|
type Message,
|
|
20
22
|
type QueryRequest,
|
|
21
23
|
} from '@dxos/protocols/proto/dxos/edge/signal';
|
|
@@ -47,16 +49,16 @@ export class NetworkServiceImpl implements NetworkService {
|
|
|
47
49
|
await this.networkManager.setConnectionState(request.swarm);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
async joinSwarm(request: JoinRequest): Promise<void> {
|
|
51
|
-
return this.signalManager.join(request);
|
|
52
|
+
async joinSwarm(request: JoinRequest, options?: RequestOptions): Promise<void> {
|
|
53
|
+
return this.signalManager.join(options?.ctx ?? Context.default(), request);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
async leaveSwarm(request: LeaveRequest): Promise<void> {
|
|
55
|
-
return this.signalManager.leave(request);
|
|
56
|
+
async leaveSwarm(request: LeaveRequest, options?: RequestOptions): Promise<void> {
|
|
57
|
+
return this.signalManager.leave(options?.ctx ?? Context.default(), request);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
async querySwarm(request: QueryRequest): Promise<SwarmResponse> {
|
|
59
|
-
return this.signalManager.query(request);
|
|
60
|
+
async querySwarm(request: QueryRequest, options?: RequestOptions): Promise<SwarmResponse> {
|
|
61
|
+
return this.signalManager.query(options?.ctx ?? Context.default(), request);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
subscribeSwarmState(request: SubscribeSwarmStateRequest): Stream<SwarmResponse> {
|
|
@@ -69,8 +71,8 @@ export class NetworkServiceImpl implements NetworkService {
|
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
async sendMessage(message: Message): Promise<void> {
|
|
73
|
-
return this.signalManager.sendMessage(message);
|
|
74
|
+
async sendMessage(message: Message, options?: RequestOptions): Promise<void> {
|
|
75
|
+
return this.signalManager.sendMessage(options?.ctx ?? Context.default(), message);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
subscribeMessages(peer: Peer): Stream<Message> {
|
|
@@ -3,25 +3,27 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type ClientServices } from '@dxos/client-protocol';
|
|
6
|
-
import { type Any, type ServiceHandler, Stream } from '@dxos/codec-protobuf';
|
|
6
|
+
import { type Any, type RequestOptions, type ServiceHandler, Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import {
|
|
8
|
+
import { RpcPeer, type RpcPeerOptions, type ServiceBundle, parseMethodName } from '@dxos/rpc';
|
|
9
9
|
import { MapCounter, trace } from '@dxos/tracing';
|
|
10
10
|
import { type MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { type ServiceRegistry } from './service-registry';
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type ClientRpcServerProps = {
|
|
15
15
|
serviceRegistry: ServiceRegistry<ClientServices>;
|
|
16
16
|
handleCall?: (
|
|
17
17
|
method: string,
|
|
18
18
|
params: Any,
|
|
19
|
-
handler: (method: string, params: Any) => MaybePromise<Any>,
|
|
19
|
+
handler: (method: string, params: Any, options?: RequestOptions) => MaybePromise<Any>,
|
|
20
|
+
options?: RequestOptions,
|
|
20
21
|
) => Promise<Any>;
|
|
21
22
|
handleStream?: (
|
|
22
23
|
method: string,
|
|
23
24
|
params: Any,
|
|
24
|
-
handler: (method: string, params: Any) => Stream<Any>,
|
|
25
|
+
handler: (method: string, params: Any, options?: RequestOptions) => Stream<Any>,
|
|
26
|
+
options?: RequestOptions,
|
|
25
27
|
) => MaybePromise<Stream<Any>>;
|
|
26
28
|
} & Omit<RpcPeerOptions, 'callHandler' | 'streamHandler'>;
|
|
27
29
|
|
|
@@ -30,8 +32,8 @@ export class ClientRpcServer {
|
|
|
30
32
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|
|
31
33
|
private readonly _rpcPeer: RpcPeer;
|
|
32
34
|
private readonly _handlerCache = new Map<string, ServiceHandler<any>>();
|
|
33
|
-
private readonly _handleCall:
|
|
34
|
-
private readonly _handleStream:
|
|
35
|
+
private readonly _handleCall: ClientRpcServerProps['handleCall'];
|
|
36
|
+
private readonly _handleStream: ClientRpcServerProps['handleStream'];
|
|
35
37
|
|
|
36
38
|
@trace.metricsCounter()
|
|
37
39
|
private readonly _callMetrics = new MapCounter();
|
|
@@ -41,7 +43,7 @@ export class ClientRpcServer {
|
|
|
41
43
|
return Object.keys(this._serviceRegistry.services);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
constructor(params:
|
|
46
|
+
constructor(params: ClientRpcServerProps) {
|
|
45
47
|
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
46
48
|
this._handleCall = handleCall;
|
|
47
49
|
this._handleStream = handleStream;
|
|
@@ -49,32 +51,33 @@ export class ClientRpcServer {
|
|
|
49
51
|
this._serviceRegistry = serviceRegistry;
|
|
50
52
|
this._rpcPeer = new RpcPeer({
|
|
51
53
|
...rpcOptions,
|
|
52
|
-
callHandler: (method, params) => {
|
|
54
|
+
callHandler: (method, params, options) => {
|
|
53
55
|
const [serviceName, methodName] = parseMethodName(method);
|
|
54
|
-
const handler = (method: string, params: Any
|
|
56
|
+
const handler = (method: string, params: Any, handlerOptions?: RequestOptions) =>
|
|
57
|
+
this._getServiceHandler(serviceName).call(method, params, handlerOptions);
|
|
55
58
|
|
|
56
59
|
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
57
60
|
|
|
58
61
|
if (this._handleCall) {
|
|
59
|
-
return this._handleCall(methodName, params, handler);
|
|
62
|
+
return this._handleCall(methodName, params, handler, options);
|
|
60
63
|
} else {
|
|
61
|
-
return handler(methodName, params);
|
|
64
|
+
return handler(methodName, params, options);
|
|
62
65
|
}
|
|
63
66
|
},
|
|
64
|
-
streamHandler: (method, params) => {
|
|
67
|
+
streamHandler: (method, params, options) => {
|
|
65
68
|
const [serviceName, methodName] = parseMethodName(method);
|
|
66
|
-
const handler = (method: string, params: Any) =>
|
|
67
|
-
this._getServiceHandler(serviceName).callStream(method, params);
|
|
69
|
+
const handler = (method: string, params: Any, handlerOptions?: RequestOptions) =>
|
|
70
|
+
this._getServiceHandler(serviceName).callStream(method, params, handlerOptions);
|
|
68
71
|
|
|
69
72
|
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
70
73
|
|
|
71
74
|
if (this._handleStream) {
|
|
72
|
-
return Stream.map(Stream.unwrapPromise(this._handleStream(methodName, params, handler)), (data) => {
|
|
75
|
+
return Stream.map(Stream.unwrapPromise(this._handleStream(methodName, params, handler, options)), (data) => {
|
|
73
76
|
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
74
77
|
return data;
|
|
75
78
|
});
|
|
76
79
|
} else {
|
|
77
|
-
return handler(methodName, params);
|
|
80
|
+
return handler(methodName, params, options);
|
|
78
81
|
}
|
|
79
82
|
},
|
|
80
83
|
});
|