@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.
@@ -633,6 +633,7 @@ import { PublicKey as PublicKey3 } from "@dxos/keys";
633
633
  import { log as log3 } from "@dxos/log";
634
634
  import { trace as trace2 } from "@dxos/protocols";
635
635
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
636
+ import { Timeframe } from "@dxos/timeframe";
636
637
  import { trace as Trace } from "@dxos/tracing";
637
638
  import { deferFunction } from "@dxos/util";
638
639
  function _ts_decorate2(decorators, target, key, desc) {
@@ -857,10 +858,42 @@ var IdentityManager = class IdentityManager2 {
857
858
  });
858
859
  return identity;
859
860
  }
861
+ /**
862
+ * Update the profile document of an existing identity.
863
+ */
864
+ async updateProfile(profile) {
865
+ invariant2(this._identity, "Identity not initialized.", {
866
+ F: __dxlog_file3,
867
+ L: 200,
868
+ S: this,
869
+ A: [
870
+ "this._identity",
871
+ "'Identity not initialized.'"
872
+ ]
873
+ });
874
+ const credential = await this._identity.getIdentityCredentialSigner().createCredential({
875
+ subject: this._identity.identityKey,
876
+ assertion: {
877
+ "@type": "dxos.halo.credentials.IdentityProfile",
878
+ profile
879
+ }
880
+ });
881
+ const receipt = await this._identity.controlPipeline.writer.write({
882
+ credential: {
883
+ credential
884
+ }
885
+ });
886
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
887
+ [
888
+ receipt.feedKey,
889
+ receipt.seq
890
+ ]
891
+ ]));
892
+ }
860
893
  async _constructIdentity(identityRecord) {
861
894
  invariant2(!this._identity, void 0, {
862
895
  F: __dxlog_file3,
863
- L: 197,
896
+ L: 214,
864
897
  S: this,
865
898
  A: [
866
899
  "!this._identity",
@@ -871,13 +904,13 @@ var IdentityManager = class IdentityManager2 {
871
904
  identityRecord
872
905
  }, {
873
906
  F: __dxlog_file3,
874
- L: 198,
907
+ L: 215,
875
908
  S: this,
876
909
  C: (f, a) => f(...a)
877
910
  });
878
911
  invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
879
912
  F: __dxlog_file3,
880
- L: 201,
913
+ L: 218,
881
914
  S: this,
882
915
  A: [
883
916
  "identityRecord.haloSpace.controlFeedKey",
@@ -889,7 +922,7 @@ var IdentityManager = class IdentityManager2 {
889
922
  });
890
923
  invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
891
924
  F: __dxlog_file3,
892
- L: 205,
925
+ L: 222,
893
926
  S: this,
894
927
  A: [
895
928
  "identityRecord.haloSpace.dataFeedKey",
@@ -921,7 +954,7 @@ var IdentityManager = class IdentityManager2 {
921
954
  identityKey: identityRecord.identityKey
922
955
  }, {
923
956
  F: __dxlog_file3,
924
- L: 229,
957
+ L: 246,
925
958
  S: this,
926
959
  C: (f, a) => f(...a)
927
960
  });
@@ -942,7 +975,7 @@ var IdentityManager = class IdentityManager2 {
942
975
  onAuthFailure: () => {
943
976
  log3.warn("auth failure", void 0, {
944
977
  F: __dxlog_file3,
945
- L: 248,
978
+ L: 265,
946
979
  S: this,
947
980
  C: (f, a) => f(...a)
948
981
  });
@@ -965,12 +998,13 @@ import { todo } from "@dxos/debug";
965
998
  import { invariant as invariant3 } from "@dxos/invariant";
966
999
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
967
1000
  var IdentityServiceImpl = class {
968
- // TODO(wittjosiah): Remove dependency on service context.
969
- constructor(_serviceContext) {
970
- this._serviceContext = _serviceContext;
1001
+ constructor(_createIdentity, _identityManager, _keyring) {
1002
+ this._createIdentity = _createIdentity;
1003
+ this._identityManager = _identityManager;
1004
+ this._keyring = _keyring;
971
1005
  }
972
1006
  async createIdentity(request) {
973
- await this._serviceContext.createIdentity(request);
1007
+ await this._createIdentity(request);
974
1008
  return this._getIdentity();
975
1009
  }
976
1010
  async recoverIdentity(request) {
@@ -982,34 +1016,47 @@ var IdentityServiceImpl = class {
982
1016
  identity: this._getIdentity()
983
1017
  });
984
1018
  emitNext();
985
- return this._serviceContext.identityManager.stateUpdate.on(emitNext);
1019
+ return this._identityManager.stateUpdate.on(emitNext);
986
1020
  });
987
1021
  }
988
1022
  _getIdentity() {
989
- if (!this._serviceContext.identityManager.identity) {
1023
+ if (!this._identityManager.identity) {
990
1024
  return void 0;
991
1025
  }
992
1026
  return {
993
- identityKey: this._serviceContext.identityManager.identity.identityKey,
994
- spaceKey: this._serviceContext.identityManager.identity.space.key,
995
- profile: this._serviceContext.identityManager.identity.profileDocument
1027
+ identityKey: this._identityManager.identity.identityKey,
1028
+ spaceKey: this._identityManager.identity.space.key,
1029
+ profile: this._identityManager.identity.profileDocument
996
1030
  };
997
1031
  }
1032
+ async updateProfile(profile) {
1033
+ invariant3(this._identityManager.identity, "Identity not initialized.", {
1034
+ F: __dxlog_file4,
1035
+ L: 59,
1036
+ S: this,
1037
+ A: [
1038
+ "this._identityManager.identity",
1039
+ "'Identity not initialized.'"
1040
+ ]
1041
+ });
1042
+ await this._identityManager.updateProfile(profile);
1043
+ return this._getIdentity();
1044
+ }
998
1045
  async signPresentation({ presentation, nonce }) {
999
- invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.", {
1046
+ invariant3(this._identityManager.identity, "Identity not initialized.", {
1000
1047
  F: __dxlog_file4,
1001
- L: 56,
1048
+ L: 65,
1002
1049
  S: this,
1003
1050
  A: [
1004
- "this._serviceContext.identityManager.identity",
1051
+ "this._identityManager.identity",
1005
1052
  "'Identity not initialized.'"
1006
1053
  ]
1007
1054
  });
1008
1055
  return await signPresentation({
1009
1056
  presentation,
1010
- signer: this._serviceContext.keyring,
1011
- signerKey: this._serviceContext.identityManager.identity.deviceKey,
1012
- chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
1057
+ signer: this._keyring,
1058
+ signerKey: this._identityManager.identity.deviceKey,
1059
+ chain: this._identityManager.identity.deviceCredentialChain,
1013
1060
  nonce
1014
1061
  });
1015
1062
  }
@@ -2413,7 +2460,7 @@ import { STORAGE_VERSION } from "@dxos/protocols";
2413
2460
  import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2414
2461
 
2415
2462
  // packages/sdk/client-services/src/version.ts
2416
- var DXOS_VERSION = "0.1.56-main.538bda2";
2463
+ var DXOS_VERSION = "0.1.56-main.5db35f4";
2417
2464
 
2418
2465
  // packages/sdk/client-services/src/packlets/services/platform.ts
2419
2466
  var getPlatform = () => {
@@ -2572,7 +2619,7 @@ import { PublicKey as PublicKey7 } from "@dxos/keys";
2572
2619
  import { log as log10 } from "@dxos/log";
2573
2620
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2574
2621
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2575
- import { Timeframe } from "@dxos/timeframe";
2622
+ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2576
2623
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2577
2624
 
2578
2625
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
@@ -3080,7 +3127,7 @@ var DataSpace = class DataSpace2 {
3080
3127
  })
3081
3128
  }
3082
3129
  });
3083
- await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([
3130
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
3084
3131
  [
3085
3132
  receipt.feedKey,
3086
3133
  receipt.seq
@@ -3149,7 +3196,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
3149
3196
  import { createCredential } from "@dxos/credentials";
3150
3197
  import { failUndefined as failUndefined2 } from "@dxos/debug";
3151
3198
  import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3152
- import { Timeframe as Timeframe2 } from "@dxos/timeframe";
3199
+ import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3153
3200
  var spaceGenesis = async (keyring, signingContext, space) => {
3154
3201
  const credentials = [
3155
3202
  await createCredential({
@@ -3199,7 +3246,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3199
3246
  "@type": "dxos.halo.credentials.Epoch",
3200
3247
  number: 0,
3201
3248
  previousId: void 0,
3202
- timeframe: new Timeframe2(),
3249
+ timeframe: new Timeframe3(),
3203
3250
  snapshotCid: void 0
3204
3251
  }
3205
3252
  })
@@ -4660,7 +4707,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4660
4707
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4661
4708
  this._serviceRegistry.setServices({
4662
4709
  SystemService: this._systemService,
4663
- IdentityService: new IdentityServiceImpl(this._serviceContext),
4710
+ IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4664
4711
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4665
4712
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4666
4713
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4687,7 +4734,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4687
4734
  deviceKey
4688
4735
  }, {
4689
4736
  F: __dxlog_file17,
4690
- L: 280,
4737
+ L: 284,
4691
4738
  S: this,
4692
4739
  C: (f, a) => f(...a)
4693
4740
  });
@@ -4695,7 +4742,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4695
4742
  id: traceId
4696
4743
  }), {
4697
4744
  F: __dxlog_file17,
4698
- L: 281,
4745
+ L: 285,
4699
4746
  S: this,
4700
4747
  C: (f, a) => f(...a)
4701
4748
  });
@@ -4709,7 +4756,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4709
4756
  deviceKey
4710
4757
  }, {
4711
4758
  F: __dxlog_file17,
4712
- L: 292,
4759
+ L: 296,
4713
4760
  S: this,
4714
4761
  C: (f, a) => f(...a)
4715
4762
  });
@@ -4724,7 +4771,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4724
4771
  deviceKey
4725
4772
  }, {
4726
4773
  F: __dxlog_file17,
4727
- L: 298,
4774
+ L: 302,
4728
4775
  S: this,
4729
4776
  C: (f, a) => f(...a)
4730
4777
  });
