@dxos/client-services 0.1.56-main.538bda2 → 0.1.56-main.5db35f4

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.
@@ -70,7 +70,7 @@ var import_protocols = require("@dxos/protocols");
70
70
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
71
71
 
72
72
  // packages/sdk/client-services/src/version.ts
73
- var DXOS_VERSION = "0.1.56-main.538bda2";
73
+ var DXOS_VERSION = "0.1.56-main.5db35f4";
74
74
 
75
75
  // packages/sdk/client-services/src/packlets/services/platform.ts
76
76
  var getPlatform = () => {
@@ -531,6 +531,7 @@ var import_keys2 = require("@dxos/keys");
531
531
  var import_log4 = require("@dxos/log");
532
532
  var import_protocols3 = require("@dxos/protocols");
533
533
  var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
534
+ var import_timeframe = require("@dxos/timeframe");
534
535
  var import_tracing2 = require("@dxos/tracing");
535
536
  var import_util = require("@dxos/util");
536
537
  function _ts_decorate2(decorators, target, key, desc) {
@@ -755,10 +756,42 @@ var IdentityManager = class IdentityManager2 {
755
756
  });
756
757
  return identity;
757
758
  }
759
+ /**
760
+ * Update the profile document of an existing identity.
761
+ */
762
+ async updateProfile(profile) {
763
+ (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
764
+ F: __dxlog_file4,
765
+ L: 200,
766
+ S: this,
767
+ A: [
768
+ "this._identity",
769
+ "'Identity not initialized.'"
770
+ ]
771
+ });
772
+ const credential = await this._identity.getIdentityCredentialSigner().createCredential({
773
+ subject: this._identity.identityKey,
774
+ assertion: {
775
+ "@type": "dxos.halo.credentials.IdentityProfile",
776
+ profile
777
+ }
778
+ });
779
+ const receipt = await this._identity.controlPipeline.writer.write({
780
+ credential: {
781
+ credential
782
+ }
783
+ });
784
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
785
+ [
786
+ receipt.feedKey,
787
+ receipt.seq
788
+ ]
789
+ ]));
790
+ }
758
791
  async _constructIdentity(identityRecord) {
759
792
  (0, import_invariant3.invariant)(!this._identity, void 0, {
760
793
  F: __dxlog_file4,
761
- L: 197,
794
+ L: 214,
762
795
  S: this,
763
796
  A: [
764
797
  "!this._identity",
@@ -769,13 +802,13 @@ var IdentityManager = class IdentityManager2 {
769
802
  identityRecord
770
803
  }, {
771
804
  F: __dxlog_file4,
772
- L: 198,
805
+ L: 215,
773
806
  S: this,
774
807
  C: (f, a) => f(...a)
775
808
  });
776
809
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
777
810
  F: __dxlog_file4,
778
- L: 201,
811
+ L: 218,
779
812
  S: this,
780
813
  A: [
781
814
  "identityRecord.haloSpace.controlFeedKey",
@@ -787,7 +820,7 @@ var IdentityManager = class IdentityManager2 {
787
820
  });
788
821
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
789
822
  F: __dxlog_file4,
790
- L: 205,
823
+ L: 222,
791
824
  S: this,
792
825
  A: [
793
826
  "identityRecord.haloSpace.dataFeedKey",
@@ -819,7 +852,7 @@ var IdentityManager = class IdentityManager2 {
819
852
  identityKey: identityRecord.identityKey
820
853
  }, {
821
854
  F: __dxlog_file4,
822
- L: 229,
855
+ L: 246,
823
856
  S: this,
824
857
  C: (f, a) => f(...a)
825
858
  });
@@ -840,7 +873,7 @@ var IdentityManager = class IdentityManager2 {
840
873
  onAuthFailure: () => {
841
874
  import_log4.log.warn("auth failure", void 0, {
842
875
  F: __dxlog_file4,
843
- L: 248,
876
+ L: 265,
844
877
  S: this,
845
878
  C: (f, a) => f(...a)
846
879
  });
@@ -863,12 +896,13 @@ var import_debug3 = require("@dxos/debug");
863
896
  var import_invariant4 = require("@dxos/invariant");
864
897
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
865
898
  var IdentityServiceImpl = class {
866
- // TODO(wittjosiah): Remove dependency on service context.
867
- constructor(_serviceContext) {
868
- this._serviceContext = _serviceContext;
899
+ constructor(_createIdentity, _identityManager, _keyring) {
900
+ this._createIdentity = _createIdentity;
901
+ this._identityManager = _identityManager;
902
+ this._keyring = _keyring;
869
903
  }
870
904
  async createIdentity(request) {
871
- await this._serviceContext.createIdentity(request);
905
+ await this._createIdentity(request);
872
906
  return this._getIdentity();
873
907
  }
874
908
  async recoverIdentity(request) {
@@ -880,34 +914,47 @@ var IdentityServiceImpl = class {
880
914
  identity: this._getIdentity()
881
915
  });
882
916
  emitNext();
883
- return this._serviceContext.identityManager.stateUpdate.on(emitNext);
917
+ return this._identityManager.stateUpdate.on(emitNext);
884
918
  });
885
919
  }
886
920
  _getIdentity() {
887
- if (!this._serviceContext.identityManager.identity) {
921
+ if (!this._identityManager.identity) {
888
922
  return void 0;
889
923
  }
890
924
  return {
891
- identityKey: this._serviceContext.identityManager.identity.identityKey,
892
- spaceKey: this._serviceContext.identityManager.identity.space.key,
893
- profile: this._serviceContext.identityManager.identity.profileDocument
925
+ identityKey: this._identityManager.identity.identityKey,
926
+ spaceKey: this._identityManager.identity.space.key,
927
+ profile: this._identityManager.identity.profileDocument
894
928
  };
895
929
  }
930
+ async updateProfile(profile) {
931
+ (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
932
+ F: __dxlog_file5,
933
+ L: 59,
934
+ S: this,
935
+ A: [
936
+ "this._identityManager.identity",
937
+ "'Identity not initialized.'"
938
+ ]
939
+ });
940
+ await this._identityManager.updateProfile(profile);
941
+ return this._getIdentity();
942
+ }
896
943
  async signPresentation({ presentation, nonce }) {
897
- (0, import_invariant4.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
944
+ (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
898
945
  F: __dxlog_file5,
899
- L: 56,
946
+ L: 65,
900
947
  S: this,
901
948
  A: [
902
- "this._serviceContext.identityManager.identity",
949
+ "this._identityManager.identity",
903
950
  "'Identity not initialized.'"
904
951
  ]
905
952
  });
906
953
  return await (0, import_credentials8.signPresentation)({
907
954
  presentation,
908
- signer: this._serviceContext.keyring,
909
- signerKey: this._serviceContext.identityManager.identity.deviceKey,
910
- chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
955
+ signer: this._keyring,
956
+ signerKey: this._identityManager.identity.deviceKey,
957
+ chain: this._identityManager.identity.deviceCredentialChain,
911
958
  nonce
912
959
  });
913
960
  }
@@ -2272,7 +2319,7 @@ var import_keys6 = require("@dxos/keys");
2272
2319
  var import_log10 = require("@dxos/log");
2273
2320
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2274
2321
  var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
2275
- var import_timeframe = require("@dxos/timeframe");
2322
+ var import_timeframe2 = require("@dxos/timeframe");
2276
2323
  var import_util3 = require("@dxos/util");
2277
2324
 
2278
2325
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
@@ -2780,7 +2827,7 @@ var DataSpace = class DataSpace2 {
2780
2827
  })
2781
2828
  }
2782
2829
  });
