@dxos/client-services 0.5.9-main.eacfffa → 0.5.9-main.f099efe

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 (35) hide show
  1. package/dist/lib/browser/{chunk-J4DDMC6A.mjs → chunk-H3XJK6ZN.mjs} +483 -187
  2. package/dist/lib/browser/{chunk-J4DDMC6A.mjs.map → chunk-H3XJK6ZN.mjs.map} +4 -4
  3. package/dist/lib/browser/index.mjs +9 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-6HFQ2SQ5.cjs → chunk-JRDM7NQS.cjs} +502 -206
  8. package/dist/lib/node/chunk-JRDM7NQS.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +49 -41
  10. package/dist/lib/node/index.cjs.map +1 -1
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  13. package/dist/types/src/packlets/identity/contacts-service.d.ts +14 -0
  14. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -0
  15. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  16. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  17. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -1
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
  20. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  22. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  23. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  24. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +36 -36
  27. package/src/packlets/identity/contacts-service.ts +85 -0
  28. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  29. package/src/packlets/services/service-host.ts +12 -4
  30. package/src/packlets/spaces/data-space-manager.ts +55 -2
  31. package/src/packlets/spaces/spaces-service.ts +38 -0
  32. package/src/packlets/storage/index.ts +1 -0
  33. package/src/packlets/storage/profile-archive.ts +97 -0
  34. package/src/version.ts +1 -1
  35. package/dist/lib/node/chunk-6HFQ2SQ5.cjs.map +0 -7
@@ -359,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
359
359
  import { TRACE_PROCESSOR } from "@dxos/tracing";
360
360
 
361
361
  // packages/sdk/client-services/src/version.ts
362
- var DXOS_VERSION = "0.5.9-main.eacfffa";
362
+ var DXOS_VERSION = "0.5.9-main.f099efe";
363
363
 
364
364
  // packages/sdk/client-services/src/packlets/services/platform.ts
365
365
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -3083,7 +3083,7 @@ var InvitationsServiceImpl = class {
3083
3083
  };
3084
3084
 
3085
3085
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
3086
- import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3086
+ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3087
3087
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
3088
3088
  import { invariant as invariant10 } from "@dxos/invariant";
3089
3089
  import { log as log11 } from "@dxos/log";
@@ -3124,79 +3124,43 @@ var SpaceInvitationProtocol = class {
3124
3124
  };
3125
3125
  }
