@dxos/client-services 0.4.6-main.9c97a50 → 0.4.6-main.b69a2b5

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 (44) hide show
  1. package/dist/lib/browser/{chunk-7JCJI2VR.mjs → chunk-KFMLOQZY.mjs} +164 -115
  2. package/dist/lib/browser/chunk-KFMLOQZY.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 +7 -7
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-YJ2ASSPD.cjs → chunk-QDJO4DXB.cjs} +177 -128
  8. package/dist/lib/node/chunk-QDJO4DXB.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +37 -37
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +14 -14
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -2
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts +0 -1
  16. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -1
  18. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -2
  20. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  21. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +2 -1
  22. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  23. package/dist/types/src/packlets/invitations/invitations-service.d.ts +2 -2
  24. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/testing/invitation-utils.d.ts +4 -2
  26. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  27. package/dist/types/src/version.d.ts +1 -1
  28. package/package.json +35 -35
  29. package/src/packlets/identity/identity-manager.test.ts +1 -0
  30. package/src/packlets/identity/identity-manager.ts +50 -12
  31. package/src/packlets/identity/identity-service.ts +1 -1
  32. package/src/packlets/identity/identity.test.ts +9 -9
  33. package/src/packlets/identity/identity.ts +0 -9
  34. package/src/packlets/invitations/device-invitation-protocol.ts +5 -2
  35. package/src/packlets/invitations/invitation-protocol.ts +2 -2
  36. package/src/packlets/invitations/invitations-handler.ts +11 -2
  37. package/src/packlets/invitations/invitations-service.ts +8 -2
  38. package/src/packlets/services/service-host.ts +3 -3
  39. package/src/packlets/spaces/data-space-manager.ts +3 -3
  40. package/src/packlets/spaces/data-space.ts +4 -4
  41. package/src/packlets/testing/invitation-utils.ts +8 -4
  42. package/src/version.ts +1 -1
  43. package/dist/lib/browser/chunk-7JCJI2VR.mjs.map +0 -7
  44. package/dist/lib/node/chunk-YJ2ASSPD.cjs.map +0 -7
@@ -464,7 +464,6 @@ var TrustedKeySetAuthVerifier = class {
464
464
  import { Event } from "@dxos/async";
465
465
  import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
466
466
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
467
- import { failUndefined } from "@dxos/debug";
468
467
  import { writeMessages } from "@dxos/feed-store";
469
468
  import { invariant } from "@dxos/invariant";
470
469
  import { PublicKey as PublicKey3 } from "@dxos/keys";
@@ -494,7 +493,7 @@ var Identity = class {
494
493
  deviceKey
495
494
  }, {
496
495
  F: __dxlog_file2,
497
- L: 64,
496
+ L: 63,
498
497
  S: this,
499
498
  C: (f, a) => f(...a)
500
499
  });
