@dxos/client-services 0.7.5-labs.e27f9b9 → 0.7.5-labs.ea4b4c2

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 (30) hide show
  1. package/dist/lib/browser/{chunk-OHBCYJRF.mjs → chunk-X65X3DJU.mjs} +104 -20
  2. package/dist/lib/browser/chunk-X65X3DJU.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/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-X3IYGB6Q.cjs → chunk-2XAKPWJ6.cjs} +107 -23
  7. package/dist/lib/node/chunk-2XAKPWJ6.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +47 -47
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/node-esm/{chunk-U5S4G236.mjs → chunk-UCFK27SP.mjs} +104 -20
  12. package/dist/lib/node-esm/chunk-UCFK27SP.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +10 -1
  18. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  19. package/dist/types/src/packlets/identity/identity-service.d.ts +5 -0
  20. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  21. package/dist/types/src/version.d.ts +1 -1
  22. package/package.json +38 -38
  23. package/src/packlets/agents/edge-agent-manager.ts +6 -0
  24. package/src/packlets/identity/identity-recovery-manager.ts +64 -2
  25. package/src/packlets/identity/identity-service.ts +12 -1
  26. package/src/packlets/spaces/data-space-manager.ts +2 -2
  27. package/src/version.ts +1 -1
  28. package/dist/lib/browser/chunk-OHBCYJRF.mjs.map +0 -7
  29. package/dist/lib/node/chunk-X3IYGB6Q.cjs.map +0 -7
  30. package/dist/lib/node-esm/chunk-U5S4G236.mjs.map +0 -7
@@ -32,7 +32,7 @@ __export(testing_exports, {
32
32
  sanitizeInvitation: () => sanitizeInvitation
33
33
  });
34
34
  module.exports = __toCommonJS(testing_exports);
35
- var import_chunk_X3IYGB6Q = require("../chunk-X3IYGB6Q.cjs");
35
+ var import_chunk_2XAKPWJ6 = require("../chunk-2XAKPWJ6.cjs");
36
36
  var import_credentials = require("@dxos/credentials");
37
37
  var import_keys = require("@dxos/keys");
38
38
  var import_async = require("@dxos/async");
@@ -235,7 +235,7 @@ var createInvitation = async (host, options) => {
235
235
  authMethod: import_services.Invitation.AuthMethod.NONE,
236
236
  ...options ?? {}
237
237
  };
