@dxos/client-services 0.8.4-main.84f28bd → 0.8.4-main.937b3ca

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 (201) hide show
  1. package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
  2. package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
  4. package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-OCFDRCSN.mjs → chunk-UDCUM4WV.mjs} +3626 -3714
  6. package/dist/lib/browser/chunk-UDCUM4WV.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +462 -76
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
  11. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
  12. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
  13. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
  14. package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
  15. package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
  16. package/dist/lib/browser/packlets/locks/node.mjs +66 -0
  17. package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
  18. package/dist/lib/browser/testing/index.mjs +34 -22
  19. package/dist/lib/browser/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
  21. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
  22. package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
  23. package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-D7F3FYZS.mjs → chunk-Q56HAUWS.mjs} +2636 -2592
  25. package/dist/lib/node-esm/chunk-Q56HAUWS.mjs.map +7 -0
  26. package/dist/lib/node-esm/index.mjs +462 -76
  27. package/dist/lib/node-esm/index.mjs.map +4 -4
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
  30. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
  31. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
  32. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
  33. package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
  34. package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
  35. package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
  36. package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
  37. package/dist/lib/node-esm/testing/index.mjs +34 -22
  38. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  39. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  40. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  41. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  42. package/dist/types/src/packlets/devtools/devtools.d.ts +20 -20
  43. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  44. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  45. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  46. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  47. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  48. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +1 -1
  49. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
  50. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +1 -1
  51. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  52. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -1
  53. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  54. package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
  55. package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
  56. package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
  57. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  58. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  59. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  60. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +3 -3
  61. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  62. package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -5
  63. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  64. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
  65. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  66. package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
  67. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  68. package/dist/types/src/packlets/identity/identity.d.ts +3 -3
  69. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  70. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
  71. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  72. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -1
  73. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  74. package/dist/types/src/packlets/invitations/index.d.ts +1 -1
  75. package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
  76. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  77. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  78. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +3 -4
  79. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  80. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
  81. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  82. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  83. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  84. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  85. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +3 -3
  86. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  87. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  88. package/dist/types/src/packlets/locks/index.d.ts +2 -2
  89. package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
  90. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  91. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  92. package/dist/types/src/packlets/network/network-service.d.ts +2 -2
  93. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  94. package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
  95. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  96. package/dist/types/src/packlets/services/service-context.d.ts +14 -8
  97. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  98. package/dist/types/src/packlets/services/service-host.d.ts +20 -6
  99. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  100. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +1 -1
  101. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  102. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +1 -1
  103. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  104. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +12 -7
  105. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  106. package/dist/types/src/packlets/spaces/data-space.d.ts +6 -6
  107. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  108. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
  109. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  110. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
  111. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  112. package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
  113. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  114. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
  115. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  116. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  117. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  118. package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
  119. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  120. package/dist/types/src/packlets/testing/test-builder.d.ts +8 -7
  121. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  122. package/dist/types/src/packlets/worker/worker-runtime.d.ts +23 -4
  123. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  124. package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
  125. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  126. package/dist/types/src/version.d.ts +1 -1
  127. package/dist/types/tsconfig.tsbuildinfo +1 -1
  128. package/package.json +72 -48
  129. package/src/packlets/agents/edge-agent-manager.ts +2 -2
  130. package/src/packlets/agents/edge-agent-service.ts +13 -3
  131. package/src/packlets/devices/devices-service.test.ts +4 -3
  132. package/src/packlets/devices/devices-service.ts +2 -2
  133. package/src/packlets/devtools/devtools.ts +30 -29
  134. package/src/packlets/devtools/feeds.ts +2 -2
  135. package/src/packlets/devtools/network.ts +1 -1
  136. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
  137. package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
  138. package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
  139. package/src/packlets/diagnostics/diagnostics.ts +1 -1
  140. package/src/packlets/diagnostics/index.ts +1 -1
  141. package/src/packlets/identity/authenticator.node.test.ts +1 -1
  142. package/src/packlets/identity/authenticator.ts +3 -3
  143. package/src/packlets/identity/contacts-service.ts +3 -2
  144. package/src/packlets/identity/default-space-state-machine.ts +3 -3
  145. package/src/packlets/identity/identity-manager.test.ts +3 -3
  146. package/src/packlets/identity/identity-manager.ts +9 -9
  147. package/src/packlets/identity/identity-recovery-manager.ts +2 -2
  148. package/src/packlets/identity/identity-service.test.ts +3 -2
  149. package/src/packlets/identity/identity-service.ts +2 -1
  150. package/src/packlets/identity/identity.test.ts +9 -9
  151. package/src/packlets/identity/identity.ts +9 -8
  152. package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
  153. package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
  154. package/src/packlets/invitations/edge-invitation-handler.ts +1 -1
  155. package/src/packlets/invitations/index.ts +1 -1
  156. package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
  157. package/src/packlets/invitations/invitation-host-extension.ts +8 -6
  158. package/src/packlets/invitations/invitation-protocol.ts +3 -4
  159. package/src/packlets/invitations/invitations-handler.test.ts +302 -292
  160. package/src/packlets/invitations/invitations-handler.ts +10 -10
  161. package/src/packlets/invitations/invitations-manager.ts +3 -3
  162. package/src/packlets/invitations/invitations-service.ts +1 -1
  163. package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
  164. package/src/packlets/invitations/space-invitation-protocol.ts +10 -15
  165. package/src/packlets/invitations/utils.ts +1 -1
  166. package/src/packlets/locks/browser.ts +1 -1
  167. package/src/packlets/locks/index.ts +2 -2
  168. package/src/packlets/logging/logging-service.ts +4 -3
  169. package/src/packlets/logging/logging.test.ts +1 -1
  170. package/src/packlets/network/network-service.test.ts +4 -3
  171. package/src/packlets/network/network-service.ts +2 -2
  172. package/src/packlets/services/client-rpc-server.ts +5 -5
  173. package/src/packlets/services/service-context.test.ts +1 -1
  174. package/src/packlets/services/service-context.ts +39 -27
  175. package/src/packlets/services/service-host.test.ts +3 -2
  176. package/src/packlets/services/service-host.ts +74 -25
  177. package/src/packlets/services/service-registry.test.ts +2 -1
  178. package/src/packlets/space-export/space-archive-reader.ts +2 -2
  179. package/src/packlets/space-export/space-archive-writer.ts +7 -5
  180. package/src/packlets/space-export/tar.test.ts +1 -1
  181. package/src/packlets/spaces/automerge-space-state.ts +1 -1
  182. package/src/packlets/spaces/data-space-manager.ts +76 -36
  183. package/src/packlets/spaces/data-space.ts +15 -13
  184. package/src/packlets/spaces/edge-feed-replicator.test.ts +3 -3
  185. package/src/packlets/spaces/edge-feed-replicator.ts +4 -4
  186. package/src/packlets/spaces/epoch-migrations.ts +2 -2
  187. package/src/packlets/spaces/notarization-plugin.test.ts +3 -3
  188. package/src/packlets/spaces/notarization-plugin.ts +11 -11
  189. package/src/packlets/spaces/spaces-service.test.ts +3 -2
  190. package/src/packlets/spaces/spaces-service.ts +27 -23
  191. package/src/packlets/storage/profile-archive.ts +1 -1
  192. package/src/packlets/storage/storage.ts +7 -8
  193. package/src/packlets/system/system-service.test.ts +1 -1
  194. package/src/packlets/system/system-service.ts +4 -4
  195. package/src/packlets/testing/invitation-utils.ts +8 -5
  196. package/src/packlets/testing/test-builder.ts +39 -13
  197. package/src/packlets/worker/worker-runtime.ts +143 -12
  198. package/src/packlets/worker/worker-session.ts +7 -7
  199. package/src/version.ts +1 -1
  200. package/dist/lib/browser/chunk-OCFDRCSN.mjs.map +0 -7
  201. package/dist/lib/node-esm/chunk-D7F3FYZS.mjs.map +0 -7
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { save } from '@automerge/automerge';
6
- import { type DocHandle } from '@automerge/automerge-repo';
6
+ import { type AutomergeUrl, type DocHandle } from '@automerge/automerge-repo';
7
7
 