@@ -552,13 +551,6 @@ var Identity = class {
552
551
  get deviceCredentialChain() {
553
552
  return this._deviceStateMachine.deviceCredentialChain;
554
553
  }
555
- getAdmissionCredentials() {
556
- return {
557
- deviceKey: this.deviceKey,
558
- controlFeedKey: this.space.controlFeedKey ?? failUndefined(),
559
- dataFeedKey: this.space.dataFeedKey ?? failUndefined()
560
- };
561
- }
562
554
  /**
563
555
  * Issues credentials as identity.
564
556
  * Requires identity to be ready.
@@ -566,7 +558,7 @@ var Identity = class {
566
558
  getIdentityCredentialSigner() {
567
559
  invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
568
560
  F: __dxlog_file2,
569
- L: 145,
561
+ L: 136,
570
562
  S: this,
571
563
  A: [
572
564
  "this._deviceStateMachine.deviceCredentialChain",
@@ -590,7 +582,7 @@ var Identity = class {
590
582
  dataFeedKey
591
583
  }, {
592
584
  F: __dxlog_file2,
593
- L: 161,
585
+ L: 152,
594
586
  S: this,
595
587
  C: (f, a) => f(...a)
596
588
  });
@@ -651,10 +643,10 @@ import { PublicKey as PublicKey4 } from "@dxos/keys";
651
643
  import { log as log3 } from "@dxos/log";
652
644
  import { trace as trace2 } from "@dxos/protocols";
653
645
  import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
654
- import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
646
+ import { AdmittedFeed as AdmittedFeed2, DeviceType } from "@dxos/protocols/proto/dxos/halo/credentials";
655
647
  import { Timeframe } from "@dxos/timeframe";
656
648
  import { trace as Trace } from "@dxos/tracing";
657
- import { deferFunction } from "@dxos/util";
649
+ import { isNode, deferFunction } from "@dxos/util";
658
650
  function _ts_decorate2(decorators, target, key, desc) {
659
651
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
660
652
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -685,7 +677,7 @@ var IdentityManager = class {
685
677
  id: traceId
686
678
  }), {
687
679
  F: __dxlog_file3,
688
- L: 80,
680
+ L: 84,
689
681
  S: this,
690
682
  C: (f, a) => f(...a)
691
683
  });
@@ -694,7 +686,7 @@ var IdentityManager = class {
694
686
  identityRecord
695
687
  }, {
696
688
  F: __dxlog_file3,
697
- L: 83,
689
+ L: 87,
698
690
  S: this,
699
691
  C: (f, a) => f(...a)
700
692
  });
@@ -707,7 +699,7 @@ var IdentityManager = class {
707
699
  displayName: this._identity.profileDocument?.displayName
708
700
  }, {
709
701
  F: __dxlog_file3,
710
- L: 88,
702
+ L: 92,
711
703
  S: this,
712
704
  C: (f, a) => f(...a)
713
705
  });
@@ -717,7 +709,7 @@ var IdentityManager = class {
717
709
  id: traceId
718
710
  }), {
719
711
  F: __dxlog_file3,
720
- L: 94,
712
+ L: 99,
721
713
  S: this,
722
714
  C: (f, a) => f(...a)
723
715
  });
@@ -725,10 +717,10 @@ var IdentityManager = class {
725
717
  async close() {
726
718
  await this._identity?.close(new Context3());
727
719
  }
728
- async createIdentity({ displayName } = {}) {
720
+ async createIdentity({ displayName, deviceProfile } = {}) {
729
721
  invariant2(!this._identity, "Identity already exists.", {
730
722
  F: __dxlog_file3,
731
- L: 102,
723
+ L: 108,
732
724
  S: this,
733
725
  A: [
734
726
  "!this._identity",
@@ -737,7 +729,7 @@ var IdentityManager = class {
737
729
  });
738
730
  log3("creating identity...", void 0, {
739
731
  F: __dxlog_file3,
740
- L: 103,
732
+ L: 109,
741
733
  S: this,
742
734
  C: (f, a) => f(...a)
743
735
  });
@@ -758,7 +750,7 @@ var IdentityManager = class {
758
750
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
759
751
  invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
760
752
  F: __dxlog_file3,
761
- L: 122,
753
+ L: 128,
762
754
  S: this,
763
755
  A: [
764
756
  "identityRecord.haloSpace.genesisFeedKey",
@@ -767,7 +759,7 @@ var IdentityManager = class {
767
759
  });
768
760
  invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
769
761
  F: __dxlog_file3,
770
- L: 123,
762
+ L: 129,
771
763
  S: this,
772
764
  A: [
773
765
  "identityRecord.haloSpace.dataFeedKey",
@@ -787,11 +779,8 @@ var IdentityManager = class {
787
779
  }
788
780
  credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
789
781
  credentials.push(await generator.createDeviceProfile({
790
- platform: platform.name,
791
- platformVersion: platform.version,
792
- architecture: typeof platform.os?.architecture === "number" ? String(platform.os.architecture) : void 0,
793
- os: platform.os?.family,
794
- osVersion: platform.os?.version
782
+ ...this.createDefaultDeviceProfile(),
783
+ ...deviceProfile
795
784
  }));
796
785
  for (const credential of credentials) {
797
786
  await identity.controlPipeline.writer.write({
@@ -809,37 +798,61 @@ var IdentityManager = class {
809
798
  displayName: this._identity.profileDocument?.displayName
810
799
  }, {
811
800
  F: __dxlog_file3,
812
- L: 168,
801
+ L: 171,
813
802
  S: this,
814
803
  C: (f, a) => f(...a)
815
804
  });
816
805
  this.stateUpdate.emit();
817
806
  log3("created identity", {
818
807
  identityKey: identity.identityKey,
819
- deviceKey: identity.deviceKey
808
+ deviceKey: identity.deviceKey,
809
+ profile: identity.profileDocument
820
810
  }, {
821
811
  F: __dxlog_file3,
822
- L: 174,
812
+ L: 177,
823
813
  S: this,
824
814
  C: (f, a) => f(...a)
825
815
  });
826
816
  return identity;
827
817
  }
818
+ // TODO(nf): receive platform info rather than generating it here.
819
+ createDefaultDeviceProfile() {
820
+ let type;
821
+ if (isNode()) {
822
+ type = DeviceType.AGENT;
823
+ } else {
824
+ if (platform.name?.startsWith("iOS") || platform.name?.startsWith("Android")) {
825
+ type = DeviceType.MOBILE;
826
+ } else if (globalThis.__args) {
827
+ type = DeviceType.NATIVE;
828
+ } else {
829
+ type = DeviceType.BROWSER;
830
+ }
831
+ }
832
+ return {
833
+ type,
834
+ platform: platform.name,
835
+ platformVersion: platform.version,
836
+ architecture: typeof platform.os?.architecture === "number" ? String(platform.os.architecture) : void 0,
837
+ os: platform.os?.family,
838
+ osVersion: platform.os?.version
839
+ };
840
+ }
828
841
  /**
829
- * Accept an existing identity. Expects it's device key to be authorized (now or later).
842
+ * Accept an existing identity. Expects its device key to be authorized (now or later).
830
843
  */
831
844
  async acceptIdentity(params) {
832
845
  log3("accepting identity", {
833
846
  params
834
847
  }, {
835
848
  F: __dxlog_file3,
836
- L: 182,
849
+ L: 215,
837
850
  S: this,
838
851
  C: (f, a) => f(...a)
839
852
  });
840
853
  invariant2(!this._identity, "Identity already exists.", {
841
854
  F: __dxlog_file3,
842
- L: 183,
855
+ L: 216,
843
856
  S: this,
844
857
  A: [
845
858
  "!this._identity",
@@ -867,17 +880,21 @@ var IdentityManager = class {
867
880
  displayName: this._identity.profileDocument?.displayName
868
881
  }, {
869
882
  F: __dxlog_file3,
870
- L: 202,
883
+ L: 235,
871
884
  S: this,
872
885
  C: (f, a) => f(...a)
873
886
  });
887
+ await this.updateDeviceProfile({
888
+ ...this.createDefaultDeviceProfile(),
889
+ ...params.deviceProfile
890
+ });
874
891
  this.stateUpdate.emit();
875
892
  log3("accepted identity", {
876
893
  identityKey: identity.identityKey,
877
894
  deviceKey: identity.deviceKey
878
895
  }, {
879
896
  F: __dxlog_file3,
880
- L: 208,
897
+ L: 245,
881
898
  S: this,
882
899
  C: (f, a) => f(...a)
883
900
  });
@@ -889,7 +906,7 @@ var IdentityManager = class {
889
906
  async updateProfile(profile) {
890
907
  invariant2(this._identity, "Identity not initialized.", {
891
908
  F: __dxlog_file3,
892
- L: 216,
909
+ L: 253,
893
910
  S: this,
894
911
  A: [
895
912
  "this._identity",
@@ -920,14 +937,14 @@ var IdentityManager = class {
920
937
  async updateDeviceProfile(profile) {
921
938
  invariant2(this._identity, "Identity not initialized.", {
922
939
  F: __dxlog_file3,
923
- L: 233,
940
+ L: 270,
924
941
  S: this,
925
942
  A: [
926
943
  "this._identity",
927
944
  "'Identity not initialized.'"
928
945
  ]
929
946
  });
930
- const credential = await this._identity.getIdentityCredentialSigner().createCredential({
947
+ const credential = await this._identity.getDeviceCredentialSigner().createCredential({
931
948
  subject: this._identity.deviceKey,
932
949
  assertion: {
933
950
  "@type": "dxos.halo.credentials.DeviceProfile",
@@ -955,7 +972,7 @@ var IdentityManager = class {
955
972
  async _constructIdentity(identityRecord) {
956
973
  invariant2(!this._identity, void 0, {
957
974
  F: __dxlog_file3,
958
- L: 254,
975
+ L: 291,
959
976
  S: this,
960
977
  A: [
961
978
  "!this._identity",
@@ -966,13 +983,13 @@ var IdentityManager = class {
966
983
  identityRecord
967
984
  }, {
968
985
  F: __dxlog_file3,
969
- L: 255,
986
+ L: 292,
970
987
  S: this,
971
988
  C: (f, a) => f(...a)
972
989
  });
973
990
  invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
974
991
  F: __dxlog_file3,
975
- L: 258,
992
+ L: 295,
976
993
  S: this,
977
994
  A: [
978
995
  "identityRecord.haloSpace.controlFeedKey",
@@ -984,7 +1001,7 @@ var IdentityManager = class {
984
1001
  });
985
1002
  invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
986
1003
  F: __dxlog_file3,
987
- L: 262,
1004
+ L: 299,
988
1005
  S: this,
989
1006
  A: [
990
1007
  "identityRecord.haloSpace.dataFeedKey",
@@ -1004,7 +1021,7 @@ var IdentityManager = class {
1004
1021
  },
1005
1022
  identityKey: identityRecord.identityKey
1006
1023
  });
1007
- space.setControlFeed(controlFeed);
1024
+ await space.setControlFeed(controlFeed);
1008
1025
  space.setDataFeed(dataFeed);
1009
1026
  const identity = new Identity({
1010
1027
  space,
@@ -1016,13 +1033,14 @@ var IdentityManager = class {
1016
1033
  identityKey: identityRecord.identityKey
1017
1034
  }, {
1018
1035
  F: __dxlog_file3,
1019
- L: 286,
1036
+ L: 323,
1020
1037
  S: this,
1021
1038
  C: (f, a) => f(...a)
1022
1039
  });
1023
1040
  if (identityRecord.haloSpace.controlTimeframe) {
1024
1041
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
1025
1042
  }
1043
+ identity.stateUpdate.on(() => this.stateUpdate.emit());
1026
1044
  return identity;
1027
1045
  }
1028
1046
  async _constructSpace({ spaceRecord, swarmIdentity, identityKey }) {
@@ -1037,7 +1055,7 @@ var IdentityManager = class {
1037
1055
  onAuthFailure: () => {
1038
1056
  log3.warn("auth failure", void 0, {
1039
1057
  F: __dxlog_file3,
1040
- L: 305,
1058
+ L: 343,
1041
1059
  S: this,
1042
1060
  C: (f, a) => f(...a)
1043
1061
  });
@@ -1069,7 +1087,10 @@ var IdentityServiceImpl = class {
1069
1087
  this._onProfileUpdate = _onProfileUpdate;
1070
1088
  }
1071
1089
  async createIdentity(request) {
1072
- await this._createIdentity(request.profile ?? {});
1090
+ await this._createIdentity({
1091
+ displayName: request.profile?.displayName,
1092
+ deviceProfile: request.deviceProfile
1093
+ });
1073
1094
  return this._getIdentity();
1074
1095
  }
1075
1096
  async recoverIdentity(request) {
@@ -1150,7 +1171,7 @@ var DeviceInvitationProtocol = class {
1150
1171
  async admit(request) {
1151
1172
  invariant4(request.device, void 0, {
1152
1173
  F: __dxlog_file5,
1153
- L: 36,
1174
+ L: 37,
1154
1175
  S: this,
1155
1176
  A: [
1156
1177
  "request.device",
@@ -1180,7 +1201,7 @@ var DeviceInvitationProtocol = class {
1180
1201
  createIntroduction() {
1181
1202
  return {};
1182
1203
  }
1183
- async createAdmissionRequest() {
1204
+ async createAdmissionRequest(deviceProfile) {
1184
1205
  const deviceKey = await this._keyring.createKey();
1185
1206
  const controlFeedKey = await this._keyring.createKey();
1186
1207
  const dataFeedKey = await this._keyring.createKey();
@@ -1188,14 +1209,15 @@ var DeviceInvitationProtocol = class {
1188
1209
  device: {
1189
1210
  deviceKey,
1190
1211
  controlFeedKey,
1191
- dataFeedKey
1212
+ dataFeedKey,
1213
+ profile: deviceProfile
1192
1214
  }
1193
1215
  };
1194
1216
  }
1195
1217
  async accept(response, request) {
1196
1218
  invariant4(response.device, void 0, {
1197
1219
  F: __dxlog_file5,
1198
- L: 80,
1220
+ L: 82,
1199
1221
  S: this,
1200
1222
  A: [
1201
1223
  "response.device",
@@ -1205,14 +1227,14 @@ var DeviceInvitationProtocol = class {
1205
1227
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1206
1228
  invariant4(request.device, void 0, {
1207
1229
  F: __dxlog_file5,
1208
- L: 83,
1230
+ L: 85,
1209
1231
  S: this,
1210
1232
  A: [
1211
1233
  "request.device",
1212
1234
  ""
1213
1235
  ]
1214
1236
  });
1215
- const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
1237
+ const { deviceKey, controlFeedKey, dataFeedKey, profile } = request.device;
1216
1238
  await this._acceptIdentity({
1217
1239
  identityKey,
1218
1240
  deviceKey,
@@ -1220,7 +1242,8 @@ var DeviceInvitationProtocol = class {
1220
1242
  haloGenesisFeedKey: genesisFeedKey,
1221
1243
  controlFeedKey,
1222
1244
  dataFeedKey,
1223
- controlTimeframe
1245
+ controlTimeframe,
1246
+ deviceProfile: profile
1224
1247
  });
1225
1248
  return {
1226
1249
  identityKey
@@ -1594,7 +1617,7 @@ var InvitationsHandler = class {
1594
1617
  const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
1595
1618
  invariant6(protocol, void 0, {
1596
1619
  F: __dxlog_file7,
1597
- L: 80,
1620
+ L: 81,
1598
1621
  S: this,
1599
1622
  A: [
1600
1623
  "protocol",
@@ -1623,7 +1646,7 @@ var InvitationsHandler = class {
1623
1646
  ...protocol.toJSON()
1624
1647
  }, {
1625
1648
  F: __dxlog_file7,
1626
- L: 102,
1649
+ L: 103,
1627
1650
  S: this,
1628
1651
  C: (f, a) => f(...a)
1629
1652
  });
@@ -1648,7 +1671,7 @@ var InvitationsHandler = class {
1648
1671
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1649
1672
  invariant6(deviceKey, void 0, {
1650
1673
  F: __dxlog_file7,
1651
- L: 123,
1674
+ L: 124,
1652
1675
  S: this,
1653
1676
  A: [
1654
1677
  "deviceKey",
@@ -1671,7 +1694,7 @@ var InvitationsHandler = class {
1671
1694
  id: traceId
1672
1695
  }), {
1673
1696
  F: __dxlog_file7,
1674
- L: 141,
1697
+ L: 142,
1675
1698
  S: this,
1676
1699
  C: (f, a) => f(...a)
1677
1700
  });
@@ -1679,7 +1702,7 @@ var InvitationsHandler = class {
1679
1702
  ...protocol.toJSON()
1680
1703
  }, {
1681
1704
  F: __dxlog_file7,
1682
- L: 142,
1705
+ L: 143,
1683
1706
  S: this,
1684
1707
  C: (f, a) => f(...a)
1685
1708
  });
@@ -1695,7 +1718,7 @@ var InvitationsHandler = class {
1695
1718
  ...protocol.toJSON()
1696
1719
  }, {
1697
1720
  F: __dxlog_file7,
1698
- L: 145,
1721
+ L: 146,
1699
1722
  S: this,
1700
1723
  C: (f, a) => f(...a)
1701
1724
  });
@@ -1707,7 +1730,7 @@ var InvitationsHandler = class {
1707
1730
  id: traceId
1708
1731
  }), {
1709
1732
  F: __dxlog_file7,
1710
- L: 147,
1733
+ L: 148,
1711
1734
  S: this,
1712
1735
  C: (f, a) => f(...a)
1713
1736
  });
@@ -1717,7 +1740,7 @@ var InvitationsHandler = class {
1717
1740
  ...protocol.toJSON()
1718
1741
  }, {
1719
1742
  F: __dxlog_file7,
1720
- L: 150,
1743
+ L: 151,
1721
1744
  S: this,
1722
1745
  C: (f, a) => f(...a)
1723
1746
  });
@@ -1728,7 +1751,7 @@ var InvitationsHandler = class {
1728
1751
  } else {
1729
1752
  log5.error("failed", err, {
1730
1753
  F: __dxlog_file7,
1731
- L: 153,
1754
+ L: 154,
1732
1755
  S: this,
1733
1756
  C: (f, a) => f(...a)
1734
1757
  });
@@ -1739,7 +1762,7 @@ var InvitationsHandler = class {
1739
1762
  error: err
1740
1763
  }), {
1741
1764
  F: __dxlog_file7,
1742
- L: 156,
1765
+ L: 157,
1743
1766
  S: this,
1744
1767
  C: (f, a) => f(...a)
1745
1768
  });
@@ -1760,7 +1783,7 @@ var InvitationsHandler = class {
1760
1783
  ...protocol.toJSON()
1761
1784
  }, {
1762
1785
  F: __dxlog_file7,
1763
- L: 171,
1786
+ L: 172,
1764
1787
  S: this,
1765
1788
  C: (f, a) => f(...a)
1766
1789
  });
@@ -1771,7 +1794,7 @@ var InvitationsHandler = class {
1771
1794
  } else {
1772
1795
  log5.error("failed", err, {
1773
1796
  F: __dxlog_file7,
1774
- L: 174,
1797
+ L: 175,
1775
1798
  S: this,
1776
1799
  C: (f, a) => f(...a)
1777
1800
  });
@@ -1812,17 +1835,28 @@ var InvitationsHandler = class {
1812
1835
  });
1813
1836
  return observable;
1814
1837
  }
1815
- acceptInvitation(protocol, invitation) {
1838
+ acceptInvitation(protocol, invitation, deviceProfile) {
1816
1839
  const { timeout = INVITATION_TIMEOUT } = invitation;
1817
1840
  invariant6(protocol, void 0, {
1818
1841
  F: __dxlog_file7,
1819
- L: 215,
1842
+ L: 220,
1820
1843
  S: this,
1821
1844
  A: [
1822
1845
  "protocol",
1823
1846
  ""
1824
1847
  ]
1825
1848
  });
1849
+ if (deviceProfile) {
1850
+ invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
1851
+ F: __dxlog_file7,
1852
+ L: 224,
1853
+ S: this,
1854
+ A: [
1855
+ "invitation.kind === Invitation.Kind.DEVICE",
1856
+ "'deviceProfile provided for non-device invitation'"
1857
+ ]
1858
+ });
1859
+ }
1826
1860
  const authenticated = new Trigger3();
1827
1861
  let admitted = false;
1828
1862
  let currentState;
@@ -1830,7 +1864,7 @@ var InvitationsHandler = class {
1830
1864
  const setState = (newData) => {
1831
1865
  invariant6(newData.state !== void 0, void 0, {
1832
1866
  F: __dxlog_file7,
1833
- L: 226,
1867
+ L: 235,
1834
1868
  S: this,
1835
1869
  A: [
1836
1870
  "newData.state !== undefined",
@@ -1850,7 +1884,7 @@ var InvitationsHandler = class {
1850
1884
  ...protocol.toJSON()
1851
1885
  }, {
1852
1886
  F: __dxlog_file7,
1853
- L: 234,
1887
+ L: 243,
1854
1888
  S: this,
1855
1889
  C: (f, a) => f(...a)
1856
1890
  });
@@ -1860,7 +1894,7 @@ var InvitationsHandler = class {
1860
1894
  } else {
1861
1895
  log5.warn("auth failed", err, {
1862
1896
  F: __dxlog_file7,
1863
- L: 237,
1897
+ L: 246,
1864
1898
  S: this,
1865
1899
  C: (f, a) => f(...a)
1866
1900
  });
@@ -1874,7 +1908,7 @@ var InvitationsHandler = class {
1874
1908
  ...protocol.toJSON()
1875
1909
  }, {
1876
1910
  F: __dxlog_file7,
1877
- L: 245,
1911
+ L: 254,
1878
1912
  S: this,
1879
1913
  C: (f, a) => f(...a)
1880
1914
  });
@@ -1889,7 +1923,7 @@ var InvitationsHandler = class {
1889
1923
  currentState
1890
1924
  }, {
1891
1925
  F: __dxlog_file7,
1892
- L: 255,
1926
+ L: 264,
1893
1927
  S: this,
1894
1928
  C: (f, a) => f(...a)
1895
1929
  });
@@ -1904,7 +1938,7 @@ var InvitationsHandler = class {
1904
1938
  id: traceId
1905
1939
  }), {
1906
1940
  F: __dxlog_file7,
1907
- L: 264,
1941
+ L: 273,
1908
1942
  S: this,
1909
1943
  C: (f, a) => f(...a)
1910
1944
  });
@@ -1916,7 +1950,7 @@ var InvitationsHandler = class {
1916
1950
  ...protocol.toJSON()
1917
1951
  }, {
1918
1952
  F: __dxlog_file7,
1919
- L: 272,
1953
+ L: 281,
1920
1954
  S: this,
1921
1955
  C: (f, a) => f(...a)
1922
1956
  });
@@ -1927,7 +1961,7 @@ var InvitationsHandler = class {
1927
1961
  ...protocol.toJSON()
1928
1962
  }, {
1929
1963
  F: __dxlog_file7,
1930
- L: 276,
1964
+ L: 285,
1931
1965
  S: this,
1932
1966
  C: (f, a) => f(...a)
1933
1967
  });
@@ -1937,7 +1971,7 @@ var InvitationsHandler = class {
1937
1971
  response: introductionResponse
1938
1972
  }, {
1939
1973
  F: __dxlog_file7,
1940
- L: 280,
1974
+ L: 289,
1941
1975
  S: this,
1942
1976
  C: (f, a) => f(...a)
1943
1977
  });
@@ -1946,7 +1980,7 @@ var InvitationsHandler = class {
1946
1980
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1947
1981
  log5("guest waiting for authentication code...", void 0, {
1948
1982
  F: __dxlog_file7,
1949
- L: 286,
1983
+ L: 295,
1950
1984
  S: this,
1951
1985
  C: (f, a) => f(...a)
1952
1986
  });
@@ -1958,7 +1992,7 @@ var InvitationsHandler = class {
1958
1992
  });
1959
1993
  log5("sending authentication request", void 0, {
1960
1994
  F: __dxlog_file7,
1961
- L: 290,
1995
+ L: 299,
1962
1996
  S: this,
1963
1997
  C: (f, a) => f(...a)
1964
1998
  });
@@ -1979,7 +2013,7 @@ var InvitationsHandler = class {
1979
2013
  attempt
1980
2014
  }, {
1981
2015
  F: __dxlog_file7,
1982
- L: 301,
2016
+ L: 310,
1983
2017
  S: this,
1984
2018
  C: (f, a) => f(...a)
1985
2019
  });
@@ -1992,11 +2026,11 @@ var InvitationsHandler = class {
1992
2026
  ...protocol.toJSON()
1993
2027
  }, {
1994
2028
  F: __dxlog_file7,
1995
- L: 309,
2029
+ L: 318,
1996
2030
  S: this,
1997
2031
  C: (f, a) => f(...a)
1998
2032
  });
1999
- const admissionRequest = await protocol.createAdmissionRequest();
2033
+ const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
2000
2034
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
2001
2035
  admitted = true;
2002
2036
  const result = await protocol.accept(admissionResponse, admissionRequest);
@@ -2004,7 +2038,7 @@ var InvitationsHandler = class {
2004
2038
  ...protocol.toJSON()
2005
2039
  }, {
2006
2040
  F: __dxlog_file7,
2007
- L: 320,
2041
+ L: 329,
2008
2042
  S: this,
2009
2043
  C: (f, a) => f(...a)
2010
2044
  });
@@ -2017,7 +2051,7 @@ var InvitationsHandler = class {
2017
2051
  id: traceId
2018
2052
  }), {
2019
2053
  F: __dxlog_file7,
2020
- L: 322,
2054
+ L: 331,
2021
2055
  S: this,
2022
2056
  C: (f, a) => f(...a)
2023
2057
  });
@@ -2027,7 +2061,7 @@ var InvitationsHandler = class {
2027
2061
  ...protocol.toJSON()
2028
2062
  }, {
2029
2063
  F: __dxlog_file7,
2030
- L: 325,
2064
+ L: 334,
2031
2065
  S: this,
2032
2066
  C: (f, a) => f(...a)
2033
2067
  });
@@ -2037,7 +2071,7 @@ var InvitationsHandler = class {
2037
2071
  } else {
2038
2072
  log5("auth failed", err, {
2039
2073
  F: __dxlog_file7,
2040
- L: 328,
2074
+ L: 337,
2041
2075
  S: this,
2042
2076
  C: (f, a) => f(...a)
2043
2077
  });
@@ -2048,7 +2082,7 @@ var InvitationsHandler = class {
2048
2082
  error: err
2049
2083
  }), {
2050
2084
  F: __dxlog_file7,
2051
- L: 331,
2085
+ L: 340,
2052
2086
  S: this,
2053
2087
  C: (f, a) => f(...a)
2054
2088
  });
@@ -2066,7 +2100,7 @@ var InvitationsHandler = class {
2066
2100
  ...protocol.toJSON()
2067
2101
  }, {
2068
2102
  F: __dxlog_file7,
2069
- L: 342,
2103
+ L: 351,
2070
2104
  S: this,
2071
2105
  C: (f, a) => f(...a)
2072
2106
  });
@@ -2076,7 +2110,7 @@ var InvitationsHandler = class {
2076
2110
  } else {
2077
2111
  log5("auth failed", err, {
2078
2112
  F: __dxlog_file7,
2079
- L: 345,
2113
+ L: 354,
2080
2114
  S: this,
2081
2115
  C: (f, a) => f(...a)
2082
2116
  });
@@ -2093,7 +2127,7 @@ var InvitationsHandler = class {
2093
2127
  } else {
2094
2128
  invariant6(invitation.swarmKey, void 0, {
2095
2129
  F: __dxlog_file7,
2096
- L: 359,
2130
+ L: 368,
2097
2131
  S: this,
2098
2132
  A: [
2099
2133
  "invitation.swarmKey",
@@ -2180,14 +2214,25 @@ var InvitationsServiceImpl = class {
2180
2214
  });
2181
2215
  });
2182
2216
  }
2183
- acceptInvitation(options) {
2217
+ acceptInvitation({ invitation: options, deviceProfile }) {
2184
2218
  let invitation;
2219
+ if (deviceProfile) {
2220
+ invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2221
+ F: __dxlog_file8,
2222
+ L: 81,
2223
+ S: this,
2224
+ A: [
2225
+ "options.kind === Invitation.Kind.DEVICE",
2226
+ "'deviceProfile provided for non-device invitation'"
2227
+ ]
2228
+ });
2229
+ }
2185
2230
  const existingInvitation = this._acceptInvitations.get(options.invitationId);
2186
2231
  if (existingInvitation) {
2187
2232
  invitation = existingInvitation;
2188
2233
  } else {
2189
2234
  const handler = this._getHandler(options);
2190
- invitation = this._invitationsHandler.acceptInvitation(handler, options);
2235
+ invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
2191
2236
  this._acceptInvitations.set(invitation.get().invitationId, invitation);
2192
2237
  this._invitationAccepted.emit(invitation.get());
2193
2238
  }
@@ -2208,13 +2253,13 @@ var InvitationsServiceImpl = class {
2208
2253
  async authenticate({ invitationId, authCode }) {
2209
2254
  log6("authenticating...", void 0, {
2210
2255
  F: __dxlog_file8,
2211
- L: 108,
2256
+ L: 114,
2212
2257
  S: this,
2213
2258
  C: (f, a) => f(...a)
2214
2259
  });
2215
2260
  invariant7(invitationId, void 0, {
2216
2261
  F: __dxlog_file8,
2217
- L: 109,
2262
+ L: 115,
2218
2263
  S: this,
2219
2264
  A: [
2220
2265
  "invitationId",
@@ -2227,7 +2272,7 @@ var InvitationsServiceImpl = class {
2227
2272
  invitationId
2228
2273
  }, {
2229
2274
  F: __dxlog_file8,
2230
- L: 112,
2275
+ L: 118,
2231
2276
  S: this,
2232
2277
  C: (f, a) => f(...a)
2233
2278
  });
@@ -2238,13 +2283,13 @@ var InvitationsServiceImpl = class {
2238
2283
  async cancelInvitation({ invitationId }) {
2239
2284
  log6("deleting...", void 0, {
2240
2285
  F: __dxlog_file8,
2241
- L: 119,
2286
+ L: 125,
2242
2287
  S: this,
2243
2288
  C: (f, a) => f(...a)
2244
2289
  });
2245
2290
  invariant7(invitationId, void 0, {
2246
2291
  F: __dxlog_file8,
2247
- L: 120,
2292
+ L: 126,
2248
2293
  S: this,
2249
2294
  A: [
2250
2295
  "invitationId",
@@ -2601,7 +2646,7 @@ var getPlatform = () => {
2601
2646
  };
2602
2647
 
2603
2648
  // packages/sdk/client-services/src/version.ts
2604
- var DXOS_VERSION = "0.4.6-main.9c97a50";
2649
+ var DXOS_VERSION = "0.4.6-main.b69a2b5";
2605
2650
 
2606
2651
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2607
2652
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -3301,7 +3346,7 @@ var DataSpace = class {
3301
3346
  const controlFeed = await this._feedStore.openFeed(await this._keyring.createKey(), {
3302
3347
  writable: true
3303
3348
  });
3304
- this.inner.setControlFeed(controlFeed);
3349
+ await this.inner.setControlFeed(controlFeed);
3305
3350
  credentials.push(await this._signingContext.credentialSigner.createCredential({
3306
3351
  subject: controlFeed.key,
3307
3352
  assertion: {
@@ -3318,7 +3363,7 @@ var DataSpace = class {
3318
3363
  writable: true,
3319
3364
  sparse: true
3320
3365
  });
3321
- this.inner.setDataFeed(dataFeed);
3366
+ await this.inner.setDataFeed(dataFeed);
3322
3367
  credentials.push(await this._signingContext.credentialSigner.createCredential({
3323
3368
  subject: dataFeed.key,
3324
3369
  assertion: {
@@ -3360,9 +3405,11 @@ var DataSpace = class {
3360
3405
  return;
3361
3406
  }
3362
3407
  const doc = handle.docSync() ?? failedInvariant();
3363
- if (!doc.experimental_spaceKey) {
3408
+ if (!doc.access?.spaceKey) {
3364
3409
  handle.change((doc2) => {
3365
- doc2.experimental_spaceKey = this.key.toHex();
3410
+ doc2.access = {
3411
+ spaceKey: this.key.toHex()
3412
+ };
3366
3413
  });
3367
3414
  }
3368
3415
  } catch (err) {
@@ -3532,7 +3579,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsyn
3532
3579
 
3533
3580
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
3534
3581
  import { createCredential } from "@dxos/credentials";
3535
- import { failUndefined as failUndefined2 } from "@dxos/debug";
3582
+ import { failUndefined } from "@dxos/debug";
3536
3583
  import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3537
3584
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3538
3585
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
@@ -3555,11 +3602,11 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3555
3602
  spaceKey: space.key,
3556
3603
  role: SpaceMember2.Role.ADMIN,
3557
3604
  profile: signingContext.getProfile(),
3558
- genesisFeedKey: space.controlFeedKey ?? failUndefined2()
3605
+ genesisFeedKey: space.controlFeedKey ?? failUndefined()
3559
3606
  }
3560
3607
  }),
3561
3608
  await signingContext.credentialSigner.createCredential({
3562
- subject: space.controlFeedKey ?? failUndefined2(),
3609
+ subject: space.controlFeedKey ?? failUndefined(),
3563
3610
  assertion: {
3564
3611
  "@type": "dxos.halo.credentials.AdmittedFeed",
3565
3612
  spaceKey: space.key,
@@ -3569,7 +3616,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3569
3616
  }
3570
3617
  }),
3571
3618
  await signingContext.credentialSigner.createCredential({
3572
- subject: space.dataFeedKey ?? failUndefined2(),
3619
+ subject: space.dataFeedKey ?? failUndefined(),
3573
3620
  assertion: {
3574
3621
  "@type": "dxos.halo.credentials.AdmittedFeed",
3575
3622
  spaceKey: space.key,
@@ -3579,7 +3626,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3579
3626
  }
3580
3627
  }),
3581
3628
  await signingContext.credentialSigner.createCredential({
3582
- subject: space.key ?? failUndefined2(),
3629
+ subject: space.key ?? failUndefined(),
3583
3630
  assertion: {
3584
3631
  "@type": "dxos.halo.credentials.Epoch",
3585
3632
  number: 0,
@@ -3741,7 +3788,9 @@ var DataSpaceManager = class {
3741
3788
  });
3742
3789
  const automergeRoot = this._automergeHost.repo.create();
3743
3790
  automergeRoot.change((doc) => {
3744
- doc.experimental_spaceKey = spaceKey.toHex();
3791
+ doc.access = {
3792
+ spaceKey: spaceKey.toHex()
3793
+ };
3745
3794
  });
3746
3795
  const space = await this._constructSpace(metadata);
3747
3796
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
@@ -3862,8 +3911,8 @@ var DataSpaceManager = class {
3862
3911
  },
3863
3912
  memberKey: this._signingContext.identityKey
3864
3913
  });
3865
- controlFeed && space.setControlFeed(controlFeed);
3866
- dataFeed && space.setDataFeed(dataFeed);
3914
+ controlFeed && await space.setControlFeed(controlFeed);
3915
+ dataFeed && await space.setDataFeed(dataFeed);
3867
3916
  const dataSpace = new DataSpace({
3868
3917
  inner: space,
3869
3918
  initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
@@ -4168,7 +4217,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
4168
4217
  import { Trigger as Trigger5 } from "@dxos/async";
4169
4218
  import { Context as Context9 } from "@dxos/context";
4170
4219
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4171
- import { failUndefined as failUndefined3 } from "@dxos/debug";
4220
+ import { failUndefined as failUndefined2 } from "@dxos/debug";
4172
4221
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
4173
4222
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
4174
4223
  import { invariant as invariant13 } from "@dxos/invariant";
@@ -4226,7 +4275,7 @@ var ServiceContext = class {
4226
4275
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4227
4276
  this.automergeHost = new AutomergeHost(storage.createDirectory("automerge"));
4228
4277
  this.invitations = new InvitationsHandler(this.networkManager);
4229
- this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
4278
+ this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
4230
4279
  }
4231
4280
  async open(ctx) {
4232
4281
  await this._checkStorageVersion();
@@ -4338,7 +4387,7 @@ var ServiceContext = class {
4338
4387
  S: this,
4339
4388
  C: (f, a) => f(...a)
4340
4389
  });
4341
- const identity = this.identityManager.identity ?? failUndefined3();
4390
+ const identity = this.identityManager.identity ?? failUndefined2();
4342
4391
  const signingContext = {
4343
4392
  credentialSigner: identity.getIdentityCredentialSigner(),
4344
4393
  identityKey: identity.identityKey,
@@ -4588,10 +4637,10 @@ import { DX_DATA } from "@dxos/client-protocol";
4588
4637
  import { InvalidConfigError } from "@dxos/protocols";
4589
4638
  import { Runtime } from "@dxos/protocols/proto/dxos/config";
4590
4639
  import { createStorage, StorageType } from "@dxos/random-access-storage";
4591
- import { isNode } from "@dxos/util";
4640
+ import { isNode as isNode2 } from "@dxos/util";
4592
4641
  var StorageDriver = Runtime.Client.Storage.StorageDriver;
4593
4642
  var createStorageObjects = (config) => {
4594
- const { persistent = false, keyStore, dataStore, dataRoot = isNode() ? DX_DATA : "dxos/storage" } = config ?? {};
4643
+ const { persistent = false, keyStore, dataStore, dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
4595
4644
  if (persistent && dataStore === StorageDriver.RAM) {
4596
4645
  throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
4597
4646
  }
@@ -5313,4 +5362,4 @@ export {
5313
5362
  createDefaultModelFactory,
5314
5363
  ClientServicesHost
5315
5364
  };
5316
- //# sourceMappingURL=chunk-7JCJI2VR.mjs.map
5365
+ //# sourceMappingURL=chunk-KFMLOQZY.mjs.map