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

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.
@@ -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.f5080a1";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -3814,15 +3814,26 @@ var IdentityServiceImpl = class extends Resource5 {
3814
3814
  async createRecoveryCredential(request) {
3815
3815
  return this._recoveryManager.createRecoveryCredential(request);
3816
3816
  }
3817
+ async requestRecoveryChallenge() {
3818
+ return this._recoveryManager.requestRecoveryChallenge();
3819
+ }
3817
3820
  async recoverIdentity(request) {
3818
- await this._recoveryManager.recoverIdentity(request);
3821
+ if (request.recoveryCode) {
3822
+ await this._recoveryManager.recoverIdentity({
3823
+ recoveryCode: request.recoveryCode
3824
+ });
3825
+ } else if (request.external) {
3826
+ await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
3827
+ } else {
3828
+ throw new Error("Invalid request.");
3829
+ }
3819
3830
  return this._getIdentity();
3820
3831
  }
3821
3832
  // TODO(burdon): Rename createPresentation?
3822
3833
  async signPresentation({ presentation, nonce }) {
3823
3834
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3824
3835
  F: __dxlog_file14,
3825
- L: 105,
3836
+ L: 116,
3826
3837
  S: this,
3827
3838
  A: [
3828
3839
  "this._identityManager.identity",
@@ -3841,7 +3852,7 @@ var IdentityServiceImpl = class extends Resource5 {
3841
3852
  const identity = this._identityManager.identity;
3842
3853
  invariant9(identity, "Identity not initialized.", {
3843
3854
  F: __dxlog_file14,
3844
- L: 119,
3855
+ L: 130,
3845
3856
  S: this,
3846
3857
  A: [
3847
3858
  "identity",
@@ -3879,7 +3890,7 @@ var IdentityServiceImpl = class extends Resource5 {
3879
3890
  duplicate: space.id
3880
3891
  }, {
3881
3892
  F: __dxlog_file14,
3882
- L: 153,
3893
+ L: 164,
3883
3894
  S: this,
3884
3895
  C: (f, a) => f(...a)
3885
3896
  });
@@ -3893,7 +3904,7 @@ var IdentityServiceImpl = class extends Resource5 {
3893
3904
  }, (err) => {
3894
3905
  log11.catch(err, void 0, {
3895
3906
  F: __dxlog_file14,
3896
- L: 164,
3907
+ L: 175,
3897
3908
  S: this,
3898
3909
  C: (f, a) => f(...a)
3899
3910
  });
@@ -7421,7 +7432,7 @@ var EdgeIdentityRecoveryManager = class {
7421
7432
  recoveryCode = generateSeedPhrase();
7422
7433
  const keypair = keyPairFromSeedPhrase(recoveryCode);
7423
7434
  recoveryKey = PublicKey14.from(keypair.publicKey);
7424
- algorithm = -8;
7435
+ algorithm = "ED25519";
7425
7436
  }
7426
7437
  invariant19(algorithm, "Algorithm is required.", {
7427
7438
  F: __dxlog_file27,
@@ -7457,7 +7468,7 @@ var EdgeIdentityRecoveryManager = class {
7457
7468
  recoveryCode
7458
7469
  };
7459
7470
  }
7460
- async recoverIdentity({ recoveryCode }) {
7471
+ async requestRecoveryChallenge() {
7461
7472
  invariant19(this._edgeClient, "Not connected to EDGE.", {
7462
7473
  F: __dxlog_file27,
7463
7474
  L: 66,
@@ -7467,6 +7478,67 @@ var EdgeIdentityRecoveryManager = class {
7467
7478
  "'Not connected to EDGE.'"
7468
7479
  ]
7469
7480
  });
7481
+ const deviceKey = await this._keyring.createKey();
7482
+ const controlFeedKey = await this._keyring.createKey();
7483
+ const request = {
7484
+ deviceKey: deviceKey.toHex(),
7485
+ controlFeedKey: controlFeedKey.toHex()
7486
+ };
7487
+ try {
7488
+ await this._edgeClient.recoverIdentity(request);
7489
+ throw new Error("No challenge received.");
7490
+ } catch (error) {
7491
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7492
+ throw error;
7493
+ }
7494
+ return {
7495
+ deviceKey,
7496
+ controlFeedKey,
7497
+ challenge: error.challenge
7498
+ };
7499
+ }
7500
+ }
7501
+ async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7502
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7503
+ F: __dxlog_file27,
7504
+ L: 98,
7505
+ S: this,
7506
+ A: [
7507
+ "this._edgeClient",
7508
+ "'Not connected to EDGE.'"
7509
+ ]
7510
+ });
7511
+ const request = {
7512
+ identityDid,
7513
+ deviceKey: deviceKey.toHex(),
7514
+ controlFeedKey: controlFeedKey.toHex(),
7515
+ signature: clientDataJson && authenticatorData ? {
7516
+ signature: Buffer.from(signature).toString("base64"),
7517
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7518
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7519
+ } : Buffer.from(signature).toString("base64")
7520
+ };
7521
+ const response = await this._edgeClient.recoverIdentity(request);
7522
+ await this._acceptRecoveredIdentity({
7523
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7524
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7525
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7526
+ identityKey: PublicKey14.fromHex(response.identityKey),
7527
+ deviceKey,
7528
+ controlFeedKey,
7529
+ dataFeedKey: await this._keyring.createKey()
7530
+ });
7531
+ }
7532
+ async recoverIdentity({ recoveryCode }) {
7533
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7534
+ F: __dxlog_file27,
7535
+ L: 128,
7536
+ S: this,
7537
+ A: [
7538
+ "this._edgeClient",
7539
+ "'Not connected to EDGE.'"
7540
+ ]
7541
+ });
7470
7542
  const recoveryKeypair = keyPairFromSeedPhrase(recoveryCode);
7471
7543
  const recoveryKey = PublicKey14.from(recoveryKeypair.publicKey);
7472
7544
  const deviceKey = await this._keyring.createKey();
@@ -7491,7 +7563,7 @@ var EdgeIdentityRecoveryManager = class {
7491
7563
  }
7492
7564
  log23.info("recovering identity", response, {
7493
7565
  F: __dxlog_file27,
7494
- L: 92,
7566
+ L: 154,
7495
7567
  S: this,
7496
7568
  C: (f, a) => f(...a)
7497
7569
  });
@@ -9093,4 +9165,4 @@ export {
9093
9165
  importProfileData,
9094
9166
  ClientServicesHost
9095
9167
  };
9096
- //# sourceMappingURL=chunk-OHBCYJRF.mjs.map
9168
+ //# sourceMappingURL=chunk-DBNNIIDX.mjs.map