@dxos/client-services 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b

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.
Files changed (154) hide show
  1. package/dist/lib/browser/{chunk-NPM7LZLM.mjs → chunk-OD5PC2PZ.mjs} +2400 -2140
  2. package/dist/lib/browser/chunk-OD5PC2PZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +37 -18
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +12 -12
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node-esm/{chunk-3GXJDHS7.mjs → chunk-CRPF6ZN2.mjs} +2397 -2136
  9. package/dist/lib/node-esm/chunk-CRPF6ZN2.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +37 -18
  11. package/dist/lib/node-esm/index.mjs.map +3 -3
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +12 -12
  14. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  15. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  16. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/devtools/devtools.d.ts +18 -18
  19. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  20. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  21. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  22. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  23. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  24. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +1 -1
  25. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
  26. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +1 -1
  27. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  28. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -1
  29. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  30. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  31. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  32. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  33. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +1 -1
  34. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -1
  36. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  37. package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
  38. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  39. package/dist/types/src/packlets/identity/identity.d.ts +1 -1
  40. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  41. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -3
  42. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  43. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -1
  44. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  47. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +3 -4
  48. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  50. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  51. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  52. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  53. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +3 -3
  54. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  55. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  56. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  57. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  58. package/dist/types/src/packlets/network/network-service.d.ts +2 -2
  59. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  60. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  61. package/dist/types/src/packlets/services/service-context.d.ts +3 -3
  62. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  63. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  64. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +1 -1
  65. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  66. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +1 -1
  67. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  68. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -2
  69. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  70. package/dist/types/src/packlets/spaces/data-space.d.ts +4 -4
  71. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  72. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  73. package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
  74. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  75. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
  76. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  77. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  78. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  79. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  80. package/dist/types/src/packlets/testing/test-builder.d.ts +2 -2
  81. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  82. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  83. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  84. package/dist/types/src/version.d.ts +1 -1
  85. package/dist/types/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +41 -39
  87. package/src/packlets/agents/edge-agent-manager.ts +2 -2
  88. package/src/packlets/agents/edge-agent-service.ts +13 -3
  89. package/src/packlets/devices/devices-service.test.ts +4 -3
  90. package/src/packlets/devices/devices-service.ts +2 -2
  91. package/src/packlets/devtools/devtools.ts +28 -27
  92. package/src/packlets/devtools/feeds.ts +2 -2
  93. package/src/packlets/devtools/network.ts +1 -1
  94. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
  95. package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
  96. package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
  97. package/src/packlets/diagnostics/diagnostics.ts +1 -1
  98. package/src/packlets/identity/authenticator.node.test.ts +1 -1
  99. package/src/packlets/identity/authenticator.ts +1 -1
  100. package/src/packlets/identity/contacts-service.ts +3 -2
  101. package/src/packlets/identity/default-space-state-machine.ts +1 -1
  102. package/src/packlets/identity/identity-manager.test.ts +3 -3
  103. package/src/packlets/identity/identity-manager.ts +3 -3
  104. package/src/packlets/identity/identity-service.test.ts +3 -2
  105. package/src/packlets/identity/identity-service.ts +2 -1
  106. package/src/packlets/identity/identity.test.ts +9 -9
  107. package/src/packlets/identity/identity.ts +7 -6
  108. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  109. package/src/packlets/invitations/device-invitation-protocol.ts +5 -4
  110. package/src/packlets/invitations/edge-invitation-handler.ts +1 -1
  111. package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
  112. package/src/packlets/invitations/invitation-host-extension.ts +8 -6
  113. package/src/packlets/invitations/invitation-protocol.ts +3 -4
  114. package/src/packlets/invitations/invitations-handler.test.ts +4 -3
  115. package/src/packlets/invitations/invitations-handler.ts +4 -4
  116. package/src/packlets/invitations/invitations-manager.ts +3 -3
  117. package/src/packlets/invitations/invitations-service.ts +1 -1
  118. package/src/packlets/invitations/space-invitation-protocol.test.ts +2 -2
  119. package/src/packlets/invitations/space-invitation-protocol.ts +10 -15
  120. package/src/packlets/invitations/utils.ts +1 -1
  121. package/src/packlets/locks/browser.ts +1 -1
  122. package/src/packlets/logging/logging-service.ts +3 -3
  123. package/src/packlets/logging/logging.test.ts +1 -1
  124. package/src/packlets/network/network-service.test.ts +4 -3
  125. package/src/packlets/network/network-service.ts +2 -2
  126. package/src/packlets/services/client-rpc-server.ts +1 -1
  127. package/src/packlets/services/service-context.test.ts +1 -1
  128. package/src/packlets/services/service-context.ts +9 -8
  129. package/src/packlets/services/service-host.test.ts +3 -2
  130. package/src/packlets/services/service-host.ts +17 -9
  131. package/src/packlets/services/service-registry.test.ts +2 -1
  132. package/src/packlets/space-export/space-archive-reader.ts +2 -2
  133. package/src/packlets/space-export/space-archive-writer.ts +7 -5
  134. package/src/packlets/space-export/tar.test.ts +1 -1
  135. package/src/packlets/spaces/automerge-space-state.ts +1 -1
  136. package/src/packlets/spaces/data-space-manager.ts +44 -23
  137. package/src/packlets/spaces/data-space.ts +10 -9
  138. package/src/packlets/spaces/edge-feed-replicator.test.ts +3 -3
  139. package/src/packlets/spaces/edge-feed-replicator.ts +2 -2
  140. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  141. package/src/packlets/spaces/notarization-plugin.ts +5 -5
  142. package/src/packlets/spaces/spaces-service.test.ts +3 -2
  143. package/src/packlets/spaces/spaces-service.ts +27 -23
  144. package/src/packlets/storage/profile-archive.ts +1 -1
  145. package/src/packlets/storage/storage.ts +7 -8
  146. package/src/packlets/system/system-service.test.ts +1 -1
  147. package/src/packlets/system/system-service.ts +4 -4
  148. package/src/packlets/testing/invitation-utils.ts +1 -1
  149. package/src/packlets/testing/test-builder.ts +3 -3
  150. package/src/packlets/worker/worker-runtime.ts +2 -1
  151. package/src/packlets/worker/worker-session.ts +4 -4
  152. package/src/version.ts +1 -1
  153. package/dist/lib/browser/chunk-NPM7LZLM.mjs.map +0 -7
  154. package/dist/lib/node-esm/chunk-3GXJDHS7.mjs.map +0 -7