8
8
  import { Event, Mutex, scheduleTask, sleep, synchronized, trackLeaks } from '@dxos/async';
9
9
  import { AUTH_TIMEOUT } from '@dxos/client-protocol';
@@ -11,14 +11,13 @@ import { Context, ContextDisposedError, cancelWithContext } from '@dxos/context'
11
11
  import type { SpecificCredential } from '@dxos/credentials';
12
12
  import { timed, warnAfterTimeout } from '@dxos/debug';
13
13
  import {
14
- type EchoHost,
15
14
  type DatabaseRoot,
16
- createMappedFeedWriter,
15
+ type EchoHost,
17
16
  type MetadataStore,
18
17
  type Space,
19
- FIND_PARAMS,
18
+ createMappedFeedWriter,
20
19
  } from '@dxos/echo-pipeline';
21
- import { SpaceDocVersion, type DatabaseDirectory } from '@dxos/echo-protocol';
20
+ import { type DatabaseDirectory, SpaceDocVersion } from '@dxos/echo-protocol';
22
21
  import type { EdgeConnection, EdgeHttpClient } from '@dxos/edge-client';
23
22
  import { type FeedStore, type FeedWrapper } from '@dxos/feed-store';
24
23
  import { failedInvariant, invariant } from '@dxos/invariant';
