@dxos/client-services 0.3.11-main.cc2fe2c → 0.3.11-main.cf49a01

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 (35) hide show
  1. package/dist/lib/browser/{chunk-RGWEY4Z2.mjs → chunk-IXZHQ3JB.mjs} +81 -34
  2. package/dist/lib/browser/chunk-IXZHQ3JB.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/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-Q5PLF45D.cjs → chunk-CBKC2732.cjs} +160 -113
  7. package/dist/lib/node/chunk-CBKC2732.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +37 -37
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  11. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  12. package/dist/types/src/packlets/services/diagnostics.d.ts +1 -2
  13. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
  14. package/dist/types/src/packlets/services/platform.d.ts +1 -14
  15. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
  17. package/dist/types/src/packlets/spaces/automerge-space-state.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 +1 -0
  20. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  21. package/dist/types/src/packlets/system/system-service.d.ts +2 -1
  22. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/package.json +35 -35
  25. package/src/packlets/identity/identity-manager.ts +1 -1
  26. package/src/packlets/network/network-service.ts +1 -0
  27. package/src/packlets/services/diagnostics.ts +2 -1
  28. package/src/packlets/services/platform.ts +7 -19
  29. package/src/packlets/spaces/automerge-space-state.ts +4 -0
  30. package/src/packlets/spaces/data-space-manager.ts +5 -1
  31. package/src/packlets/spaces/data-space.ts +21 -1
  32. package/src/packlets/system/system-service.ts +6 -0
  33. package/src/version.ts +1 -1
  34. package/dist/lib/browser/chunk-RGWEY4Z2.mjs.map +0 -7
  35. package/dist/lib/node/chunk-Q5PLF45D.cjs.map +0 -7
@@ -996,7 +996,7 @@ var IdentityManager = class {
996
996
  genesisFeedKey: spaceRecord.genesisFeedKey
997
997
  },
998
998
  swarmIdentity,
