@dxos/client-services 0.1.52 → 0.1.53-main.01cbc6b

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 (64) hide show
  1. package/dist/lib/browser/{chunk-C3SPTMW3.mjs → chunk-EYXOVYW5.mjs} +817 -694
  2. package/dist/lib/browser/chunk-EYXOVYW5.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +101 -120
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +24 -7
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +884 -782
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +801 -664
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  16. package/dist/types/src/packlets/services/service-host.d.ts +7 -1
  17. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
  20. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
  22. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
  24. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
  26. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  27. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
  28. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  29. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
  30. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  31. package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
  32. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  33. package/package.json +33 -32
  34. package/src/packlets/devtools/devtools.ts +2 -2
  35. package/src/packlets/identity/identity-manager.test.ts +1 -1
  36. package/src/packlets/identity/identity-manager.ts +8 -8
  37. package/src/packlets/identity/identity-service.ts +2 -2
  38. package/src/packlets/identity/identity.test.ts +1 -1
  39. package/src/packlets/identity/identity.ts +22 -27
  40. package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
  41. package/src/packlets/invitations/invitation-extension.ts +5 -5
  42. package/src/packlets/invitations/invitations-handler.ts +6 -6
  43. package/src/packlets/invitations/invitations-service.ts +3 -3
  44. package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
  45. package/src/packlets/locks/node.ts +2 -2
  46. package/src/packlets/logging/logging-service.ts +4 -4
  47. package/src/packlets/services/service-context.test.ts +1 -1
  48. package/src/packlets/services/service-context.ts +12 -10
  49. package/src/packlets/services/service-host.test.ts +50 -2
  50. package/src/packlets/services/service-host.ts +28 -10
  51. package/src/packlets/spaces/data-space-manager.test.ts +72 -118
  52. package/src/packlets/spaces/data-space-manager.ts +18 -9
  53. package/src/packlets/spaces/data-space.ts +66 -20
  54. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  55. package/src/packlets/spaces/notarization-plugin.ts +9 -5
  56. package/src/packlets/spaces/spaces-service.ts +46 -32
  57. package/src/packlets/testing/invitation-utils.ts +2 -2
  58. package/src/packlets/testing/test-builder.ts +36 -4
  59. package/src/packlets/vault/iframe-host-runtime.ts +2 -2
  60. package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
  61. package/src/packlets/vault/shell-runtime.ts +3 -49
  62. package/src/packlets/vault/worker-runtime.ts +1 -1
  63. package/src/packlets/vault/worker-session.ts +2 -2
  64. package/dist/lib/browser/chunk-C3SPTMW3.mjs.map +0 -7
@@ -61,12 +61,12 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
61
61
  });
62
62
 
63
63
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
64
- var import_node_assert14 = __toESM(require("node:assert"));
64
+ var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
65
65
  var import_async18 = require("@dxos/async");
66
66
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
67
67
 
68
68
  // packages/sdk/client-services/src/packlets/services/service-context.ts
69
- var import_node_assert11 = __toESM(require("node:assert"));
69
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
70
70
  var import_async11 = require("@dxos/async");
71
71
  var import_credentials14 = require("@dxos/credentials");
72
72
  var import_debug6 = require("@dxos/debug");
@@ -85,6 +85,7 @@ var import_context = require("@dxos/context");
85
85
  var import_credentials2 = require("@dxos/credentials");
86
86
  var import_log = require("@dxos/log");
87
87
  var import_protocols = require("@dxos/protocols");
88
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
88
89
  var createAuthProvider = (signer) => async (nonce) => {
89
90
  const credential = await signer.createCredential({
90
91
  assertion: {
@@ -110,20 +111,20 @@ var TrustedKeySetAuthVerifier = class {
110
111
  (0, import_log.log)("authenticating...", {
111
112
  credential
112
113
  }, {
113
- file: "authenticator.ts",
114
- line: 57,
115
- scope: this,
116
- callSite: (f, a) => f(...a)
114
+ F: __dxlog_file,
115
+ L: 57,
116
+ S: this,
117
+ C: (f, a) => f(...a)
117
118
  });
118
119
  const result = await (0, import_credentials2.verifyCredential)(credential);
119
120
  if (result.kind === "fail") {
120
121
  (0, import_log.log)("Invalid credential", {
121
122
  result
122
123
  }, {
123
- file: "authenticator.ts",
124
- line: 61,
125
- scope: this,
126
- callSite: (f, a) => f(...a)
124
+ F: __dxlog_file,
125
+ L: 61,
126
+ S: this,
127
+ C: (f, a) => f(...a)
127
128
  });
128
129
  return false;
129
130
  }
@@ -132,10 +133,10 @@ var TrustedKeySetAuthVerifier = class {
132
133
  nonce,
133
134
  credential
134
135
  }, {
135
- file: "authenticator.ts",
136
- line: 66,
137
- scope: this,
138
- callSite: (f, a) => f(...a)
136
+ F: __dxlog_file,
137
+ L: 66,
138
+ S: this,
139
+ C: (f, a) => f(...a)
139
140
  });
140
141
  return false;
141
142
  }
@@ -143,10 +144,10 @@ var TrustedKeySetAuthVerifier = class {
143
144
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
144
145
  key: credential.issuer
145
146
  }, {
146
- file: "authenticator.ts",
147
- line: 71,
148
- scope: this,
149
- callSite: (f, a) => f(...a)
147
+ F: __dxlog_file,
148
+ L: 71,
149
+ S: this,
150
+ C: (f, a) => f(...a)
150
151
  });
151
152
  return true;
152
153
  }
@@ -159,20 +160,20 @@ var TrustedKeySetAuthVerifier = class {
159
160
  (0, import_log.log)("auth success", {
160
161
  key: credential.issuer
161
162
  }, {
162
- file: "authenticator.ts",
163
- line: 82,
164
- scope: this,
165
- callSite: (f, a) => f(...a)
163
+ F: __dxlog_file,
164
+ L: 82,
165
+ S: this,
166
+ C: (f, a) => f(...a)
166
167
  });
167
168
  trigger.wake(true);
168
169
  } else {
169
170
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
170
171
  key: credential.issuer
171
172
  }, {
172
- file: "authenticator.ts",
173
- line: 85,
174
- scope: this,
175
- callSite: (f, a) => f(...a)
173
+ F: __dxlog_file,
174
+ L: 85,
175
+ S: this,
176
+ C: (f, a) => f(...a)
176
177
  });
177
178
  }
178
179
  });
@@ -194,7 +195,7 @@ var TrustedKeySetAuthVerifier = class {
194
195
  };
195
196
 
196
197
  // packages/sdk/client-services/src/packlets/identity/identity.ts
197
- var import_node_assert = __toESM(require("node:assert"));
198
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
198
199
  var import_async2 = require("@dxos/async");
199
200
  var import_client_protocol = require("@dxos/client-protocol");
200
201
  var import_credentials3 = require("@dxos/credentials");
@@ -202,6 +203,7 @@ var import_debug = require("@dxos/debug");
202
203
  var import_feed_store = require("@dxos/feed-store");
203
204
  var import_log2 = require("@dxos/log");
204
205
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
206
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
205
207
  var Identity = class {
206
208
  constructor({ space, signer, identityKey, deviceKey }) {
207
209
  this.stateUpdate = new import_async2.Event();
@@ -209,15 +211,15 @@ var Identity = class {
209
211
  this._signer = signer;
210
212
  this.identityKey = identityKey;
211
213
  this.deviceKey = deviceKey;
212
- this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.DeviceStateMachine({
214
+ this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
213
215
  identityKey: this.identityKey,
214
216
  deviceKey: this.deviceKey,
215
217
  onUpdate: () => this.stateUpdate.emit()
216
- }));
217
- this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.ProfileStateMachine({
218
+ });
219
+ this._profileStateMachine = new import_credentials3.ProfileStateMachine({
218
220
  identityKey: this.identityKey,
219
221
  onUpdate: () => this.stateUpdate.emit()
220
- }));
222
+ });
221
223
  this.authVerifier = new TrustedKeySetAuthVerifier({
222
224
  trustedKeysProvider: () => this.authorizedDeviceKeys,
223
225
  update: this.stateUpdate,
@@ -226,27 +228,27 @@ var Identity = class {
226
228
  }
227
229
  // TODO(burdon): Expose state object?
228
230
  get authorizedDeviceKeys() {
229
- return this._deviceStateMachine.processor.authorizedDeviceKeys;
231
+ return this._deviceStateMachine.authorizedDeviceKeys;
230
232
  }
231
233
  async open() {
232
- await this._deviceStateMachine.open();
233
- await this._profileStateMachine.open();
234
+ await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
235
+ await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
234
236
  await this.space.open();
235
237
  }
236
238
  async close() {
237
239
  await this.authVerifier.close();
238
- await this._deviceStateMachine.close();
239
- await this._profileStateMachine.close();
240
+ await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
241
+ await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
240
242
  await this.space.close();
241
243
  }
242
244
  async ready() {
243
- await this._deviceStateMachine.processor.deviceChainReady.wait();
245
+ await this._deviceStateMachine.deviceChainReady.wait();
244
246
  await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
245
247
  timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
246
248
  });
247
249
  }
248
250
  get profileDocument() {
249
- return this._profileStateMachine.processor.profile;
251
+ return this._profileStateMachine.profile;
250
252
  }
251
253
  /**
252
254
  * @test-only
@@ -261,7 +263,7 @@ var Identity = class {
261
263
  return this.space.genesisFeedKey;
262
264
  }
263
265
  get deviceCredentialChain() {
264
- return this._deviceStateMachine.processor.deviceCredentialChain;
266
+ return this._deviceStateMachine.deviceCredentialChain;
265
267
  }
266
268
  getAdmissionCredentials() {
267
269
  var _a, _b;
@@ -276,8 +278,8 @@ var Identity = class {
276
278
  * Requires identity to be ready.
277
279
  */