3126
3126
  async admit(invitation, request, guestProfile) {
3127
- invariant10(this._spaceKey, void 0, {
3127
+ invariant10(this._spaceKey && request.space, void 0, {
3128
3128
  F: __dxlog_file14,
3129
- L: 76,
3129
+ L: 74,
3130
3130
  S: this,
3131
3131
  A: [
3132
- "this._spaceKey",
3132
+ "this._spaceKey && request.space",
3133
3133
  ""
3134
3134
  ]
3135
3135
  });
3136
- const space = this._spaceManager.spaces.get(this._spaceKey);
3137
- invariant10(space, void 0, {
3138
- F: __dxlog_file14,
3139
- L: 78,
3140
- S: this,
3141
- A: [
3142
- "space",
3143
- ""
3144
- ]
3145
- });
3146
- invariant10(request.space, void 0, {
3147
- F: __dxlog_file14,
3148
- L: 80,
3149
- S: this,
3150
- A: [
3151
- "request.space",
3152
- ""
3153
- ]
3154
- });
3155
- const { identityKey, deviceKey } = request.space;
3156
- if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
3157
- throw new AlreadyJoinedError2();
3158
- }
3159
3136
  log11("writing guest credentials", {
3160
3137
  host: this._signingContext.deviceKey,
3161
- guest: deviceKey
3138
+ guest: request.space.deviceKey
3162
3139
  }, {
3163
3140
  F: __dxlog_file14,
3164
- L: 87,
3141
+ L: 75,
3165
3142
  S: this,
3166
3143
  C: (f, a) => f(...a)
3167
3144
  });
3168
- const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember2.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3169
- invariant10(credentials[0].credential, void 0, {
3170
- F: __dxlog_file14,
3171
- L: 101,
3172
- S: this,
3173
- A: [
3174
- "credentials[0].credential",
3175
- ""
3176
- ]
3177
- });
3178
- const spaceMemberCredential = credentials[0].credential.credential;
3179
- invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3180
- F: __dxlog_file14,
3181
- L: 103,
3182
- S: this,
3183
- A: [
3184
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3185
- ""
3186
- ]
3145
+ const spaceMemberCredential = await this._spaceManager.admitMember({
3146
+ spaceKey: this._spaceKey,
3147
+ identityKey: request.space.identityKey,
3148
+ role: invitation.role ?? SpaceMember2.Role.ADMIN,
3149
+ profile: guestProfile,
3150
+ delegationCredentialId: invitation.delegationCredentialId
3187
3151
  });
3188
- await writeMessages2(space.inner.controlPipeline.writer, credentials);
3152
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3189
3153
  return {
3190
3154
  space: {
3191
3155
  credential: spaceMemberCredential,
3192
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3156
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3193
3157
  }
3194
3158
  };
3195
3159
  }
3196
3160
  async delegate(invitation) {
3197
3161
  invariant10(this._spaceKey, void 0, {
3198
3162
  F: __dxlog_file14,
3199
- L: 116,
3163
+ L: 95,
3200
3164
  S: this,
3201
3165
  A: [
3202
3166
  "this._spaceKey",
@@ -3206,7 +3170,7 @@ var SpaceInvitationProtocol = class {
3206
3170
  const space = this._spaceManager.spaces.get(this._spaceKey);
3207
3171
  invariant10(space, void 0, {
3208
3172
  F: __dxlog_file14,
3209
- L: 118,
3173
+ L: 97,
3210
3174
  S: this,
3211
3175
  A: [
3212
3176
  "space",
@@ -3216,7 +3180,7 @@ var SpaceInvitationProtocol = class {
3216
3180
  if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
3217
3181
  invariant10(invitation.guestKeypair?.publicKey, void 0, {
3218
3182
  F: __dxlog_file14,
3219
- L: 120,
3183
+ L: 99,
3220
3184
  S: this,
3221
3185
  A: [
3222
3186
  "invitation.guestKeypair?.publicKey",
@@ -3229,7 +3193,7 @@ var SpaceInvitationProtocol = class {
3229
3193
  id: invitation.invitationId
3230
3194
  }, {
3231
3195
  F: __dxlog_file14,
3232
- L: 123,
3196
+ L: 102,
3233
3197
  S: this,
3234
3198
  C: (f, a) => f(...a)
3235
3199
  });
@@ -3244,7 +3208,7 @@ var SpaceInvitationProtocol = class {
3244
3208
  });
3245
3209
  invariant10(credential.credential, void 0, {
3246
3210
  F: __dxlog_file14,
3247
- L: 143,
3211
+ L: 122,
3248
3212
  S: this,
3249
3213
  A: [
3250
3214
  "credential.credential",
@@ -3259,7 +3223,7 @@ var SpaceInvitationProtocol = class {
3259
3223
  async cancelDelegation(invitation) {
3260
3224
  invariant10(this._spaceKey, void 0, {
3261
3225
  F: __dxlog_file14,
3262
- L: 149,
3226
+ L: 128,
3263
3227
  S: this,
3264
3228
  A: [
3265
3229
  "this._spaceKey",
@@ -3268,7 +3232,7 @@ var SpaceInvitationProtocol = class {
3268
3232
  });
3269
3233
  invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3270
3234
  F: __dxlog_file14,
3271
- L: 150,
3235
+ L: 129,
3272
3236
  S: this,
3273
3237
  A: [
3274
3238
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3278,7 +3242,7 @@ var SpaceInvitationProtocol = class {
3278
3242
  const space = this._spaceManager.spaces.get(this._spaceKey);
3279
3243
  invariant10(space, void 0, {
3280
3244
  F: __dxlog_file14,
3281
- L: 152,
3245
+ L: 131,
3282
3246
  S: this,
3283
3247
  A: [
3284
3248
  "space",
@@ -3290,14 +3254,14 @@ var SpaceInvitationProtocol = class {
3290
3254
  id: invitation.invitationId
3291
3255
  }, {
3292
3256
  F: __dxlog_file14,
3293
- L: 154,
3257
+ L: 133,
3294
3258
  S: this,
3295
3259
  C: (f, a) => f(...a)
3296
3260
  });
3297
3261
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3298
3262
  invariant10(credential.credential, void 0, {
3299
3263
  F: __dxlog_file14,
3300
- L: 161,
3264
+ L: 140,
3301
3265
  S: this,
3302
3266
  A: [
3303
3267
  "credential.credential",
@@ -3336,7 +3300,7 @@ var SpaceInvitationProtocol = class {
3336
3300
  async accept(response) {
3337
3301
  invariant10(response.space, void 0, {
3338
3302
  F: __dxlog_file14,
3339
- L: 196,
3303
+ L: 175,
3340
3304
  S: this,
3341
3305
  A: [
3342
3306
  "response.space",
@@ -3347,7 +3311,7 @@ var SpaceInvitationProtocol = class {
3347
3311
  const assertion = getCredentialAssertion2(credential);
3348
3312
  invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3349
3313
  F: __dxlog_file14,
3350
- L: 199,
3314
+ L: 178,
3351
3315
  S: this,
3352
3316
  A: [
3353
3317
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3356,7 +3320,7 @@ var SpaceInvitationProtocol = class {
3356
3320
  });
3357
3321
  invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3358
3322
  F: __dxlog_file14,
3359
- L: 200,
3323
+ L: 179,
3360
3324
  S: this,
3361
3325
  A: [
3362
3326
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -4794,15 +4758,17 @@ DataSpace = _ts_decorate4([
4794
4758
  import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
4795
4759
  import { PropertiesType } from "@dxos/client-protocol";
4796
4760
  import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
4797
- import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4761
+ import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
4798
4762
  import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
4799
4763
  import { AuthStatus } from "@dxos/echo-pipeline";
4764
+ import { CredentialServerExtension } from "@dxos/echo-pipeline";
4800
4765
  import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
4801
4766
  import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
4767
+ import { writeMessages as writeMessages3 } from "@dxos/feed-store";
4802
4768
  import { invariant as invariant14 } from "@dxos/invariant";
4803
4769
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4804
4770
  import { log as log16 } from "@dxos/log";
4805
- import { trace as Trace2 } from "@dxos/protocols";
4771
+ import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
4806
4772
  import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4807
4773
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
4808
4774
  import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
@@ -4906,7 +4872,7 @@ var DataSpaceManager = class {
4906
4872
  this._params = _params;
4907
4873
  this._ctx = new Context9(void 0, {
4908
4874
  F: __dxlog_file19,
4909
- L: 94
4875
+ L: 104
4910
4876
  });
4911
4877
  this.updated = new Event7();
4912
4878
  this._spaces = new ComplexMap3(PublicKey11.hash);
@@ -4942,7 +4908,7 @@ var DataSpaceManager = class {
4942
4908
  async open() {
4943
4909
  log16("open", void 0, {
4944
4910
  F: __dxlog_file19,
4945
- L: 146,
4911
+ L: 156,
4946
4912
  S: this,
4947
4913
  C: (f, a) => f(...a)
4948
4914
  });
@@ -4950,7 +4916,7 @@ var DataSpaceManager = class {
4950
4916
  id: this._instanceId
4951
4917
  }), {
4952
4918
  F: __dxlog_file19,
4953
- L: 147,
4919
+ L: 157,
4954
4920
  S: this,
4955
4921
  C: (f, a) => f(...a)
4956
4922
  });
@@ -4958,7 +4924,7 @@ var DataSpaceManager = class {
4958
4924
  spaces: this._metadataStore.spaces.length
4959
4925
  }, {
4960
4926
  F: __dxlog_file19,
4961
- L: 148,
4927
+ L: 158,
4962
4928
  S: this,
4963
4929
  C: (f, a) => f(...a)
4964
4930
  });
@@ -4968,7 +4934,7 @@ var DataSpaceManager = class {
4968
4934
  spaceMetadata
4969
4935
  }, {
4970
4936
  F: __dxlog_file19,
4971
- L: 152,
4937
+ L: 162,
4972
4938
  S: this,
4973
4939
  C: (f, a) => f(...a)
4974
4940
  });
@@ -4979,7 +4945,7 @@ var DataSpaceManager = class {
4979
4945
  err
4980
4946
  }, {
4981
4947
  F: __dxlog_file19,
4982
- L: 155,
4948
+ L: 165,
4983
4949
  S: this,
4984
4950
  C: (f, a) => f(...a)
4985
4951
  });
@@ -4991,7 +4957,7 @@ var DataSpaceManager = class {
4991
4957
  id: this._instanceId
4992
4958
  }), {
4993
4959
  F: __dxlog_file19,
4994
- L: 162,
4960
+ L: 172,
4995
4961
  S: this,
4996
4962
  C: (f, a) => f(...a)
4997
4963
  });
@@ -4999,7 +4965,7 @@ var DataSpaceManager = class {
4999
4965
  async close() {
5000
4966
  log16("close", void 0, {
5001
4967
  F: __dxlog_file19,
5002
- L: 167,
4968
+ L: 177,
5003
4969
  S: this,
5004
4970
  C: (f, a) => f(...a)
5005
4971
  });
@@ -5016,7 +4982,7 @@ var DataSpaceManager = class {
5016
4982
  async createSpace() {
5017
4983
  invariant14(this._isOpen, "Not open.", {
5018
4984
  F: __dxlog_file19,
5019
- L: 181,
4985
+ L: 191,
5020
4986
  S: this,
5021
4987
  A: [
5022
4988
  "this._isOpen",
@@ -5037,7 +5003,7 @@ var DataSpaceManager = class {
5037
5003
  spaceKey
5038
5004
  }, {
5039
5005
  F: __dxlog_file19,
5040
- L: 193,
5006
+ L: 203,
5041
5007
  S: this,
5042
5008
  C: (f, a) => f(...a)
5043
5009
  });
@@ -5049,7 +5015,7 @@ var DataSpaceManager = class {
5049
5015
  const memberCredential = credentials[1];
5050
5016
  invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5051
5017
  F: __dxlog_file19,
5052
- L: 203,
5018
+ L: 213,
5053
5019
  S: this,
5054
5020
  A: [
5055
5021
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -5081,7 +5047,7 @@ var DataSpaceManager = class {
5081
5047
  spaceId: space.id
5082
5048
  }, {
5083
5049
  F: __dxlog_file19,
5084
- L: 228,
5050
+ L: 238,
5085
5051
  S: this,
5086
5052
  C: (f, a) => f(...a)
5087
5053
  });
@@ -5116,7 +5082,7 @@ var DataSpaceManager = class {
5116
5082
  const automergeIndex = space.automergeSpaceState.rootUrl;
5117
5083
  invariant14(automergeIndex, void 0, {
5118
5084
  F: __dxlog_file19,
5119
- L: 261,
5085
+ L: 271,
5120
5086
  S: this,
5121
5087
  A: [
5122
5088
  "automergeIndex",
@@ -5133,13 +5099,13 @@ var DataSpaceManager = class {
5133
5099
  opts
5134
5100
  }, {
5135
5101
  F: __dxlog_file19,
5136
- L: 270,
5102
+ L: 280,
5137
5103
  S: this,
5138
5104
  C: (f, a) => f(...a)
5139
5105
  });
5140
5106
  invariant14(this._isOpen, "Not open.", {
5141
5107
  F: __dxlog_file19,
5142
- L: 271,
5108
+ L: 281,
5143
5109
  S: this,
5144
5110
  A: [
5145
5111
  "this._isOpen",
@@ -5148,7 +5114,7 @@ var DataSpaceManager = class {
5148
5114
  });
5149
5115
  invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5150
5116
  F: __dxlog_file19,
5151
- L: 272,
5117
+ L: 282,
5152
5118
  S: this,
5153
5119
  A: [
5154
5120
  "!this._spaces.has(opts.spaceKey)",
@@ -5168,6 +5134,43 @@ var DataSpaceManager = class {
5168
5134
  this.updated.emit();
5169
5135
  return space;
5170
5136
  }
5137
+ async admitMember(options) {
5138
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5139
+ invariant14(space, void 0, {
5140
+ F: __dxlog_file19,
5141
+ L: 302,
5142
+ S: this,
5143
+ A: [
5144
+ "space",
5145
+ ""
5146
+ ]
5147
+ });
5148
+ if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
5149
+ throw new AlreadyJoinedError3();
5150
+ }
5151
+ const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5152
+ invariant14(credentials[0].credential, void 0, {
5153
+ F: __dxlog_file19,
5154
+ L: 321,
5155
+ S: this,
5156
+ A: [
5157
+ "credentials[0].credential",
5158
+ ""
5159
+ ]
5160
+ });
5161
+ const spaceMemberCredential = credentials[0].credential.credential;
5162
+ invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5163
+ F: __dxlog_file19,
5164
+ L: 323,
5165
+ S: this,
5166
+ A: [
5167
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5168
+ ""
5169
+ ]
5170
+ });
5171
+ await writeMessages3(space.controlPipeline.writer, credentials);
5172
+ return spaceMemberCredential;
5173
+ }
5171
5174
  /**
5172
5175
  * Wait until the space data pipeline is fully initialized.
5173
5176
  * Used by invitation handler.
@@ -5179,12 +5182,24 @@ var DataSpaceManager = class {
5179
5182
  return !!space && space.state === SpaceState3.READY;
5180
5183
  }));
5181
5184
  }
5185
+ async requestSpaceAdmissionCredential(spaceKey) {
5186
+ return this._spaceManager.requestSpaceAdmissionCredential({
5187
+ spaceKey,
5188
+ identityKey: this._signingContext.identityKey,
5189
+ timeout: 15e3,
5190
+ swarmIdentity: {
5191
+ peerKey: this._signingContext.deviceKey,
5192
+ credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5193
+ credentialAuthenticator: async () => true
5194
+ }
5195
+ });
5196
+ }
5182
5197
  async _constructSpace(metadata) {
5183
5198
  log16("construct space", {
5184
5199
  metadata
5185
5200
  }, {
5186
5201
  F: __dxlog_file19,
5187
- L: 306,
5202
+ L: 358,
5188
5203
  S: this,
5189
5204
  C: (f, a) => f(...a)
5190
5205
  });
@@ -5212,6 +5227,7 @@ var DataSpaceManager = class {
5212
5227
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
5213
5228
  },
5214
5229
  onAuthorizedConnection: (session) => {
5230
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
5215
5231
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5216
5232
  remotePeerId: session.remotePeerId
5217
5233
  }));
@@ -5222,7 +5238,7 @@ var DataSpaceManager = class {
5222
5238
  onAuthFailure: () => {
5223
5239
  log16.warn("auth failure", void 0, {
5224
5240
  F: __dxlog_file19,
5225
- L: 343,
5241
+ L: 396,
5226
5242
  S: this,
5227
5243
  C: (f, a) => f(...a)
5228
5244
  });
@@ -5255,7 +5271,7 @@ var DataSpaceManager = class {
5255
5271
  space: space.key
5256
5272
  }, {
5257
5273
  F: __dxlog_file19,
5258
- L: 370,
5274
+ L: 423,
5259
5275
  S: this,
5260
5276
  C: (f, a) => f(...a)
5261
5277
  });
@@ -5266,7 +5282,7 @@ var DataSpaceManager = class {
5266
5282
  open: this._isOpen
5267
5283
  }, {
5268
5284
  F: __dxlog_file19,
5269
- L: 373,
5285
+ L: 426,
5270
5286
  S: this,
5271
5287
  C: (f, a) => f(...a)
5272
5288
  });
@@ -5285,7 +5301,7 @@ var DataSpaceManager = class {
5285
5301
  space: space.key
5286
5302
  }, {
5287
5303
  F: __dxlog_file19,
5288
- L: 381,
5304
+ L: 434,
5289
5305
  S: this,
5290
5306
  C: (f, a) => f(...a)
5291
5307
  });
@@ -5326,7 +5342,7 @@ var DataSpaceManager = class {
5326
5342
  closedSessions
5327
5343
  }, {
5328
5344
  F: __dxlog_file19,
5329
- L: 417,
5345
+ L: 470,
5330
5346
  S: this,
5331
5347
  C: (f, a) => f(...a)
5332
5348
  });
@@ -5341,7 +5357,7 @@ var DataSpaceManager = class {
5341
5357
  peerId: peerState.peerId
5342
5358
  }, {
5343
5359
  F: __dxlog_file19,
5344
- L: 431,
5360
+ L: 484,
5345
5361
  S: this,
5346
5362
  C: (f, a) => f(...a)
5347
5363
  });
@@ -5406,7 +5422,7 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
5406
5422
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
5407
5423
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5408
5424
  import { raise as raise2 } from "@dxos/debug";
5409
- import { writeMessages as writeMessages3 } from "@dxos/feed-store";
5425
+ import { writeMessages as writeMessages4 } from "@dxos/feed-store";
5410
5426
  import { invariant as invariant15 } from "@dxos/invariant";
5411
5427
  import { log as log17 } from "@dxos/log";
5412
5428
  import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
@@ -5457,7 +5473,7 @@ var SpacesServiceImpl = class {
5457
5473
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5458
5474
  invariant15(credentials[0].credential, void 0, {
5459
5475
  F: __dxlog_file20,
5460
- L: 98,
5476
+ L: 102,
5461
5477
  S: this,
5462
5478
  A: [
5463
5479
  "credentials[0].credential",
@@ -5467,14 +5483,14 @@ var SpacesServiceImpl = class {
5467
5483
  const spaceMemberCredential = credentials[0].credential.credential;
5468
5484
  invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5469
5485
  F: __dxlog_file20,
5470
- L: 100,
5486
+ L: 104,
5471
5487
  S: this,
5472
5488
  A: [
5473
5489
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5474
5490
  ""
5475
5491
  ]
5476
5492
  });
5477
- await writeMessages3(space.controlPipeline.writer, credentials);
5493
+ await writeMessages4(space.controlPipeline.writer, credentials);
5478
5494
  }
5479
5495
  querySpaces() {
5480
5496
  return new Stream10(({ next, ctx }) => {
@@ -5485,7 +5501,7 @@ var SpacesServiceImpl = class {
5485
5501
  spaces
5486
5502
  }, {
5487
5503
  F: __dxlog_file20,
5488
- L: 111,
5504
+ L: 115,
5489
5505
  S: this,
5490
5506
  C: (f, a) => f(...a)
5491
5507
  });
@@ -5577,7 +5593,7 @@ var SpacesServiceImpl = class {
5577
5593
  } else {
5578
5594
  invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
5579
5595
  F: __dxlog_file20,
5580
- L: 209,
5596
+ L: 213,
5581
5597
  S: this,
5582
5598
  A: [
5583
5599
  "!credential.id",
@@ -5586,7 +5602,7 @@ var SpacesServiceImpl = class {
5586
5602
  });
5587
5603
  invariant15(this._identityManager.identity, "Identity is not available", {
5588
5604
  F: __dxlog_file20,
5589
- L: 210,
5605
+ L: 214,
5590
5606
  S: this,
5591
5607
  A: [
5592
5608
  "this._identityManager.identity",
@@ -5596,7 +5612,7 @@ var SpacesServiceImpl = class {
5596
5612
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5597
5613
  invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
5598
5614
  F: __dxlog_file20,
5599
- L: 212,
5615
+ L: 216,
5600
5616
  S: this,
5601
5617
  A: [
5602
5618
  "credential.issuer.equals(signer.getIssuer())",
@@ -5626,6 +5642,59 @@ var SpacesServiceImpl = class {
5626
5642
  epochCredential: credential ?? void 0
5627
5643
  };
5628
5644
  }
5645
+ async admitContact(request) {
5646
+ const dataSpaceManager = await this._getDataSpaceManager();
5647
+ await dataSpaceManager.admitMember({
5648
+ spaceKey: request.spaceKey,
5649
+ identityKey: request.contact.identityKey,
5650
+ role: request.role
5651
+ });
5652
+ }
5653
+ async joinBySpaceKey({ spaceKey }) {
5654
+ const dataSpaceManager = await this._getDataSpaceManager();
5655
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5656
+ return this._joinByAdmission({
5657
+ credential
5658
+ });
5659
+ }
5660
+ async _joinByAdmission({ credential }) {
5661
+ const assertion = getCredentialAssertion4(credential);
5662
+ invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5663
+ F: __dxlog_file20,
5664
+ L: 250,
5665
+ S: this,
5666
+ A: [
5667
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5668
+ "'Invalid credential'"
5669
+ ]
5670
+ });
5671
+ const myIdentity = this._identityManager.identity;
5672
+ invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5673
+ F: __dxlog_file20,
5674
+ L: 252,
5675
+ S: this,
5676
+ A: [
5677
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5678
+ ""
5679
+ ]
5680
+ });
5681
+ const dataSpaceManager = await this._getDataSpaceManager();
5682
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5683
+ if (!dataSpace) {
5684
+ dataSpace = await dataSpaceManager.acceptSpace({
5685
+ spaceKey: assertion.spaceKey,
5686
+ genesisFeedKey: assertion.genesisFeedKey
5687
+ });
5688
+ await myIdentity.controlPipeline.writer.write({
5689
+ credential: {
5690
+ credential
5691
+ }
5692
+ });
5693
+ }
5694
+ return {
5695
+ space: this._serializeSpace(dataSpace)
5696
+ };
5697
+ }
5629
5698
  _serializeSpace(space) {
5630
5699
  return {
5631
5700
  id: space.id,
@@ -6198,13 +6267,151 @@ var createLevel = async (config) => {
6198
6267
  return level;
6199
6268
  };
6200
6269
 
6270
+ // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
6271
+ import { cbor } from "@dxos/automerge/automerge-repo";
6272
+ import { invariant as invariant17 } from "@dxos/invariant";
6273
+ import { log as log20 } from "@dxos/log";
6274
+ import { ProfileArchiveEntryType } from "@dxos/protocols";
6275
+ import { arrayToBuffer } from "@dxos/util";
6276
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6277
+ var encodeProfileArchive = (profile) => cbor.encode(profile);
6278
+ var decodeProfileArchive = (data) => cbor.decode(data);
6279
+ var exportProfileData = async ({ storage, level }) => {
6280
+ const archive = {
6281
+ storage: [],
6282
+ meta: {
6283
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6284
+ }
6285
+ };
6286
+ {
6287
+ const directory = await storage.createDirectory();
6288
+ const files = await directory.list();
6289
+ log20.info("begin exporting files", {
6290
+ count: files.length
6291
+ }, {
6292
+ F: __dxlog_file23,
6293
+ L: 30,
6294
+ S: void 0,
6295
+ C: (f, a) => f(...a)
6296
+ });
6297
+ for (const filename of files) {
6298
+ const file = await directory.getOrCreateFile(filename);
6299
+ const { size } = await file.stat();
6300
+ const data = await file.read(0, size);
6301
+ archive.storage.push({
6302
+ type: ProfileArchiveEntryType.FILE,
6303
+ key: filename,
6304
+ value: data
6305
+ });
6306
+ }
6307
+ log20.info("done exporting files", {
6308
+ count: files.length
6309
+ }, {
6310
+ F: __dxlog_file23,
6311
+ L: 41,
6312
+ S: void 0,
6313
+ C: (f, a) => f(...a)
6314
+ });
6315
+ }
6316
+ {
6317
+ log20.info("begin exporting kv pairs", void 0, {
6318
+ F: __dxlog_file23,
6319
+ L: 45,
6320
+ S: void 0,
6321
+ C: (f, a) => f(...a)
6322
+ });
6323
+ const iter = await level.iterator({
6324
+ keyEncoding: "binary",
6325
+ valueEncoding: "binary"
6326
+ });
6327
+ let count = 0;
6328
+ for await (const [key, value] of iter) {
6329
+ archive.storage.push({
6330
+ type: ProfileArchiveEntryType.KEY_VALUE,
6331
+ key,
6332
+ value
6333
+ });
6334
+ count++;
6335
+ }
6336
+ log20.info("done exporting kv pairs", {
6337
+ count
6338
+ }, {
6339
+ F: __dxlog_file23,
6340
+ L: 56,
6341
+ S: void 0,
6342
+ C: (f, a) => f(...a)
6343
+ });
6344
+ }
6345
+ return archive;
6346
+ };
6347
+ var importProfileData = async ({ storage, level }, archive) => {
6348
+ const batch = level.batch();
6349
+ for (const entry2 of archive.storage) {
6350
+ switch (entry2.type) {
6351
+ case ProfileArchiveEntryType.FILE: {
6352
+ const directory = await storage.createDirectory();
6353
+ invariant17(typeof entry2.key === "string", "Invalid key type", {
6354
+ F: __dxlog_file23,
6355
+ L: 78,
6356
+ S: void 0,
6357
+ A: [
6358
+ "typeof entry.key === 'string'",
6359
+ "'Invalid key type'"
6360
+ ]
6361
+ });
6362
+ const file = await directory.getOrCreateFile(entry2.key);
6363
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6364
+ F: __dxlog_file23,
6365
+ L: 80,
6366
+ S: void 0,
6367
+ A: [
6368
+ "entry.value instanceof Uint8Array",
6369
+ "'Invalid value type'"
6370
+ ]
6371
+ });
6372
+ await file.write(0, arrayToBuffer(entry2.value));
6373
+ await file.close();
6374
+ break;
6375
+ }
6376
+ case ProfileArchiveEntryType.KEY_VALUE: {
6377
+ invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
6378
+ F: __dxlog_file23,
6379
+ L: 86,
6380
+ S: void 0,
6381
+ A: [
6382
+ "entry.key instanceof Uint8Array",
6383
+ "'Invalid key type'"
6384
+ ]
6385
+ });
6386
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6387
+ F: __dxlog_file23,
6388
+ L: 87,
6389
+ S: void 0,
6390
+ A: [
6391
+ "entry.value instanceof Uint8Array",
6392
+ "'Invalid value type'"
6393
+ ]
6394
+ });
6395
+ batch.put(entry2.key, entry2.value, {
6396
+ keyEncoding: "binary",
6397
+ valueEncoding: "binary"
6398
+ });
6399
+ break;
6400
+ }
6401
+ default:
6402
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6403
+ }
6404
+ }
6405
+ await batch.write();
6406
+ };
6407
+
6201
6408
  // packages/sdk/client-services/src/packlets/services/service-host.ts
6202
6409
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
6203
6410
  import { clientServiceBundle } from "@dxos/client-protocol";
6204
6411
  import { Context as Context11 } from "@dxos/context";
6205
- import { invariant as invariant18 } from "@dxos/invariant";
6206
- import { PublicKey as PublicKey16 } from "@dxos/keys";
6207
- import { log as log21 } from "@dxos/log";
6412
+ import { invariant as invariant19 } from "@dxos/invariant";
6413
+ import { PublicKey as PublicKey17 } from "@dxos/keys";
6414
+ import { log as log22 } from "@dxos/log";
6208
6415
  import { WebsocketSignalManager } from "@dxos/messaging";
6209
6416
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
6210
6417
  import { trace as trace10 } from "@dxos/protocols";
@@ -6215,9 +6422,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
6215
6422
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
6216
6423
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
6217
6424
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
6218
- import { invariant as invariant17 } from "@dxos/invariant";
6425
+ import { invariant as invariant18 } from "@dxos/invariant";
6219
6426
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
6220
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6427
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6221
6428
  var DevicesServiceImpl = class {
6222
6429
  constructor(_identityManager) {
6223
6430
  this._identityManager = _identityManager;
@@ -6234,8 +6441,8 @@ var DevicesServiceImpl = class {
6234
6441
  devices: []
6235
6442
  });
6236
6443
  } else {
6237
- invariant17(this._identityManager.identity?.presence, "presence not present", {
6238
- F: __dxlog_file23,
6444
+ invariant18(this._identityManager.identity?.presence, "presence not present", {
6445
+ F: __dxlog_file24,
6239
6446
  L: 32,
6240
6447
  S: this,
6241
6448
  A: [
@@ -6341,28 +6548,111 @@ var findConfigs = () => {
6341
6548
  return configs.map((r) => r.instance.deref()).filter(nonNullable);
6342
6549
  };
6343
6550
 
6344
- // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6345
- import { Event as Event8 } from "@dxos/async";
6551
+ // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
6552
+ import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
6346
6553
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
6347
6554
  import { PublicKey as PublicKey15 } from "@dxos/keys";
6348
- import { getContextFromEntry, log as log20 } from "@dxos/log";
6555
+ import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
6556
+ var ContactsServiceImpl = class {
6557
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6558
+ this._identityManager = _identityManager;
6559
+ this._spaceManager = _spaceManager;
6560
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6561
+ }
6562
+ async getContacts() {
6563
+ const identity = this._identityManager.identity;
6564
+ if (identity == null) {
6565
+ return {
6566
+ contacts: []
6567
+ };
6568
+ }
6569
+ const contacts = [
6570
+ ...this._spaceManager.spaces.values()
6571
+ ].flatMap((s) => [
6572
+ ...s.spaceState.members.values()
6573
+ ].map((m) => [
6574
+ s.key,
6575
+ m
6576
+ ])).reduce((acc, v) => {
6577
+ const [spaceKey, memberInfo] = v;
6578
+ if (memberInfo.key.equals(identity.identityKey)) {
6579
+ return acc;
6580
+ }
6581
+ const existing = acc.get(memberInfo.key);
6582
+ if (existing != null) {
6583
+ existing.profile ??= memberInfo.profile;
6584
+ existing.commonSpaces?.push(spaceKey);
6585
+ } else {
6586
+ acc.set(memberInfo.key, {
6587
+ identityKey: memberInfo.key,
6588
+ profile: memberInfo.profile,
6589
+ commonSpaces: [
6590
+ spaceKey
6591
+ ]
6592
+ });
6593
+ }
6594
+ return acc;
6595
+ }, new ComplexMap4(PublicKey15.hash));
6596
+ return {
6597
+ contacts: [
6598
+ ...contacts.values()
6599
+ ]
6600
+ };
6601
+ }
6602
+ queryContacts() {
6603
+ const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
6604
+ return new Stream12(({ next, ctx }) => {
6605
+ const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
6606
+ const contacts = await this.getContacts();
6607
+ next(contacts);
6608
+ }, {
6609
+ maxFrequency: 2
6610
+ });
6611
+ scheduleTask7(ctx, async () => {
6612
+ const subscriptions = new EventSubscriptions4();
6613
+ ctx.onDispose(() => subscriptions.clear());
6614
+ const subscribeToSpaceAndUpdate = () => {
6615
+ const oldSetSize = subscribedSpaceKeySet.size;
6616
+ for (const space of this._spaceManager.spaces.values()) {
6617
+ if (!subscribedSpaceKeySet.has(space.key)) {
6618
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6619
+ subscribedSpaceKeySet.add(space.key);
6620
+ }
6621
+ }
6622
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6623
+ pushUpdateTask.trigger();
6624
+ }
6625
+ };
6626
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6627
+ ctx.onDispose(unsubscribe);
6628
+ subscribeToSpaceAndUpdate();
6629
+ });
6630
+ });
6631
+ }
6632
+ };
6633
+
6634
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6635
+ import { Event as Event8 } from "@dxos/async";
6636
+ import { Stream as Stream13 } from "@dxos/codec-protobuf";
6637
+ import { PublicKey as PublicKey16 } from "@dxos/keys";
6638
+ import { getContextFromEntry, log as log21 } from "@dxos/log";
6349
6639
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
6350
6640
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
6351
6641
  var LoggingServiceImpl = class {
6352
6642
  constructor() {
6353
6643
  this._logs = new Event8();
6354
6644
  this._started = Date.now();
6355
- this._sessionId = PublicKey15.random().toHex();
6645
+ this._sessionId = PublicKey16.random().toHex();
6356
6646
  this._logProcessor = (_config, entry2) => {
6357
6647
  this._logs.emit(entry2);
6358
6648
  };
6359
6649
  }
6360
6650
  async open() {
6361
- log20.runtimeConfig.processors.push(this._logProcessor);
6651
+ log21.runtimeConfig.processors.push(this._logProcessor);
6362
6652
  }
6363
6653
  async close() {
6364
- const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6365
- log20.runtimeConfig.processors.splice(index, 1);
6654
+ const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6655
+ log21.runtimeConfig.processors.splice(index, 1);
6366
6656
  }
6367
6657
  async controlMetrics({ reset, record }) {
6368
6658
  if (reset) {
@@ -6388,7 +6678,7 @@ var LoggingServiceImpl = class {
6388
6678
  stats: numericalValues(events, "duration")
6389
6679
  };
6390
6680
  };
6391
- return new Stream12(({ next }) => {
6681
+ return new Stream13(({ next }) => {
6392
6682
  const update = () => {
6393
6683
  const metrics = {
6394
6684
  timestamp: /* @__PURE__ */ new Date(),
@@ -6410,7 +6700,7 @@ var LoggingServiceImpl = class {
6410
6700
  });
6411
6701
  }
6412
6702
  queryLogs(request) {
6413
- return new Stream12(({ ctx, next }) => {
6703
+ return new Stream13(({ ctx, next }) => {
6414
6704
  const handler = (entry2) => {
6415
6705
  if (LOG_PROCESSING > 0) {
6416
6706
  return;
@@ -6466,14 +6756,14 @@ var shouldLog = (entry2, request) => {
6466
6756
  var LOG_PROCESSING = 0;
6467
6757
 
6468
6758
  // packages/sdk/client-services/src/packlets/network/network-service.ts
6469
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
6759
+ import { Stream as Stream14 } from "@dxos/codec-protobuf";
6470
6760
  var NetworkServiceImpl = class {
6471
6761
  constructor(networkManager, signalManager) {
6472
6762
  this.networkManager = networkManager;
6473
6763
  this.signalManager = signalManager;
6474
6764
  }
6475
6765
  queryStatus() {
6476
- return new Stream13(({ next }) => {
6766
+ return new Stream14(({ next }) => {
6477
6767
  const update = () => {
6478
6768
  next({
6479
6769
  swarm: this.networkManager.connectionState,
@@ -6499,7 +6789,7 @@ var NetworkServiceImpl = class {
6499
6789
  };
6500
6790
 
6501
6791
  // packages/sdk/client-services/src/packlets/system/system-service.ts
6502
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
6792
+ import { Stream as Stream15 } from "@dxos/codec-protobuf";
6503
6793
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
6504
6794
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
6505
6795
  var SystemServiceImpl = class {
@@ -6535,7 +6825,7 @@ var SystemServiceImpl = class {
6535
6825
  }
6536
6826
  // TODO(burdon): Standardize interval option in stream request?
6537
6827
  queryStatus({ interval = 3e3 } = {}) {
6538
- return new Stream14(({ next }) => {
6828
+ return new Stream15(({ next }) => {
6539
6829
  const update = () => {
6540
6830
  next({
6541
6831
  status: this._getCurrentStatus()
@@ -6566,7 +6856,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6566
6856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6567
6857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6568
6858
  }
6569
- var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6859
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6570
6860
  var ClientServicesHost = class {
6571
6861
  constructor({
6572
6862
  config,
@@ -6600,8 +6890,8 @@ var ClientServicesHost = class {
6600
6890
  onAcquire: () => {
6601
6891
  if (!this._opening) {
6602
6892
  void this.open(new Context11(void 0, {
6603
- F: __dxlog_file24,
6604
- L: 120
6893
+ F: __dxlog_file25,
6894
+ L: 121
6605
6895
  }));
6606
6896
  }
6607
6897
  },
@@ -6657,25 +6947,25 @@ var ClientServicesHost = class {
6657
6947
  * Can only be called once.
6658
6948
  */
6659
6949
  initialize({ config, ...options }) {
6660
- invariant18(!this._open, "service host is open", {
6661
- F: __dxlog_file24,
6662
- L: 186,
6950
+ invariant19(!this._open, "service host is open", {
6951
+ F: __dxlog_file25,
6952
+ L: 187,
6663
6953
  S: this,
6664
6954
  A: [
6665
6955
  "!this._open",
6666
6956
  "'service host is open'"
6667
6957
  ]
6668
6958
  });
6669
- log21("initializing...", void 0, {
6670
- F: __dxlog_file24,
6671
- L: 187,
6959
+ log22("initializing...", void 0, {
6960
+ F: __dxlog_file25,
6961
+ L: 188,
6672
6962
  S: this,
6673
6963
  C: (f, a) => f(...a)
6674
6964
  });
6675
6965
  if (config) {
6676
- invariant18(!this._config, "config already set", {
6677
- F: __dxlog_file24,
6678
- L: 190,
6966
+ invariant19(!this._config, "config already set", {
6967
+ F: __dxlog_file25,
6968
+ L: 191,
6679
6969
  S: this,
6680
6970
  A: [
6681
6971
  "!this._config",
@@ -6688,9 +6978,9 @@ var ClientServicesHost = class {
6688
6978
  }
6689
6979
  }
6690
6980
  if (!options.signalManager) {
6691
- log21.warn("running signaling without telemetry metadata.", void 0, {
6692
- F: __dxlog_file24,
6693
- L: 198,
6981
+ log22.warn("running signaling without telemetry metadata.", void 0, {
6982
+ F: __dxlog_file25,
6983
+ L: 199,
6694
6984
  S: this,
6695
6985
  C: (f, a) => f(...a)
6696
6986
  });
@@ -6699,9 +6989,9 @@ var ClientServicesHost = class {
6699
6989
  iceServers: this._config?.get("runtime.services.ice")
6700
6990
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6701
6991
  this._signalManager = signalManager;
6702
- invariant18(!this._networkManager, "network manager already set", {
6703
- F: __dxlog_file24,
6704
- L: 209,
6992
+ invariant19(!this._networkManager, "network manager already set", {
6993
+ F: __dxlog_file25,
6994
+ L: 210,
6705
6995
  S: this,
6706
6996
  A: [
6707
6997
  "!this._networkManager",
@@ -6713,9 +7003,9 @@ var ClientServicesHost = class {
6713
7003
  transportFactory,
6714
7004
  signalManager
6715
7005
  });
6716
- log21("initialized", void 0, {
6717
- F: __dxlog_file24,
6718
- L: 216,
7006
+ log22("initialized", void 0, {
7007
+ F: __dxlog_file25,
7008
+ L: 217,
6719
7009
  S: this,
6720
7010
  C: (f, a) => f(...a)
6721
7011
  });
@@ -6724,45 +7014,45 @@ var ClientServicesHost = class {
6724
7014
  if (this._open) {
6725
7015
  return;
6726
7016
  }
6727
- const traceId = PublicKey16.random().toHex();
6728
- log21.trace("dxos.client-services.host.open", trace10.begin({
7017
+ const traceId = PublicKey17.random().toHex();
7018
+ log22.trace("dxos.client-services.host.open", trace10.begin({
6729
7019
  id: traceId
6730
7020
  }), {
6731
- F: __dxlog_file24,
6732
- L: 227,
7021
+ F: __dxlog_file25,
7022
+ L: 228,
6733
7023
  S: this,
6734
7024
  C: (f, a) => f(...a)
6735
7025
  });
6736
- invariant18(this._config, "config not set", {
6737
- F: __dxlog_file24,
6738
- L: 229,
7026
+ invariant19(this._config, "config not set", {
7027
+ F: __dxlog_file25,
7028
+ L: 230,
6739
7029
  S: this,
6740
7030
  A: [
6741
7031
  "this._config",
6742
7032
  "'config not set'"
6743
7033
  ]
6744
7034
  });
6745
- invariant18(this._storage, "storage not set", {
6746
- F: __dxlog_file24,
6747
- L: 230,
7035
+ invariant19(this._storage, "storage not set", {
7036
+ F: __dxlog_file25,
7037
+ L: 231,
6748
7038
  S: this,
6749
7039
  A: [
6750
7040
  "this._storage",
6751
7041
  "'storage not set'"
6752
7042
  ]
6753
7043
  });
6754
- invariant18(this._signalManager, "signal manager not set", {
6755
- F: __dxlog_file24,
6756
- L: 231,
7044
+ invariant19(this._signalManager, "signal manager not set", {
7045
+ F: __dxlog_file25,
7046
+ L: 232,
6757
7047
  S: this,
6758
7048
  A: [
6759
7049
  "this._signalManager",
6760
7050
  "'signal manager not set'"
6761
7051
  ]
6762
7052
  });
6763
- invariant18(this._networkManager, "network manager not set", {
6764
- F: __dxlog_file24,
6765
- L: 232,
7053
+ invariant19(this._networkManager, "network manager not set", {
7054
+ F: __dxlog_file25,
7055
+ L: 233,
6766
7056
  S: this,
6767
7057
  A: [
6768
7058
  "this._networkManager",
@@ -6770,11 +7060,11 @@ var ClientServicesHost = class {
6770
7060
  ]
6771
7061
  });
6772
7062
  this._opening = true;
6773
- log21("opening...", {
7063
+ log22("opening...", {
6774
7064
  lockKey: this._resourceLock?.lockKey
6775
7065
  }, {
6776
- F: __dxlog_file24,
6777
- L: 235,
7066
+ F: __dxlog_file25,
7067
+ L: 236,
6778
7068
  S: this,
6779
7069
  C: (f, a) => f(...a)
6780
7070
  });
@@ -6785,16 +7075,18 @@ var ClientServicesHost = class {
6785
7075
  await this._level.open();
6786
7076
  await this._loggingService.open();
6787
7077
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
7078
+ const dataSpaceManagerProvider = async () => {
7079
+ await this._serviceContext.initialized.wait();
7080
+ return this._serviceContext.dataSpaceManager;
7081
+ };
6788
7082
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6789
7083
  this._serviceRegistry.setServices({
6790
7084
  SystemService: this._systemService,
6791
7085
  IdentityService: identityService,
7086
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6792
7087
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6793
7088
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6794
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6795
- await this._serviceContext.initialized.wait();
6796
- return this._serviceContext.dataSpaceManager;
6797
- }),
7089
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6798
7090
  DataService: this._serviceContext.echoHost.dataService,
6799
7091
  QueryService: this._serviceContext.echoHost.queryService,
6800
7092
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6824,19 +7116,19 @@ var ClientServicesHost = class {
6824
7116
  this._open = true;
6825
7117
  this._statusUpdate.emit();
6826
7118
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6827
- log21("opened", {
7119
+ log22("opened", {
6828
7120
  deviceKey
6829
7121
  }, {
6830
- F: __dxlog_file24,
6831
- L: 314,
7122
+ F: __dxlog_file25,
7123
+ L: 322,
6832
7124
  S: this,
6833
7125
  C: (f, a) => f(...a)
6834
7126
  });
6835
- log21.trace("dxos.client-services.host.open", trace10.end({
7127
+ log22.trace("dxos.client-services.host.open", trace10.end({
6836
7128
  id: traceId
6837
7129
  }), {
6838
- F: __dxlog_file24,
6839
- L: 315,
7130
+ F: __dxlog_file25,
7131
+ L: 323,
6840
7132
  S: this,
6841
7133
  C: (f, a) => f(...a)
6842
7134
  });
@@ -6846,11 +7138,11 @@ var ClientServicesHost = class {
6846
7138
  return;
6847
7139
  }
6848
7140
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6849
- log21("closing...", {
7141
+ log22("closing...", {
6850
7142
  deviceKey
6851
7143
  }, {
6852
- F: __dxlog_file24,
6853
- L: 326,
7144
+ F: __dxlog_file25,
7145
+ L: 334,
6854
7146
  S: this,
6855
7147
  C: (f, a) => f(...a)
6856
7148
  });
@@ -6864,44 +7156,44 @@ var ClientServicesHost = class {
6864
7156
  await this._level?.close();
6865
7157
  this._open = false;
6866
7158
  this._statusUpdate.emit();
6867
- log21("closed", {
7159
+ log22("closed", {
6868
7160
  deviceKey
6869
7161
  }, {
6870
- F: __dxlog_file24,
6871
- L: 335,
7162
+ F: __dxlog_file25,
7163
+ L: 343,
6872
7164
  S: this,
6873
7165
  C: (f, a) => f(...a)
6874
7166
  });
6875
7167
  }
6876
7168
  async reset() {
6877
- const traceId = PublicKey16.random().toHex();
6878
- log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
7169
+ const traceId = PublicKey17.random().toHex();
7170
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6879
7171
  id: traceId
6880
7172
  }), {
6881
- F: __dxlog_file24,
6882
- L: 340,
7173
+ F: __dxlog_file25,
7174
+ L: 348,
6883
7175
  S: this,
6884
7176
  C: (f, a) => f(...a)
6885
7177
  });
6886
- log21.info("resetting...", void 0, {
6887
- F: __dxlog_file24,
6888
- L: 342,
7178
+ log22.info("resetting...", void 0, {
7179
+ F: __dxlog_file25,
7180
+ L: 350,
6889
7181
  S: this,
6890
7182
  C: (f, a) => f(...a)
6891
7183
  });
6892
7184
  await this._serviceContext?.close();
6893
7185
  await this._storage.reset();
6894
- log21.info("reset", void 0, {
6895
- F: __dxlog_file24,
6896
- L: 345,
7186
+ log22.info("reset", void 0, {
7187
+ F: __dxlog_file25,
7188
+ L: 353,
6897
7189
  S: this,
6898
7190
  C: (f, a) => f(...a)
6899
7191
  });
6900
- log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
7192
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
6901
7193
  id: traceId
6902
7194
  }), {
6903
- F: __dxlog_file24,
6904
- L: 346,
7195
+ F: __dxlog_file25,
7196
+ L: 354,
6905
7197
  S: this,
6906
7198
  C: (f, a) => f(...a)
6907
7199
  });
@@ -6967,8 +7259,12 @@ export {
6967
7259
  isLocked,
6968
7260
  createStorageObjects,
6969
7261
  createLevel,
7262
+ encodeProfileArchive,
7263
+ decodeProfileArchive,
7264
+ exportProfileData,
7265
+ importProfileData,
6970
7266
  ClientServicesHost,
6971
7267
  ClientServicesProviderResource,
6972
7268
  DiagnosticsCollector
6973
7269
  };
6974
- //# sourceMappingURL=chunk-J4DDMC6A.mjs.map
7270
+ //# sourceMappingURL=chunk-H3XJK6ZN.mjs.map