@@ -28,31 +27,32 @@ import { log } from '@dxos/log';
28
27
  import { CancelledError, SystemError } from '@dxos/protocols';
29
28
  import {
30
29
  type CreateEpochRequest,
31
- SpaceState,
32
30
  type Space as SpaceProto,
31
+ SpaceState,
33
32
  } from '@dxos/protocols/proto/dxos/client/services';
34
33
  import { type Runtime } from '@dxos/protocols/proto/dxos/config';
35
34
  import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
36
35
  import { type SpaceCache } from '@dxos/protocols/proto/dxos/echo/metadata';
37
36
  import {
38
37
  AdmittedFeed,
39
- SpaceMember,
40
38
  type Credential,
41
39
  type Epoch,
42
40
  type ProfileDocument,
41
+ SpaceMember,
43
42
  } from '@dxos/protocols/proto/dxos/halo/credentials';
44
43
  import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
45
44
  import { type Gossip, type Presence } from '@dxos/teleport-extension-gossip';
46
45
  import { Timeframe } from '@dxos/timeframe';
47
46
  import { trace } from '@dxos/tracing';
48
- import { CallbackCollection, ComplexSet, type AsyncCallback } from '@dxos/util';
47
+ import { type AsyncCallback, CallbackCollection, ComplexSet } from '@dxos/util';
48
+
49
+ import { TrustedKeySetAuthVerifier } from '../identity';
49
50
 
50
51
  import { AutomergeSpaceState } from './automerge-space-state';
51
52
  import { type SigningContext } from './data-space-manager';
52
53
  import { EdgeFeedReplicator } from './edge-feed-replicator';
53
54
  import { runEpochMigration } from './epoch-migrations';
54
55
  import { NotarizationPlugin } from './notarization-plugin';
55
- import { TrustedKeySetAuthVerifier } from '../identity';
56
56
 