278
280
  getIdentityCredentialSigner() {
279
- (0, import_node_assert.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
280
- return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
281
+ (0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
282
+ return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
281
283
  }
282
284
  /**
283
285
  * Issues credentials as device.
@@ -293,10 +295,10 @@ var Identity = class {
293
295
  controlFeedKey,
294
296
  dataFeedKey
295
297
  }, {
296
- file: "identity.ts",
297
- line: 156,
298
- scope: this,
299
- callSite: (f, a) => f(...a)
298
+ F: __dxlog_file2,
299
+ L: 151,
300
+ S: this,
301
+ C: (f, a) => f(...a)
300
302
  });
301
303
  const signer = this.getIdentityCredentialSigner();
302
304
  await (0, import_feed_store.writeMessages)(this.controlPipeline.writer, [
@@ -337,7 +339,7 @@ var Identity = class {
337
339
  };
338
340
 
339
341
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
340
- var import_node_assert2 = __toESM(require("node:assert"));
342
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
341
343
  var import_async3 = require("@dxos/async");
342
344
  var import_credentials5 = require("@dxos/credentials");
343
345
  var import_keys2 = require("@dxos/keys");
@@ -345,6 +347,7 @@ var import_log3 = require("@dxos/log");
345
347
  var import_protocols2 = require("@dxos/protocols");
346
348
  var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
347
349
  var import_util = require("@dxos/util");
350
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
348
351
  var IdentityManager = class {
349
352
  // TODO(burdon): IdentityManagerParams.
350
353
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
@@ -364,20 +367,20 @@ var IdentityManager = class {
364
367
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
365
368
  id: traceId
366
369
  }), {
367
- file: "identity-manager.ts",
368
- line: 70,
369
- scope: this,
370
- callSite: (f, a) => f(...a)
370
+ F: __dxlog_file3,
371
+ L: 70,
372
+ S: this,
373
+ C: (f, a) => f(...a)
371
374
  });
372
375
  await this._metadataStore.load();
373
376
  const identityRecord = this._metadataStore.getIdentityRecord();
374
377
  (0, import_log3.log)("identity record", {
375
378
  identityRecord
376
379
  }, {
377
- file: "identity-manager.ts",
378
- line: 74,
379
- scope: this,
380
- callSite: (f, a) => f(...a)
380
+ F: __dxlog_file3,
381
+ L: 74,
382
+ S: this,
383
+ C: (f, a) => f(...a)
381
384
  });
382
385
  if (identityRecord) {
383
386
  this._identity = await this._constructIdentity(identityRecord);
@@ -387,20 +390,20 @@ var IdentityManager = class {
387
390
  identityKey: identityRecord.identityKey,
388
391
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
389
392
  }, {
390
- file: "identity-manager.ts",
391
- line: 79,
392
- scope: this,
393
- callSite: (f, a) => f(...a)
393
+ F: __dxlog_file3,
394
+ L: 79,
395
+ S: this,
396
+ C: (f, a) => f(...a)
394
397
  });
395
398
  this.stateUpdate.emit();
396
399
  }
397
400
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
398
401
  id: traceId
399
402
  }), {
400
- file: "identity-manager.ts",
401
- line: 85,
402
- scope: this,
403
- callSite: (f, a) => f(...a)
403
+ F: __dxlog_file3,
404
+ L: 85,
405
+ S: this,
406
+ C: (f, a) => f(...a)
404
407
  });
405
408
  }
406
409
  async close() {
@@ -409,12 +412,12 @@ var IdentityManager = class {
409
412
  }
410
413
  async createIdentity({ displayName } = {}) {
411
414
  var _a;
412
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
413
- (0, import_log3.log)("creating identity...", {}, {
414
- file: "identity-manager.ts",
415
- line: 94,
416
- scope: this,
417
- callSite: (f, a) => f(...a)
415
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
416
+ (0, import_log3.log)("creating identity...", void 0, {
417
+ F: __dxlog_file3,
418
+ L: 94,
419
+ S: this,
420
+ C: (f, a) => f(...a)
418
421
  });
419
422
  const controlFeedKey = await this._keyring.createKey();
420
423
  const identityRecord = {
@@ -431,8 +434,8 @@ var IdentityManager = class {
431
434
  await identity.open();
432
435
  {
433
436
  const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
434
- (0, import_node_assert2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
435
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
437
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
438
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
436
439
  const credentials = [
437
440
  // Space genesis.
438
441
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -460,20 +463,20 @@ var IdentityManager = class {
460
463
  identityKey: identityRecord.identityKey,
461
464
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
462
465
  }, {
463
- file: "identity-manager.ts",
464
- line: 149,
465
- scope: this,
466
- callSite: (f, a) => f(...a)
466
+ F: __dxlog_file3,
467
+ L: 149,
468
+ S: this,
469
+ C: (f, a) => f(...a)
467
470
  });
468
471
  this.stateUpdate.emit();
469
472
  (0, import_log3.log)("created identity", {
470
473
  identityKey: identity.identityKey,
471
474
  deviceKey: identity.deviceKey
472
475
  }, {
473
- file: "identity-manager.ts",
474
- line: 155,
475
- scope: this,
476
- callSite: (f, a) => f(...a)
476
+ F: __dxlog_file3,
477
+ L: 155,
478
+ S: this,
479
+ C: (f, a) => f(...a)
477
480
  });
478
481
  return identity;
479
482
  }
@@ -485,12 +488,12 @@ var IdentityManager = class {
485
488
  (0, import_log3.log)("accepting identity", {
486
489
  params
487
490
  }, {
488
- file: "identity-manager.ts",
489
- line: 163,
490
- scope: this,
491
- callSite: (f, a) => f(...a)
491
+ F: __dxlog_file3,
492
+ L: 163,
493
+ S: this,
494
+ C: (f, a) => f(...a)
492
495
  });
493
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
496
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
494
497
  const identityRecord = {
495
498
  identityKey: params.identityKey,
496
499
  deviceKey: params.deviceKey,
@@ -511,38 +514,38 @@ var IdentityManager = class {
511
514
  identityKey: identityRecord.identityKey,
512
515
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
513
516
  }, {
514
- file: "identity-manager.ts",
515
- line: 183,
516
- scope: this,
517
- callSite: (f, a) => f(...a)
517
+ F: __dxlog_file3,
518
+ L: 183,
519
+ S: this,
520
+ C: (f, a) => f(...a)
518
521
  });
519
522
  this.stateUpdate.emit();
520
523
  (0, import_log3.log)("accepted identity", {
521
524
  identityKey: identity.identityKey,
522
525
  deviceKey: identity.deviceKey
523
526
  }, {
524
- file: "identity-manager.ts",
525
- line: 189,
526
- scope: this,
527
- callSite: (f, a) => f(...a)
527
+ F: __dxlog_file3,
528
+ L: 189,
529
+ S: this,
530
+ C: (f, a) => f(...a)
528
531
  });
529
532
  return identity;
530
533
  }
531
534
  async _constructIdentity(identityRecord) {
532
- (0, import_node_assert2.default)(!this._identity);
535
+ (0, import_tiny_invariant2.default)(!this._identity);
533
536
  (0, import_log3.log)("constructing identity", {
534
537
  identityRecord
535
538
  }, {
536
- file: "identity-manager.ts",
537
- line: 195,
538
- scope: this,
539
- callSite: (f, a) => f(...a)
539
+ F: __dxlog_file3,
540
+ L: 195,
541
+ S: this,
542
+ C: (f, a) => f(...a)
540
543
  });
541
- (0, import_node_assert2.default)(identityRecord.haloSpace.controlFeedKey);
544
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
542
545
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
543
546
  writable: true
544
547
  });
545
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
548
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
546
549
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
547
550
  writable: true,
548
551
  sparse: true
@@ -567,10 +570,10 @@ var IdentityManager = class {
567
570
  (0, import_log3.log)("done", {
568
571
  identityKey: identityRecord.identityKey
569
572
  }, {
570
- file: "identity-manager.ts",
571
- line: 226,
572
- scope: this,
573
- callSite: (f, a) => f(...a)
573
+ F: __dxlog_file3,
574
+ L: 226,
575
+ S: this,
576
+ C: (f, a) => f(...a)
574
577
  });
575
578
  if (identityRecord.haloSpace.controlTimeframe) {
576
579
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
@@ -587,11 +590,11 @@ var IdentityManager = class {
587
590
  onNetworkConnection: () => {
588
591
  },
589
592
  onAuthFailure: () => {
590
- import_log3.log.warn("auth failure", {}, {
591
- file: "identity-manager.ts",
592
- line: 245,
593
- scope: this,
594
- callSite: (f, a) => f(...a)
593
+ import_log3.log.warn("auth failure", void 0, {
594
+ F: __dxlog_file3,
595
+ L: 245,
596
+ S: this,
597
+ C: (f, a) => f(...a)
595
598
  });
596
599
  },
597
600
  memberKey: identityKey
@@ -600,7 +603,7 @@ var IdentityManager = class {
600
603
  };
601
604
 
602
605
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
603
- var import_node_assert3 = __toESM(require("node:assert"));
606
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
604
607
  var import_codec_protobuf = require("@dxos/codec-protobuf");
605
608
  var import_credentials7 = require("@dxos/credentials");
606
609
  var import_debug2 = require("@dxos/debug");
@@ -636,7 +639,7 @@ var IdentityServiceImpl = class {
636
639
  };
637
640
  }
638
641
  async signPresentation({ presentation, nonce }) {
639
- (0, import_node_assert3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
642
+ (0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
640
643
  return await (0, import_credentials7.signPresentation)({
641
644
  presentation,
642
645
  signer: this._serviceContext.keyring,
@@ -648,7 +651,7 @@ var IdentityServiceImpl = class {
648
651
  };
649
652
 
650
653
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
651
- var import_node_assert4 = __toESM(require("node:assert"));
654
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
652
655
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
653
656
  var DeviceInvitationProtocol = class {
654
657
  constructor(_keyring, _getIdentity, _acceptIdentity) {
@@ -665,7 +668,7 @@ var DeviceInvitationProtocol = class {
665
668
  };
666
669
  }
667
670
  async admit(request) {
668
- (0, import_node_assert4.default)(request.device);
671
+ (0, import_tiny_invariant4.default)(request.device);
669
672
  const identity = this._getIdentity();
670
673
  await identity.admitDevice(request.device);
671
674
  return {
@@ -693,9 +696,9 @@ var DeviceInvitationProtocol = class {
693
696
  };
694
697
  }
695
698
  async accept(response, request) {
696
- (0, import_node_assert4.default)(response.device);
699
+ (0, import_tiny_invariant4.default)(response.device);
697
700
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
698
- (0, import_node_assert4.default)(request.device);
701
+ (0, import_tiny_invariant4.default)(request.device);
699
702
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
700
703
  await this._acceptIdentity({
701
704
  identityKey,
@@ -713,7 +716,7 @@ var DeviceInvitationProtocol = class {
713
716
  };
714
717
 
715
718
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
716
- var import_node_assert6 = __toESM(require("node:assert"));
719
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
717
720
  var import_async5 = require("@dxos/async");
718
721
  var import_client_protocol2 = require("@dxos/client-protocol");
719
722
  var import_context3 = require("@dxos/context");
@@ -727,7 +730,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
727
730
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
728
731
 
729
732
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
730
- var import_node_assert5 = __toESM(require("node:assert"));
733
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
731
734
  var import_async4 = require("@dxos/async");
732
735
  var import_context2 = require("@dxos/context");
733
736
  var import_errors = require("@dxos/errors");
@@ -737,6 +740,7 @@ var import_protocols3 = require("@dxos/protocols");
737
740
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
738
741
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
739
742
  var import_teleport = require("@dxos/teleport");
743
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
740
744
  var OPTIONS_TIMEOUT = 1e4;
741
745
  var MAX_OTP_ATTEMPTS = 3;
742
746
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
@@ -764,7 +768,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
764
768
  // Perhaps in the future we will have more complex logic here.
765
769
  InvitationHostService: {
766
770
  options: async (options) => {
767
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
771
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
768
772
  this._remoteOptions = options;
769
773
  this._remoteOptionsTrigger.wake();
770
774
  },
@@ -774,20 +778,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
774
778
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
775
779
  id: traceId
776
780
  }), {
777
- file: "invitation-extension.ts",
778
- line: 98,
779
- scope: this,
780
- callSite: (f, a) => f(...a)
781
+ F: __dxlog_file4,
782
+ L: 98,
783
+ S: this,
784
+ C: (f, a) => f(...a)
781
785
  });
782
786
  const invitation = await this._callbacks.resolveInvitation(request);
783
787
  if (!invitation) {
784
788
  import_log4.log.warn("invitation not found", {
785
789
  invitationId
786
790
  }, {
787
- file: "invitation-extension.ts",
788
- line: 102,
789
- scope: this,
790
- callSite: (f, a) => f(...a)
791
+ F: __dxlog_file4,
792
+ L: 102,
793
+ S: this,
794
+ C: (f, a) => f(...a)
791
795
  });
792
796
  this._callbacks.onError(new Error("Invitation not found."));
793
797
  return {
@@ -798,10 +802,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
798
802
  (0, import_log4.log)("guest introduced itself", {
799
803
  guestProfile: profile
800
804
  }, {
801
- file: "invitation-extension.ts",
802
- line: 111,
803
- scope: this,
804
- callSite: (f, a) => f(...a)
805
+ F: __dxlog_file4,
806
+ L: 111,
807
+ S: this,
808
+ C: (f, a) => f(...a)
805
809
  });
806
810
  this.guestProfile = profile;
807
811
  this._callbacks.onStateUpdate({
@@ -811,10 +815,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
811
815
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
812
816
  id: traceId
813
817
  }), {
814
- file: "invitation-extension.ts",
815
- line: 118,
816
- scope: this,
817
- callSite: (f, a) => f(...a)
818
+ F: __dxlog_file4,
819
+ L: 118,
820
+ S: this,
821
+ C: (f, a) => f(...a)
818
822
  });
819
823
  return {
820
824
  spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
@@ -826,28 +830,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
826
830
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
827
831
  id: traceId
828
832
  }), {
829
- file: "invitation-extension.ts",
830
- line: 127,
831
- scope: this,
832
- callSite: (f, a) => f(...a)
833
+ F: __dxlog_file4,
834
+ L: 127,
835
+ S: this,
836
+ C: (f, a) => f(...a)
833
837
  });
834
838
  (0, import_log4.log)("received authentication request", {
835
839
  authCode: code
836
840
  }, {
837
- file: "invitation-extension.ts",
838
- line: 128,
839
- scope: this,
840
- callSite: (f, a) => f(...a)
841
+ F: __dxlog_file4,
842
+ L: 128,
843
+ S: this,
844
+ C: (f, a) => f(...a)
841
845
  });
842
846
  let status = import_invitations.AuthenticationResponse.Status.OK;
843
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
847
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
844
848
  switch (this.invitation.authMethod) {
845
849
  case import_services2.Invitation.AuthMethod.NONE: {
846
- (0, import_log4.log)("authentication not required", {}, {
847
- file: "invitation-extension.ts",
848
- line: 134,
849
- scope: this,
850
- callSite: (f, a) => f(...a)
850
+ (0, import_log4.log)("authentication not required", void 0, {
851
+ F: __dxlog_file4,
852
+ L: 134,
853
+ S: this,
854
+ C: (f, a) => f(...a)
851
855
  });
852
856
  return {
853
857
  status: import_invitations.AuthenticationResponse.Status.OK
@@ -869,10 +873,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
869
873
  import_log4.log.error("invalid authentication method", {
870
874
  authMethod: this.invitation.authMethod
871
875
  }, {
872
- file: "invitation-extension.ts",
873
- line: 152,
874
- scope: this,
875
- callSite: (f, a) => f(...a)
876
+ F: __dxlog_file4,
877
+ L: 152,
878
+ S: this,
879
+ C: (f, a) => f(...a)
876
880
  });
877
881
  status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
878
882
  break;
@@ -884,10 +888,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
884
888
  status
885
889
  }
886
890
  }), {
887
- file: "invitation-extension.ts",
888
- line: 158,
889
- scope: this,
890
- callSite: (f, a) => f(...a)
891
+ F: __dxlog_file4,
892
+ L: 158,
893
+ S: this,
894
+ C: (f, a) => f(...a)
891
895
  });
892
896
  return {
893
897
  status
@@ -898,13 +902,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
898
902
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
899
903
  id: traceId
900
904
  }), {
901
- file: "invitation-extension.ts",
902
- line: 164,
903
- scope: this,
904
- callSite: (f, a) => f(...a)
905
+ F: __dxlog_file4,
906
+ L: 164,
907
+ S: this,
908
+ C: (f, a) => f(...a)
905
909
  });
906
910
  try {
907
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
911
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
908
912
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
909
913
  throw new Error("Not authenticated");
910
914
  }
@@ -912,10 +916,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
912
916
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
913
917
  id: traceId
914
918
  }), {
915
- file: "invitation-extension.ts",
916
- line: 175,
917
- scope: this,
918
- callSite: (f, a) => f(...a)
919
+ F: __dxlog_file4,
920
+ L: 175,
921
+ S: this,
922
+ C: (f, a) => f(...a)
919
923
  });
920
924
  return response;
921
925
  } catch (err) {
@@ -969,7 +973,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
969
973
  return {
970
974
  InvitationHostService: {
971
975
  options: async (options) => {
972
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
976
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
973
977
  this._remoteOptions = options;
974
978
  this._remoteOptionsTrigger.wake();
975
979
  },
@@ -989,11 +993,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
989
993
  var _a;
990
994
  await super.onOpen(context);
991
995
  try {
992
- (0, import_log4.log)("begin options", {}, {
993
- file: "invitation-extension.ts",
994
- line: 263,
995
- scope: this,
996
- callSite: (f, a) => f(...a)
996
+ (0, import_log4.log)("begin options", void 0, {
997
+ F: __dxlog_file4,
998
+ L: 263,
999
+ S: this,
1000
+ C: (f, a) => f(...a)
997
1001
  });
998
1002
  await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
999
1003
  role: import_invitations.Options.Role.GUEST
@@ -1001,11 +1005,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1001
1005
  await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1002
1006
  timeout: OPTIONS_TIMEOUT
1003
1007
  }));
1004
- (0, import_log4.log)("end options", {}, {
1005
- file: "invitation-extension.ts",
1006
- line: 266,
1007
- scope: this,
1008
- callSite: (f, a) => f(...a)
1008
+ (0, import_log4.log)("end options", void 0, {
1009
+ F: __dxlog_file4,
1010
+ L: 266,
1011
+ S: this,
1012
+ C: (f, a) => f(...a)
1009
1013
  });
1010
1014
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
1011
1015
  throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
@@ -1016,20 +1020,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1016
1020
  this._callbacks.onOpen(this._ctx);
1017
1021
  } catch (err) {
1018
1022
  (0, import_log4.log)("openError", err, {
1019
- file: "invitation-extension.ts",
1020
- line: 276,
1021
- scope: this,
1022
- callSite: (f, a) => f(...a)
1023
+ F: __dxlog_file4,
1024
+ L: 276,
1025
+ S: this,
1026
+ C: (f, a) => f(...a)
1023
1027
  });
1024
1028
  this._callbacks.onError(err);
1025
1029
  }
1026
1030
  }
1027
1031
  async onClose() {
1028
- (0, import_log4.log)("onClose", {}, {
1029
- file: "invitation-extension.ts",
1030
- line: 282,
1031
- scope: this,
1032
- callSite: (f, a) => f(...a)
1032
+ (0, import_log4.log)("onClose", void 0, {
1033
+ F: __dxlog_file4,
1034
+ L: 282,
1035
+ S: this,
1036
+ C: (f, a) => f(...a)
1033
1037
  });
1034
1038
  await this._ctx.dispose();
1035
1039
  }
@@ -1037,6 +1041,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1037
1041
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1038
1042
 
1039
1043
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1044
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1040
1045
  var InvitationsHandler = class {
1041
1046
  /**
1042
1047
  * @internal
@@ -1048,7 +1053,7 @@ var InvitationsHandler = class {
1048
1053
  var _a;
1049
1054
  const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
1050
1055
  const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1051
- (0, import_node_assert6.default)(protocol);
1056
+ (0, import_tiny_invariant6.default)(protocol);
1052
1057
  const invitation = {
1053
1058
  invitationId,
1054
1059
  type,
@@ -1070,10 +1075,10 @@ var InvitationsHandler = class {
1070
1075
  (0, import_log5.log)("complete", {
1071
1076
  ...protocol.toJSON()
1072
1077
  }, {
1073
- file: "invitations-handler.ts",
1074
- line: 99,
1075
- scope: this,
1076
- callSite: (f, a) => f(...a)
1078
+ F: __dxlog_file5,
1079
+ L: 99,
1080
+ S: this,
1081
+ C: (f, a) => f(...a)
1077
1082
  });
1078
1083
  stream.complete();
1079
1084
  });
@@ -1095,7 +1100,7 @@ var InvitationsHandler = class {
1095
1100
  var _a2, _b, _c;
1096
1101
  try {
1097
1102
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1098
- (0, import_node_assert6.default)(deviceKey);
1103
+ (0, import_tiny_invariant6.default)(deviceKey);
1099
1104
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1100
1105
  extension.completedTrigger.wake(deviceKey);
1101
1106
  return admissionResponse;
@@ -1111,18 +1116,18 @@ var InvitationsHandler = class {
1111
1116
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
1112
1117
  id: traceId
1113
1118
  }), {
1114
- file: "invitations-handler.ts",
1115
- line: 138,
1116
- scope: this,
1117
- callSite: (f, a) => f(...a)
1119
+ F: __dxlog_file5,
1120
+ L: 138,
1121
+ S: this,
1122
+ C: (f, a) => f(...a)
1118
1123
  });
1119
1124
  (0, import_log5.log)("connected", {
1120
1125
  ...protocol.toJSON()
1121
1126
  }, {
1122
- file: "invitations-handler.ts",
1123
- line: 139,
1124
- scope: this,
1125
- callSite: (f, a) => f(...a)
1127
+ F: __dxlog_file5,
1128
+ L: 139,
1129
+ S: this,
1130
+ C: (f, a) => f(...a)
1126
1131
  });
1127
1132
  stream.next({
1128
1133
  ...invitation,
@@ -1135,10 +1140,10 @@ var InvitationsHandler = class {
1135
1140
  guest: deviceKey,
1136
1141
  ...protocol.toJSON()
1137
1142
  }, {
1138
- file: "invitations-handler.ts",
1139
- line: 142,
1140
- scope: this,
1141
- callSite: (f, a) => f(...a)
1143
+ F: __dxlog_file5,
1144
+ L: 142,
1145
+ S: this,
1146
+ C: (f, a) => f(...a)
1142
1147
  });
1143
1148
  stream.next({
1144
1149
  ...invitation,
@@ -1147,20 +1152,20 @@ var InvitationsHandler = class {
1147
1152
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1148
1153
  id: traceId
1149
1154
  }), {
1150
- file: "invitations-handler.ts",
1151
- line: 144,
1152
- scope: this,
1153
- callSite: (f, a) => f(...a)
1155
+ F: __dxlog_file5,
1156
+ L: 144,
1157
+ S: this,
1158
+ C: (f, a) => f(...a)
1154
1159
  });
1155
1160
  } catch (err) {
1156
1161
  if (err instanceof import_async5.TimeoutError) {
1157
1162
  (0, import_log5.log)("timeout", {
1158
1163
  ...protocol.toJSON()
1159
1164
  }, {
1160
- file: "invitations-handler.ts",
1161
- line: 147,
1162
- scope: this,
1163
- callSite: (f, a) => f(...a)
1165
+ F: __dxlog_file5,
1166
+ L: 147,
1167
+ S: this,
1168
+ C: (f, a) => f(...a)
1164
1169
  });
1165
1170
  stream.next({
1166
1171
  ...invitation,
@@ -1168,10 +1173,10 @@ var InvitationsHandler = class {
1168
1173
  });
1169
1174
  } else {
1170
1175
  import_log5.log.error("failed", err, {
1171
- file: "invitations-handler.ts",
1172
- line: 150,
1173
- scope: this,
1174
- callSite: (f, a) => f(...a)
1176
+ F: __dxlog_file5,
1177
+ L: 150,
1178
+ S: this,
1179
+ C: (f, a) => f(...a)
1175
1180
  });
1176
1181
  stream.error(err);
1177
1182
  }
@@ -1179,10 +1184,10 @@ var InvitationsHandler = class {
1179
1184
  id: traceId,
1180
1185
  error: err
1181
1186
  }), {
1182
- file: "invitations-handler.ts",
1183
- line: 153,
1184
- scope: this,
1185
- callSite: (f, a) => f(...a)
1187
+ F: __dxlog_file5,
1188
+ L: 153,
1189
+ S: this,
1190
+ C: (f, a) => f(...a)
1186
1191
  });
1187
1192
  } finally {
1188
1193
  if (type !== import_services3.Invitation.Type.MULTIUSE) {
@@ -1200,10 +1205,10 @@ var InvitationsHandler = class {
1200
1205
  (0, import_log5.log)("timeout", {
1201
1206
  ...protocol.toJSON()
1202
1207
  }, {
1203
- file: "invitations-handler.ts",
1204
- line: 168,
1205
- scope: this,
1206
- callSite: (f, a) => f(...a)
1208
+ F: __dxlog_file5,
1209
+ L: 168,
1210
+ S: this,
1211
+ C: (f, a) => f(...a)
1207
1212
  });
1208
1213
  stream.next({
1209
1214
  ...invitation,
@@ -1211,10 +1216,10 @@ var InvitationsHandler = class {
1211
1216
  });
1212
1217
  } else {
1213
1218
  import_log5.log.error("failed", err, {
1214
- file: "invitations-handler.ts",
1215
- line: 171,
1216
- scope: this,
1217
- callSite: (f, a) => f(...a)
1219
+ F: __dxlog_file5,
1220
+ L: 171,
1221
+ S: this,
1222
+ C: (f, a) => f(...a)
1218
1223
  });
1219
1224
  stream.error(err);
1220
1225
  }
@@ -1254,13 +1259,13 @@ var InvitationsHandler = class {
1254
1259
  }
1255
1260
  acceptInvitation(protocol, invitation) {
1256
1261
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1257
- (0, import_node_assert6.default)(protocol);
1262
+ (0, import_tiny_invariant6.default)(protocol);
1258
1263
  const authenticated = new import_async5.Trigger();
1259
1264
  let admitted = false;
1260
1265
  let currentState;
1261
1266
  const stream = new import_async5.PushStream();
1262
1267
  const setState = (newData) => {
1263
- (0, import_node_assert6.default)(newData.state !== void 0);
1268
+ (0, import_tiny_invariant6.default)(newData.state !== void 0);
1264
1269
  currentState = newData.state;
1265
1270
  stream.next({
1266
1271
  ...invitation,
@@ -1273,20 +1278,20 @@ var InvitationsHandler = class {
1273
1278
  (0, import_log5.log)("timeout", {
1274
1279
  ...protocol.toJSON()
1275
1280
  }, {
1276
- file: "invitations-handler.ts",
1277
- line: 230,
1278
- scope: this,
1279
- callSite: (f, a) => f(...a)
1281
+ F: __dxlog_file5,
1282
+ L: 230,
1283
+ S: this,
1284
+ C: (f, a) => f(...a)
1280
1285
  });
1281
1286
  setState({
1282
1287
  state: import_services3.Invitation.State.TIMEOUT
1283
1288
  });
1284
1289
  } else {
1285
1290
  import_log5.log.warn("auth failed", err, {
1286
- file: "invitations-handler.ts",
1287
- line: 233,
1288
- scope: this,
1289
- callSite: (f, a) => f(...a)
1291
+ F: __dxlog_file5,
1292
+ L: 233,
1293
+ S: this,
1294
+ C: (f, a) => f(...a)
1290
1295
  });
1291
1296
  stream.error(err);
1292
1297
  }
@@ -1297,10 +1302,10 @@ var InvitationsHandler = class {
1297
1302
  (0, import_log5.log)("complete", {
1298
1303
  ...protocol.toJSON()
1299
1304
  }, {
1300
- file: "invitations-handler.ts",
1301
- line: 241,
1302
- scope: this,
1303
- callSite: (f, a) => f(...a)
1305
+ F: __dxlog_file5,
1306
+ L: 241,
1307
+ S: this,
1308
+ C: (f, a) => f(...a)
1304
1309
  });
1305
1310
  stream.complete();
1306
1311
  });
@@ -1312,10 +1317,10 @@ var InvitationsHandler = class {
1312
1317
  (0, import_log5.log)("extension disposed", {
1313
1318
  currentState
1314
1319
  }, {
1315
- file: "invitations-handler.ts",
1316
- line: 251,
1317
- scope: this,
1318
- callSite: (f, a) => f(...a)
1320
+ F: __dxlog_file5,
1321
+ L: 251,
1322
+ S: this,
1323
+ C: (f, a) => f(...a)
1319
1324
  });
1320
1325
  if (!admitted) {
1321
1326
  stream.error(new Error("Remote peer disconnected."));
@@ -1327,10 +1332,10 @@ var InvitationsHandler = class {
1327
1332
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
1328
1333
  id: traceId
1329
1334
  }), {
1330
- file: "invitations-handler.ts",
1331
- line: 260,
1332
- scope: this,
1333
- callSite: (f, a) => f(...a)
1335
+ F: __dxlog_file5,
1336
+ L: 260,
1337
+ S: this,
1338
+ C: (f, a) => f(...a)
1334
1339
  });
1335
1340
  if (++connectionCount > 1) {
1336
1341
  throw new Error(`multiple connections detected: ${connectionCount}`);
@@ -1339,10 +1344,10 @@ var InvitationsHandler = class {
1339
1344
  (0, import_log5.log)("connected", {
1340
1345
  ...protocol.toJSON()
1341
1346
  }, {
1342
- file: "invitations-handler.ts",
1343
- line: 268,
1344
- scope: this,
1345
- callSite: (f, a) => f(...a)
1347
+ F: __dxlog_file5,
1348
+ L: 268,
1349
+ S: this,
1350
+ C: (f, a) => f(...a)
1346
1351
  });
1347
1352
  setState({
1348
1353
  state: import_services3.Invitation.State.CONNECTED
@@ -1350,20 +1355,20 @@ var InvitationsHandler = class {
1350
1355
  (0, import_log5.log)("introduce", {
1351
1356
  ...protocol.toJSON()
1352
1357
  }, {
1353
- file: "invitations-handler.ts",
1354
- line: 272,
1355
- scope: this,
1356
- callSite: (f, a) => f(...a)
1358
+ F: __dxlog_file5,
1359
+ L: 272,
1360
+ S: this,
1361
+ C: (f, a) => f(...a)
1357
1362
  });
1358
1363
  const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
1359
1364
  (0, import_log5.log)("introduce response", {
1360
1365
  ...protocol.toJSON(),
1361
1366
  response: introductionResponse
1362
1367
  }, {
1363
- file: "invitations-handler.ts",
1364
- line: 276,
1365
- scope: this,
1366
- callSite: (f, a) => f(...a)
1368
+ F: __dxlog_file5,
1369
+ L: 276,
1370
+ S: this,
1371
+ C: (f, a) => f(...a)
1367
1372
  });
1368
1373
  invitation.authMethod = introductionResponse.authMethod;
1369
1374
  if (introductionResponse.spaceKey) {
@@ -1371,11 +1376,11 @@ var InvitationsHandler = class {
1371
1376
  }
1372
1377
  if (isAuthenticationRequired(invitation)) {
1373
1378
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1374
- (0, import_log5.log)("guest waiting for authentication code...", {}, {
1375
- file: "invitations-handler.ts",
1376
- line: 285,
1377
- scope: this,
1378
- callSite: (f, a) => f(...a)
1379
+ (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1380
+ F: __dxlog_file5,
1381
+ L: 285,
1382
+ S: this,
1383
+ C: (f, a) => f(...a)
1379
1384
  });
1380
1385
  setState({
1381
1386
  state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
@@ -1383,11 +1388,11 @@ var InvitationsHandler = class {
1383
1388
  const authCode = await authenticated.wait({
1384
1389
  timeout
1385
1390
  });
1386
- (0, import_log5.log)("sending authentication request", {}, {
1387
- file: "invitations-handler.ts",
1388
- line: 289,
1389
- scope: this,
1390
- callSite: (f, a) => f(...a)
1391
+ (0, import_log5.log)("sending authentication request", void 0, {
1392
+ F: __dxlog_file5,
1393
+ L: 289,
1394
+ S: this,
1395
+ C: (f, a) => f(...a)
1391
1396
  });
1392
1397
  setState({
1393
1398
  state: import_services3.Invitation.State.AUTHENTICATING
@@ -1405,10 +1410,10 @@ var InvitationsHandler = class {
1405
1410
  (0, import_log5.log)("retrying invalid code", {
1406
1411
  attempt
1407
1412
  }, {
1408
- file: "invitations-handler.ts",
1409
- line: 300,
1410
- scope: this,
1411
- callSite: (f, a) => f(...a)
1413
+ F: __dxlog_file5,
1414
+ L: 300,
1415
+ S: this,
1416
+ C: (f, a) => f(...a)
1412
1417
  });
1413
1418
  authenticated.reset();
1414
1419
  }
@@ -1422,10 +1427,10 @@ var InvitationsHandler = class {
1422
1427
  (0, import_log5.log)("request admission", {
1423
1428
  ...protocol.toJSON()
1424
1429
  }, {
1425
- file: "invitations-handler.ts",
1426
- line: 311,
1427
- scope: this,
1428
- callSite: (f, a) => f(...a)
1430
+ F: __dxlog_file5,
1431
+ L: 311,
1432
+ S: this,
1433
+ C: (f, a) => f(...a)
1429
1434
  });
1430
1435
  const admissionRequest = await protocol.createAdmissionRequest();
1431
1436
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
@@ -1434,10 +1439,10 @@ var InvitationsHandler = class {
1434
1439
  (0, import_log5.log)("admitted by host", {
1435
1440
  ...protocol.toJSON()
1436
1441
  }, {
1437
- file: "invitations-handler.ts",
1438
- line: 322,
1439
- scope: this,
1440
- callSite: (f, a) => f(...a)
1442
+ F: __dxlog_file5,
1443
+ L: 322,
1444
+ S: this,
1445
+ C: (f, a) => f(...a)
1441
1446
  });
1442
1447
  setState({
1443
1448
  ...result,
@@ -1446,30 +1451,30 @@ var InvitationsHandler = class {
1446
1451
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1447
1452
  id: traceId
1448
1453
  }), {
1449
- file: "invitations-handler.ts",
1450
- line: 324,
1451
- scope: this,
1452
- callSite: (f, a) => f(...a)
1454
+ F: __dxlog_file5,
1455
+ L: 324,
1456
+ S: this,
1457
+ C: (f, a) => f(...a)
1453
1458
  });
1454
1459
  } catch (err) {
1455
1460
  if (err instanceof import_async5.TimeoutError) {
1456
1461
  (0, import_log5.log)("timeout", {
1457
1462
  ...protocol.toJSON()
1458
1463
  }, {
1459
- file: "invitations-handler.ts",
1460
- line: 327,
1461
- scope: this,
1462
- callSite: (f, a) => f(...a)
1464
+ F: __dxlog_file5,
1465
+ L: 327,
1466
+ S: this,
1467
+ C: (f, a) => f(...a)
1463
1468
  });
1464
1469
  setState({
1465
1470
  state: import_services3.Invitation.State.TIMEOUT
1466
1471
  });
1467
1472
  } else {
1468
1473
  (0, import_log5.log)("auth failed", err, {
1469
- file: "invitations-handler.ts",
1470
- line: 330,
1471
- scope: this,
1472
- callSite: (f, a) => f(...a)
1474
+ F: __dxlog_file5,
1475
+ L: 330,
1476
+ S: this,
1477
+ C: (f, a) => f(...a)
1473
1478
  });
1474
1479
  stream.error(err);
1475
1480
  }
@@ -1477,10 +1482,10 @@ var InvitationsHandler = class {
1477
1482
  id: traceId,
1478
1483
  error: err
1479
1484
  }), {
1480
- file: "invitations-handler.ts",
1481
- line: 333,
1482
- scope: this,
1483
- callSite: (f, a) => f(...a)
1485
+ F: __dxlog_file5,
1486
+ L: 333,
1487
+ S: this,
1488
+ C: (f, a) => f(...a)
1484
1489
  });
1485
1490
  } finally {
1486
1491
  await ctx.dispose();
@@ -1495,20 +1500,20 @@ var InvitationsHandler = class {
1495
1500
  (0, import_log5.log)("timeout", {
1496
1501
  ...protocol.toJSON()
1497
1502
  }, {
1498
- file: "invitations-handler.ts",
1499
- line: 344,
1500
- scope: this,
1501
- callSite: (f, a) => f(...a)
1503
+ F: __dxlog_file5,
1504
+ L: 344,
1505
+ S: this,
1506
+ C: (f, a) => f(...a)
1502
1507
  });
1503
1508
  setState({
1504
1509
  state: import_services3.Invitation.State.TIMEOUT
1505
1510
  });
1506
1511
  } else {
1507
1512
  (0, import_log5.log)("auth failed", err, {
1508
- file: "invitations-handler.ts",
1509
- line: 347,
1510
- scope: this,
1511
- callSite: (f, a) => f(...a)
1513
+ F: __dxlog_file5,
1514
+ L: 347,
1515
+ S: this,
1516
+ C: (f, a) => f(...a)
1512
1517
  });
1513
1518
  stream.error(err);
1514
1519
  }
@@ -1517,7 +1522,7 @@ var InvitationsHandler = class {
1517
1522
  return extension;
1518
1523
  };
1519
1524
  (0, import_async5.scheduleTask)(ctx, async () => {
1520
- (0, import_node_assert6.default)(invitation.swarmKey);
1525
+ (0, import_tiny_invariant6.default)(invitation.swarmKey);
1521
1526
  const topic = invitation.swarmKey;
1522
1527
  const swarmConnection = await this._networkManager.joinSwarm({
1523
1528
  topic,
@@ -1550,11 +1555,12 @@ var InvitationsHandler = class {
1550
1555
  };
1551
1556
 
1552
1557
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1553
- var import_node_assert7 = __toESM(require("node:assert"));
1558
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1554
1559
  var import_async6 = require("@dxos/async");
1555
1560
  var import_codec_protobuf2 = require("@dxos/codec-protobuf");
1556
1561
  var import_log6 = require("@dxos/log");
1557
1562
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1563
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1558
1564
  var InvitationsServiceImpl = class {
1559
1565
  constructor(_invitationsHandler, _getHandler) {
1560
1566
  this._invitationsHandler = _invitationsHandler;
@@ -1615,35 +1621,35 @@ var InvitationsServiceImpl = class {
1615
1621
  });
1616
1622
  }
1617
1623
  async authenticate({ invitationId, authCode }) {
1618
- (0, import_log6.log)("authenticating...", {}, {
1619
- file: "invitations-service.ts",
1620
- line: 103,
1621
- scope: this,
1622
- callSite: (f, a) => f(...a)
1624
+ (0, import_log6.log)("authenticating...", void 0, {
1625
+ F: __dxlog_file6,
1626
+ L: 103,
1627
+ S: this,
1628
+ C: (f, a) => f(...a)
1623
1629
  });
1624
- (0, import_node_assert7.default)(invitationId);
1630
+ (0, import_tiny_invariant7.default)(invitationId);
1625
1631
  const observable = this._acceptInvitations.get(invitationId);
1626
1632
  if (!observable) {
1627
1633
  import_log6.log.warn("invalid invitation", {
1628
1634
  invitationId
1629
1635
  }, {
1630
- file: "invitations-service.ts",
1631
- line: 107,
1632
- scope: this,
1633
- callSite: (f, a) => f(...a)
1636
+ F: __dxlog_file6,
1637
+ L: 107,
1638
+ S: this,
1639
+ C: (f, a) => f(...a)
1634
1640
  });
1635
1641
  } else {
1636
1642
  await observable.authenticate(authCode);
1637
1643
  }
1638
1644
  }
1639
1645
  async cancelInvitation({ invitationId }) {
1640
- (0, import_log6.log)("deleting...", {}, {
1641
- file: "invitations-service.ts",
1642
- line: 114,
1643
- scope: this,
1644
- callSite: (f, a) => f(...a)
1646
+ (0, import_log6.log)("deleting...", void 0, {
1647
+ F: __dxlog_file6,
1648
+ L: 114,
1649
+ S: this,
1650
+ C: (f, a) => f(...a)
1645
1651
  });
1646
- (0, import_node_assert7.default)(invitationId);
1652
+ (0, import_tiny_invariant7.default)(invitationId);
1647
1653
  const created = this._createInvitations.get(invitationId);
1648
1654
  const accepted = this._acceptInvitations.get(invitationId);
1649
1655
  if (created) {
@@ -1658,10 +1664,10 @@ var InvitationsServiceImpl = class {
1658
1664
  import_log6.log.warn("invalid invitation", {
1659
1665
  invitationId
1660
1666
  }, {
1661
- file: "invitations-service.ts",
1662
- line: 127,
1663
- scope: this,
1664
- callSite: (f, a) => f(...a)
1667
+ F: __dxlog_file6,
1668
+ L: 127,
1669
+ S: this,
1670
+ C: (f, a) => f(...a)
1665
1671
  });
1666
1672
  }
1667
1673
  }
@@ -1718,11 +1724,12 @@ var InvitationsServiceImpl = class {
1718
1724
  };
1719
1725
 
1720
1726
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
1721
- var import_node_assert8 = __toESM(require("node:assert"));
1727
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1722
1728
  var import_credentials9 = require("@dxos/credentials");
1723
1729
  var import_feed_store2 = require("@dxos/feed-store");
1724
1730
  var import_log7 = require("@dxos/log");
1725
1731
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1732
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
1726
1733
  var SpaceInvitationProtocol = class {
1727
1734
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
1728
1735
  this._spaceManager = _spaceManager;
@@ -1744,24 +1751,24 @@ var SpaceInvitationProtocol = class {
1744
1751
  }
1745
1752
  async admit(request, guestProfile) {
1746
1753
  var _a;
1747
- (0, import_node_assert8.default)(this._spaceKey);
1754
+ (0, import_tiny_invariant8.default)(this._spaceKey);
1748
1755
  const space = await this._spaceManager.spaces.get(this._spaceKey);
1749
- (0, import_node_assert8.default)(space);
1750
- (0, import_node_assert8.default)(request.space);
1756
+ (0, import_tiny_invariant8.default)(space);
1757
+ (0, import_tiny_invariant8.default)(request.space);
1751
1758
  const { identityKey, deviceKey } = request.space;
1752
1759
  (0, import_log7.log)("writing guest credentials", {
1753
1760
  host: this._signingContext.deviceKey,
1754
1761
  guest: deviceKey
1755
1762
  }, {
1756
- file: "space-invitation-protocol.ts",
1757
- line: 50,
1758
- scope: this,
1759
- callSite: (f, a) => f(...a)
1763
+ F: __dxlog_file7,
1764
+ L: 50,
1765
+ S: this,
1766
+ C: (f, a) => f(...a)
1760
1767
  });
1761
1768
  const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
1762
- (0, import_node_assert8.default)(credentials[0].credential);
1769
+ (0, import_tiny_invariant8.default)(credentials[0].credential);
1763
1770
  const spaceMemberCredential = credentials[0].credential.credential;
1764
- (0, import_node_assert8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1771
+ (0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1765
1772
  await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
1766
1773
  return {
1767
1774
  space: {
@@ -1789,11 +1796,11 @@ var SpaceInvitationProtocol = class {
1789
1796
  };
1790
1797
  }
1791
1798
  async accept(response) {
1792
- (0, import_node_assert8.default)(response.space);
1799
+ (0, import_tiny_invariant8.default)(response.space);
1793
1800
  const { credential, controlTimeframe, dataTimeframe } = response.space;
1794
1801
  const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
1795
- (0, import_node_assert8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
1796
- (0, import_node_assert8.default)(credential.subject.id.equals(this._signingContext.identityKey));
1802
+ (0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
1803
+ (0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
1797
1804
  await this._spaceManager.acceptSpace({
1798
1805
  spaceKey: assertion.spaceKey,
1799
1806
  genesisFeedKey: assertion.genesisFeedKey,
@@ -1808,7 +1815,7 @@ var SpaceInvitationProtocol = class {
1808
1815
  };
1809
1816
 
1810
1817
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1811
- var import_node_assert10 = __toESM(require("node:assert"));
1818
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
1812
1819
  var import_async9 = require("@dxos/async");
1813
1820
  var import_context6 = require("@dxos/context");
1814
1821
  var import_credentials13 = require("@dxos/credentials");
@@ -1834,7 +1841,7 @@ var import_timeframe = require("@dxos/timeframe");
1834
1841
  var import_util3 = require("@dxos/util");
1835
1842
 
1836
1843
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
1837
- var import_node_assert9 = __toESM(require("node:assert"));
1844
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1838
1845
  var import_async7 = require("@dxos/async");
1839
1846
  var import_context4 = require("@dxos/context");
1840
1847
  var import_keys5 = require("@dxos/keys");
@@ -1842,6 +1849,7 @@ var import_log8 = require("@dxos/log");
1842
1849
  var import_protocols5 = require("@dxos/protocols");
1843
1850
  var import_teleport2 = require("@dxos/teleport");
1844
1851
  var import_util2 = require("@dxos/util");
1852
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
1845
1853
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1846
1854
  var DEFAULT_SUCCESS_DELAY = 1e3;
1847
1855
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -1854,6 +1862,9 @@ var NotarizationPlugin = class {
1854
1862
  this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
1855
1863
  this._processCredentialsTriggers = new import_util2.ComplexMap(import_keys5.PublicKey.hash);
1856
1864
  }
1865
+ get hasWriter() {
1866
+ return !!this._writer;
1867
+ }
1857
1868
  async open() {
1858
1869
  }
1859
1870
  async close() {
@@ -1866,22 +1877,22 @@ var NotarizationPlugin = class {
1866
1877
  (0, import_log8.log)("notarize", {
1867
1878
  credentials
1868
1879
  }, {
1869
- file: "notarization-plugin.ts",
1870
- line: 87,
1871
- scope: this,
1872
- callSite: (f, a) => f(...a)
1880
+ F: __dxlog_file8,
1881
+ L: 91,
1882
+ S: this,
1883
+ C: (f, a) => f(...a)
1873
1884
  });
1874
- (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
1885
+ (0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
1875
1886
  const errors = new import_async7.Trigger();
1876
1887
  const ctx = this._ctx.derive({
1877
1888
  onError: (err) => {
1878
1889
  import_log8.log.warn("Notarization error", {
1879
1890
  err
1880
1891
  }, {
1881
- file: "notarization-plugin.ts",
1882
- line: 96,
1883
- scope: this,
1884
- callSite: (f, a) => f(...a)
1892
+ F: __dxlog_file8,
1893
+ L: 100,
1894
+ S: this,
1895
+ C: (f, a) => f(...a)
1885
1896
  });
1886
1897
  void ctx.dispose();
1887
1898
  errors.throw(err);
@@ -1894,10 +1905,10 @@ var NotarizationPlugin = class {
1894
1905
  timeout,
1895
1906
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1896
1907
  }, {
1897
- file: "notarization-plugin.ts",
1898
- line: 108,
1899
- scope: this,
1900
- callSite: (f, a) => f(...a)
1908
+ F: __dxlog_file8,
1909
+ L: 112,
1910
+ S: this,
1911
+ C: (f, a) => f(...a)
1901
1912
  });
1902
1913
  void ctx.dispose();
1903
1914
  errors.throw(new import_async7.TimeoutError(timeout, "Notarization timed out"));
@@ -1917,10 +1928,10 @@ var NotarizationPlugin = class {
1917
1928
  import_log8.log.warn("Exhausted all peers to notarize with", {
1918
1929
  retryIn: retryTimeout
1919
1930
  }, {
1920
- file: "notarization-plugin.ts",
1921
- line: 133,
1922
- scope: this,
1923
- callSite: (f, a) => f(...a)
1931
+ F: __dxlog_file8,
1932
+ L: 137,
1933
+ S: this,
1934
+ C: (f, a) => f(...a)
1924
1935
  });
1925
1936
  peersTried.clear();
1926
1937
  (0, import_async7.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
@@ -1931,28 +1942,28 @@ var NotarizationPlugin = class {
1931
1942
  peer: peer.localPeerId,
1932
1943
  credentialId: credentials.map((credential) => credential.id)
1933
1944
  }, {
1934
- file: "notarization-plugin.ts",
1935
- line: 140,
1936
- scope: this,
1937
- callSite: (f, a) => f(...a)
1945
+ F: __dxlog_file8,
1946
+ L: 144,
1947
+ S: this,
1948
+ C: (f, a) => f(...a)
1938
1949
  });
1939
1950
  await peer.rpc.NotarizationService.notarize({
1940
1951
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
1941
1952
  });
1942
- (0, import_log8.log)("success", {}, {
1943
- file: "notarization-plugin.ts",
1944
- line: 144,
1945
- scope: this,
1946
- callSite: (f, a) => f(...a)
1953
+ (0, import_log8.log)("success", void 0, {
1954
+ F: __dxlog_file8,
1955
+ L: 148,
1956
+ S: this,
1957
+ C: (f, a) => f(...a)
1947
1958
  });
1948
1959
  await (0, import_async7.sleep)(successDelay);
1949
1960
  } catch (err) {
1950
1961
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1951
1962
  import_log8.log.warn("error notarizing (recoverable)", err, {
1952
- file: "notarization-plugin.ts",
1953
- line: 148,
1954
- scope: this,
1955
- callSite: (f, a) => f(...a)
1963
+ F: __dxlog_file8,
1964
+ L: 152,
1965
+ S: this,
1966
+ C: (f, a) => f(...a)
1956
1967
  });
1957
1968
  }
1958
1969
  notarizeTask.schedule();
@@ -1966,11 +1977,11 @@ var NotarizationPlugin = class {
1966
1977
  allNotarized,
1967
1978
  errors.wait()
1968
1979
  ]);
1969
- (0, import_log8.log)("done", {}, {
1970
- file: "notarization-plugin.ts",
1971
- line: 159,
1972
- scope: this,
1973
- callSite: (f, a) => f(...a)
1980
+ (0, import_log8.log)("done", void 0, {
1981
+ F: __dxlog_file8,
1982
+ L: 163,
1983
+ S: this,
1984
+ C: (f, a) => f(...a)
1974
1985
  });
1975
1986
  } finally {
1976
1987
  await ctx.dispose();
@@ -1979,7 +1990,7 @@ var NotarizationPlugin = class {
1979
1990
  /**
1980
1991
  * Called with credentials arriving from the control pipeline.
1981
1992
  */
1982
- async process(credential) {
1993
+ async processCredential(credential) {
1983
1994
  var _a;
1984
1995
  if (!credential.id) {
1985
1996
  return;
@@ -1989,7 +2000,7 @@ var NotarizationPlugin = class {
1989
2000
  this._processCredentialsTriggers.delete(credential.id);
1990
2001
  }
1991
2002
  setWriter(writer) {
1992
- (0, import_node_assert9.default)(!this._writer, "Writer already set.");
2003
+ (0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
1993
2004
  this._writer = writer;
1994
2005
  }
1995
2006
  async _waitUntilProcessed(id) {
@@ -2007,7 +2018,7 @@ var NotarizationPlugin = class {
2007
2018
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2008
2019
  }
2009
2020
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2010
- (0, import_node_assert9.default)(credential.id, "Credential must have an id");
2021
+ (0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
2011
2022
  if (this._processedCredentials.has(credential.id)) {
2012
2023
  continue;
2013
2024
  }
@@ -2020,10 +2031,10 @@ var NotarizationPlugin = class {
2020
2031
  (0, import_log8.log)("extension opened", {
2021
2032
  peer: extension.localPeerId
2022
2033
  }, {
2023
- file: "notarization-plugin.ts",
2024
- line: 208,
2025
- scope: this,
2026
- callSite: (f, a) => f(...a)
2034
+ F: __dxlog_file8,
2035
+ L: 212,
2036
+ S: this,
2037
+ C: (f, a) => f(...a)
2027
2038
  });
2028
2039
  this._extensions.add(extension);
2029
2040
  this._extensionOpened.emit();
@@ -2032,10 +2043,10 @@ var NotarizationPlugin = class {
2032
2043
  (0, import_log8.log)("extension closed", {
2033
2044
  peer: extension.localPeerId
2034
2045
  }, {
2035
- file: "notarization-plugin.ts",
2036
- line: 213,
2037
- scope: this,
2038
- callSite: (f, a) => f(...a)
2046
+ F: __dxlog_file8,
2047
+ L: 217,
2048
+ S: this,
2049
+ C: (f, a) => f(...a)
2039
2050
  });
2040
2051
  this._extensions.delete(extension);
2041
2052
  },
@@ -2076,7 +2087,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2076
2087
  };
2077
2088
 
2078
2089
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2079
- var __decorate = function(decorators, target, key, desc) {
2090
+ function _ts_decorate(decorators, target, key, desc) {
2080
2091
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2081
2092
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2082
2093
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2085,10 +2096,12 @@ var __decorate = function(decorators, target, key, desc) {
2085
2096
  if (d = decorators[i])
2086
2097
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2087
2098
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2088
- };
2099
+ }
2100
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2089
2101
  var DataSpace = class DataSpace2 {
2090
2102
  constructor(params) {
2091
2103
  this._ctx = new import_context5.Context();
2104
+ this._notarizationPlugin = new NotarizationPlugin();
2092
2105
  this._state = import_services6.SpaceState.CLOSED;
2093
2106
  /**
2094
2107
  * Error for _state === SpaceState.ERROR.
@@ -2111,8 +2124,8 @@ var DataSpace = class DataSpace2 {
2111
2124
  update: this._inner.stateUpdate,
2112
2125
  authTimeout: import_client_protocol3.AUTH_TIMEOUT
2113
2126
  });
2114
- this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
2115
2127
  this._cache = params.cache;
2128
+ this._state = params.initialState;
2116
2129
  }
2117
2130
  get key() {
2118
2131
  return this._inner.key;
@@ -2134,25 +2147,36 @@ var DataSpace = class DataSpace2 {
2134
2147
  return this._presence;
2135
2148
  }
2136
2149
  get notarizationPlugin() {
2137
- return this._notarizationPluginConsumer.processor;
2150
+ return this._notarizationPlugin;
2138
2151
  }
2139
2152
  get cache() {
2140
2153
  return this._cache;
2141
2154
  }
2142
2155
  async open() {
2143
- await this.notarizationPlugin.open();
2144
- await this._notarizationPluginConsumer.open();
2156
+ await this._open();
2157
+ }
2158
+ async _open() {
2159
+ await this._notarizationPlugin.open();
2160
+ await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2145
2161
  await this._inner.open();
2146
- this._state = import_services6.SpaceState.INACTIVE;
2162
+ this._state = import_services6.SpaceState.CONTROL_ONLY;
2163
+ this.stateUpdate.emit();
2164
+ this.metrics = {};
2147
2165
  this.metrics.open = new Date();
2148
2166
  }
2149
2167
  async close() {
2168
+ await this._close();
2169
+ }
2170
+ async _close() {
2171
+ var _a, _b;
2172
+ await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2150
2173
  this._state = import_services6.SpaceState.CLOSED;
2151
2174
  await this._ctx.dispose();
2175
+ this._ctx = new import_context5.Context();
2152
2176
  await this.authVerifier.close();
2153
2177
  await this._inner.close();
2154
- await this._notarizationPluginConsumer.close();
2155
- await this.notarizationPlugin.close();
2178
+ await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
2179
+ await this._notarizationPlugin.close();
2156
2180
  await this._presence.destroy();
2157
2181
  }
2158
2182
  async postMessage(channel, message) {
@@ -2172,18 +2196,18 @@ var DataSpace = class DataSpace2 {
2172
2196
  } catch (err) {
2173
2197
  if (err instanceof import_errors3.CancelledError) {
2174
2198
  (0, import_log9.log)("Data pipeline initialization cancelled", err, {
2175
- file: "data-space.ts",
2176
- line: 173,
2177
- scope: this,
2178
- callSite: (f, a) => f(...a)
2199
+ F: __dxlog_file9,
2200
+ L: 193,
2201
+ S: this,
2202
+ C: (f, a) => f(...a)
2179
2203
  });
2180
2204
  return;
2181
2205
  }
2182
2206
  import_log9.log.error("Error initializing data pipeline", err, {
2183
- file: "data-space.ts",
2184
- line: 177,
2185
- scope: this,
2186
- callSite: (f, a) => f(...a)
2207
+ F: __dxlog_file9,
2208
+ L: 197,
2209
+ S: this,
2210
+ C: (f, a) => f(...a)
2187
2211
  });
2188
2212
  this._state = import_services6.SpaceState.ERROR;
2189
2213
  this.error = err;
@@ -2195,7 +2219,7 @@ var DataSpace = class DataSpace2 {
2195
2219
  }
2196
2220
  async initializeDataPipeline() {
2197
2221
  var _a, _b, _c, _d;
2198
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2222
+ if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
2199
2223
  throw new import_errors3.SystemError("Invalid operation");
2200
2224
  }
2201
2225
  this._state = import_services6.SpaceState.INITIALIZING;
@@ -2205,37 +2229,39 @@ var DataSpace = class DataSpace2 {
2205
2229
  });
2206
2230
  this.metrics.controlPipelineReady = new Date();
2207
2231
  await this._createWritableFeeds();
2208
- (0, import_log9.log)("Writable feeds created", {}, {
2209
- file: "data-space.ts",
2210
- line: 201,
2211
- scope: this,
2212
- callSite: (f, a) => f(...a)
2232
+ (0, import_log9.log)("Writable feeds created", void 0, {
2233
+ F: __dxlog_file9,
2234
+ L: 221,
2235
+ S: this,
2236
+ C: (f, a) => f(...a)
2213
2237
  });
2214
2238
  this.stateUpdate.emit();
2215
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2216
- credential: {
2217
- credential
2218
- }
2219
- }), this._inner.controlPipeline.writer));
2239
+ if (!this.notarizationPlugin.hasWriter) {
2240
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2241
+ credential: {
2242
+ credential
2243
+ }
2244
+ }), this._inner.controlPipeline.writer));
2245
+ }
2220
2246
  await this._inner.initializeDataPipeline();
2221
2247
  this.metrics.dataPipelineOpen = new Date();
2222
2248
  await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2223
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
2224
- file: "data-space.ts",
2225
- line: 220,
2226
- scope: this,
2227
- callSite: (f, a) => f(...a)
2249
+ (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2250
+ F: __dxlog_file9,
2251
+ L: 242,
2252
+ S: this,
2253
+ C: (f, a) => f(...a)
2228
2254
  });
2229
2255
  await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
2230
2256
  ctx: this._ctx,
2231
2257
  breakOnStall: false
2232
2258
  });
2233
2259
  this.metrics.dataPipelineReady = new Date();
2234
- (0, import_log9.log)("data pipeline ready", {}, {
2235
- file: "data-space.ts",
2236
- line: 229,
2237
- scope: this,
2238
- callSite: (f, a) => f(...a)
2260
+ (0, import_log9.log)("data pipeline ready", void 0, {
2261
+ F: __dxlog_file9,
2262
+ L: 251,
2263
+ S: this,
2264
+ C: (f, a) => f(...a)
2239
2265
  });
2240
2266
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2241
2267
  this._state = import_services6.SpaceState.READY;
@@ -2313,11 +2339,40 @@ var DataSpace = class DataSpace2 {
2313
2339
  }
2314
2340
  }
2315
2341
  }
2342
+ async activate() {
2343
+ if (this._state !== import_services6.SpaceState.INACTIVE) {
2344
+ throw new import_errors3.SystemError("Invalid operation");
2345
+ }
2346
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
2347
+ await this._open();
2348
+ this.initializeDataPipelineAsync();
2349
+ }
2350
+ async deactivate() {
2351
+ if (this._state === import_services6.SpaceState.INACTIVE) {
2352
+ throw new import_errors3.SystemError("Invalid operation");
2353
+ }
2354
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
2355
+ await this._close();
2356
+ this._state = import_services6.SpaceState.INACTIVE;
2357
+ this.stateUpdate.emit();
2358
+ }
2316
2359
  };
2317
- __decorate([
2360
+ _ts_decorate([
2361
+ import_async8.synchronized
2362
+ ], DataSpace.prototype, "open", null);
2363
+ _ts_decorate([
2364
+ import_async8.synchronized
2365
+ ], DataSpace.prototype, "close", null);
2366
+ _ts_decorate([
2318
2367
  (0, import_debug3.timed)(1e4)
2319
2368
  ], DataSpace.prototype, "_createWritableFeeds", null);
2320
- DataSpace = __decorate([
2369
+ _ts_decorate([
2370
+ import_async8.synchronized
2371
+ ], DataSpace.prototype, "activate", null);
2372
+ _ts_decorate([
2373
+ import_async8.synchronized
2374
+ ], DataSpace.prototype, "deactivate", null);
2375
+ DataSpace = _ts_decorate([
2321
2376
  (0, import_async8.trackLeaks)("open", "close")
2322
2377
  ], DataSpace);
2323
2378
 
@@ -2392,7 +2447,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2392
2447
  };
2393
2448
 
2394
2449
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2395
- var __decorate2 = function(decorators, target, key, desc) {
2450
+ function _ts_decorate2(decorators, target, key, desc) {
2396
2451
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2397
2452
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2398
2453
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2401,7 +2456,8 @@ var __decorate2 = function(decorators, target, key, desc) {
2401
2456
  if (d = decorators[i])
2402
2457
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2403
2458
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2404
- };
2459
+ }
2460
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2405
2461
  var DataSpaceManager = class DataSpaceManager2 {
2406
2462
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2407
2463
  this._spaceManager = _spaceManager;
@@ -2421,50 +2477,52 @@ var DataSpaceManager = class DataSpaceManager2 {
2421
2477
  return this._spaces;
2422
2478
  }
2423
2479
  async open() {
2424
- (0, import_log10.log)("open", {}, {
2425
- file: "data-space-manager.ts",
2426
- line: 80,
2427
- scope: this,
2428
- callSite: (f, a) => f(...a)
2480
+ (0, import_log10.log)("open", void 0, {
2481
+ F: __dxlog_file10,
2482
+ L: 80,
2483
+ S: this,
2484
+ C: (f, a) => f(...a)
2429
2485
  });
2430
2486
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2431
2487
  id: this._instanceId
2432
2488
  }), {
2433
- file: "data-space-manager.ts",
2434
- line: 81,
2435
- scope: this,
2436
- callSite: (f, a) => f(...a)
2489
+ F: __dxlog_file10,
2490
+ L: 81,
2491
+ S: this,
2492
+ C: (f, a) => f(...a)
2437
2493
  });
2438
2494
  await this._metadataStore.load();
2439
2495
  (0, import_log10.log)("metadata loaded", {
2440
2496
  spaces: this._metadataStore.spaces.length
2441
2497
  }, {
2442
- file: "data-space-manager.ts",
2443
- line: 83,
2444
- scope: this,
2445
- callSite: (f, a) => f(...a)
2498
+ F: __dxlog_file10,
2499
+ L: 83,
2500
+ S: this,
2501
+ C: (f, a) => f(...a)
2446
2502
  });
2447
2503
  for (const spaceMetadata of this._metadataStore.spaces) {
2448
2504
  try {
2449
2505
  (0, import_log10.log)("load space", {
2450
2506
  spaceMetadata
2451
2507
  }, {
2452
- file: "data-space-manager.ts",
2453
- line: 87,
2454
- scope: this,
2455
- callSite: (f, a) => f(...a)
2508
+ F: __dxlog_file10,
2509
+ L: 87,
2510
+ S: this,
2511
+ C: (f, a) => f(...a)
2456
2512
  });
2457
2513
  const space = await this._constructSpace(spaceMetadata);
2458
- space.initializeDataPipelineAsync();
2514
+ if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
2515
+ space.initializeDataPipelineAsync();
2516
+ }
2459
2517
  } catch (err) {
2460
2518
  import_log10.log.error("Error loading space", {
2461
2519
  spaceMetadata,
2462
2520
  err
2463
2521
  }, {
2464
- file: "data-space-manager.ts",
2465
- line: 91,
2466
- scope: this,
2467
- callSite: (f, a) => f(...a)
2522
+ F: __dxlog_file10,
2523
+ L: 93,
2524
+ S: this,
2525
+ C: (f, a) => f(...a)
2468
2526
  });
2469
2527
  }
2470
2528
  }
@@ -2473,18 +2531,18 @@ var DataSpaceManager = class DataSpaceManager2 {
2473
2531
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2474
2532
  id: this._instanceId
2475
2533
  }), {
2476
- file: "data-space-manager.ts",
2477
- line: 97,
2478
- scope: this,
2479
- callSite: (f, a) => f(...a)
2534
+ F: __dxlog_file10,
2535
+ L: 99,
2536
+ S: this,
2537
+ C: (f, a) => f(...a)
2480
2538
  });
2481
2539
  }
2482
2540
  async close() {
2483
- (0, import_log10.log)("close", {}, {
2484
- file: "data-space-manager.ts",
2485
- line: 102,
2486
- scope: this,
2487
- callSite: (f, a) => f(...a)
2541
+ (0, import_log10.log)("close", void 0, {
2542
+ F: __dxlog_file10,
2543
+ L: 104,
2544
+ S: this,
2545
+ C: (f, a) => f(...a)
2488
2546
  });
2489
2547
  this._isOpen = false;
2490
2548
  await this._ctx.dispose();
@@ -2496,7 +2554,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2496
2554
  * Creates a new space writing the genesis credentials to the control feed.
2497
2555
  */
2498
2556
  async createSpace() {
2499
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2557
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2500
2558
  const spaceKey = await this._keyring.createKey();
2501
2559
  const controlFeedKey = await this._keyring.createKey();
2502
2560
  const dataFeedKey = await this._keyring.createKey();
@@ -2504,21 +2562,22 @@ var DataSpaceManager = class DataSpaceManager2 {
2504
2562
  key: spaceKey,
2505
2563
  genesisFeedKey: controlFeedKey,
2506
2564
  controlFeedKey,
2507
- dataFeedKey
2565
+ dataFeedKey,
2566
+ state: import_services7.SpaceState.ACTIVE
2508
2567
  };
2509
2568
  (0, import_log10.log)("creating space...", {
2510
2569
  spaceKey
2511
2570
  }, {
2512
- file: "data-space-manager.ts",
2513
- line: 126,
2514
- scope: this,
2515
- callSite: (f, a) => f(...a)
2571
+ F: __dxlog_file10,
2572
+ L: 129,
2573
+ S: this,
2574
+ C: (f, a) => f(...a)
2516
2575
  });
2517
2576
  const space = await this._constructSpace(metadata);
2518
2577
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2519
2578
  await this._metadataStore.addSpace(metadata);
2520
2579
  const memberCredential = credentials[1];
2521
- (0, import_node_assert10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2580
+ (0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2522
2581
  await this._signingContext.recordCredential(memberCredential);
2523
2582
  await space.initializeDataPipeline();
2524
2583
  this.updated.emit();
@@ -2529,13 +2588,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2529
2588
  (0, import_log10.log)("accept space", {
2530
2589
  opts
2531
2590
  }, {
2532
- file: "data-space-manager.ts",
2533
- line: 145,
2534
- scope: this,
2535
- callSite: (f, a) => f(...a)
2591
+ F: __dxlog_file10,
2592
+ L: 148,
2593
+ S: this,
2594
+ C: (f, a) => f(...a)
2536
2595
  });
2537
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2538
- (0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2596
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2597
+ (0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2539
2598
  const metadata = {
2540
2599
  key: opts.spaceKey,
2541
2600
  genesisFeedKey: opts.genesisFeedKey,
@@ -2563,10 +2622,10 @@ var DataSpaceManager = class DataSpaceManager2 {
2563
2622
  (0, import_log10.log)("construct space", {
2564
2623
  metadata
2565
2624
  }, {
2566
- file: "data-space-manager.ts",
2567
- line: 181,
2568
- scope: this,
2569
- callSite: (f, a) => f(...a)
2625
+ F: __dxlog_file10,
2626
+ L: 183,
2627
+ S: this,
2628
+ C: (f, a) => f(...a)
2570
2629
  });
2571
2630
  const gossip = new import_teleport_extension_gossip.Gossip({
2572
2631
  localPeerId: this._signingContext.deviceKey
@@ -2598,11 +2657,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2598
2657
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2599
2658
  },
2600
2659
  onAuthFailure: () => {
2601
- import_log10.log.warn("auth failure", {}, {
2602
- file: "data-space-manager.ts",
2603
- line: 212,
2604
- scope: this,
2605
- callSite: (f, a) => f(...a)
2660
+ import_log10.log.warn("auth failure", void 0, {
2661
+ F: __dxlog_file10,
2662
+ L: 214,
2663
+ S: this,
2664
+ C: (f, a) => f(...a)
2606
2665
  });
2607
2666
  },
2608
2667
  memberKey: this._signingContext.identityKey
@@ -2611,6 +2670,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2611
2670
  dataFeed && space.setDataFeed(dataFeed);
2612
2671
  const dataSpace = new DataSpace({
2613
2672
  inner: space,
2673
+ initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
2614
2674
  metadataStore: this._metadataStore,
2615
2675
  gossip,
2616
2676
  presence,
@@ -2622,31 +2682,44 @@ var DataSpaceManager = class DataSpaceManager2 {
2622
2682
  (0, import_log10.log)("before space ready", {
2623
2683
  space: space.key
2624
2684
  }, {
2625
- file: "data-space-manager.ts",
2626
- line: 229,
2627
- scope: this,
2628
- callSite: (f, a) => f(...a)
2685
+ F: __dxlog_file10,
2686
+ L: 232,
2687
+ S: this,
2688
+ C: (f, a) => f(...a)
2629
2689
  });
2630
- this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2690
+ await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2631
2691
  },
2632
2692
  afterReady: async () => {
2633
2693
  (0, import_log10.log)("after space ready", {
2634
2694
  space: space.key,
2635
2695
  open: this._isOpen
2636
2696
  }, {
2637
- file: "data-space-manager.ts",
2638
- line: 236,
2639
- scope: this,
2640
- callSite: (f, a) => f(...a)
2697
+ F: __dxlog_file10,
2698
+ L: 239,
2699
+ S: this,
2700
+ C: (f, a) => f(...a)
2641
2701
  });
2642
2702
  if (this._isOpen) {
2643
2703
  this.updated.emit();
2644
2704
  }
2705
+ },
2706
+ beforeClose: async () => {
2707
+ (0, import_log10.log)("before space close", {
2708
+ space: space.key
2709
+ }, {
2710
+ F: __dxlog_file10,
2711
+ L: 245,
2712
+ S: this,
2713
+ C: (f, a) => f(...a)
2714
+ });
2715
+ await this._dataServiceSubscriptions.unregisterSpace(space.key);
2645
2716
  }
2646
2717
  },
2647
2718
  cache: metadata.cache
2648
2719
  });
2649
- await dataSpace.open();
2720
+ if (metadata.state !== import_services7.SpaceState.INACTIVE) {
2721
+ await dataSpace.open();
2722
+ }
2650
2723
  if (metadata.controlTimeframe) {
2651
2724
  dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
2652
2725
  }
@@ -2657,19 +2730,19 @@ var DataSpaceManager = class DataSpaceManager2 {
2657
2730
  return dataSpace;
2658
2731
  }
2659
2732
  };
2660
- __decorate2([
2733
+ _ts_decorate2([
2661
2734
  import_async9.synchronized
2662
2735
  ], DataSpaceManager.prototype, "open", null);
2663
- __decorate2([
2736
+ _ts_decorate2([
2664
2737
  import_async9.synchronized
2665
2738
  ], DataSpaceManager.prototype, "close", null);
2666
- __decorate2([
2739
+ _ts_decorate2([
2667
2740
  import_async9.synchronized
2668
2741
  ], DataSpaceManager.prototype, "createSpace", null);
2669
- __decorate2([
2742
+ _ts_decorate2([
2670
2743
  import_async9.synchronized
2671
2744
  ], DataSpaceManager.prototype, "acceptSpace", null);
2672
- DataSpaceManager = __decorate2([
2745
+ DataSpaceManager = _ts_decorate2([
2673
2746
  (0, import_async9.trackLeaks)("open", "close")
2674
2747
  ], DataSpaceManager);
2675
2748
 
@@ -2678,11 +2751,12 @@ var import_async10 = require("@dxos/async");
2678
2751
  var import_codec_protobuf3 = require("@dxos/codec-protobuf");
2679
2752
  var import_debug5 = require("@dxos/debug");
2680
2753
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
2754
+ var import_errors4 = require("@dxos/errors");
2681
2755
  var import_log11 = require("@dxos/log");
2682
2756
  var import_protocols7 = require("@dxos/protocols");
2683
2757
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2684
2758
  var import_util5 = require("@dxos/util");
2685
- var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
2759
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2686
2760
  var SpacesServiceImpl = class {
2687
2761
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
2688
2762
  this._identityManager = _identityManager;
@@ -2696,28 +2770,44 @@ var SpacesServiceImpl = class {
2696
2770
  }
2697
2771
  const dataSpaceManager = await this._getDataSpaceManager();
2698
2772
  const space = await dataSpaceManager.createSpace();
2699
- return this._transformSpace(space);
2773
+ return this._serializeSpace(space);
2700
2774
  }
2701
- async updateSpace(request) {
2702
- (0, import_debug5.todo)();
2775
+ async updateSpace({ spaceKey, state }) {
2776
+ var _a;
2777
+ const dataSpaceManager = await this._getDataSpaceManager();
2778
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
2779
+ if (state) {
2780
+ switch (state) {
2781
+ case import_services8.SpaceState.ACTIVE:
2782
+ await space.activate();
2783
+ break;
2784
+ case import_services8.SpaceState.INACTIVE:
2785
+ await space.deactivate();
2786
+ break;
2787
+ default:
2788
+ throw new import_errors4.ApiError("Invalid space state");
2789
+ }
2790
+ }
2703
2791
  }
2704
2792
  querySpaces() {
2705
2793
  return new import_codec_protobuf3.Stream(({ next, ctx }) => {
2706
- const onUpdate = async () => {
2794
+ const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
2707
2795
  const dataSpaceManager = await this._getDataSpaceManager();
2708
- const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
2796
+ const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2709
2797
  (0, import_log11.log)("update", {
2710
2798
  spaces
2711
2799
  }, {
2712
- file: "spaces-service.ts",
2713
- line: 60,
2714
- scope: this,
2715
- callSite: (f, a) => f(...a)
2800
+ F: __dxlog_file11,
2801
+ L: 78,
2802
+ S: this,
2803
+ C: (f, a) => f(...a)
2716
2804
  });
2717
2805
  next({
2718
2806
  spaces
2719
2807
  });
2720
- };
2808
+ }, {
2809
+ maxFrequency: 2
2810
+ });
2721
2811
  (0, import_async10.scheduleTask)(ctx, async () => {
2722
2812
  const dataSpaceManager = await this._getDataSpaceManager();
2723
2813
  const subscriptions = new import_async10.EventSubscriptions();
@@ -2725,21 +2815,21 @@ var SpacesServiceImpl = class {
2725
2815
  const subscribeSpaces = () => {
2726
2816
  subscriptions.clear();
2727
2817
  for (const space of dataSpaceManager.spaces.values()) {
2728
- subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
2729
- subscriptions.add(space.presence.updated.on(ctx, onUpdate));
2730
- subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, onUpdate));
2731
- space.inner.controlPipeline.state.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate);
2818
+ subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
2819
+ subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
2820
+ subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
2821
+ space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
2732
2822
  if (space.dataPipeline.pipelineState) {
2733
- subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate));
2823
+ subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
2734
2824
  }
2735
2825
  }
2736
2826
  };
2737
2827
  dataSpaceManager.updated.on(ctx, () => {
2738
2828
  subscribeSpaces();
2739
- void onUpdate();
2829
+ scheduler.trigger();
2740
2830
  });
2741
2831
  subscribeSpaces();
2742
- void onUpdate();
2832
+ scheduler.trigger();
2743
2833
  });
2744
2834
  if (!this._identityManager.identity) {
2745
2835
  next({
@@ -2771,13 +2861,13 @@ var SpacesServiceImpl = class {
2771
2861
  return new import_codec_protobuf3.Stream(({ ctx, next }) => {
2772
2862
  var _a;
2773
2863
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
2774
- const processor = space.spaceState.registerProcessor({
2775
- process: async (credential) => {
2864
+ const processor = {
2865
+ processCredential: async (credential) => {
2776
2866
  next(credential);
2777
2867
  }
2778
- });
2779
- ctx.onDispose(() => processor.close());
2780
- (0, import_async10.scheduleTask)(ctx, () => processor.open());
2868
+ };
2869
+ ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
2870
+ (0, import_async10.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
2781
2871
  });
2782
2872
  }
2783
2873
  async writeCredentials({ spaceKey, credentials }) {
@@ -2797,7 +2887,7 @@ var SpacesServiceImpl = class {
2797
2887
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
2798
2888
  await space.createEpoch();
2799
2889
  }
2800
- _transformSpace(space) {
2890
+ _serializeSpace(space) {
2801
2891
  var _a, _b, _c, _d, _e, _f, _g;
2802
2892
  return {
2803
2893
  spaceKey: space.key,
@@ -2837,6 +2927,7 @@ var SpacesServiceImpl = class {
2837
2927
  var getChannelId = (channel) => `user-channel/${channel}`;
2838
2928
 
2839
2929
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2930
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
2840
2931
  var ServiceContext = class {
2841
2932
  // prettier-ignore
2842
2933
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -2880,17 +2971,17 @@ var ServiceContext = class {
2880
2971
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
2881
2972
  id: this._instanceId
2882
2973
  }), {
2883
- file: "service-context.ts",
2884
- line: 126,
2885
- scope: this,
2886
- callSite: (f, a) => f(...a)
2974
+ F: __dxlog_file12,
2975
+ L: 126,
2976
+ S: this,
2977
+ C: (f, a) => f(...a)
2887
2978
  });
2888
2979
  await this._checkStorageVersion();
2889
- (0, import_log12.log)("opening...", {}, {
2890
- file: "service-context.ts",
2891
- line: 130,
2892
- scope: this,
2893
- callSite: (f, a) => f(...a)
2980
+ (0, import_log12.log)("opening...", void 0, {
2981
+ F: __dxlog_file12,
2982
+ L: 130,
2983
+ S: this,
2984
+ C: (f, a) => f(...a)
2894
2985
  });
2895
2986
  await this.signalManager.open();
2896
2987
  await this.networkManager.open();
@@ -2899,42 +2990,44 @@ var ServiceContext = class {
2899
2990
  if (this.identityManager.identity) {
2900
2991
  await this._initialize();
2901
2992
  }
2902
- (0, import_log12.log)("opened", {}, {
2903
- file: "service-context.ts",
2904
- line: 138,
2905
- scope: this,
2906
- callSite: (f, a) => f(...a)
2993
+ (0, import_log12.log)("opened", void 0, {
2994
+ F: __dxlog_file12,
2995
+ L: 138,
2996
+ S: this,
2997
+ C: (f, a) => f(...a)
2907
2998
  });
2908
2999
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
2909
3000
  id: this._instanceId
2910
3001
  }), {
2911
- file: "service-context.ts",
2912
- line: 139,
2913
- scope: this,
2914
- callSite: (f, a) => f(...a)
3002
+ F: __dxlog_file12,
3003
+ L: 139,
3004
+ S: this,
3005
+ C: (f, a) => f(...a)
2915
3006
  });
2916
3007
  }
2917
3008
  async close() {
2918
- var _a, _b;
2919
- (0, import_log12.log)("closing...", {}, {
2920
- file: "service-context.ts",
2921
- line: 143,
2922
- scope: this,
2923
- callSite: (f, a) => f(...a)
3009
+ var _a;
3010
+ (0, import_log12.log)("closing...", void 0, {
3011
+ F: __dxlog_file12,
3012
+ L: 143,
3013
+ S: this,
3014
+ C: (f, a) => f(...a)
2924
3015
  });
2925
- await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
2926
- await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
3016
+ if (this._deviceSpaceSync && this.identityManager.identity) {
3017
+ await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
3018
+ }
3019
+ await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
2927
3020
  await this.identityManager.close();
2928
3021
  await this.spaceManager.close();
2929
3022
  await this.feedStore.close();
2930
3023
  await this.networkManager.close();
2931
3024
  await this.signalManager.close();
2932
3025
  this.dataServiceSubscriptions.clear();
2933
- (0, import_log12.log)("closed", {}, {
2934
- file: "service-context.ts",
2935
- line: 152,
2936
- scope: this,
2937
- callSite: (f, a) => f(...a)
3026
+ (0, import_log12.log)("closed", void 0, {
3027
+ F: __dxlog_file12,
3028
+ L: 154,
3029
+ S: this,
3030
+ C: (f, a) => f(...a)
2938
3031
  });
2939
3032
  }
2940
3033
  async createIdentity(params = {}) {
@@ -2944,7 +3037,7 @@ var ServiceContext = class {
2944
3037
  }
2945
3038
  getInvitationHandler(invitation) {
2946
3039
  const factory = this._handlerFactories.get(invitation.kind);
2947
- (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3040
+ (0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
2948
3041
  return factory(invitation);
2949
3042
  }
2950
3043
  async _acceptIdentity(params) {
@@ -2961,11 +3054,11 @@ var ServiceContext = class {
2961
3054
  // Called when identity is created.
2962
3055
  async _initialize() {
2963
3056
  var _a;
2964
- (0, import_log12.log)("initializing spaces...", {}, {
2965
- file: "service-context.ts",
2966
- line: 185,
2967
- scope: this,
2968
- callSite: (f, a) => f(...a)
3057
+ (0, import_log12.log)("initializing spaces...", void 0, {
3058
+ F: __dxlog_file12,
3059
+ L: 187,
3060
+ S: this,
3061
+ C: (f, a) => f(...a)
2969
3062
  });
2970
3063
  const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
2971
3064
  const signingContext = {
@@ -2984,12 +3077,12 @@ var ServiceContext = class {
2984
3077
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
2985
3078
  await this.dataSpaceManager.open();
2986
3079
  this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
2987
- (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3080
+ (0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
2988
3081
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
2989
3082
  });
2990
3083
  this.initialized.wake();
2991
- this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
2992
- process: async (credential) => {
3084
+ this._deviceSpaceSync = {
3085
+ processCredential: async (credential) => {
2993
3086
  const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
2994
3087
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
2995
3088
  return;
@@ -3001,10 +3094,10 @@ var ServiceContext = class {
3001
3094
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3002
3095
  details: assertion
3003
3096
  }, {
3004
- file: "service-context.ts",
3005
- line: 224,
3006
- scope: this,
3007
- callSite: (f, a) => f(...a)
3097
+ F: __dxlog_file12,
3098
+ L: 226,
3099
+ S: this,
3100
+ C: (f, a) => f(...a)
3008
3101
  });
3009
3102
  return;
3010
3103
  }
@@ -3012,10 +3105,10 @@ var ServiceContext = class {
3012
3105
  (0, import_log12.log)("space already exists, ignoring space admission", {
3013
3106
  details: assertion
3014
3107
  }, {
3015
- file: "service-context.ts",
3016
- line: 228,
3017
- scope: this,
3018
- callSite: (f, a) => f(...a)
3108
+ F: __dxlog_file12,
3109
+ L: 230,
3110
+ S: this,
3111
+ C: (f, a) => f(...a)
3019
3112
  });
3020
3113
  return;
3021
3114
  }
@@ -3023,40 +3116,43 @@ var ServiceContext = class {
3023
3116
  (0, import_log12.log)("accepting space recorded in halo", {
3024
3117
  details: assertion
3025
3118
  }, {
3026
- file: "service-context.ts",
3027
- line: 233,
3028
- scope: this,
3029
- callSite: (f, a) => f(...a)
3119
+ F: __dxlog_file12,
3120
+ L: 235,
3121
+ S: this,
3122
+ C: (f, a) => f(...a)
3030
3123
  });
3031
3124
  await this.dataSpaceManager.acceptSpace({
3032
3125
  spaceKey: assertion.spaceKey,
3033
3126
  genesisFeedKey: assertion.genesisFeedKey
3034
3127
  });
3035
3128
  } catch (err) {
3036
- import_log12.log.catch(err, {}, {
3037
- file: "service-context.ts",
3038
- line: 239,
3039
- scope: this,
3040
- callSite: (f, a) => f(...a)
3129
+ import_log12.log.catch(err, void 0, {
3130
+ F: __dxlog_file12,
3131
+ L: 241,
3132
+ S: this,
3133
+ C: (f, a) => f(...a)
3041
3134
  });
3042
3135
  }
3043
3136
  }
3044
- });
3045
- await this._deviceSpaceSync.open();
3137
+ };
3138
+ await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3046
3139
  }
3047
3140
  };
3048
3141
 
3049
3142
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3050
- var import_node_assert13 = __toESM(require("node:assert"));
3143
+ var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
3051
3144
  var import_async17 = require("@dxos/async");
3052
3145
  var import_client_protocol5 = require("@dxos/client-protocol");
3146
+ var import_document_model = require("@dxos/document-model");
3053
3147
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3054
3148
  var import_keys12 = require("@dxos/keys");
3055
3149
  var import_log15 = require("@dxos/log");
3056
3150
  var import_messaging = require("@dxos/messaging");
3151
+ var import_model_factory = require("@dxos/model-factory");
3057
3152
  var import_network_manager2 = require("@dxos/network-manager");
3058
3153
  var import_protocols9 = require("@dxos/protocols");
3059
3154
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3155
+ var import_text_model = require("@dxos/text-model");
3060
3156
 
3061
3157
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3062
3158
  var import_async12 = require("@dxos/async");
@@ -3320,8 +3416,10 @@ var DevtoolsServiceImpl = class {
3320
3416
  });
3321
3417
  });
3322
3418
  }
3323
- getConfig(request) {
3324
- throw new Error();
3419
+ async getConfig(request) {
3420
+ return {
3421
+ config: JSON.stringify(this.params.config.values)
3422
+ };
3325
3423
  }
3326
3424
  async getStorageInfo() {
3327
3425
  var _a, _b, _c, _d, _e;
@@ -3417,10 +3515,10 @@ var DevtoolsServiceImpl = class {
3417
3515
  };
3418
3516
 
3419
3517
  // packages/sdk/client-services/src/packlets/locks/node.ts
3420
- var import_node_assert12 = __toESM(require("node:assert"));
3518
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
3421
3519
  var import_lock_file = require("@dxos/lock-file");
3422
3520
  var import_log13 = require("@dxos/log");
3423
- var __decorate3 = function(decorators, target, key, desc) {
3521
+ function _ts_decorate3(decorators, target, key, desc) {
3424
3522
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3425
3523
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3426
3524
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3429,7 +3527,8 @@ var __decorate3 = function(decorators, target, key, desc) {
3429
3527
  if (d = decorators[i])
3430
3528
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3431
3529
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3432
- };
3530
+ }
3531
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3433
3532
  var Lock = class {
3434
3533
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3435
3534
  this._lockPath = lockPath;
@@ -3441,29 +3540,29 @@ var Lock = class {
3441
3540
  }
3442
3541
  async acquire() {
3443
3542
  var _a;
3444
- (0, import_log13.log)("acquiring lock...", {}, {
3445
- file: "node.ts",
3446
- line: 32,
3447
- scope: this,
3448
- callSite: (f, a) => f(...a)
3543
+ (0, import_log13.log)("acquiring lock...", void 0, {
3544
+ F: __dxlog_file13,
3545
+ L: 32,
3546
+ S: this,
3547
+ C: (f, a) => f(...a)
3449
3548
  });
3450
3549
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3451
3550
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3452
- (0, import_log13.log)("acquired lock", {}, {
3453
- file: "node.ts",
3454
- line: 37,
3455
- scope: this,
3456
- callSite: (f, a) => f(...a)
3551
+ (0, import_log13.log)("acquired lock", void 0, {
3552
+ F: __dxlog_file13,
3553
+ L: 37,
3554
+ S: this,
3555
+ C: (f, a) => f(...a)
3457
3556
  });
3458
3557
  }
3459
3558
  async release() {
3460
3559
  var _a;
3461
3560
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3462
- (0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
3561
+ (0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
3463
3562
  await import_lock_file.LockFile.release(this._fileHandle);
3464
3563
  }
3465
3564
  };
3466
- __decorate3([
3565
+ _ts_decorate3([
3467
3566
  import_log13.logInfo
3468
3567
  ], Lock.prototype, "lockKey", null);
3469
3568
 
@@ -3494,7 +3593,7 @@ var LoggingServiceImpl = class {
3494
3593
  if (LOG_PROCESSING > 0) {
3495
3594
  return;
3496
3595
  }
3497
- if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3596
+ if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3498
3597
  return;
3499
3598
  }
3500
3599
  if (!shouldLog(entry2, request)) {
@@ -3506,8 +3605,8 @@ var LoggingServiceImpl = class {
3506
3605
  timestamp: new Date(),
3507
3606
  meta: {
3508
3607
  // TODO(dmaretskyi): Fix proto.
3509
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
3510
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
3608
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
3609
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
3511
3610
  }
3512
3611
  };
3513
3612
  try {
@@ -3537,7 +3636,7 @@ var shouldLog = (entry2, request) => {
3537
3636
  } else {
3538
3637
  return request.filters.some((filter) => {
3539
3638
  var _a2, _b;
3540
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
3639
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
3541
3640
  });
3542
3641
  }
3543
3642
  };
@@ -3577,7 +3676,7 @@ var NetworkServiceImpl = class {
3577
3676
 
3578
3677
  // packages/sdk/client-services/src/packlets/storage/storage.ts
3579
3678
  var import_client_protocol4 = require("@dxos/client-protocol");
3580
- var import_errors4 = require("@dxos/errors");
3679
+ var import_errors5 = require("@dxos/errors");
3581
3680
  var import_config = require("@dxos/protocols/proto/dxos/config");
3582
3681
  var import_random_access_storage = require("@dxos/random-access-storage");
3583
3682
  var import_util8 = require("@dxos/util");
@@ -3585,16 +3684,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
3585
3684
  var createStorageObjects = (config) => {
3586
3685
  const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
3587
3686
  if (persistent && storageType === StorageDriver.RAM) {
3588
- throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3687
+ throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3589
3688
  }
3590
3689
  if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
3591
- throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3690
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3592
3691
  }
3593
3692
  if (persistent && keyStorage === StorageDriver.RAM) {
3594
- throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3693
+ throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3595
3694
  }
3596
3695
  if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
3597
- throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3696
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3598
3697
  }
3599
3698
  return {
3600
3699
  storage: (0, import_random_access_storage.createStorage)({
@@ -3687,23 +3786,39 @@ var ServiceRegistry = class {
3687
3786
  };
3688
3787
 
3689
3788
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3789
+ function _ts_decorate4(decorators, target, key, desc) {
3790
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3791
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3792
+ r = Reflect.decorate(decorators, target, key, desc);
3793
+ else
3794
+ for (var i = decorators.length - 1; i >= 0; i--)
3795
+ if (d = decorators[i])
3796
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3797
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3798
+ }
3799
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3800
+ var createDefaultModelFactory = () => {
3801
+ return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
3802
+ };
3690
3803
  var ClientServicesHost = class {
3691
3804
  constructor({
3692
3805
  config,
3693
- modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
3806
+ modelFactory = createDefaultModelFactory(),
3694
3807
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3695
3808
  transportFactory,
3696
3809
  signalManager,
3697
3810
  connectionLog,
3698
3811
  storage,
3699
3812
  // TODO(wittjosiah): Turn this on by default.
3700
- lockKey
3813
+ lockKey,
3814
+ callbacks
3701
3815
  } = {}) {
3702
3816
  this._statusUpdate = new import_async17.Event();
3703
3817
  this._opening = false;
3704
3818
  this._open = false;
3705
3819
  this._storage = storage;
3706
3820
  this._modelFactory = modelFactory;
3821
+ this._callbacks = callbacks;
3707
3822
  if (config) {
3708
3823
  this.initialize({
3709
3824
  config,
@@ -3762,9 +3877,9 @@ var ClientServicesHost = class {
3762
3877
  */
3763
3878
  initialize({ config, ...options }) {
3764
3879
  var _a, _b, _c;
3765
- (0, import_node_assert13.default)(!this._open, "service host is open");
3880
+ (0, import_tiny_invariant13.default)(!this._open, "service host is open");
3766
3881
  if (config) {
3767
- (0, import_node_assert13.default)(!this._config, "config already set");
3882
+ (0, import_tiny_invariant13.default)(!this._config, "config already set");
3768
3883
  this._config = config;
3769
3884
  if (!this._storage) {
3770
3885
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -3774,7 +3889,7 @@ var ClientServicesHost = class {
3774
3889
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
3775
3890
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3776
3891
  this._signalManager = signalManager;
3777
- (0, import_node_assert13.default)(!this._networkManager, "network manager already set");
3892
+ (0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
3778
3893
  this._networkManager = new import_network_manager2.NetworkManager({
3779
3894
  log: connectionLog,
3780
3895
  transportFactory,
@@ -3790,23 +3905,23 @@ var ClientServicesHost = class {
3790
3905
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
3791
3906
  id: traceId
3792
3907
  }), {
3793
- file: "service-host.ts",
3794
- line: 187,
3795
- scope: this,
3796
- callSite: (f, a) => f(...a)
3908
+ F: __dxlog_file14,
3909
+ L: 203,
3910
+ S: this,
3911
+ C: (f, a) => f(...a)
3797
3912
  });
3798
- (0, import_node_assert13.default)(this._config, "config not set");
3799
- (0, import_node_assert13.default)(this._storage, "storage not set");
3800
- (0, import_node_assert13.default)(this._signalManager, "signal manager not set");
3801
- (0, import_node_assert13.default)(this._networkManager, "network manager not set");
3913
+ (0, import_tiny_invariant13.default)(this._config, "config not set");
3914
+ (0, import_tiny_invariant13.default)(this._storage, "storage not set");
3915
+ (0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
3916
+ (0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
3802
3917
  this._opening = true;
3803
3918
  (0, import_log15.log)("opening...", {
3804
3919
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3805
3920
  }, {
3806
- file: "service-host.ts",
3807
- line: 195,
3808
- scope: this,
3809
- callSite: (f, a) => f(...a)
3921
+ F: __dxlog_file14,
3922
+ L: 211,
3923
+ S: this,
3924
+ C: (f, a) => f(...a)
3810
3925
  });
3811
3926
  await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
3812
3927
  await this._loggingService.open();
@@ -3838,18 +3953,18 @@ var ClientServicesHost = class {
3838
3953
  (0, import_log15.log)("opened", {
3839
3954
  deviceKey
3840
3955
  }, {
3841
- file: "service-host.ts",
3842
- line: 250,
3843
- scope: this,
3844
- callSite: (f, a) => f(...a)
3956
+ F: __dxlog_file14,
3957
+ L: 266,
3958
+ S: this,
3959
+ C: (f, a) => f(...a)
3845
3960
  });
3846
3961
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
3847
3962
  id: traceId
3848
3963
  }), {
3849
- file: "service-host.ts",
3850
- line: 251,
3851
- scope: this,
3852
- callSite: (f, a) => f(...a)
3964
+ F: __dxlog_file14,
3965
+ L: 267,
3966
+ S: this,
3967
+ C: (f, a) => f(...a)
3853
3968
  });
3854
3969
  }
3855
3970
  async close() {
@@ -3861,10 +3976,10 @@ var ClientServicesHost = class {
3861
3976
  (0, import_log15.log)("closing...", {
3862
3977
  deviceKey
3863
3978
  }, {
3864
- file: "service-host.ts",
3865
- line: 260,
3866
- scope: this,
3867
- callSite: (f, a) => f(...a)
3979
+ F: __dxlog_file14,
3980
+ L: 277,
3981
+ S: this,
3982
+ C: (f, a) => f(...a)
3868
3983
  });
3869
3984
  this._serviceRegistry.setServices({
3870
3985
  SystemService: this._systemService
@@ -3876,47 +3991,54 @@ var ClientServicesHost = class {
3876
3991
  (0, import_log15.log)("closed", {
3877
3992
  deviceKey
3878
3993
  }, {
3879
- file: "service-host.ts",
3880
- line: 266,
3881
- scope: this,
3882
- callSite: (f, a) => f(...a)
3994
+ F: __dxlog_file14,
3995
+ L: 283,
3996
+ S: this,
3997
+ C: (f, a) => f(...a)
3883
3998
  });
3884
3999
  }
3885
4000
  async reset() {
3886
- var _a;
4001
+ var _a, _b, _c;
3887
4002
  const traceId = import_keys12.PublicKey.random().toHex();
3888
4003
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
3889
4004
  id: traceId
3890
4005
  }), {
3891
- file: "service-host.ts",
3892
- line: 271,
3893
- scope: this,
3894
- callSite: (f, a) => f(...a)
4006
+ F: __dxlog_file14,
4007
+ L: 288,
4008
+ S: this,
4009
+ C: (f, a) => f(...a)
3895
4010
  });
3896
- (0, import_log15.log)("resetting...", {}, {
3897
- file: "service-host.ts",
3898
- line: 273,
3899
- scope: this,
3900
- callSite: (f, a) => f(...a)
4011
+ (0, import_log15.log)("resetting...", void 0, {
4012
+ F: __dxlog_file14,
4013
+ L: 290,
4014
+ S: this,
4015
+ C: (f, a) => f(...a)
3901
4016
  });
3902
4017
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
3903
4018
  await this._storage.reset();
3904
- (0, import_log15.log)("reset", {}, {
3905
- file: "service-host.ts",
3906
- line: 276,
3907
- scope: this,
3908
- callSite: (f, a) => f(...a)
4019
+ (0, import_log15.log)("reset", void 0, {
4020
+ F: __dxlog_file14,
4021
+ L: 293,
4022
+ S: this,
4023
+ C: (f, a) => f(...a)
3909
4024
  });
3910
4025
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
3911
4026
  id: traceId
3912
4027
  }), {
3913
- file: "service-host.ts",
3914
- line: 277,
3915
- scope: this,
3916
- callSite: (f, a) => f(...a)
4028
+ F: __dxlog_file14,
4029
+ L: 294,
4030
+ S: this,
4031
+ C: (f, a) => f(...a)
3917
4032
  });
4033
+ await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
3918
4034
  }
3919
4035
  };
4036
+ _ts_decorate4([
4037
+ import_async17.synchronized
4038
+ ], ClientServicesHost.prototype, "open", null);
4039
+ _ts_decorate4([
4040
+ import_async17.synchronized
4041
+ ], ClientServicesHost.prototype, "close", null);
3920
4042
 
3921
4043
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
3922
4044
  var sanitizeInvitation = (invitation) => {
@@ -3950,7 +4072,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3950
4072
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
3951
4073
  break;
3952
4074
  }
3953
- (0, import_node_assert14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
4075
+ (0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
3954
4076
  break;
3955
4077
  }
3956
4078
  case import_services13.Invitation.State.CONNECTED: {
@@ -4091,9 +4213,9 @@ var acceptInvitation = (guest, invitation) => {
4091
4213
  };
4092
4214
 
4093
4215
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
4094
- var import_client_protocol6 = require("@dxos/client-protocol");
4095
4216
  var import_context8 = require("@dxos/context");
4096
4217
  var import_credentials15 = require("@dxos/credentials");
4218
+ var import_debug7 = require("@dxos/debug");
4097
4219
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
4098
4220
  var import_testing = require("@dxos/echo-pipeline/testing");
4099
4221
  var import_feed_store5 = require("@dxos/feed-store");
@@ -4117,7 +4239,7 @@ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignal
4117
4239
  signalManager,
4118
4240
  transportFactory: import_network_manager3.MemoryTransportFactory
4119
4241
  });
4120
- const modelFactory = (0, import_client_protocol6.createDefaultModelFactory)();
4242
+ const modelFactory = createDefaultModelFactory();
4121
4243
  return new ServiceContext(storage, networkManager, signalManager, modelFactory);
4122
4244
  };
4123
4245
  var createPeers = async (numPeers) => {
@@ -4160,6 +4282,9 @@ var TestPeer = class {
4160
4282
  this.opts = opts;
4161
4283
  this._props = {};
4162
4284
  }
4285
+ get props() {
4286
+ return this._props;
4287
+ }
4163
4288
  get storage() {
4164
4289
  var _a, _b;
4165
4290
  return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
@@ -4207,11 +4332,23 @@ var TestPeer = class {
4207
4332
  feedStore: this.feedStore,
4208
4333
  networkManager: this.networkManager,
4209
4334
  metadataStore: this.metadataStore,
4210
- modelFactory: (0, import_client_protocol6.createDefaultModelFactory)(),
4335
+ modelFactory: createDefaultModelFactory(),
4211
4336
  snapshotStore: this.snapshotStore,
4212
4337
  blobStore: this.blobStore
4213
4338
  });
4214
4339
  }
4340
+ get identity() {
4341
+ var _a;
4342
+ return (_a = this._props.signingContext) != null ? _a : (0, import_debug7.failUndefined)();
4343
+ }
4344
+ get dataSpaceManager() {
4345
+ var _a, _b;
4346
+ return (_b = (_a = this._props).dataSpaceManager) != null ? _b : _a.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
4347
+ }
4348
+ async createIdentity() {
4349
+ var _a, _b;
4350
+ (_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
4351
+ }
4215
4352
  async destroy() {
4216
4353
  await this.storage.reset();
4217
4354
  }