@dxos/client-services 0.6.12-main.89e9959 → 0.6.12-main.ac23639

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 (30) hide show
  1. package/dist/lib/browser/{chunk-XVI3VSJT.mjs → chunk-HJR7N476.mjs} +61 -23
  2. package/dist/lib/browser/chunk-HJR7N476.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-NZL66D6K.cjs → chunk-JU4QYYUL.cjs} +64 -26
  7. package/dist/lib/node/chunk-JU4QYYUL.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +45 -45
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/node-esm/{chunk-6747X7GN.mjs → chunk-MIHFUPW7.mjs} +61 -23
  12. package/dist/lib/node-esm/chunk-MIHFUPW7.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
  17. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
  19. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  21. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  22. package/dist/types/src/version.d.ts +1 -1
  23. package/package.json +38 -38
  24. package/src/packlets/spaces/data-space-manager.ts +29 -3
  25. package/src/packlets/spaces/data-space.ts +4 -0
  26. package/src/packlets/spaces/spaces-service.ts +6 -1
  27. package/src/version.ts +1 -1
  28. package/dist/lib/browser/chunk-XVI3VSJT.mjs.map +0 -7
  29. package/dist/lib/node/chunk-NZL66D6K.cjs.map +0 -7
  30. package/dist/lib/node-esm/chunk-6747X7GN.mjs.map +0 -7
@@ -32,7 +32,7 @@ __export(testing_exports, {
32
32
  sanitizeInvitation: () => sanitizeInvitation
33
33
  });
34
34
  module.exports = __toCommonJS(testing_exports);
35
- var import_chunk_NZL66D6K = require("../chunk-NZL66D6K.cjs");
35
+ var import_chunk_JU4QYYUL = require("../chunk-JU4QYYUL.cjs");
36
36
  var import_credentials = require("@dxos/credentials");
37
37
  var import_keys = require("@dxos/keys");
38
38
  var import_async = require("@dxos/async");
@@ -228,7 +228,7 @@ var createInvitation = async (host, options) => {
228
228
  authMethod: import_services.Invitation.AuthMethod.NONE,
229
229
  ...options ?? {}
230
230
  };