238
- if (host instanceof import_chunk_X3IYGB6Q.ServiceContext) {
238
+ if (host instanceof import_chunk_2XAKPWJ6.ServiceContext) {
239
239
  return host.invitationsManager.createInvitation({
240
240
  kind: import_services.Invitation.Kind.SPACE,
241
241
  ...options
@@ -245,7 +245,7 @@ var createInvitation = async (host, options) => {
245
245
  };
246
246
  var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
247
247
  invitation = sanitizeInvitation(invitation);
248
- if (guest instanceof import_chunk_X3IYGB6Q.ServiceContext) {
248
+ if (guest instanceof import_chunk_2XAKPWJ6.ServiceContext) {
249
249
  return guest.invitationsManager.acceptInvitation({
250
250
  invitation,
251
251
  deviceProfile: guestDeviceProfile
@@ -255,7 +255,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
255
255
  };
256
256
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/test-builder.ts";
257
257
  var createServiceHost = (config, signalManagerContext) => {
258
- return new import_chunk_X3IYGB6Q.ClientServicesHost({
258
+ return new import_chunk_2XAKPWJ6.ClientServicesHost({
259
259
  config,
260
260
  signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
261
261
  transportFactory: import_network_manager.MemoryTransportFactory
@@ -274,7 +274,7 @@ var createServiceContext = async ({ signalManagerFactory = async () => {
274
274
  });
275
275
  const level = (0, import_testing.createTestLevel)();
276
276
  await level.open();
277
- return new import_chunk_X3IYGB6Q.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
277
+ return new import_chunk_2XAKPWJ6.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
278
278
  invitationConnectionDefaultParams: {
279
279
  teleport: {
280
280
  controlHeartbeatInterval: 200
@@ -385,7 +385,7 @@ var TestPeer = class {
385
385
  return this._props.meshEchoReplicator ??= new import_echo_pipeline.MeshEchoReplicator();
386
386
  }
387
387
  get dataSpaceManager() {
388
- return this._props.dataSpaceManager ??= new import_chunk_X3IYGB6Q.DataSpaceManager({
388
+ return this._props.dataSpaceManager ??= new import_chunk_2XAKPWJ6.DataSpaceManager({
389
389
  spaceManager: this.spaceManager,
390
390
  metadataStore: this.metadataStore,
391
391
  keyring: this.keyring,
@@ -400,9 +400,9 @@ var TestPeer = class {
400
400
  });
401
401
  }
402
402
  get invitationsManager() {
403
- return this._props.invitationsManager ??= new import_chunk_X3IYGB6Q.InvitationsManager(new import_chunk_X3IYGB6Q.InvitationsHandler(this.networkManager), (invitation) => {
403
+ return this._props.invitationsManager ??= new import_chunk_2XAKPWJ6.InvitationsManager(new import_chunk_2XAKPWJ6.InvitationsHandler(this.networkManager), (invitation) => {
404
404
  if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
405
- return new import_chunk_X3IYGB6Q.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
405
+ return new import_chunk_2XAKPWJ6.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
406
406
  } else {
407
407
  throw new Error("not implemented");
408
408
  }
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.7.5-labs.e27f9b9";
400
+ var DXOS_VERSION = "0.7.5-labs.ea4b4c2";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -2452,7 +2452,7 @@ var DataSpaceManager = class extends Resource4 {
2452
2452
  });
2453
2453
  dataSpace.postOpen.append(async () => {
2454
2454
  const setting = dataSpace.getEdgeReplicationSetting();
2455
- if (setting === EdgeReplicationSetting.ENABLED) {
2455
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2456
2456
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2457
2457
  } else if (this._echoEdgeReplicator) {
2458
2458
  log6("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
@@ -2467,7 +2467,7 @@ var DataSpaceManager = class extends Resource4 {
2467
2467
  });
2468
2468
  dataSpace.preClose.append(async () => {
2469
2469
  const setting = dataSpace.getEdgeReplicationSetting();
2470
- if (setting === EdgeReplicationSetting.ENABLED) {
2470
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2471
2471
  await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2472
2472
  }
2473
2473
  });
@@ -3736,15 +3736,26 @@ var IdentityServiceImpl = class extends Resource5 {
3736
3736
  async createRecoveryCredential(request) {
3737
3737
  return this._recoveryManager.createRecoveryCredential(request);
3738
3738
  }
3739
+ async requestRecoveryChallenge() {
3740
+ return this._recoveryManager.requestRecoveryChallenge();
3741
+ }
3739
3742
  async recoverIdentity(request) {
3740
- await this._recoveryManager.recoverIdentity(request);
3743
+ if (request.recoveryCode) {
3744
+ await this._recoveryManager.recoverIdentity({
3745
+ recoveryCode: request.recoveryCode
3746
+ });
3747
+ } else if (request.external) {
3748
+ await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
3749
+ } else {
3750
+ throw new Error("Invalid request.");
3751
+ }
3741
3752
  return this._getIdentity();
3742
3753
  }
3743
3754
  // TODO(burdon): Rename createPresentation?
3744
3755
  async signPresentation({ presentation, nonce }) {
3745
3756
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3746
3757
  F: __dxlog_file13,
3747
- L: 105,
3758
+ L: 116,
3748
3759
  S: this,
3749
3760
  A: [
3750
3761
  "this._identityManager.identity",
@@ -3763,7 +3774,7 @@ var IdentityServiceImpl = class extends Resource5 {
3763
3774
  const identity = this._identityManager.identity;
3764
3775
  invariant9(identity, "Identity not initialized.", {
3765
3776
  F: __dxlog_file13,
3766
- L: 119,
3777
+ L: 130,
3767
3778
  S: this,
3768
3779
  A: [
3769
3780
  "identity",
@@ -3801,7 +3812,7 @@ var IdentityServiceImpl = class extends Resource5 {
3801
3812
  duplicate: space.id
3802
3813
  }, {
3803
3814
  F: __dxlog_file13,
3804
- L: 153,
3815
+ L: 164,
3805
3816
  S: this,
3806
3817
  C: (f, a) => f(...a)
3807
3818
  });
@@ -3815,7 +3826,7 @@ var IdentityServiceImpl = class extends Resource5 {
3815
3826
  }, (err) => {
3816
3827
  log10.catch(err, void 0, {
3817
3828
  F: __dxlog_file13,
3818
- L: 164,
3829
+ L: 175,
3819
3830
  S: this,
3820
3831
  C: (f, a) => f(...a)
3821
3832
  });
@@ -7005,6 +7016,18 @@ var EdgeAgentManager = class extends Resource6 {
7005
7016
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7006
7017
  });
7007
7018
  const deviceKey = PublicKey13.fromHex(response.deviceKey);
7019
+ if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7020
+ log21.info("agent was already added to HALO, ignoring response", {
7021
+ response
7022
+ }, {
7023
+ F: __dxlog_file25,
7024
+ L: 67,
7025
+ S: this,
7026
+ C: (f, a) => f(...a)
7027
+ });
7028
+ this._updateStatus(EdgeAgentStatus.ACTIVE, deviceKey);
7029
+ return;
7030
+ }
7008
7031
  await this._identity.admitDevice({
7009
7032
  deviceKey,
7010
7033
  controlFeedKey: PublicKey13.fromHex(response.feedKey),
@@ -7013,7 +7036,7 @@ var EdgeAgentManager = class extends Resource6 {
7013
7036
  });
7014
7037
  log21("agent created", response, {
7015
7038
  F: __dxlog_file25,
7016
- L: 73,
7039
+ L: 79,
7017
7040
  S: this,
7018
7041
  C: (f, a) => f(...a)
7019
7042
  });
@@ -7025,7 +7048,7 @@ var EdgeAgentManager = class extends Resource6 {
7025
7048
  isEnabled
7026
7049
  }, {
7027
7050
  F: __dxlog_file25,
7028
- L: 81,
7051
+ L: 87,
7029
7052
  S: this,
7030
7053
  C: (f, a) => f(...a)
7031
7054
  });
@@ -7058,7 +7081,7 @@ var EdgeAgentManager = class extends Resource6 {
7058
7081
  async _fetchAgentStatus() {
7059
7082
  invariant19(this._edgeHttpClient, void 0, {
7060
7083
  F: __dxlog_file25,
7061
- L: 115,
7084
+ L: 121,
7062
7085
  S: this,
7063
7086
  A: [
7064
7087
  "this._edgeHttpClient",
@@ -7068,7 +7091,7 @@ var EdgeAgentManager = class extends Resource6 {
7068
7091
  try {
7069
7092
  log21("fetching agent status", void 0, {
7070
7093
  F: __dxlog_file25,
7071
- L: 117,
7094
+ L: 123,
7072
7095
  S: this,
7073
7096
  C: (f, a) => f(...a)
7074
7097
  });
@@ -7087,7 +7110,7 @@ var EdgeAgentManager = class extends Resource6 {
7087
7110
  err
7088
7111
  }, {
7089
7112
  F: __dxlog_file25,
7090
- L: 127,
7113
+ L: 133,
7091
7114
  S: this,
7092
7115
  C: (f, a) => f(...a)
7093
7116
  });
@@ -7100,7 +7123,7 @@ var EdgeAgentManager = class extends Resource6 {
7100
7123
  retryAfterMs
7101
7124
  }, {
7102
7125
  F: __dxlog_file25,
7103
- L: 132,
7126
+ L: 138,
7104
7127
  S: this,
7105
7128
  C: (f, a) => f(...a)
7106
7129
  });
@@ -7136,7 +7159,7 @@ var EdgeAgentManager = class extends Resource6 {
7136
7159
  spaceId: space.id
7137
7160
  }, {
7138
7161
  F: __dxlog_file25,
7139
- L: 159,
7162
+ L: 165,
7140
7163
  S: this,
7141
7164
  C: (f, a) => f(...a)
7142
7165
  });
@@ -7156,7 +7179,7 @@ var EdgeAgentManager = class extends Resource6 {
7156
7179
  status
7157
7180
  }, {
7158
7181
  F: __dxlog_file25,
7159
- L: 175,
7182
+ L: 181,
7160
7183
  S: this,
7161
7184
  C: (f, a) => f(...a)
7162
7185
  });
@@ -7278,7 +7301,7 @@ var EdgeIdentityRecoveryManager = class {
7278
7301
  recoveryCode = generateSeedPhrase();
7279
7302
  const keypair = keyPairFromSeedPhrase(recoveryCode);
7280
7303
  recoveryKey = PublicKey14.from(keypair.publicKey);
7281
- algorithm = -8;
7304
+ algorithm = "ED25519";
7282
7305
  }
7283
7306
  invariant20(algorithm, "Algorithm is required.", {
7284
7307
  F: __dxlog_file26,
@@ -7314,7 +7337,7 @@ var EdgeIdentityRecoveryManager = class {
7314
7337
  recoveryCode
7315
7338
  };
7316
7339
  }
7317
- async recoverIdentity({ recoveryCode }) {
7340
+ async requestRecoveryChallenge() {
7318
7341
  invariant20(this._edgeClient, "Not connected to EDGE.", {
7319
7342
  F: __dxlog_file26,
7320
7343
  L: 66,
@@ -7324,6 +7347,67 @@ var EdgeIdentityRecoveryManager = class {
7324
7347
  "'Not connected to EDGE.'"
7325
7348
  ]
7326
7349
  });
7350
+ const deviceKey = await this._keyring.createKey();
7351
+ const controlFeedKey = await this._keyring.createKey();
7352
+ const request = {
7353
+ deviceKey: deviceKey.toHex(),
7354
+ controlFeedKey: controlFeedKey.toHex()
7355
+ };
7356
+ try {
7357
+ await this._edgeClient.recoverIdentity(request);
7358
+ throw new Error("No challenge received.");
7359
+ } catch (error) {
7360
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7361
+ throw error;
7362
+ }
7363
+ return {
7364
+ deviceKey,
7365
+ controlFeedKey,
7366
+ challenge: error.challenge
7367
+ };
7368
+ }
7369
+ }
7370
+ async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7371
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7372
+ F: __dxlog_file26,
7373
+ L: 98,
7374
+ S: this,
7375
+ A: [
7376
+ "this._edgeClient",
7377
+ "'Not connected to EDGE.'"
7378
+ ]
7379
+ });
7380
+ const request = {
7381
+ identityDid,
7382
+ deviceKey: deviceKey.toHex(),
7383
+ controlFeedKey: controlFeedKey.toHex(),
7384
+ signature: clientDataJson && authenticatorData ? {
7385
+ signature: Buffer.from(signature).toString("base64"),
7386
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7387
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7388
+ } : Buffer.from(signature).toString("base64")
7389
+ };
7390
+ const response = await this._edgeClient.recoverIdentity(request);
7391
+ await this._acceptRecoveredIdentity({
7392
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7393
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7394
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7395
+ identityKey: PublicKey14.fromHex(response.identityKey),
7396
+ deviceKey,
7397
+ controlFeedKey,
7398
+ dataFeedKey: await this._keyring.createKey()
7399
+ });
7400
+ }
7401
+ async recoverIdentity({ recoveryCode }) {
7402
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7403
+ F: __dxlog_file26,
7404
+ L: 128,
7405
+ S: this,
7406
+ A: [
7407
+ "this._edgeClient",
7408
+ "'Not connected to EDGE.'"
7409
+ ]
7410
+ });
7327
7411
  const recoveryKeypair = keyPairFromSeedPhrase(recoveryCode);
7328
7412
  const recoveryKey = PublicKey14.from(recoveryKeypair.publicKey);
7329
7413
  const deviceKey = await this._keyring.createKey();
@@ -7348,7 +7432,7 @@ var EdgeIdentityRecoveryManager = class {
7348
7432
  }
7349
7433
  log22.info("recovering identity", response, {
7350
7434
  F: __dxlog_file26,
7351
- L: 92,
7435
+ L: 154,
7352
7436
  S: this,
7353
7437
  C: (f, a) => f(...a)
7354
7438
  });
@@ -8950,4 +9034,4 @@ export {
8950
9034
  importProfileData,
8951
9035
  ClientServicesHost
8952
9036
  };
8953
- //# sourceMappingURL=chunk-U5S4G236.mjs.map
9037
+ //# sourceMappingURL=chunk-UCFK27SP.mjs.map