@@ -4735,13 +4782,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4735
4782
  id: traceId
4736
4783
  }), {
4737
4784
  F: __dxlog_file17,
4738
- L: 303,
4785
+ L: 307,
4739
4786
  S: this,
4740
4787
  C: (f, a) => f(...a)
4741
4788
  });
4742
4789
  log16("resetting...", void 0, {
4743
4790
  F: __dxlog_file17,
4744
- L: 305,
4791
+ L: 309,
4745
4792
  S: this,
4746
4793
  C: (f, a) => f(...a)
4747
4794
  });
@@ -4749,7 +4796,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4749
4796
  await this._storage.reset();
4750
4797
  log16("reset", void 0, {
4751
4798
  F: __dxlog_file17,
4752
- L: 308,
4799
+ L: 312,
4753
4800
  S: this,
4754
4801
  C: (f, a) => f(...a)
4755
4802
  });
@@ -4757,7 +4804,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4757
4804
  id: traceId
4758
4805
  }), {
4759
4806
  F: __dxlog_file17,
4760
- L: 309,
4807
+ L: 313,
4761
4808
  S: this,
4762
4809
  C: (f, a) => f(...a)
4763
4810
  });
@@ -4815,4 +4862,4 @@ export {
4815
4862
  createDefaultModelFactory,
4816
4863
  ClientServicesHost
4817
4864
  };
4818
- //# sourceMappingURL=chunk-Y4AYNWBO.mjs.map
4865
+ //# sourceMappingURL=chunk-FVGGGXU6.mjs.map