231
- if (host instanceof import_chunk_NZL66D6K.ServiceContext) {
231
+ if (host instanceof import_chunk_JU4QYYUL.ServiceContext) {
232
232
  return host.invitationsManager.createInvitation({
233
233
  kind: import_services.Invitation.Kind.SPACE,
234
234
  ...options
@@ -238,7 +238,7 @@ var createInvitation = async (host, options) => {
238
238
  };
239
239
  var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
240
240
  invitation = sanitizeInvitation(invitation);
241
- if (guest instanceof import_chunk_NZL66D6K.ServiceContext) {
241
+ if (guest instanceof import_chunk_JU4QYYUL.ServiceContext) {
242
242
  return guest.invitationsManager.acceptInvitation({
243
243
  invitation,
244
244
  deviceProfile: guestDeviceProfile
@@ -248,7 +248,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
248
248
  };
249
249
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/test-builder.ts";
250
250
  var createServiceHost = (config, signalManagerContext) => {
251
- return new import_chunk_NZL66D6K.ClientServicesHost({
251
+ return new import_chunk_JU4QYYUL.ClientServicesHost({
252
252
  config,
253
253
  signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
254
254
  transportFactory: import_network_manager.MemoryTransportFactory
@@ -267,7 +267,7 @@ var createServiceContext = async ({ signalManagerFactory = async () => {
267
267
  });
268
268
  const level = (0, import_testing.createTestLevel)();
269
269
  await level.open();
270
- return new import_chunk_NZL66D6K.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
270
+ return new import_chunk_JU4QYYUL.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
271
271
  invitationConnectionDefaultParams: {
272
272
  controlHeartbeatInterval: 200
273
273
  },
@@ -376,7 +376,7 @@ var TestPeer = class {
376
376
  return this._props.meshEchoReplicator ??= new import_echo_pipeline.MeshEchoReplicator();
377
377
  }
378
378
  get dataSpaceManager() {
379
- return this._props.dataSpaceManager ??= new import_chunk_NZL66D6K.DataSpaceManager({
379
+ return this._props.dataSpaceManager ??= new import_chunk_JU4QYYUL.DataSpaceManager({
380
380
  spaceManager: this.spaceManager,
381
381
  metadataStore: this.metadataStore,
382
382
  keyring: this.keyring,
@@ -391,9 +391,9 @@ var TestPeer = class {
391
391
  });
392
392
  }
393
393
  get invitationsManager() {
394
- return this._props.invitationsManager ??= new import_chunk_NZL66D6K.InvitationsManager(new import_chunk_NZL66D6K.InvitationsHandler(this.networkManager), (invitation) => {
394
+ return this._props.invitationsManager ??= new import_chunk_JU4QYYUL.InvitationsManager(new import_chunk_JU4QYYUL.InvitationsHandler(this.networkManager), (invitation) => {
395
395
  if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
396
- return new import_chunk_NZL66D6K.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
396
+ return new import_chunk_JU4QYYUL.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
397
397
  } else {
398
398
  throw new Error("not implemented");
399
399
  }
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.6.12-main.89e9959";
400
+ var DXOS_VERSION = "0.6.12-main.ac23639";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1935,6 +1935,7 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
1935
1935
  import { log as log7 } from "@dxos/log";
1936
1936
  import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
1937
1937
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
1938
+ import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
1938
1939
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
1939
1940
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
1940
1941
  import { trace } from "@dxos/tracing";
@@ -2360,12 +2361,36 @@ var DataSpaceManager = class extends Resource4 {
2360
2361
  }
2361
2362
  });
2362
2363
  }
2364
+ async setSpaceEdgeReplicationSetting(spaceKey, setting) {
2365
+ const space = this._spaces.get(spaceKey);
2366
+ invariant5(space, "Space not found.", {
2367
+ F: __dxlog_file9,
2368
+ L: 399,
2369
+ S: this,
2370
+ A: [
2371
+ "space",
2372
+ "'Space not found.'"
2373
+ ]
2374
+ });
2375
+ await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
2376
+ if (space.isOpen) {
2377
+ switch (setting) {
2378
+ case EdgeReplicationSetting.DISABLED:
2379
+ await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
2380
+ break;
2381
+ case EdgeReplicationSetting.ENABLED:
2382
+ await this._echoEdgeReplicator?.connectToSpace(space.id);
2383
+ break;
2384
+ }
2385
+ }
2386
+ space.stateUpdate.emit();
2387
+ }
2363
2388
  async _constructSpace(metadata) {
2364
2389
  log7("construct space", {
2365
2390
  metadata
2366
2391
  }, {
2367
2392
  F: __dxlog_file9,
2368
- L: 398,
2393
+ L: 418,
2369
2394
  S: this,
2370
2395
  C: (f, a) => f(...a)
2371
2396
  });
@@ -2409,7 +2434,7 @@ var DataSpaceManager = class extends Resource4 {
2409
2434
  err
2410
2435
  }, {
2411
2436
  F: __dxlog_file9,
2412
- L: 440,
2437
+ L: 460,
2413
2438
  S: this,
2414
2439
  C: (f, a) => f(...a)
2415
2440
  });
@@ -2419,7 +2444,7 @@ var DataSpaceManager = class extends Resource4 {
2419
2444
  onAuthFailure: () => {
2420
2445
  log7.warn("auth failure", void 0, {
2421
2446
  F: __dxlog_file9,
2422
- L: 445,
2447
+ L: 465,
2423
2448
  S: this,
2424
2449
  C: (f, a) => f(...a)
2425
2450
  });
@@ -2452,7 +2477,7 @@ var DataSpaceManager = class extends Resource4 {
2452
2477
  space: space.key
2453
2478
  }, {
2454
2479
  F: __dxlog_file9,
2455
- L: 472,
2480
+ L: 492,
2456
2481
  S: this,
2457
2482
  C: (f, a) => f(...a)
2458
2483
  });
@@ -2463,7 +2488,7 @@ var DataSpaceManager = class extends Resource4 {
2463
2488
  open: this._lifecycleState === LifecycleState.OPEN
2464
2489
  }, {
2465
2490
  F: __dxlog_file9,
2466
- L: 475,
2491
+ L: 495,
2467
2492
  S: this,
2468
2493
  C: (f, a) => f(...a)
2469
2494
  });
@@ -2482,7 +2507,7 @@ var DataSpaceManager = class extends Resource4 {
2482
2507
  space: space.key
2483
2508
  }, {
2484
2509
  F: __dxlog_file9,
2485
- L: 483,
2510
+ L: 503,
2486
2511
  S: this,
2487
2512
  C: (f, a) => f(...a)
2488
2513
  });
@@ -2494,10 +2519,16 @@ var DataSpaceManager = class extends Resource4 {
2494
2519
  edgeFeatures: this._edgeFeatures
2495
2520
  });
2496
2521
  dataSpace.postOpen.append(async () => {
2497
- await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2522
+ const setting = dataSpace.getEdgeReplicationSetting();
2523
+ if (setting === EdgeReplicationSetting.ENABLED) {
2524
+ await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2525
+ }
2498
2526
  });
2499
2527
  dataSpace.preClose.append(async () => {
2500
- await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2528
+ const setting = dataSpace.getEdgeReplicationSetting();
2529
+ if (setting === EdgeReplicationSetting.ENABLED) {
2530
+ await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2531
+ }
2501
2532
  });
2502
2533
  presence.newPeer.on((peerState) => {
2503
2534
  if (dataSpace.state === SpaceState.SPACE_READY) {
@@ -2517,7 +2548,7 @@ var DataSpaceManager = class extends Resource4 {
2517
2548
  space: space.key
2518
2549
  }, {
2519
2550
  F: __dxlog_file9,
2520
- L: 515,
2551
+ L: 541,
2521
2552
  S: this,
2522
2553
  C: (f, a) => f(...a)
2523
2554
  });
@@ -2550,7 +2581,7 @@ var DataSpaceManager = class extends Resource4 {
2550
2581
  closedSessions
2551
2582
  }, {
2552
2583
  F: __dxlog_file9,
2553
- L: 541,
2584
+ L: 567,
2554
2585
  S: this,
2555
2586
  C: (f, a) => f(...a)
2556
2587
  });
@@ -2565,7 +2596,7 @@ var DataSpaceManager = class extends Resource4 {
2565
2596
  peerId: peerState.peerId
2566
2597
  }, {
2567
2598
  F: __dxlog_file9,
2568
- L: 555,
2599
+ L: 581,
2569
2600
  S: this,
2570
2601
  C: (f, a) => f(...a)
2571
2602
  });
@@ -2650,7 +2681,7 @@ var SpacesServiceImpl = class {
2650
2681
  await this._updateMetrics();
2651
2682
  return this._serializeSpace(space);
2652
2683
  }
2653
- async updateSpace({ spaceKey, state }) {
2684
+ async updateSpace({ spaceKey, state, edgeReplication }) {
2654
2685
  const dataSpaceManager = await this._getDataSpaceManager();
2655
2686
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise(new SpaceNotFoundError(spaceKey));
2656
2687
  if (state) {
@@ -2665,6 +2696,9 @@ var SpacesServiceImpl = class {
2665
2696
  throw new ApiError("Invalid space state");
2666
2697
  }
2667
2698
  }
2699
+ if (edgeReplication !== void 0) {
2700
+ await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
2701
+ }
2668
2702
  }
2669
2703
  async updateMemberRole(request) {
2670
2704
  const identity = this._requireIdentity();
@@ -2681,7 +2715,7 @@ var SpacesServiceImpl = class {
2681
2715
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2682
2716
  invariant6(credentials[0].credential, void 0, {
2683
2717
  F: __dxlog_file10,
2684
- L: 102,
2718
+ L: 106,
2685
2719
  S: this,
2686
2720
  A: [
2687
2721
  "credentials[0].credential",
@@ -2691,7 +2725,7 @@ var SpacesServiceImpl = class {
2691
2725
  const spaceMemberCredential = credentials[0].credential.credential;
2692
2726
  invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2693
2727
  F: __dxlog_file10,
2694
- L: 104,
2728
+ L: 108,
2695
2729
  S: this,
2696
2730
  A: [
2697
2731
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2709,7 +2743,7 @@ var SpacesServiceImpl = class {
2709
2743
  ids: spaces.map((space) => space.id)
2710
2744
  }), {
2711
2745
  F: __dxlog_file10,
2712
- L: 115,
2746
+ L: 119,
2713
2747
  S: this,
2714
2748
  C: (f, a) => f(...a)
2715
2749
  });
@@ -2801,7 +2835,7 @@ var SpacesServiceImpl = class {
2801
2835
  } else {
2802
2836
  invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
2803
2837
  F: __dxlog_file10,
2804
- L: 213,
2838
+ L: 217,
2805
2839
  S: this,
2806
2840
  A: [
2807
2841
  "!credential.id",
@@ -2810,7 +2844,7 @@ var SpacesServiceImpl = class {
2810
2844
  });
2811
2845
  invariant6(this._identityManager.identity, "Identity is not available", {
2812
2846
  F: __dxlog_file10,
2813
- L: 214,
2847
+ L: 218,
2814
2848
  S: this,
2815
2849
  A: [
2816
2850
  "this._identityManager.identity",
@@ -2820,7 +2854,7 @@ var SpacesServiceImpl = class {
2820
2854
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2821
2855
  invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
2822
2856
  F: __dxlog_file10,
2823
- L: 216,
2857
+ L: 220,
2824
2858
  S: this,
2825
2859
  A: [
2826
2860
  "credential.issuer.equals(signer.getIssuer())",
@@ -2870,7 +2904,7 @@ var SpacesServiceImpl = class {
2870
2904
  const assertion = getCredentialAssertion3(credential);
2871
2905
  invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2872
2906
  F: __dxlog_file10,
2873
- L: 250,
2907
+ L: 254,
2874
2908
  S: this,
2875
2909
  A: [
2876
2910
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2880,7 +2914,7 @@ var SpacesServiceImpl = class {
2880
2914
  const myIdentity = this._identityManager.identity;
2881
2915
  invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2882
2916
  F: __dxlog_file10,
2883
- L: 252,
2917
+ L: 256,
2884
2918
  S: this,
2885
2919
  A: [
2886
2920
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2942,7 +2976,8 @@ var SpacesServiceImpl = class {
2942
2976
  }),
2943
2977
  creator: space.inner.spaceState.creator?.key,
2944
2978
  cache: space.cache,
2945
- metrics: space.metrics
2979
+ metrics: space.metrics,
2980
+ edgeReplication: space.getEdgeReplicationSetting()
2946
2981
  };
2947
2982
  }
2948
2983
  _requireIdentity() {
@@ -4393,6 +4428,9 @@ var DataSpace = class {
4393
4428
  });
4394
4429
  this.stateUpdate.emit();
4395
4430
  }
4431
+ getEdgeReplicationSetting() {
4432
+ return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4433
+ }
4396
4434
  };
4397
4435
  _ts_decorate6([
4398
4436
  trace5.info()
@@ -8151,4 +8189,4 @@ export {
8151
8189
  importProfileData,
8152
8190
  ClientServicesHost
8153
8191
  };
8154
- //# sourceMappingURL=chunk-6747X7GN.mjs.map
8192
+ //# sourceMappingURL=chunk-MIHFUPW7.mjs.map