57
57
  export type DataSpaceCallbacks = {
58
58
  /**
@@ -71,7 +71,7 @@ export type DataSpaceCallbacks = {
71
71
  beforeClose?: () => Promise<void>;
72
72
  };
73
73
 
74
- export type DataSpaceParams = {
74
+ export type DataSpaceProps = {
75
75
  initialState: SpaceState;
76
76
  inner: Space;
77
77
  metadataStore: MetadataStore;
@@ -135,7 +135,7 @@ export class DataSpace {
135
135
 
136
136
  public metrics: SpaceProto.Metrics = {};
137
137
 
138
- constructor(params: DataSpaceParams) {
138
+ constructor(params: DataSpaceProps) {
139
139
  this._inner = params.inner;
140
140
  this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
141
141
 
@@ -330,7 +330,7 @@ export class DataSpace {
330
330
  @trace.span({ showInBrowserTimeline: true })
331
331
  async initializeDataPipeline(): Promise<void> {
332
332
  if (this._state !== SpaceState.SPACE_CONTROL_ONLY) {
333
- throw new SystemError('Invalid operation');
333
+ throw new SystemError({ message: 'Invalid operation' });
334
334
  }
335
335
 
336
336
  this._state = SpaceState.SPACE_INITIALIZING;
@@ -470,7 +470,9 @@ export class DataSpace {
470
470
  await warnAfterTimeout(5_000, 'Automerge root doc load timeout (DataSpace)', async () => {
471
471
  handle = await cancelWithContext(
472
472
  this._ctx,
473
- this._echoHost.automergeRepo.find<DatabaseDirectory>(rootUrl as any, FIND_PARAMS),
473
+ this._echoHost.loadDoc<DatabaseDirectory>(Context.default(), rootUrl as AutomergeUrl, {
474
+ fetchFromNetwork: true,
475
+ }),
474
476
  );
475
477
  await cancelWithContext(this._ctx, handle.whenReady());
476
478
  });
@@ -6,10 +6,10 @@ import { decode as decodeCbor, encode as encodeCbor } from 'cbor-x';
6
6
  import { getPort } from 'get-port-please';
7
7
  import { describe, expect, onTestFinished, test, vi } from 'vitest';
8
8
 
9
- import { sleep, Trigger } from '@dxos/async';
9
+ import { Trigger, sleep } from '@dxos/async';
10
10
  import { Context } from '@dxos/context';
11
11
  import { valueEncoding } from '@dxos/echo-pipeline';
12
- import { createEphemeralEdgeIdentity, EdgeClient, EdgeIdentityChangedError } from '@dxos/edge-client';
12
+ import { EdgeClient, EdgeIdentityChangedError, createEphemeralEdgeIdentity } from '@dxos/edge-client';
13
13
  import { createTestEdgeWsServer } from '@dxos/edge-client/testing';
14
14
  import { FeedFactory, FeedStore, type FeedWrapper } from '@dxos/feed-store';
15
15
  import { Keyring } from '@dxos/keyring';
@@ -45,7 +45,7 @@ describe('EdgeFeedReplicator', () => {
45
45
  const { endpoint, admitConnection, messageSink } = await createEdge();
46
46
  const { messenger } = await createClient(endpoint);
47
47
  admitConnection.wake();
48
- await expect.poll(() => messenger.status).toBe(EdgeStatus.CONNECTED);
48
+ await expect.poll(() => messenger.status.state).toBe(EdgeStatus.ConnectionState.CONNECTED);
49
49
 
50
50
  await attachReplicator(messenger);
51
51
  await expect.poll(() => messageSink.length).toEqual(1);
@@ -15,14 +15,14 @@ import { log, logInfo } from '@dxos/log';
15
15
  import { EdgeService } from '@dxos/protocols';
16
16
  import { buf } from '@dxos/protocols/buf';
17
17
  import {
18
- MessageSchema as RouterMessageSchema,
19
18
  type Message as RouterMessage,
19
+ MessageSchema as RouterMessageSchema,
20
20
  } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
21
21
  import type { FeedBlock, ProtocolMessage } from '@dxos/protocols/feed-replication';
22
22
  import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
23
23
  import { ComplexMap, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from '@dxos/util';
24
24
 
25
- export type EdgeFeedReplicatorParams = {
25
+ export type EdgeFeedReplicatorProps = {
26
26
  messenger: EdgeConnection;
27
27
  spaceId: SpaceId;
28
28
  };
@@ -47,7 +47,7 @@ export class EdgeFeedReplicator extends Resource {
47
47
  */
48
48
  private _pushMutex = new ComplexMap<PublicKey, Mutex>(PublicKey.hash);
49
49
 
50
- constructor({ messenger, spaceId }: EdgeFeedReplicatorParams) {
50
+ constructor({ messenger, spaceId }: EdgeFeedReplicatorProps) {
51
51
  super();
52
52
  this._messenger = messenger;
53
53
  this._spaceId = spaceId;
@@ -87,7 +87,7 @@ export class EdgeFeedReplicator extends Resource {
87
87
 
88
88
  private async _handleReconnect(): Promise<void> {
89
89
  await this._resetConnection();
90
- if (this._messenger.status === EdgeStatus.CONNECTED) {
90
+ if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
91
91
  this._startReplication();
92
92
  }
93
93
  }
@@ -36,7 +36,7 @@ const LOAD_DOC_TIMEOUT = 10_000;
36
36
  export const runEpochMigration = async (ctx: Context, context: MigrationContext): Promise<MigrationResult> => {
37
37
  switch (context.migration) {
38
38
  case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
39
- const document = context.echoHost.createDoc();
39
+ const document = await context.echoHost.createDoc();
40
40
  await context.echoHost.flush();
41
41
  return { newRoot: document.url };
42
42
  }
@@ -48,7 +48,7 @@ export const runEpochMigration = async (ctx: Context, context: MigrationContext)
48
48
  timeout: LOAD_DOC_TIMEOUT,
49
49
  });
50
50
 
51
- const newRoot = context.echoHost.createDoc(rootHandle.doc());
51
+ const newRoot = await context.echoHost.createDoc(rootHandle.doc());
52
52
  await context.echoHost.flush();
53
53
  return { newRoot: newRoot.url };
54
54
  }
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 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
7
  import { Context } from '@dxos/context';
8
8
  import { CredentialGenerator } from '@dxos/credentials';
@@ -13,7 +13,7 @@ import { log } from '@dxos/log';
13
13
  import { AdmittedFeed, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
14
14
  import { TestBuilder, type TestConnection, TestPeer } from '@dxos/teleport/testing';
15
15
 
16
- import { NotarizationPlugin, type NotarizationPluginParams } from './notarization-plugin';
16
+ import { NotarizationPlugin, type NotarizationPluginProps } from './notarization-plugin';
17
17
 
18
18
  class TestAgent extends TestPeer {
19
19
  private readonly _ctx = new Context();
@@ -21,7 +21,7 @@ class TestAgent extends TestPeer {
21
21
  feed = new MockFeedWriter<Credential>();
22
22
  notarizationPlugin: NotarizationPlugin;
23
23
 
24
- constructor(params: NotarizationPluginParams) {
24
+ constructor(params: NotarizationPluginProps) {
25
25
  super();
26
26
  this.notarizationPlugin = new NotarizationPlugin(params);
27
27
  this.feed.written.on(this._ctx, async ([credential]) => {
@@ -2,15 +2,15 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { DeferredTask, Event, scheduleTask, sleep, TimeoutError, Trigger, scheduleMicroTask } from '@dxos/async';
6
- import { type Context, rejectOnDispose, Resource } from '@dxos/context';
5
+ import { DeferredTask, Event, TimeoutError, Trigger, scheduleMicroTask, scheduleTask, sleep } from '@dxos/async';
6
+ import { type Context, Resource, rejectOnDispose } from '@dxos/context';
7
7
  import { type CredentialProcessor, verifyCredential } from '@dxos/credentials';
8
8
  import { type EdgeHttpClient } from '@dxos/edge-client';
9
9
  import { type FeedWriter } from '@dxos/feed-store';
10
10
  import { invariant } from '@dxos/invariant';
11
11
  import { PublicKey } from '@dxos/keys';
12
12
  import { type SpaceId } from '@dxos/keys';
13
- import { logInfo, log } from '@dxos/log';
13
+ import { log, logInfo } from '@dxos/log';
14
14
  import { EdgeCallFailedError } from '@dxos/protocols';
15
15
  import { schema } from '@dxos/protocols/proto';
16
16
  import { type Runtime } from '@dxos/protocols/proto/dxos/config';
@@ -33,14 +33,14 @@ const WRITER_NOT_SET_ERROR_CODE = 'WRITER_NOT_SET';
33
33
 
34
34
  const credentialCodec = schema.getCodecForType('dxos.halo.credentials.Credential');
35
35
 
36
- export type NotarizationPluginParams = {
36
+ export type NotarizationPluginProps = {
37
37
  spaceId: SpaceId;
38
38
  edgeClient?: EdgeHttpClient;
39
39
  edgeFeatures?: Runtime.Client.EdgeFeatures;
40
40
  activeEdgePollingInterval?: number;
41
41
  };
42
42
 
43
- export type NotarizeParams = {
43
+ export type NotarizeProps = {
44
44
  /**
45
45
  * For cancellation.
46
46
  */
@@ -97,7 +97,7 @@ export class NotarizationPlugin extends Resource implements CredentialProcessor
97
97
 
98
98
  private readonly _edgeClient: EdgeHttpClient | undefined;
99
99
 
100
- constructor(params: NotarizationPluginParams) {
100
+ constructor(params: NotarizationPluginProps) {
101
101
  super();
102
102
  this._spaceId = params.spaceId;
103
103
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
@@ -149,7 +149,7 @@ export class NotarizationPlugin extends Resource implements CredentialProcessor
149
149
  retryTimeout = DEFAULT_RETRY_TIMEOUT,
150
150
  successDelay = DEFAULT_SUCCESS_DELAY,
151
151
  edgeRetryJitter,
152
- }: NotarizeParams): Promise<void> {
152
+ }: NotarizeProps): Promise<void> {
153
153
  log('notarize', { credentials });
154
154
  invariant(
155
155
  credentials.every((credential) => credential.id),
@@ -392,21 +392,21 @@ export class NotarizationPlugin extends Resource implements CredentialProcessor
392
392
  }
393
393
 
394
394
  const handleEdgeError = (error: any) => {
395
- if (!(error instanceof EdgeCallFailedError) || error.errorData) {
395
+ if (!(error instanceof EdgeCallFailedError) || error.data) {
396
396
  log.catch(error);
397
397
  } else {
398
- log.info('Edge notarization failure', { reason: error.reason });
398
+ log.info('Edge notarization failure', { message: error.message });
399
399
  }
400
400
  };
401
401
 
402
- export type NotarizationTeleportExtensionParams = {
402
+ export type NotarizationTeleportExtensionProps = {
403
403
  onOpen: () => Promise<void>;
404
404
  onClose: () => Promise<void>;
405
405
  onNotarize: (request: NotarizeRequest) => Promise<void>;
406
406
  };
407
407
 
408
408
  export class NotarizationTeleportExtension extends RpcExtension<Services, Services> {
409
- constructor(private readonly _params: NotarizationTeleportExtensionParams) {
409
+ constructor(private readonly _params: NotarizationTeleportExtensionProps) {
410
410
  super({
411
411
  requested: {
412
412
  NotarizationService: schema.getService('dxos.mesh.teleport.notarization.NotarizationService'),
@@ -2,17 +2,18 @@
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
9
  import { PublicKey } from '@dxos/keys';
10
10
  import { type Space, type SpacesService } from '@dxos/protocols/proto/dxos/client/services';
11
11
 
12
- import { SpacesServiceImpl } from './spaces-service';
13
12
  import { type ServiceContext } from '../services';
14
13
  import { createServiceContext } from '../testing';
15
14
 
15
+ import { SpacesServiceImpl } from './spaces-service';
16
+
16
17
  describe('SpacesService', () => {
17
18
  let serviceContext: ServiceContext;
18
19
  let spacesService: SpacesService;
@@ -19,44 +19,45 @@ import { assertArgument, assertState, invariant } from '@dxos/invariant';
19
19
  import { SpaceId } from '@dxos/keys';
20
20
  import { log } from '@dxos/log';
21
21
  import {
22
- encodeError,
23
22
  ApiError,
24
23
  AuthorizationError,
25
24
  IdentityNotInitializedError,
26
25
  SpaceNotFoundError,
26
+ encodeError,
27
27
  } from '@dxos/protocols';
28
28
  import {
29
- SpaceMember,
30
- SpaceState,
29
+ type AdmitContactRequest,
30
+ type ContactAdmission,
31
31
  type CreateEpochRequest,
32
+ type CreateEpochResponse,
33
+ type ExportSpaceRequest,
34
+ type ExportSpaceResponse,
35
+ type ImportSpaceRequest,
36
+ type ImportSpaceResponse,
37
+ type JoinBySpaceKeyRequest,
38
+ type JoinSpaceResponse,
32
39
  type PostMessageRequest,
33
40
  type QueryCredentialsRequest,
34
41
  type QuerySpacesResponse,
35
42
  type Space,
43
+ SpaceMember,
44
+ SpaceState,
36
45
  type SpacesService,
37
46
  type SubscribeMessagesRequest,
47
+ type UpdateMemberRoleRequest,
38
48
  type UpdateSpaceRequest,
39
49
  type WriteCredentialsRequest,
40
- type UpdateMemberRoleRequest,
41
- type AdmitContactRequest,
42
- type ContactAdmission,
43
- type JoinSpaceResponse,
44
- type JoinBySpaceKeyRequest,
45
- type CreateEpochResponse,
46
- type ExportSpaceResponse,
47
- type ExportSpaceRequest,
48
- type ImportSpaceRequest,
49
- type ImportSpaceResponse,
50
50
  } from '@dxos/protocols/proto/dxos/client/services';
51
51
  import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
52
52
  import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
53
53
  import { trace } from '@dxos/tracing';
54
54
  import { type Provider } from '@dxos/util';
55
55
 
56
+ import { type IdentityManager } from '../identity';
57
+ import { SpaceArchiveWriter, extractSpaceArchive } from '../space-export';
58
+
56
59
  import { type DataSpace } from './data-space';
57
60
  import { type DataSpaceManager } from './data-space-manager';
58
- import { type IdentityManager } from '../identity';
59
- import { extractSpaceArchive, SpaceArchiveWriter } from '../space-export';
60
61
 
61
62
  export class SpacesServiceImpl implements SpacesService {
62
63
  constructor(
@@ -87,7 +88,7 @@ export class SpacesServiceImpl implements SpacesService {
87
88
  await space.deactivate();
88
89
  break;
89
90
  default:
90
- throw new ApiError('Invalid space state');
91
+ throw new ApiError({ message: 'Invalid space state' });
91
92
  }
92
93
  }
93
94
 
@@ -103,9 +104,12 @@ export class SpacesServiceImpl implements SpacesService {
103
104
  throw new SpaceNotFoundError(request.spaceKey);
104
105
  }
105
106
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
106
- throw new AuthorizationError('No member management permission.', {
107
- spaceKey: space.key,
108
- role: space.spaceState.getMemberRole(identity.identityKey),
107
+ throw new AuthorizationError({
108
+ message: 'No member management permission.',
109
+ context: {
110
+ spaceKey: space.key,
111
+ role: space.spaceState.getMemberRole(identity.identityKey),
112
+ },
109
113
  });
110
114
  }
111
115
  const credentials = await createAdmissionCredentials(
@@ -266,7 +270,7 @@ export class SpacesServiceImpl implements SpacesService {
266
270
 
267
271
  async exportSpace(request: ExportSpaceRequest): Promise<ExportSpaceResponse> {
268
272
  await using writer = await new SpaceArchiveWriter().open();
269
- assertArgument(SpaceId.isValid(request.spaceId), 'Invalid space ID');
273
+ assertArgument(SpaceId.isValid(request.spaceId), 'spaceId', 'Invalid space ID');
270
274
 
271
275
  const dataSpaceManager = await this._getDataSpaceManager();
272
276
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error('Space not found'));
@@ -367,9 +371,9 @@ export class SpacesServiceImpl implements SpacesService {
367
371
 
368
372
  private _requireIdentity() {
369
373
  if (!this._identityManager.identity) {
370
- throw new IdentityNotInitializedError(
371
- 'This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo',
372
- );
374
+ throw new IdentityNotInitializedError({
375
+ message: 'This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo',
376
+ });
373
377
  }
374
378
  return this._identityManager.identity;
375
379
  }
@@ -7,7 +7,7 @@ import { cbor } from '@automerge/automerge-repo';
7
7
  import { invariant } from '@dxos/invariant';
8
8
  import type { LevelDB } from '@dxos/kv-store';
9
9
  import { log } from '@dxos/log';
10
- import { ProfileArchiveEntryType, type ProfileArchive } from '@dxos/protocols';
10
+ import { type ProfileArchive, ProfileArchiveEntryType } from '@dxos/protocols';
11
11
  import type { Storage } from '@dxos/random-access-storage';
12
12
  import { arrayToBuffer } from '@dxos/util';
13
13
 
@@ -1,30 +1,29 @@
1
- //
2
-
3
1
  //
4
2
  // Copyright 2023 DXOS.org
5
3
  //
6
4
 
7
5
  import { InvalidConfigError } from '@dxos/protocols';
8
6
  import { Runtime } from '@dxos/protocols/proto/dxos/config';
9
- import { createStorage, StorageType } from '@dxos/random-access-storage';
7
+ import { StorageType, createStorage } from '@dxos/random-access-storage';
10
8
 
11
- import StorageDriver = Runtime.Client.Storage.StorageDriver;
12
9
  import { getRootPath } from './util';
13
10
 
11
+ import StorageDriver = Runtime.Client.Storage.StorageDriver;
12
+
14
13
  // TODO(burdon): Factor out.
15
14
  export const createStorageObjects = (config: Runtime.Client.Storage) => {
16
15
  const { persistent = false, keyStore, dataStore } = config ?? {};
17
16
  if (persistent && dataStore === StorageDriver.RAM) {
18
- throw new InvalidConfigError('RAM storage cannot be used in persistent mode.');
17
+ throw new InvalidConfigError({ message: 'RAM storage cannot be used in persistent mode.' });
19
18
  }
20
19
  if (!persistent && dataStore !== undefined && dataStore !== StorageDriver.RAM) {
21
- throw new InvalidConfigError('Cannot use a persistent storage in not persistent mode.');
20
+ throw new InvalidConfigError({ message: 'Cannot use a persistent storage in not persistent mode.' });
22
21
  }
23
22
  if (persistent && keyStore === StorageDriver.RAM) {
24
- throw new InvalidConfigError('RAM key storage cannot be used in persistent mode.');
23
+ throw new InvalidConfigError({ message: 'RAM key storage cannot be used in persistent mode.' });
25
24
  }
26
25
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== undefined) {
27
- throw new InvalidConfigError('Cannot use a persistent key storage in not persistent mode.');
26
+ throw new InvalidConfigError({ message: 'Cannot use a persistent key storage in not persistent mode.' });
28
27
  }
29
28
 
30
29
  return {
@@ -6,7 +6,7 @@ import { beforeEach, describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Event, Trigger } from '@dxos/async';
8
8
  import { Config } from '@dxos/config';
9
- import { type SystemService, SystemStatus, type QueryStatusResponse } from '@dxos/protocols/proto/dxos/client/services';
9
+ import { type QueryStatusResponse, type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
10
10
 
11
11
  import { SystemServiceImpl } from './system-service';
12
12
 
@@ -7,14 +7,14 @@ import { Stream } from '@dxos/codec-protobuf/stream';
7
7
  import { type Config } from '@dxos/config';
8
8
  import {
9
9
  GetDiagnosticsRequest,
10
+ type Platform,
11
+ type QueryStatusRequest,
12
+ type QueryStatusResponse,
10
13
  type SystemService,
11
14
  type SystemStatus,
12
15
  type UpdateStatusRequest,
13
- type QueryStatusRequest,
14
- type QueryStatusResponse,
15
- type Platform,
16
16
  } from '@dxos/protocols/proto/dxos/client/services';
17
- import { jsonKeyReplacer, type MaybePromise } from '@dxos/util';
17
+ import { type MaybePromise, jsonKeyReplacer } from '@dxos/util';
18
18
 
19
19
  import { type Diagnostics } from '../diagnostics';
20
20
  import { getPlatform } from '../services/platform';
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Trigger } from '@dxos/async';
6
- import { InvitationEncoder, type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';
6
+ import { type AuthenticatingInvitation, type CancellableInvitation, InvitationEncoder } from '@dxos/client-protocol';
7
7
  import { invariant } from '@dxos/invariant';
8
8
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
9
9
  import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
@@ -36,15 +36,15 @@ export type PerformInvitationCallbacks<T> = {
36
36
  onError?: (value: T) => boolean | void;
37
37
  };
38
38
 
39
- export type PerformInvitationParams = {
39
+ export type PerformInvitationProps = {
40
40
  host: ServiceContext | InvitationHost;
41
41
  guest: ServiceContext | InvitationGuest;
42
+ guestDeviceProfile?: DeviceProfileDocument;
42
43
  options?: Partial<Invitation>;
43
44
  hooks?: {
44
45
  host?: PerformInvitationCallbacks<CancellableInvitation>;
45
46
  guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;
46
47
  };
47
- guestDeviceProfile?: DeviceProfileDocument;
48
48
  codeInputDelay?: number;
49
49
  };
50
50
 
@@ -52,14 +52,17 @@ export type Result = { invitation?: Invitation; error?: Error };
52
52
 
53
53
  // TODO(burdon): Make async.
54
54
  // TODO(burdon): Rename startInvitation.
55
+ /**
56
+ *
57
+ */
55
58
  export const performInvitation = ({
56
59
  host,
57
60
  guest,
61
+ guestDeviceProfile,
58
62
  options,
59
63
  hooks,
60
- guestDeviceProfile,
61
64
  codeInputDelay,
62
- }: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {
65
+ }: PerformInvitationProps): [Promise<Result>, Promise<Result>] => {
63
66
  let guestError = false;
64
67
  let guestConnected = false;
65
68
  let wereConnected = false;