@dxos/client-services 0.3.11-main.13264f1 → 0.3.11-main.1690b50

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.
@@ -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, {
@@ -2563,7 +2563,7 @@ var getPlatform = () => {
2563
2563
  };
2564
2564
 
2565
2565
  // packages/sdk/client-services/src/version.ts
2566
- var DXOS_VERSION = "0.3.11-main.13264f1";
2566
+ var DXOS_VERSION = "0.3.11-main.1690b50";
2567
2567
 
2568
2568
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2569
2569
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2709,6 +2709,7 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2709
2709
  import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
2710
2710
  import { timed } from "@dxos/debug";
2711
2711
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2712
+ import { failedInvariant } from "@dxos/invariant";
2712
2713
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2713
2714
  import { log as log10 } from "@dxos/log";
2714
2715
  import { CancelledError, SystemError } from "@dxos/protocols";
@@ -2721,7 +2722,8 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
2721
2722
  // packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
2722
2723
  import { checkCredentialType } from "@dxos/credentials";
2723
2724
  var AutomergeSpaceState = class {
2724
- constructor() {
2725
+ constructor(_onNewRoot) {
2726
+ this._onNewRoot = _onNewRoot;
2725
2727
  this.rootUrl = void 0;
2726
2728
  this.lastEpoch = void 0;
2727
2729
  }
@@ -2732,6 +2734,7 @@ var AutomergeSpaceState = class {
2732
2734
  this.lastEpoch = credential;
2733
2735
  if (credential.subject.assertion.automergeRoot) {
2734
2736
  this.rootUrl = credential.subject.assertion.automergeRoot;
2737
+ this._onNewRoot(this.rootUrl);
2735
2738
  }
2736
2739
  }
2737
2740
  };
@@ -3023,7 +3026,7 @@ var DataSpace = class {
3023
3026
  this._notarizationPlugin = new NotarizationPlugin();
3024
3027
  this._cache = void 0;
3025
3028
  // TODO(dmaretskyi): Move into Space?
3026
- this._automergeSpaceState = new AutomergeSpaceState();
3029
+ this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3027
3030
  this._state = SpaceState.CLOSED;
3028
3031
  /**
3029
3032
  * Error for _state === SpaceState.ERROR.
@@ -3052,7 +3055,7 @@ var DataSpace = class {
3052
3055
  state: SpaceState[this._state]
3053
3056
  }, {
3054
3057
  F: __dxlog_file12,
3055
- L: 137,
3058
+ L: 138,
3056
3059
  S: this,
3057
3060
  C: (f, a) => f(...a)
3058
3061
  });
@@ -3099,7 +3102,7 @@ var DataSpace = class {
3099
3102
  state: SpaceState[this._state]
3100
3103
  }, {
3101
3104
  F: __dxlog_file12,
3102
- L: 189,
3105
+ L: 190,
3103
3106
  S: this,
3104
3107
  C: (f, a) => f(...a)
3105
3108
  });
@@ -3117,7 +3120,7 @@ var DataSpace = class {
3117
3120
  state: SpaceState[this._state]
3118
3121
  }, {
3119
3122
  F: __dxlog_file12,
3120
- L: 203,
3123
+ L: 204,
3121
3124
  S: this,
3122
3125
  C: (f, a) => f(...a)
3123
3126
  });
@@ -3149,7 +3152,7 @@ var DataSpace = class {
3149
3152
  if (err instanceof CancelledError) {
3150
3153
  log10("data pipeline initialization cancelled", err, {
3151
3154
  F: __dxlog_file12,
3152
- L: 236,
3155
+ L: 237,
3153
3156
  S: this,
3154
3157
  C: (f, a) => f(...a)
3155
3158
  });
@@ -3157,7 +3160,7 @@ var DataSpace = class {
3157
3160
  }
3158
3161
  log10.error("Error initializing data pipeline", err, {
3159
3162
  F: __dxlog_file12,
3160
- L: 240,
3163
+ L: 241,
3161
3164
  S: this,
3162
3165
  C: (f, a) => f(...a)
3163
3166
  });
@@ -3166,7 +3169,7 @@ var DataSpace = class {
3166
3169
  state: SpaceState[this._state]
3167
3170
  }, {
3168
3171
  F: __dxlog_file12,
3169
- L: 242,
3172
+ L: 243,
3170
3173
  S: this,
3171
3174
  C: (f, a) => f(...a)
3172
3175
  });
@@ -3186,7 +3189,7 @@ var DataSpace = class {
3186
3189
  state: SpaceState[this._state]
3187
3190
  }, {
3188
3191
  F: __dxlog_file12,
3189
- L: 258,
3192
+ L: 259,
3190
3193
  S: this,
3191
3194
  C: (f, a) => f(...a)
3192
3195
  });
@@ -3197,7 +3200,7 @@ var DataSpace = class {
3197
3200
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3198
3201
  log10("waiting for data pipeline to reach target timeframe", void 0, {
3199
3202
  F: __dxlog_file12,
3200
- L: 272,
3203
+ L: 273,
3201
3204
  S: this,
3202
3205
  C: (f, a) => f(...a)
3203
3206
  });
@@ -3208,7 +3211,7 @@ var DataSpace = class {
3208
3211
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3209
3212
  log10("data pipeline ready", void 0, {
3210
3213
  F: __dxlog_file12,
3211
- L: 281,
3214
+ L: 282,
3212
3215
  S: this,
3213
3216
  C: (f, a) => f(...a)
3214
3217
  });
@@ -3218,7 +3221,7 @@ var DataSpace = class {
3218
3221
  state: SpaceState[this._state]
3219
3222
  }, {
3220
3223
  F: __dxlog_file12,
3221
- L: 285,
3224
+ L: 286,
3222
3225
  S: this,
3223
3226
  C: (f, a) => f(...a)
3224
3227
  });
@@ -3234,7 +3237,7 @@ var DataSpace = class {
3234
3237
  await this._createWritableFeeds();
3235
3238
  log10("writable feeds created", void 0, {
3236
3239
  F: __dxlog_file12,
3237
- L: 301,
3240
+ L: 302,
3238
3241
  S: this,
3239
3242
  C: (f, a) => f(...a)
3240
3243
  });
@@ -3291,6 +3294,40 @@ var DataSpace = class {
3291
3294
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
3292
3295
  }
3293
3296
  }
3297
+ _onNewAutomergeRoot(rootUrl) {
3298
+ log10.info("loading automerge root doc for space", {
3299
+ space: this.key,
3300
+ rootUrl
3301
+ }, {
3302
+ F: __dxlog_file12,
3303
+ L: 368,
3304
+ S: this,
3305
+ C: (f, a) => f(...a)
3306
+ });
3307
+ const handle = this._automergeHost.repo.find(rootUrl);
3308
+ queueMicrotask(async () => {
3309
+ try {
3310
+ await handle.whenReady();
3311
+ const doc = handle.docSync() ?? failedInvariant();
3312
+ if (!doc.experimental_spaceKey) {
3313
+ handle.change((doc2) => {
3314
+ doc2.experimental_spaceKey = this.key.toHex();
3315
+ });
3316
+ }
3317
+ } catch (err) {
3318
+ log10.warn("error loading automerge root doc", {
3319
+ space: this.key,
3320
+ rootUrl,
3321
+ err
3322
+ }, {
3323
+ F: __dxlog_file12,
3324
+ L: 381,
3325
+ S: this,
3326
+ C: (f, a) => f(...a)
3327
+ });
3328
+ }
3329
+ });
3330
+ }
3294
3331
  // TODO(dmaretskyi): Use profile from signing context.
3295
3332
  async updateOwnProfile(profile) {
3296
3333
  const credential = await this._signingContext.credentialSigner.createCredential({
@@ -3374,7 +3411,7 @@ var DataSpace = class {
3374
3411
  state: SpaceState[this._state]
3375
3412
  }, {
3376
3413
  F: __dxlog_file12,
3377
- L: 450,
3414
+ L: 470,
3378
3415
  S: this,
3379
3416
  C: (f, a) => f(...a)
3380
3417
  });
@@ -3633,12 +3670,15 @@ var DataSpaceManager = class {
3633
3670
  });
3634
3671
  const space = await this._constructSpace(metadata);
3635
3672
  const automergeRoot = this._automergeHost.repo.create();
3673
+ automergeRoot.change((doc) => {
3674
+ doc.experimental_spaceKey = spaceKey.toHex();
3675
+ });
3636
3676
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3637
3677
  await this._metadataStore.addSpace(metadata);
3638
3678
  const memberCredential = credentials[1];
3639
3679
  invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3640
3680
  F: __dxlog_file13,
3641
- L: 151,
3681
+ L: 154,
3642
3682
  S: this,
3643
3683
  A: [
3644
3684
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3656,13 +3696,13 @@ var DataSpaceManager = class {
3656
3696
  opts
3657
3697
  }, {
3658
3698
  F: __dxlog_file13,
3659
- L: 163,
3699
+ L: 166,
3660
3700
  S: this,
3661
3701
  C: (f, a) => f(...a)
3662
3702
  });
3663
3703
  invariant11(this._isOpen, "Not open.", {
3664
3704
  F: __dxlog_file13,
3665
- L: 164,
3705
+ L: 167,
3666
3706
  S: this,
3667
3707
  A: [
3668
3708
  "this._isOpen",
@@ -3671,7 +3711,7 @@ var DataSpaceManager = class {
3671
3711
  });
3672
3712
  invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3673
3713
  F: __dxlog_file13,
3674
- L: 165,
3714
+ L: 168,
3675
3715
  S: this,
3676
3716
  A: [
3677
3717
  "!this._spaces.has(opts.spaceKey)",
@@ -3706,7 +3746,7 @@ var DataSpaceManager = class {
3706
3746
  metadata
3707
3747
  }, {
3708
3748
  F: __dxlog_file13,
3709
- L: 198,
3749
+ L: 201,
3710
3750
  S: this,
3711
3751
  C: (f, a) => f(...a)
3712
3752
  });
@@ -3733,17 +3773,18 @@ var DataSpaceManager = class {
3733
3773
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
3734
3774
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
3735
3775
  },
3736
- onNetworkConnection: (session) => {
3776
+ onAuthorizedConnection: (session) => {
3737
3777
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
3738
3778
  remotePeerId: session.remotePeerId
3739
3779
  }));
3740
3780
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3781
+ this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
3741
3782
  session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
3742
3783
  },
3743
3784
  onAuthFailure: () => {
3744
3785
  log11.warn("auth failure", void 0, {
3745
3786
  F: __dxlog_file13,
3746
- L: 234,
3787
+ L: 238,
3747
3788
  S: this,
3748
3789
  C: (f, a) => f(...a)
3749
3790
  });
@@ -3767,7 +3808,7 @@ var DataSpaceManager = class {
3767
3808
  space: space.key
3768
3809
  }, {
3769
3810
  F: __dxlog_file13,
3770
- L: 252,
3811
+ L: 256,
3771
3812
  S: this,
3772
3813
  C: (f, a) => f(...a)
3773
3814
  });
@@ -3779,7 +3820,7 @@ var DataSpaceManager = class {
3779
3820
  open: this._isOpen
3780
3821
  }, {
3781
3822
  F: __dxlog_file13,
3782
- L: 259,
3823
+ L: 263,
3783
3824
  S: this,
3784
3825
  C: (f, a) => f(...a)
3785
3826
  });
@@ -3792,7 +3833,7 @@ var DataSpaceManager = class {
3792
3833
  space: space.key
3793
3834
  }, {
3794
3835
  F: __dxlog_file13,
3795
- L: 265,
3836
+ L: 269,
3796
3837
  S: this,
3797
3838
  C: (f, a) => f(...a)
3798
3839
  });
@@ -5222,4 +5263,4 @@ export {
5222
5263
  createDefaultModelFactory,
5223
5264
  ClientServicesHost
5224
5265
  };
5225
- //# sourceMappingURL=chunk-BRZQYU65.mjs.map
5266
+ //# sourceMappingURL=chunk-U3NZJDAP.mjs.map