999
- onNetworkConnection: () => {
999
+ onAuthorizedConnection: () => {
1000
1000
  },
1001
1001
  onAuthFailure: () => {
1002
1002
  log3.warn("auth failure", void 0, {
@@ -2535,27 +2535,29 @@ import { STORAGE_VERSION } from "@dxos/protocols";
2535
2535
  import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2536
2536
 
2537
2537
  // packages/sdk/client-services/src/packlets/services/platform.ts
2538
+ import { Platform } from "@dxos/protocols/proto/dxos/client/services";
2538
2539
  var getPlatform = () => {
2539
2540
  if (process.browser) {
2540
2541
  if (typeof window !== "undefined") {
2541
2542
  const { userAgent } = window.navigator;
2542
2543
  return {
2543
- type: "browser",
2544
+ type: Platform.PLATFORM_TYPE.BROWSER,
2544
2545
  userAgent,
2545
2546
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2546
2547
  };
2547
2548
  } else {
2548
2549
  return {
2549
- type: "shared-worker",
2550
+ type: Platform.PLATFORM_TYPE.SHARED_WORKER,
2550
2551
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2551
2552
  };
2552
2553
  }
2553
2554
  } else {
2554
2555
  const { platform: platform2, version, arch } = process;
2555
2556
  return {
2556
- type: "node",
2557
- platform: `${platform2} ${version} ${arch}`,
2558
- runtime: process.version,
2557
+ type: Platform.PLATFORM_TYPE.NODE,
2558
+ platform: platform2,
2559
+ arch,
2560
+ runtime: version,
2559
2561
  uptime: Math.floor(process.uptime()),
2560
2562
  memory: process.memoryUsage()
2561
2563
  };
@@ -2563,7 +2565,7 @@ var getPlatform = () => {
2563
2565
  };
2564
2566
 
2565
2567
  // packages/sdk/client-services/src/version.ts
2566
- var DXOS_VERSION = "0.3.11-main.cc2fe2c";
2568
+ var DXOS_VERSION = "0.3.11-main.cf49a01";
2567
2569
 
2568
2570
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2569
2571
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2582,7 +2584,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2582
2584
  {
2583
2585
  invariant9(clientServices.LoggingService, "SystemService is not available.", {
2584
2586
  F: __dxlog_file10,
2585
- L: 93,
2587
+ L: 94,
2586
2588
  S: void 0,
2587
2589
  A: [
2588
2590
  "clientServices.LoggingService",
@@ -2648,7 +2650,7 @@ var getProperties = (space) => {
2648
2650
  } catch (err) {
2649
2651
  log8.warn(err.message, void 0, {
2650
2652
  F: __dxlog_file10,
2651
- L: 178,
2653
+ L: 179,
2652
2654
  S: void 0,
2653
2655
  C: (f, a) => f(...a)
2654
2656
  });
@@ -2709,6 +2711,7 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2709
2711
  import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
2710
2712
  import { timed } from "@dxos/debug";
2711
2713
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2714
+ import { failedInvariant } from "@dxos/invariant";
2712
2715
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2713
2716
  import { log as log10 } from "@dxos/log";
2714
2717
  import { CancelledError, SystemError } from "@dxos/protocols";
@@ -2721,7 +2724,8 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
2721
2724
  // packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
2722
2725
  import { checkCredentialType } from "@dxos/credentials";
2723
2726
  var AutomergeSpaceState = class {
2724
- constructor() {
2727
+ constructor(_onNewRoot) {
2728
+ this._onNewRoot = _onNewRoot;
2725
2729
  this.rootUrl = void 0;
2726
2730
  this.lastEpoch = void 0;
2727
2731
  }
@@ -2732,6 +2736,7 @@ var AutomergeSpaceState = class {
2732
2736
  this.lastEpoch = credential;
2733
2737
  if (credential.subject.assertion.automergeRoot) {
2734
2738
  this.rootUrl = credential.subject.assertion.automergeRoot;
2739
+ this._onNewRoot(this.rootUrl);
2735
2740
  }
2736
2741
  }
2737
2742
  };
@@ -3023,7 +3028,7 @@ var DataSpace = class {
3023
3028
  this._notarizationPlugin = new NotarizationPlugin();
3024
3029
  this._cache = void 0;
3025
3030
  // TODO(dmaretskyi): Move into Space?
3026
- this._automergeSpaceState = new AutomergeSpaceState();
3031
+ this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3027
3032
  this._state = SpaceState.CLOSED;
3028
3033
  /**
3029
3034
  * Error for _state === SpaceState.ERROR.
@@ -3052,7 +3057,7 @@ var DataSpace = class {
3052
3057
  state: SpaceState[this._state]
3053
3058
  }, {
3054
3059
  F: __dxlog_file12,
3055
- L: 137,
3060
+ L: 138,
3056
3061
  S: this,
3057
3062
  C: (f, a) => f(...a)
3058
3063
  });
@@ -3099,7 +3104,7 @@ var DataSpace = class {
3099
3104
  state: SpaceState[this._state]
3100
3105
  }, {
3101
3106
  F: __dxlog_file12,
3102
- L: 189,
3107
+ L: 190,
3103
3108
  S: this,
3104
3109
  C: (f, a) => f(...a)
3105
3110
  });
@@ -3117,7 +3122,7 @@ var DataSpace = class {
3117
3122
  state: SpaceState[this._state]
3118
3123
  }, {
3119
3124
  F: __dxlog_file12,
3120
- L: 203,
3125
+ L: 204,
3121
3126
  S: this,
3122
3127
  C: (f, a) => f(...a)
3123
3128
  });
@@ -3149,7 +3154,7 @@ var DataSpace = class {
3149
3154
  if (err instanceof CancelledError) {
3150
3155
  log10("data pipeline initialization cancelled", err, {
3151
3156
  F: __dxlog_file12,
3152
- L: 236,
3157
+ L: 237,
3153
3158
  S: this,
3154
3159
  C: (f, a) => f(...a)
3155
3160
  });
@@ -3157,7 +3162,7 @@ var DataSpace = class {
3157
3162
  }
3158
3163
  log10.error("Error initializing data pipeline", err, {
3159
3164
  F: __dxlog_file12,
3160
- L: 240,
3165
+ L: 241,
3161
3166
  S: this,
3162
3167
  C: (f, a) => f(...a)
3163
3168
  });
@@ -3166,7 +3171,7 @@ var DataSpace = class {
3166
3171
  state: SpaceState[this._state]
3167
3172
  }, {
3168
3173
  F: __dxlog_file12,
3169
- L: 242,
3174
+ L: 243,
3170
3175
  S: this,
3171
3176
  C: (f, a) => f(...a)
3172
3177
  });
@@ -3186,7 +3191,7 @@ var DataSpace = class {
3186
3191
  state: SpaceState[this._state]
3187
3192
  }, {
3188
3193
  F: __dxlog_file12,
3189
- L: 258,
3194
+ L: 259,
3190
3195
  S: this,
3191
3196
  C: (f, a) => f(...a)
3192
3197
  });
@@ -3197,7 +3202,7 @@ var DataSpace = class {
3197
3202
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3198
3203
  log10("waiting for data pipeline to reach target timeframe", void 0, {
3199
3204
  F: __dxlog_file12,
3200
- L: 272,
3205
+ L: 273,
3201
3206
  S: this,
3202
3207
  C: (f, a) => f(...a)
3203
3208
  });
@@ -3208,7 +3213,7 @@ var DataSpace = class {
3208
3213
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3209
3214
  log10("data pipeline ready", void 0, {
3210
3215
  F: __dxlog_file12,
3211
- L: 281,
3216
+ L: 282,
3212
3217
  S: this,
3213
3218
  C: (f, a) => f(...a)
3214
3219
  });
@@ -3218,7 +3223,7 @@ var DataSpace = class {
3218
3223
  state: SpaceState[this._state]
3219
3224
  }, {
3220
3225
  F: __dxlog_file12,
3221
- L: 285,
3226
+ L: 286,
3222
3227
  S: this,
3223
3228
  C: (f, a) => f(...a)
3224
3229
  });
@@ -3234,7 +3239,7 @@ var DataSpace = class {
3234
3239
  await this._createWritableFeeds();
3235
3240
  log10("writable feeds created", void 0, {
3236
3241
  F: __dxlog_file12,
3237
- L: 301,
3242
+ L: 302,
3238
3243
  S: this,
3239
3244
  C: (f, a) => f(...a)
3240
3245
  });
@@ -3291,6 +3296,40 @@ var DataSpace = class {
3291
3296
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
3292
3297
  }
3293
3298
  }
3299
+ _onNewAutomergeRoot(rootUrl) {
3300
+ log10.info("loading automerge root doc for space", {
3301
+ space: this.key,
3302
+ rootUrl
3303
+ }, {
3304
+ F: __dxlog_file12,
3305
+ L: 368,
3306
+ S: this,
3307
+ C: (f, a) => f(...a)
3308
+ });
3309
+ const handle = this._automergeHost.repo.find(rootUrl);
3310
+ queueMicrotask(async () => {
3311
+ try {
3312
+ await handle.whenReady();
3313
+ const doc = handle.docSync() ?? failedInvariant();
3314
+ if (!doc.experimental_spaceKey) {
3315
+ handle.change((doc2) => {
3316
+ doc2.experimental_spaceKey = this.key.toHex();
3317
+ });
3318
+ }
3319
+ } catch (err) {
3320
+ log10.warn("error loading automerge root doc", {
3321
+ space: this.key,
3322
+ rootUrl,
3323
+ err
3324
+ }, {
3325
+ F: __dxlog_file12,
3326
+ L: 381,
3327
+ S: this,
3328
+ C: (f, a) => f(...a)
3329
+ });
3330
+ }
3331
+ });
3332
+ }
3294
3333
  // TODO(dmaretskyi): Use profile from signing context.
3295
3334
  async updateOwnProfile(profile) {
3296
3335
  const credential = await this._signingContext.credentialSigner.createCredential({
@@ -3374,7 +3413,7 @@ var DataSpace = class {
3374
3413
  state: SpaceState[this._state]
3375
3414
  }, {
3376
3415
  F: __dxlog_file12,
3377
- L: 450,
3416
+ L: 470,
3378
3417
  S: this,
3379
3418
  C: (f, a) => f(...a)
3380
3419
  });
@@ -3633,12 +3672,15 @@ var DataSpaceManager = class {
3633
3672
  });
3634
3673
  const space = await this._constructSpace(metadata);
3635
3674
  const automergeRoot = this._automergeHost.repo.create();
3675
+ automergeRoot.change((doc) => {
3676
+ doc.experimental_spaceKey = spaceKey.toHex();
3677
+ });
3636
3678
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3637
3679
  await this._metadataStore.addSpace(metadata);
3638
3680
  const memberCredential = credentials[1];
3639
3681
  invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3640
3682
  F: __dxlog_file13,
3641
- L: 151,
3683
+ L: 154,
3642
3684
  S: this,
3643
3685
  A: [
3644
3686
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3656,13 +3698,13 @@ var DataSpaceManager = class {
3656
3698
  opts
3657
3699
  }, {
3658
3700
  F: __dxlog_file13,
3659
- L: 163,
3701
+ L: 166,
3660
3702
  S: this,
3661
3703
  C: (f, a) => f(...a)
3662
3704
  });
3663
3705
  invariant11(this._isOpen, "Not open.", {
3664
3706
  F: __dxlog_file13,
3665
- L: 164,
3707
+ L: 167,
3666
3708
  S: this,
3667
3709
  A: [
3668
3710
  "this._isOpen",
@@ -3671,7 +3713,7 @@ var DataSpaceManager = class {
3671
3713
  });
3672
3714
  invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3673
3715
  F: __dxlog_file13,
3674
- L: 165,
3716
+ L: 168,
3675
3717
  S: this,
3676
3718
  A: [
3677
3719
  "!this._spaces.has(opts.spaceKey)",
@@ -3706,7 +3748,7 @@ var DataSpaceManager = class {
3706
3748
  metadata
3707
3749
  }, {
3708
3750
  F: __dxlog_file13,
3709
- L: 198,
3751
+ L: 201,
3710
3752
  S: this,
3711
3753
  C: (f, a) => f(...a)
3712
3754
  });
@@ -3733,17 +3775,18 @@ var DataSpaceManager = class {
3733
3775
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
3734
3776
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
3735
3777
  },
3736
- onNetworkConnection: (session) => {
3778
+ onAuthorizedConnection: (session) => {
3737
3779
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
3738
3780
  remotePeerId: session.remotePeerId
3739
3781
  }));
3740
3782
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3783
+ this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
3741
3784
  session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
3742
3785
  },
3743
3786
  onAuthFailure: () => {
3744
3787
  log11.warn("auth failure", void 0, {
3745
3788
  F: __dxlog_file13,
3746
- L: 234,
3789
+ L: 238,
3747
3790
  S: this,
3748
3791
  C: (f, a) => f(...a)
3749
3792
  });
@@ -3767,7 +3810,7 @@ var DataSpaceManager = class {
3767
3810
  space: space.key
3768
3811
  }, {
3769
3812
  F: __dxlog_file13,
3770
- L: 252,
3813
+ L: 256,
3771
3814
  S: this,
3772
3815
  C: (f, a) => f(...a)
3773
3816
  });
@@ -3779,7 +3822,7 @@ var DataSpaceManager = class {
3779
3822
  open: this._isOpen
3780
3823
  }, {
3781
3824
  F: __dxlog_file13,
3782
- L: 259,
3825
+ L: 263,
3783
3826
  S: this,
3784
3827
  C: (f, a) => f(...a)
3785
3828
  });
@@ -3792,7 +3835,7 @@ var DataSpaceManager = class {
3792
3835
  space: space.key
3793
3836
  }, {
3794
3837
  F: __dxlog_file13,
3795
- L: 265,
3838
+ L: 269,
3796
3839
  S: this,
3797
3840
  C: (f, a) => f(...a)
3798
3841
  });
@@ -4712,6 +4755,7 @@ var NetworkServiceImpl = class {
4712
4755
  const update = () => {
4713
4756
  next({
4714
4757
  swarm: this.networkManager.connectionState,
4758
+ connectionInfo: this.networkManager.connectionLog?.swarms,
4715
4759
  signaling: this.signalManager.getStatus().map(({ host, state }) => ({
4716
4760
  server: host,
4717
4761
  state
@@ -4761,6 +4805,9 @@ var SystemServiceImpl = class {
4761
4805
  })))
4762
4806
  };
4763
4807
  }
4808
+ async getPlatform() {
4809
+ return getPlatform();
4810
+ }
4764
4811
  async updateStatus({ status }) {
4765
4812
  await this._onUpdateStatus(status);
4766
4813
  }
@@ -5222,4 +5269,4 @@ export {
5222
5269
  createDefaultModelFactory,
5223
5270
  ClientServicesHost
5224
5271
  };
5225
- //# sourceMappingURL=chunk-RGWEY4Z2.mjs.map
5272
+ //# sourceMappingURL=chunk-IXZHQ3JB.mjs.map