@@ -6,16 +6,16 @@ import { Event } from '@dxos/async';
6
6
  import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from '@dxos/client-protocol';
7
7
  import { type Context } from '@dxos/context';
8
8
  import {
9
- DeviceStateMachine,
10
9
  type CredentialSigner,
11
- createCredentialSignerWithKey,
12
- createCredentialSignerWithChain,
10
+ DeviceStateMachine,
13
11
  ProfileStateMachine,
12
+ createCredentialSignerWithChain,
13
+ createCredentialSignerWithKey,
14
14
  } from '@dxos/credentials';
15
15
  import { type Signer } from '@dxos/crypto';
16
16
  import { type Space } from '@dxos/echo-pipeline';
17
17
  import { type EdgeConnection } from '@dxos/edge-client';
18
- import { writeMessages, type FeedWrapper } from '@dxos/feed-store';
18
+ import { type FeedWrapper, writeMessages } from '@dxos/feed-store';
19
19
  import { invariant } from '@dxos/invariant';
20
20
  import { type IdentityDid, PublicKey, type SpaceId } from '@dxos/keys';
21
21
  import { log } from '@dxos/log';
@@ -23,9 +23,9 @@ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
23
23
  import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
24
24
  import {
25
25
  AdmittedFeed,
26
+ type Credential,
26
27
  type DeviceProfileDocument,
27
28
  type ProfileDocument,
28
- type Credential,
29
29
  } from '@dxos/protocols/proto/dxos/halo/credentials';
