@dxos/client-services 0.1.45 → 0.1.46-next.01810f0

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.
@@ -436,12 +436,12 @@ var TrustedKeySetAuthVerifier = class {
436
436
  // packages/sdk/client-services/src/packlets/identity/identity.ts
437
437
  import assert from "@dxos/node-std/assert";
438
438
  import { Event } from "@dxos/async";
439
+ import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
439
440
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
440
441
  import { failUndefined } from "@dxos/debug";
441
442
  import { writeMessages } from "@dxos/feed-store";
442
443
  import { log as log2 } from "@dxos/log";
443
444
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
444
- var AUTH_TIMEOUT = 3e4;
445
445
  var Identity = class {
446
446
  constructor({ space, signer, identityKey, deviceKey }) {
447
447
  this.stateUpdate = new Event();
@@ -482,7 +482,7 @@ var Identity = class {
482
482
  async ready() {
483
483
  await this._deviceStateMachine.processor.deviceChainReady.wait();
484
484
  await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
485
- timeout: 3e3
485
+ timeout: LOAD_CONTROL_FEEDS_TIMEOUT
486
486
  });
487
487
  }
488
488
  get profileDocument() {
@@ -534,7 +534,7 @@ var Identity = class {
534
534
  dataFeedKey
535
535
  }, {
536
536
  file: "identity.ts",
537
- line: 160,
537
+ line: 156,
538
538
  scope: this,
539
539
  callSite: (f, a) => f(...a)
540
540
  });
@@ -2008,6 +2008,7 @@ var SpaceInvitationProtocol = class {
2008
2008
 
2009
2009
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2010
2010
  import { Event as Event5, scheduleTask as scheduleTask4, trackLeaks } from "@dxos/async";
2011
+ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2011
2012
  import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
2012
2013
  import { timed } from "@dxos/debug";
2013
2014
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
@@ -2268,7 +2269,6 @@ var __decorate = function(decorators, target, key, desc) {
2268
2269
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2269
2270
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2270
2271
  };
2271
- var AUTH_TIMEOUT2 = 3e4;
2272
2272
  var DataSpace = class DataSpace2 {
2273
2273
  constructor(params) {
2274
2274
  this._ctx = new Context6();
@@ -2356,7 +2356,7 @@ var DataSpace = class DataSpace2 {
2356
2356
  if (err instanceof CancelledError) {
2357
2357
  log9("Data pipeline initialization cancelled", err, {
2358
2358
  file: "data-space.ts",
2359
- line: 173,
2359
+ line: 172,
2360
2360
  scope: this,
2361
2361
  callSite: (f, a) => f(...a)
2362
2362
  });
@@ -2364,7 +2364,7 @@ var DataSpace = class DataSpace2 {
2364
2364
  }
2365
2365
  log9.error("Error initializing data pipeline", err, {
2366
2366
  file: "data-space.ts",
2367
- line: 177,
2367
+ line: 176,
2368
2368
  scope: this,
2369
2369
  callSite: (f, a) => f(...a)
2370
2370
  });
@@ -2390,7 +2390,7 @@ var DataSpace = class DataSpace2 {
2390
2390
  await this._createWritableFeeds();
2391
2391
  log9("Writable feeds created", {}, {
2392
2392
  file: "data-space.ts",
2393
- line: 202,
2393
+ line: 201,
2394
2394
  scope: this,
2395
2395
  callSite: (f, a) => f(...a)
2396
2396
  });
@@ -2405,7 +2405,7 @@ var DataSpace = class DataSpace2 {
2405
2405
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2406
2406
  log9("waiting for data pipeline to reach target timeframe", {}, {
2407
2407
  file: "data-space.ts",
2408
- line: 221,
2408
+ line: 220,
2409
2409
  scope: this,
2410
2410
  callSite: (f, a) => f(...a)
2411
2411
  });
@@ -2416,7 +2416,7 @@ var DataSpace = class DataSpace2 {
2416
2416
  this.metrics.dataPipelineReady = new Date();
2417
2417
  log9("data pipeline ready", {}, {
2418
2418
  file: "data-space.ts",
2419
- line: 230,
2419
+ line: 229,
2420
2420
  scope: this,
2421
2421
  callSite: (f, a) => f(...a)
2422
2422
  });
@@ -3149,6 +3149,7 @@ var MemoryShellRuntime = class {
3149
3149
 
3150
3150
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3151
3151
  import { Trigger as Trigger10 } from "@dxos/async";
3152
+ import { PROXY_CONNECTION_TIMEOUT as PROXY_CONNECTION_TIMEOUT2 } from "@dxos/client-protocol";
3152
3153
  import { log as log19, logInfo as logInfo3 } from "@dxos/log";
3153
3154
  import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager3 } from "@dxos/messaging";
3154
3155
  import { createWebRTCTransportFactory as createWebRTCTransportFactory2 } from "@dxos/network-manager";
@@ -3425,6 +3426,7 @@ var IFrameProxyRuntime = class {
3425
3426
 
3426
3427
  // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3427
3428
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3429
+ import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3428
3430
  import { log as log14, logInfo } from "@dxos/log";
3429
3431
  var __decorate3 = function(decorators, target, key, desc) {
3430
3432
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3459,28 +3461,28 @@ var VaultResourceLock = class {
3459
3461
  try {
3460
3462
  log14("aquiring lock...", {}, {
3461
3463
  file: "vault-resource-lock.ts",
3462
- line: 44,
3464
+ line: 45,
3463
3465
  scope: this,
3464
3466
  callSite: (f, a) => f(...a)
3465
3467
  });
3466
- await asyncTimeout(this._requestLock(), 3e3);
3468
+ await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
3467
3469
  log14("acquired lock", {}, {
3468
3470
  file: "vault-resource-lock.ts",
3469
- line: 46,
3471
+ line: 47,
3470
3472
  scope: this,
3471
3473
  callSite: (f, a) => f(...a)
3472
3474
  });
3473
3475
  } catch (e) {
3474
3476
  log14("stealing lock...", {}, {
3475
3477
  file: "vault-resource-lock.ts",
3476
- line: 48,
3478
+ line: 49,
3477
3479
  scope: this,
3478
3480
  callSite: (f, a) => f(...a)
3479
3481
  });
3480
3482
  await this._requestLock(true);
3481
3483
  log14("stolen lock", {}, {
3482
3484
  file: "vault-resource-lock.ts",
3483
- line: 50,
3485
+ line: 51,
3484
3486
  scope: this,
3485
3487
  callSite: (f, a) => f(...a)
3486
3488
  });
@@ -3499,7 +3501,7 @@ var VaultResourceLock = class {
3499
3501
  steal
3500
3502
  }, {
3501
3503
  file: "vault-resource-lock.ts",
3502
- line: 65,
3504
+ line: 66,
3503
3505
  scope: this,
3504
3506
  callSite: (f, a) => f(...a)
3505
3507
  });
@@ -3514,14 +3516,14 @@ var VaultResourceLock = class {
3514
3516
  await this._releaseTrigger.wait();
3515
3517
  log14("releasing lock...", {}, {
3516
3518
  file: "vault-resource-lock.ts",
3517
- line: 74,
3519
+ line: 75,
3518
3520
  scope: this,
3519
3521
  callSite: (f, a) => f(...a)
3520
3522
  });
3521
3523
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3522
3524
  log14("released lock", {}, {
3523
3525
  file: "vault-resource-lock.ts",
3524
- line: 76,
3526
+ line: 77,
3525
3527
  scope: this,
3526
3528
  callSite: (f, a) => f(...a)
3527
3529
  });
@@ -3534,7 +3536,7 @@ var VaultResourceLock = class {
3534
3536
  steal
3535
3537
  }, {
3536
3538
  file: "vault-resource-lock.ts",
3537
- line: 83,
3539
+ line: 84,
3538
3540
  scope: this,
3539
3541
  callSite: (f, a) => f(...a)
3540
3542
  });
@@ -3553,7 +3555,7 @@ import { WebRTCTransportProxyFactory } from "@dxos/network-manager";
3553
3555
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3554
3556
  import assert12 from "@dxos/node-std/assert";
3555
3557
  import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
3556
- import { iframeServiceBundle as iframeServiceBundle2, workerServiceBundle as workerServiceBundle2 } from "@dxos/client-protocol";
3558
+ import { iframeServiceBundle as iframeServiceBundle2, PROXY_CONNECTION_TIMEOUT, workerServiceBundle as workerServiceBundle2 } from "@dxos/client-protocol";
3557
3559
  import { log as log15, logInfo as logInfo2 } from "@dxos/log";
3558
3560
  import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
3559
3561
  import { Callback } from "@dxos/util";
@@ -3631,7 +3633,7 @@ var WorkerSession = class {
3631
3633
  const middleware = {
3632
3634
  handleCall: async (method, params, handler) => {
3633
3635
  const error = await readySignal.wait({
3634
- timeout: 3e3
3636
+ timeout: PROXY_CONNECTION_TIMEOUT
3635
3637
  });
3636
3638
  if (error) {
3637
3639
  throw error;
@@ -3640,7 +3642,7 @@ var WorkerSession = class {
3640
3642
  },
3641
3643
  handleStream: async (method, params, handler) => {
3642
3644
  const error = await readySignal.wait({
3643
- timeout: 3e3
3645
+ timeout: PROXY_CONNECTION_TIMEOUT
3644
3646
  });
3645
3647
  if (error) {
3646
3648
  throw error;
@@ -3675,7 +3677,7 @@ var WorkerSession = class {
3675
3677
  } catch (err) {
3676
3678
  log15.catch(err, {}, {
3677
3679
  file: "worker-session.ts",
3678
- line: 95,
3680
+ line: 100,
3679
3681
  scope: this,
3680
3682
  callSite: (f, a) => f(...a)
3681
3683
  });
@@ -3692,7 +3694,7 @@ var WorkerSession = class {
3692
3694
  async open() {
3693
3695
  log15.info("opening..", {}, {
3694
3696
  file: "worker-session.ts",
3695
- line: 109,
3697
+ line: 114,
3696
3698
  scope: this,
3697
3699
  callSite: (f, a) => f(...a)
3698
3700
  });
@@ -3702,7 +3704,7 @@ var WorkerSession = class {
3702
3704
  this._maybeOpenShell()
3703
3705
  ]);
3704
3706
  await this._startTrigger.wait({
3705
- timeout: 3e3
3707
+ timeout: PROXY_CONNECTION_TIMEOUT
3706
3708
  });
3707
3709
  if (this.lockKey) {
3708
3710
  void this._afterLockReleases(this.lockKey, () => this.close());
@@ -3711,7 +3713,7 @@ var WorkerSession = class {
3711
3713
  async close() {
3712
3714
  log15.info("closing..", {}, {
3713
3715
  file: "worker-session.ts",
3714
- line: 119,
3716
+ line: 124,
3715
3717
  scope: this,
3716
3718
  callSite: (f, a) => f(...a)
3717
3719
  });
@@ -3720,7 +3722,7 @@ var WorkerSession = class {
3720
3722
  } catch (err) {
3721
3723
  log15.catch(err, {}, {
3722
3724
  file: "worker-session.ts",
3723
- line: 123,
3725
+ line: 128,
3724
3726
  scope: this,
3725
3727
  callSite: (f, a) => f(...a)
3726
3728
  });
@@ -3736,7 +3738,7 @@ var WorkerSession = class {
3736
3738
  } catch (e) {
3737
3739
  log15.info("No shell connected.", {}, {
3738
3740
  file: "worker-session.ts",
3739
- line: 133,
3741
+ line: 138,
3740
3742
  scope: this,
3741
3743
  callSite: (f, a) => f(...a)
3742
3744
  });
@@ -3859,7 +3861,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
3859
3861
  import { Keyring } from "@dxos/keyring";
3860
3862
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3861
3863
  import { log as log17 } from "@dxos/log";
3862
- import { trace as trace5 } from "@dxos/protocols";
3864
+ import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
3863
3865
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
3864
3866
  var ServiceContext = class {
3865
3867
  // prettier-ignore
@@ -3907,9 +3909,10 @@ var ServiceContext = class {
3907
3909
  scope: this,
3908
3910
  callSite: (f, a) => f(...a)
3909
3911
  });
3912
+ await this._checkStorageVersion();
3910
3913
  log17("opening...", {}, {
3911
3914
  file: "service-context.ts",
3912
- line: 121,
3915
+ line: 123,
3913
3916
  scope: this,
3914
3917
  callSite: (f, a) => f(...a)
3915
3918
  });
@@ -3922,7 +3925,7 @@ var ServiceContext = class {
3922
3925
  }
3923
3926
  log17("opened", {}, {
3924
3927
  file: "service-context.ts",
3925
- line: 129,
3928
+ line: 131,
3926
3929
  scope: this,
3927
3930
  callSite: (f, a) => f(...a)
3928
3931
  });
@@ -3930,7 +3933,7 @@ var ServiceContext = class {
3930
3933
  id: this._instanceId
3931
3934
  }), {
3932
3935
  file: "service-context.ts",
3933
- line: 130,
3936
+ line: 132,
3934
3937
  scope: this,
3935
3938
  callSite: (f, a) => f(...a)
3936
3939
  });
@@ -3939,7 +3942,7 @@ var ServiceContext = class {
3939
3942
  var _a, _b;
3940
3943
  log17("closing...", {}, {
3941
3944
  file: "service-context.ts",
3942
- line: 134,
3945
+ line: 136,
3943
3946
  scope: this,
3944
3947
  callSite: (f, a) => f(...a)
3945
3948
  });
@@ -3953,7 +3956,7 @@ var ServiceContext = class {
3953
3956
  this.dataServiceSubscriptions.clear();
3954
3957
  log17("closed", {}, {
3955
3958
  file: "service-context.ts",
3956
- line: 143,
3959
+ line: 145,
3957
3960
  scope: this,
3958
3961
  callSite: (f, a) => f(...a)
3959
3962
  });
@@ -3973,12 +3976,27 @@ var ServiceContext = class {
3973
3976
  await this._initialize();
3974
3977
  return identity;
3975
3978
  }
3979
+ async _checkStorageVersion() {
3980
+ await this.metadataStore.load();
3981
+ if (this.metadataStore.version !== STORAGE_VERSION) {
3982
+ log17.error("Invalid storage version", {
3983
+ current: this.metadataStore.version,
3984
+ expected: STORAGE_VERSION
3985
+ }, {
3986
+ file: "service-context.ts",
3987
+ line: 171,
3988
+ scope: this,
3989
+ callSite: (f, a) => f(...a)
3990
+ });
3991
+ await this.metadataStore.clear();
3992
+ }
3993
+ }
3976
3994
  // Called when identity is created.
3977
3995
  async _initialize() {
3978
3996
  var _a;
3979
3997
  log17("initializing spaces...", {}, {
3980
3998
  file: "service-context.ts",
3981
- line: 168,
3999
+ line: 179,
3982
4000
  scope: this,
3983
4001
  callSite: (f, a) => f(...a)
3984
4002
  });
@@ -4017,7 +4035,7 @@ var ServiceContext = class {
4017
4035
  details: assertion
4018
4036
  }, {
4019
4037
  file: "service-context.ts",
4020
- line: 207,
4038
+ line: 218,
4021
4039
  scope: this,
4022
4040
  callSite: (f, a) => f(...a)
4023
4041
  });
@@ -4028,7 +4046,7 @@ var ServiceContext = class {
4028
4046
  details: assertion
4029
4047
  }, {
4030
4048
  file: "service-context.ts",
4031
- line: 211,
4049
+ line: 222,
4032
4050
  scope: this,
4033
4051
  callSite: (f, a) => f(...a)
4034
4052
  });
@@ -4039,7 +4057,7 @@ var ServiceContext = class {
4039
4057
  details: assertion
4040
4058
  }, {
4041
4059
  file: "service-context.ts",
4042
- line: 216,
4060
+ line: 227,
4043
4061
  scope: this,
4044
4062
  callSite: (f, a) => f(...a)
4045
4063
  });
@@ -4050,7 +4068,7 @@ var ServiceContext = class {
4050
4068
  } catch (err) {
4051
4069
  log17.catch(err, {}, {
4052
4070
  file: "service-context.ts",
4053
- line: 222,
4071
+ line: 233,
4054
4072
  scope: this,
4055
4073
  callSite: (f, a) => f(...a)
4056
4074
  });
@@ -4370,7 +4388,7 @@ var IFrameHostRuntime = class {
4370
4388
  var _a;
4371
4389
  log19("starting...", {}, {
4372
4390
  file: "iframe-host-runtime.ts",
4373
- line: 69,
4391
+ line: 70,
4374
4392
  scope: this,
4375
4393
  callSite: (f, a) => f(...a)
4376
4394
  });
@@ -4389,7 +4407,7 @@ var IFrameHostRuntime = class {
4389
4407
  const middleware = {
4390
4408
  handleCall: async (method, params, handler) => {
4391
4409
  const error = await this._ready.wait({
4392
- timeout: 3e3
4410
+ timeout: PROXY_CONNECTION_TIMEOUT2
4393
4411
  });
4394
4412
  if (error) {
4395
4413
  throw error;
@@ -4398,7 +4416,7 @@ var IFrameHostRuntime = class {
4398
4416
  },
4399
4417
  handleStream: async (method, params, handler) => {
4400
4418
  const error = await this._ready.wait({
4401
- timeout: 3e3
4419
+ timeout: PROXY_CONNECTION_TIMEOUT2
4402
4420
  });
4403
4421
  if (error) {
4404
4422
  throw error;
@@ -4419,7 +4437,7 @@ var IFrameHostRuntime = class {
4419
4437
  this._ready.wake(void 0);
4420
4438
  log19("started", {}, {
4421
4439
  file: "iframe-host-runtime.ts",
4422
- line: 112,
4440
+ line: 113,
4423
4441
  scope: this,
4424
4442
  callSite: (f, a) => f(...a)
4425
4443
  });
@@ -4427,7 +4445,7 @@ var IFrameHostRuntime = class {
4427
4445
  this._ready.wake(err);
4428
4446
  log19.catch(err, {}, {
4429
4447
  file: "iframe-host-runtime.ts",
4430
- line: 115,
4448
+ line: 116,
4431
4449
  scope: this,
4432
4450
  callSite: (f, a) => f(...a)
4433
4451
  });
@@ -4437,7 +4455,7 @@ var IFrameHostRuntime = class {
4437
4455
  var _a;
4438
4456
  log19("stopping...", {}, {
4439
4457
  file: "iframe-host-runtime.ts",
4440
- line: 120,
4458
+ line: 121,
4441
4459
  scope: this,
4442
4460
  callSite: (f, a) => f(...a)
4443
4461
  });
@@ -4446,7 +4464,7 @@ var IFrameHostRuntime = class {
4446
4464
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4447
4465
  log19("stopped", {}, {
4448
4466
  file: "iframe-host-runtime.ts",
4449
- line: 124,
4467
+ line: 125,
4450
4468
  scope: this,
4451
4469
  callSite: (f, a) => f(...a)
4452
4470
  });
@@ -4492,4 +4510,4 @@ export {
4492
4510
  ClientServicesHost,
4493
4511
  LocalClientServices
4494
4512
  };
4495
- //# sourceMappingURL=chunk-IHSMRQ3L.mjs.map
4513
+ //# sourceMappingURL=chunk-MGKMTUPD.mjs.map