2783
- await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
2830
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
2784
2831
  [
2785
2832
  receipt.feedKey,
2786
2833
  receipt.seq
@@ -2837,7 +2884,7 @@ DataSpace = _ts_decorate3([
2837
2884
  var import_credentials12 = require("@dxos/credentials");
2838
2885
  var import_debug5 = require("@dxos/debug");
2839
2886
  var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
2840
- var import_timeframe2 = require("@dxos/timeframe");
2887
+ var import_timeframe3 = require("@dxos/timeframe");
2841
2888
  var spaceGenesis = async (keyring, signingContext, space) => {
2842
2889
  const credentials = [
2843
2890
  await (0, import_credentials12.createCredential)({
@@ -2887,7 +2934,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2887
2934
  "@type": "dxos.halo.credentials.Epoch",
2888
2935
  number: 0,
2889
2936
  previousId: void 0,
2890
- timeframe: new import_timeframe2.Timeframe(),
2937
+ timeframe: new import_timeframe3.Timeframe(),
2891
2938
  snapshotCid: void 0
2892
2939
  }
2893
2940
  })
@@ -4574,7 +4621,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4574
4621
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4575
4622
  this._serviceRegistry.setServices({
4576
4623
  SystemService: this._systemService,
4577
- IdentityService: new IdentityServiceImpl(this._serviceContext),
4624
+ IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4578
4625
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4579
4626
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4580
4627
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4601,7 +4648,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4601
4648
  deviceKey
4602
4649
  }, {
4603
4650
  F: __dxlog_file17,
4604
- L: 280,
4651
+ L: 284,
4605
4652
  S: this,
4606
4653
  C: (f, a) => f(...a)
4607
4654
  });
@@ -4609,7 +4656,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4609
4656
  id: traceId
4610
4657
  }), {
4611
4658
  F: __dxlog_file17,
4612
- L: 281,
4659
+ L: 285,
4613
4660
  S: this,
4614
4661
  C: (f, a) => f(...a)
4615
4662
  });
@@ -4623,7 +4670,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4623
4670
  deviceKey
4624
4671
  }, {
4625
4672
  F: __dxlog_file17,
4626
- L: 292,
4673
+ L: 296,
4627
4674
  S: this,
4628
4675
  C: (f, a) => f(...a)
4629
4676
  });
@@ -4638,7 +4685,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4638
4685
  deviceKey
4639
4686
  }, {
4640
4687
  F: __dxlog_file17,
4641
- L: 298,
4688
+ L: 302,
4642
4689
  S: this,
4643
4690
  C: (f, a) => f(...a)
4644
4691
  });
@@ -4649,13 +4696,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4649
4696
  id: traceId
4650
4697
  }), {
4651
4698
  F: __dxlog_file17,
4652
- L: 303,
4699
+ L: 307,
4653
4700
  S: this,
4654
4701
  C: (f, a) => f(...a)
4655
4702
  });
4656
4703
  (0, import_log16.log)("resetting...", void 0, {
4657
4704
  F: __dxlog_file17,
4658
- L: 305,
4705
+ L: 309,
4659
4706
  S: this,
4660
4707
  C: (f, a) => f(...a)
4661
4708
  });
@@ -4663,7 +4710,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4663
4710
  await this._storage.reset();
4664
4711
  (0, import_log16.log)("reset", void 0, {
4665
4712
  F: __dxlog_file17,
4666
- L: 308,
4713
+ L: 312,
4667
4714
  S: this,
4668
4715
  C: (f, a) => f(...a)
4669
4716
  });
@@ -4671,7 +4718,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4671
4718
  id: traceId
4672
4719
  }), {
4673
4720
  F: __dxlog_file17,
4674
- L: 309,
4721
+ L: 313,
4675
4722
  S: this,
4676
4723
  C: (f, a) => f(...a)
4677
4724
  });