30
30
  import { type DeviceAdmissionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
31
31
  import { type Presence } from '@dxos/teleport-extension-gossip';
@@ -33,9 +33,10 @@ import { Timeframe } from '@dxos/timeframe';
33
33
  import { trace } from '@dxos/tracing';
34
34
  import { type ComplexMap, ComplexSet } from '@dxos/util';
35
35
 
36
+ import { EdgeFeedReplicator } from '../spaces';
37
+
36
38
  import { TrustedKeySetAuthVerifier } from './authenticator';
37
39
  import { DefaultSpaceStateMachine } from './default-space-state-machine';
38
- import { EdgeFeedReplicator } from '../spaces';
39
40
 
40
41
  export type IdentityParams = {
41
42
  did: IdentityDid;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { describe, expect, test, onTestFinished } from 'vitest';
5
+ import { describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { chain } from '@dxos/async';
8
8
  import { Context } from '@dxos/context';
@@ -6,7 +6,7 @@ import { getCredentialAssertion } from '@dxos/credentials';
6
6
  import { invariant } from '@dxos/invariant';
7
7
  import { type Keyring } from '@dxos/keyring';
8
8
  import { type PublicKey } from '@dxos/keys';
9
- import { AlreadyJoinedError, type ApiError } from '@dxos/protocols';
9
+ import { AlreadyJoinedError } from '@dxos/protocols';
10
10
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
11
11
  import type { DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
12
12
  import {
@@ -15,9 +15,10 @@ import {
15
15
  type IntroductionRequest,
16
16
  } from '@dxos/protocols/proto/dxos/halo/invitations';
17
17
 
18
- import { type InvitationProtocol } from './invitation-protocol';
19
18
  import { type Identity, type JoinIdentityParams } from '../identity';
20
19
 
20
+ import { type InvitationProtocol } from './invitation-protocol';
21
+
21
22
  export class DeviceInvitationProtocol implements InvitationProtocol {
22
23
  constructor(
23
24
  private readonly _keyring: Keyring,
@@ -31,7 +32,7 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
31
32
  };
32
33
  }
33
34
 
34
- checkCanInviteNewMembers(): ApiError | undefined {
35
+ checkCanInviteNewMembers(): Error | undefined {
35
36
  return undefined;
36
37
  }
37
38
 
@@ -70,7 +71,7 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
70
71
  try {
71
72
  const identity = this._getIdentity();
72
73
  if (identity) {
73
- return new AlreadyJoinedError('Currently only one identity per client is supported.');
74
+ return new AlreadyJoinedError({ message: 'Currently only one identity per client is supported.' });
74
75
  }
75
76
  } catch {
76
77
  // No identity.
@@ -19,8 +19,8 @@ import { schema } from '@dxos/protocols/proto';
19
19
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
20
20
  import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
21
21
  import {
22
- type AdmissionResponse,
23
22
  type AdmissionRequest,
23
+ type AdmissionResponse,
24
24
  type SpaceAdmissionRequest,
25
25
  } from '@dxos/protocols/proto/dxos/halo/invitations';
26
26
 
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { type Mutex, type MutexGuard, Trigger } from '@dxos/async';
6
- import { cancelWithContext, Context } from '@dxos/context';
6
+ import { Context, cancelWithContext } from '@dxos/context';
7
7
  import { invariant } from '@dxos/invariant';
8
8
  import { log } from '@dxos/log';
9
9
  import { InvalidInvitationExtensionRoleError } from '@dxos/protocols';
@@ -97,10 +97,12 @@ export class InvitationGuestExtension
97
97
  await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({ timeout: OPTIONS_TIMEOUT }));
98
98
  log.verbose('options received');
99
99
  if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
100
- throw new InvalidInvitationExtensionRoleError(undefined, {
101
- expected: InvitationOptions.Role.HOST,
102
- remoteOptions: this._remoteOptions,
103
- remotePeerId: context.remotePeerId,
100
+ throw new InvalidInvitationExtensionRoleError({
101
+ context: {
102
+ expected: InvitationOptions.Role.HOST,
103
+ remoteOptions: this._remoteOptions,
104
+ remotePeerId: context.remotePeerId,
105
+ },
104
106
  });
105
107
  }
106
108
 
@@ -3,9 +3,9 @@
3
3
  //
4
4
 
5
5
  import { type Mutex, type MutexGuard, Trigger, scheduleTask } from '@dxos/async';
6
- import { cancelWithContext, Context } from '@dxos/context';
6
+ import { Context, cancelWithContext } from '@dxos/context';
7
7
  import { randomBytes, verify } from '@dxos/crypto';
8
- import { invariant, InvariantViolation } from '@dxos/invariant';
8
+ import { InvariantViolation, invariant } from '@dxos/invariant';
9
9
  import { PublicKey } from '@dxos/keys';
10
10
  import { log } from '@dxos/log';
11
11
  import { InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
@@ -245,10 +245,12 @@ export class InvitationHostExtension
245
245
  await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({ timeout: OPTIONS_TIMEOUT }));
246
246
  log.verbose('options received');
247
247
  if (this._remoteOptions?.role !== InvitationOptions.Role.GUEST) {
248
- throw new InvalidInvitationExtensionRoleError(undefined, {
249
- expected: InvitationOptions.Role.GUEST,
250
- remoteOptions: this._remoteOptions,
251
- remotePeerId: context.remotePeerId,
248
+ throw new InvalidInvitationExtensionRoleError({
249
+ context: {
250
+ expected: InvitationOptions.Role.GUEST,
251
+ remoteOptions: this._remoteOptions,
252
+ remotePeerId: context.remotePeerId,
253
+ },
252
254
  });
253
255
  }
254
256
  this._callbacks.onStateUpdate(Invitation.State.CONNECTED);
@@ -3,9 +3,8 @@
3
3
  //
4
4
 
5
5
  import { type PublicKey } from '@dxos/keys';
6
- import type { ApiError } from '@dxos/protocols';
7
6
  import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
8
- import type { ProfileDocument, DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
7
+ import type { DeviceProfileDocument, ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
9
8
  import type {
10
9
  AdmissionRequest,
11
10
  AdmissionResponse,
@@ -26,7 +25,7 @@ export interface InvitationProtocol {
26
25
  // Host
27
26
  //
28
27
 
29
- checkCanInviteNewMembers(): ApiError | undefined;
28
+ checkCanInviteNewMembers(): Error | undefined;
30
29
 
31
30
  /**
32
31
  * Protocol-specific information to include in the invitation.
@@ -58,7 +57,7 @@ export interface InvitationProtocol {
58
57
  *
59
58
  * For example, the guest may already be a member of the space.
60
59
  */
61
- checkInvitation(invitation: Partial<Invitation>): ApiError | undefined;
60
+ checkInvitation(invitation: Partial<Invitation>): Error | undefined;
62
61
 
63
62
  /**
64
63
  * Get profile information to send to the host to identify the guest.
@@ -2,19 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { beforeEach, onTestFinished, describe, expect, test } from 'vitest';
5
+ import { beforeEach, describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
- import { type PushStream, sleep, Trigger, waitForCondition } from '@dxos/async';
7
+ import { type PushStream, Trigger, sleep, waitForCondition } from '@dxos/async';
8
8
  import { Context } from '@dxos/context';
9
9
  import { PublicKey } from '@dxos/keys';
10
10
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
11
11
  import { openAndClose } from '@dxos/test-utils';
12
12
  import { range } from '@dxos/util';
13
13
 
14
+ import { TestBuilder, type TestPeer } from '../testing';
15
+
14
16
  import { type InvitationProtocol } from './invitation-protocol';
15
17
  import { InvitationsHandler } from './invitations-handler';
16
18
  import { SpaceInvitationProtocol } from './space-invitation-protocol';
17
- import { TestBuilder, type TestPeer } from '../testing';
18
19
 
19
20
  interface PeerSetup {
20
21
  ctx: Context;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { type PushStream, scheduleTask, TimeoutError, type Trigger } from '@dxos/async';
5
+ import { type PushStream, TimeoutError, type Trigger, scheduleTask } from '@dxos/async';
6
6
  import { INVITATION_TIMEOUT, getExpirationTime } from '@dxos/client-protocol';
7
7
  import { type Context, ContextDisposedError } from '@dxos/context';
8
8
  import { createKeyPair, sign } from '@dxos/crypto';
@@ -10,7 +10,7 @@ import { type EdgeHttpClient } from '@dxos/edge-client';
10
10
  import { invariant } from '@dxos/invariant';
11
11
  import { PublicKey } from '@dxos/keys';
12
12
  import { log } from '@dxos/log';
13
- import { createTeleportProtocolFactory, type SwarmNetworkManager, type SwarmConnection } from '@dxos/network-manager';
13
+ import { type SwarmConnection, type SwarmNetworkManager, createTeleportProtocolFactory } from '@dxos/network-manager';
14
14
  import { InvalidInvitationError, InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
15
15
  import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
16
16
  import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
@@ -22,7 +22,7 @@ import { ComplexSet } from '@dxos/util';
22
22
 
23
23
  import { type EdgeInvitationConfig, EdgeInvitationHandler } from './edge-invitation-handler';
24
24
  import { InvitationGuestExtension } from './invitation-guest-extenstion';
25
- import { InvitationHostExtension, isAuthenticationRequired, MAX_OTP_ATTEMPTS } from './invitation-host-extension';
25
+ import { InvitationHostExtension, MAX_OTP_ATTEMPTS, isAuthenticationRequired } from './invitation-host-extension';
26
26
  import { type InvitationProtocol } from './invitation-protocol';
27
27
  import { createGuardedInvitationState } from './invitation-state';
28
28
  import { InvitationTopology } from './invitation-topology';
@@ -503,7 +503,7 @@ export class InvitationsHandler {
503
503
  const checkInvitation = (protocol: InvitationProtocol, invitation: Partial<Invitation>) => {
504
504
  const expiresOn = getExpirationTime(invitation);
505
505
  if (expiresOn && expiresOn.getTime() < Date.now()) {
506
- return new InvalidInvitationError('Invitation already expired.');
506
+ return new InvalidInvitationError({ message: 'Invitation already expired.' });
507
507
  }
508
508
  return protocol.checkInvitation(invitation);
509
509
  };
@@ -4,14 +4,14 @@
4
4
 
5
5
  import { Event, PushStream, TimeoutError, Trigger } from '@dxos/async';
6
6
  import {
7
- AuthenticatingInvitation,
8
7
  AUTHENTICATION_CODE_LENGTH,
8
+ AuthenticatingInvitation,
9
9
  CancellableInvitation,
10
10
  INVITATION_TIMEOUT,
11
11
  } from '@dxos/client-protocol';
12
12
  import { Context } from '@dxos/context';
13
13
  import { generatePasscode } from '@dxos/credentials';
14
- import { hasInvitationExpired, type MetadataStore } from '@dxos/echo-pipeline';
14
+ import { type MetadataStore, hasInvitationExpired } from '@dxos/echo-pipeline';
15
15
  import { invariant } from '@dxos/invariant';
16
16
  import { PublicKey } from '@dxos/keys';
17
17
  import { log } from '@dxos/log';
@@ -23,7 +23,7 @@ import {
23
23
  import { SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
24
24
 
25
25
  import type { InvitationProtocol } from './invitation-protocol';
26
- import { createAdmissionKeypair, type InvitationsHandler } from './invitations-handler';
26
+ import { type InvitationsHandler, createAdmissionKeypair } from './invitations-handler';
27
27
 
28
28
  /**
29
29
  * Entry point for creating and accepting invitations, keeps track of existing invitation set and
@@ -4,8 +4,8 @@
4
4
 
5
5
  import { Stream } from '@dxos/codec-protobuf/stream';
6
6
  import {
7
- type AuthenticationRequest,
8
7
  type AcceptInvitationRequest,
8
+ type AuthenticationRequest,
9
9
  type Invitation,
10
10
  type InvitationsService,
11
11
  QueryInvitationsResponse,
@@ -2,9 +2,9 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, describe, expect, test } from 'vitest';
5
+ import { describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
- import { chain, Trigger } from '@dxos/async';
7
+ import { Trigger, chain } from '@dxos/async';
8
8
  import { raise } from '@dxos/debug';
9
9
  import { AlreadyJoinedError } from '@dxos/protocols';
10
10
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
@@ -12,24 +12,19 @@ import { invariant } from '@dxos/invariant';
12
12
  import { type Keyring } from '@dxos/keyring';
13
13
  import { type PublicKey } from '@dxos/keys';
14
14
  import { log } from '@dxos/log';
15
- import {
16
- AlreadyJoinedError,
17
- type ApiError,
18
- AuthorizationError,
19
- InvalidInvitationError,
20
- SpaceNotFoundError,
21
- } from '@dxos/protocols';
15
+ import { AlreadyJoinedError, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from '@dxos/protocols';
22
16
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
23
- import { SpaceMember, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
17
+ import { type ProfileDocument, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
24
18
  import {
25
19
  type AdmissionRequest,
26
20
  type AdmissionResponse,
27
21
  type IntroductionRequest,
28
22
  } from '@dxos/protocols/proto/dxos/halo/invitations';
29
23
 
24
+ import { type DataSpaceManager, type SigningContext } from '../spaces';
25
+
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(): ApiError | undefined {
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
 
@@ -183,7 +178,7 @@ 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.
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { type Mutex, type MutexGuard } from '@dxos/async';
6
- import { cancelWithContext, type Context, ContextDisposedError } from '@dxos/context';
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 => {
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { asyncTimeout, Trigger } from '@dxos/async';
5
+ import { Trigger, asyncTimeout } from '@dxos/async';
6
6
  import { RESOURCE_LOCK_TIMEOUT } from '@dxos/client-protocol';
7
7
  import { log, logInfo } from '@dxos/log';
8
8
 
@@ -13,12 +13,12 @@ import {
13
13
  log,
14
14
  } from '@dxos/log';
15
15
  import {
16
+ type ControlMetricsRequest,
17
+ type ControlMetricsResponse,
16
18
  type LogEntry,
17
19
  type LoggingService,
18
20
  type Metrics,
19
21
  QueryLogsRequest,
20
- type ControlMetricsRequest,
21
- type ControlMetricsResponse,
22
22
  type QueryMetricsRequest,
23
23
  type QueryMetricsResponse,
24
24
  } from '@dxos/protocols/proto/dxos/client/services';
@@ -37,7 +37,7 @@ export class LoggingServiceImpl implements LoggingService {
37
37
  }
38
38
 
39
39
  async close(): Promise<void> {
40
- const index = log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
40
+ const index = log.runtimeConfig.processors.findIndex((processor: LogProcessor) => processor === this._logProcessor);
41
41
  log.runtimeConfig.processors.splice(index, 1);
42
42
  }
43
43
 
@@ -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 { log, LogLevel } from '@dxos/log';
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,16 +2,17 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
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, ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
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';
14
13
 
14
+ import { NetworkServiceImpl } from './network-service';
15
+
15
16
  describe('NetworkService', () => {
16
17
  let serviceContext: ServiceContext;
17
18
  let networkService: NetworkService;
@@ -7,15 +7,15 @@ import { type EdgeConnection } from '@dxos/edge-client';
7
7
  import { type SignalManager } from '@dxos/messaging';
8
8
  import { type SwarmNetworkManager } from '@dxos/network-manager';
9
9
  import {
10
- type SubscribeSwarmStateRequest,
11
10
  type NetworkService,
12
11
  type NetworkStatus,
12
+ type SubscribeSwarmStateRequest,
13
13
  type UpdateConfigRequest,
14
14
  } from '@dxos/protocols/proto/dxos/client/services';
15
15
  import { type Peer, type SwarmResponse } from '@dxos/protocols/proto/dxos/edge/messenger';
16
16
  import {
17
- type LeaveRequest,
18
17
  type JoinRequest,
18
+ type LeaveRequest,
19
19
  type Message,
20
20
  type QueryRequest,
21
21
  } from '@dxos/protocols/proto/dxos/edge/signal';
@@ -5,7 +5,7 @@
5
5
  import { type ClientServices } from '@dxos/client-protocol';
6
6
  import { type Any, type ServiceHandler, Stream } from '@dxos/codec-protobuf';
7
7
  import { raise } from '@dxos/debug';
8
- import { parseMethodName, RpcPeer, type RpcPeerOptions, type ServiceBundle } from '@dxos/rpc';
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
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
- import { MemorySignalManagerContext, MemorySignalManager } from '@dxos/messaging';
7
+ import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
8
8
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
9
9
  import { openAndClose } from '@dxos/test-utils';
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { Mutex, Trigger } from '@dxos/async';
6
6
  import { Context, Resource } from '@dxos/context';
7
- import { getCredentialAssertion, type CredentialProcessor } from '@dxos/credentials';
7
+ import { type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
8
8
  import { failUndefined, warnAfterTimeout } from '@dxos/debug';
9
9
  import {
10
10
  EchoEdgeReplicator,
@@ -15,7 +15,7 @@ import {
15
15
  valueEncoding,
16
16
  } from '@dxos/echo-pipeline';
17
17
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from '@dxos/edge-client';
18
- import type { EdgeHttpClient, EdgeConnection, EdgeIdentity } from '@dxos/edge-client';
18
+ import type { EdgeConnection, EdgeHttpClient, EdgeIdentity } from '@dxos/edge-client';
19
19
  import { FeedFactory, FeedStore } from '@dxos/feed-store';
20
20
  import { invariant } from '@dxos/invariant';
21
21
  import { Keyring } from '@dxos/keyring';
@@ -36,8 +36,8 @@ import { safeInstanceof } from '@dxos/util';
36
36
 
37
37
  import { EdgeAgentManager } from '../agents';
38
38
  import {
39
- IdentityManager,
40
39
  type CreateIdentityOptions,
40
+ IdentityManager,
41
41
  type IdentityManagerParams,
42
42
  type JoinIdentityParams,
43
43
  } from '../identity';
@@ -45,10 +45,10 @@ import { EdgeIdentityRecoveryManager } from '../identity/identity-recovery-manag
45
45
  import {
46
46
  DeviceInvitationProtocol,
47
47
  type InvitationConnectionParams,
48
+ type InvitationProtocol,
48
49
  InvitationsHandler,
49
50
  InvitationsManager,
50
51
  SpaceInvitationProtocol,
51
- type InvitationProtocol,
52
52
  } from '../invitations';
53
53
  import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
54
54
 
@@ -189,9 +189,10 @@ export class ServiceContext extends Resource {
189
189
  if (!this._runtimeParams?.disableP2pReplication) {
190
190
  this._meshReplicator = new MeshEchoReplicator();
191
191
  }
192
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
192
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
193
193
  this._echoEdgeReplicator = new EchoEdgeReplicator({
194
194
  edgeConnection: this._edgeConnection,
195
+ edgeHttpClient: this._edgeHttpClient,
195
196
  });
196
197
  }
197
198
  }
@@ -244,13 +245,13 @@ export class ServiceContext extends Resource {
244
245
  await this.edgeAgentManager?.close();
245
246
  await this.identityManager.close();
246
247
  await this.spaceManager.close();
247
- await this.feedStore.close();
248
- await this.metadataStore.close();
249
-
250
248
  await this.echoHost.close(ctx);
249
+
251
250
  await this.networkManager.close();
252
251
  await this.signalManager.close();
253
252
  await this._edgeConnection?.close();
253
+ await this.feedStore.close();
254
+ await this.metadataStore.close();
254
255
 
255
256
  log('closed');
256
257
  }
@@ -3,9 +3,10 @@
3
3
  //
4
4
 
5
5
  import { rmSync } from 'node:fs';
6
- import { afterEach, onTestFinished, describe, expect, test } from 'vitest';
7
6
 
8
- import { asyncTimeout, latch, Trigger } from '@dxos/async';
7
+ import { afterEach, describe, expect, onTestFinished, test } from 'vitest';
8
+
9
+ import { Trigger, asyncTimeout, latch } from '@dxos/async';
9
10
  import { Config } from '@dxos/config';
10
11
  import { Context } from '@dxos/context';
11
12
  import { verifyPresentation } from '@dxos/credentials';
@@ -3,20 +3,20 @@
3
3
  //
4
4
 
5
5
  import { Event, synchronized } from '@dxos/async';
6
- import { clientServiceBundle, type ClientServices } from '@dxos/client-protocol';
6
+ import { type ClientServices, clientServiceBundle } from '@dxos/client-protocol';
7
7
  import { type Config } from '@dxos/config';
8
8
  import { Context } from '@dxos/context';
9
- import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity, type EdgeConnection } from '@dxos/edge-client';
9
+ import { EdgeClient, type EdgeConnection, EdgeHttpClient, createStubEdgeIdentity } from '@dxos/edge-client';
10
10
  import { invariant } from '@dxos/invariant';
11
11
  import { PublicKey } from '@dxos/keys';
12
12
  import { type LevelDB } from '@dxos/kv-store';
13
13
  import { log } from '@dxos/log';
14
- import { EdgeSignalManager, WebsocketSignalManager, type SignalManager } from '@dxos/messaging';
14
+ import { EdgeSignalManager, type SignalManager, WebsocketSignalManager } from '@dxos/messaging';
15
15
  import {
16
16
  SwarmNetworkManager,
17
+ type TransportFactory,
17
18
  createIceProvider,
18
19
  createRtcTransportFactory,
19
- type TransportFactory,
20
20
  } from '@dxos/network-manager';
21
21
  import { trace } from '@dxos/protocols';
22
22
  import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
@@ -24,17 +24,15 @@ import { type Storage } from '@dxos/random-access-storage';
24
24
  import { TRACE_PROCESSOR, trace as Trace } from '@dxos/tracing';
25
25
  import { WebsocketRpcClient } from '@dxos/websocket-rpc';
26
26
 
27
- import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
28
- import { ServiceRegistry } from './service-registry';
29
27
  import { EdgeAgentServiceImpl } from '../agents';
30
28
  import { DevicesServiceImpl } from '../devices';
31
29
  import { DevtoolsHostEvents, DevtoolsServiceImpl } from '../devtools';
32
30
  import {
31
+ type CollectDiagnosticsBroadcastHandler,
33
32
  createCollectDiagnosticsBroadcastHandler,
34
33
  createDiagnostics,
35
- type CollectDiagnosticsBroadcastHandler,
36
34
  } from '../diagnostics';
37
- import { IdentityServiceImpl, type CreateIdentityOptions } from '../identity';
35
+ import { type CreateIdentityOptions, IdentityServiceImpl } from '../identity';
38
36
  import { ContactsServiceImpl } from '../identity/contacts-service';
39
37
  import { InvitationsServiceImpl } from '../invitations';
40
38
  import { Lock, type ResourceLock } from '../locks';
@@ -44,6 +42,9 @@ import { SpacesServiceImpl } from '../spaces';
44
42
  import { createLevel, createStorageObjects } from '../storage';
45
43
  import { SystemServiceImpl } from '../system';
46
44
 
45
+ import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
46
+ import { ServiceRegistry } from './service-registry';
47
+
47
48
  export type ClientServicesHostParams = {
48
49
  /**
49
50
  * Can be omitted if `initialize` is later called.
@@ -216,8 +217,9 @@ export class ClientServicesHost {
216
217
  }
217
218
  }
218
219
 
220
+ // TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
219
221
  if (!options.signalManager) {
220
- log.warn('running signaling without telemetry metadata.');
222
+ // log.warn('running signaling without telemetry metadata.');
221
223
  }
222
224
 
223
225
  const endpoint = config?.get('runtime.services.edge.url');
@@ -406,6 +408,12 @@ export class ClientServicesHost {
406
408
  this._resetting = true;
407
409
  this._statusUpdate.emit();
408
410
  await this._serviceContext?.close();
411
+ // Clear LevelDB contents to remove all persisted Echo/Automerge/index data.
412
+ try {
413
+ await this._level!.clear();
414
+ } catch (err) {
415
+ log.warn('failed to clear leveldb during reset', { err });
416
+ }
409
417
  await this._storage!.reset();
410
418
  log.info('reset');
411
419
  log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));