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

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-OHBCYJRF.mjs → chunk-VWZJYGCJ.mjs} +113 -27
  2. package/dist/lib/browser/chunk-VWZJYGCJ.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-TVKZUCQN.cjs} +115 -29
  7. package/dist/lib/node/chunk-TVKZUCQN.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-OEO5PHCK.mjs} +113 -27
  12. package/dist/lib/node-esm/chunk-OEO5PHCK.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/diagnostics/diagnostics-collector.d.ts.map +1 -1
  18. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +11 -2
  19. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  20. package/dist/types/src/packlets/identity/identity-service.d.ts +5 -0
  21. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  22. package/dist/types/src/packlets/services/service-host.d.ts +1 -1
  23. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  24. package/dist/types/src/version.d.ts +1 -1
  25. package/package.json +39 -38
  26. package/src/packlets/agents/edge-agent-manager.ts +6 -0
  27. package/src/packlets/diagnostics/diagnostics-collector.ts +2 -2
  28. package/src/packlets/identity/identity-recovery-manager.ts +69 -5
  29. package/src/packlets/identity/identity-service.ts +12 -1
  30. package/src/packlets/spaces/data-space-manager.ts +2 -2
  31. package/src/packlets/spaces/data-space.ts +2 -2
  32. package/src/version.ts +1 -1
  33. package/dist/lib/browser/chunk-OHBCYJRF.mjs.map +0 -7
  34. package/dist/lib/node/chunk-X3IYGB6Q.cjs.map +0 -7
  35. package/dist/lib/node-esm/chunk-U5S4G236.mjs.map +0 -7
@@ -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.f400bbc";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -649,7 +649,7 @@ import { ClientServicesProviderResource } from "@dxos/client-protocol";
649
649
  import { ConfigResource } from "@dxos/config";
650
650
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
651
651
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
652
- import { jsonKeyReplacer, nonNullable } from "@dxos/util";
652
+ import { jsonKeyReplacer, isNonNullable } from "@dxos/util";
653
653
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
654
654
  var DiagnosticsCollector = class {
655
655
  static {
@@ -682,7 +682,7 @@ var findSystemServiceProvider = () => {
682
682
  };
683
683
  var findConfigs = () => {
684
684
  const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
685
- return configs.map((r) => r.instance.deref()).filter(nonNullable);
685
+ return configs.map((r) => r.instance.deref()).filter(isNonNullable);
686
686
  };
687
687
 
688
688
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
@@ -2530,7 +2530,7 @@ var DataSpaceManager = class extends Resource4 {
2530
2530
  });
2531
2531
  dataSpace.postOpen.append(async () => {
2532
2532
  const setting = dataSpace.getEdgeReplicationSetting();
2533
- if (setting === EdgeReplicationSetting.ENABLED) {
2533
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2534
2534
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2535
2535
  } else if (this._echoEdgeReplicator) {
2536
2536
  log7("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
@@ -2545,7 +2545,7 @@ var DataSpaceManager = class extends Resource4 {
2545
2545
  });
2546
2546
  dataSpace.preClose.append(async () => {
2547
2547
  const setting = dataSpace.getEdgeReplicationSetting();
2548
- if (setting === EdgeReplicationSetting.ENABLED) {
2548
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2549
2549
  await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2550
2550
  }
2551
2551
  });
@@ -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
  });
@@ -7148,6 +7159,18 @@ var EdgeAgentManager = class extends Resource6 {
7148
7159
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7149
7160
  });
7150
7161
  const deviceKey = PublicKey13.fromHex(response.deviceKey);
7162
+ if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7163
+ log22.info("agent was already added to HALO, ignoring response", {
7164
+ response
7165
+ }, {
7166
+ F: __dxlog_file26,
7167
+ L: 67,
7168
+ S: this,
7169
+ C: (f, a) => f(...a)
7170
+ });
7171
+ this._updateStatus(EdgeAgentStatus.ACTIVE, deviceKey);
7172
+ return;
7173
+ }
7151
7174
  await this._identity.admitDevice({
7152
7175
  deviceKey,
7153
7176
  controlFeedKey: PublicKey13.fromHex(response.feedKey),
@@ -7156,7 +7179,7 @@ var EdgeAgentManager = class extends Resource6 {
7156
7179
  });
7157
7180
  log22("agent created", response, {
7158
7181
  F: __dxlog_file26,
7159
- L: 73,
7182
+ L: 79,
7160
7183
  S: this,
7161
7184
  C: (f, a) => f(...a)
7162
7185
  });
@@ -7168,7 +7191,7 @@ var EdgeAgentManager = class extends Resource6 {
7168
7191
  isEnabled
7169
7192
  }, {
7170
7193
  F: __dxlog_file26,
7171
- L: 81,
7194
+ L: 87,
7172
7195
  S: this,
7173
7196
  C: (f, a) => f(...a)
7174
7197
  });
@@ -7201,7 +7224,7 @@ var EdgeAgentManager = class extends Resource6 {
7201
7224
  async _fetchAgentStatus() {
7202
7225
  invariant18(this._edgeHttpClient, void 0, {
7203
7226
  F: __dxlog_file26,
7204
- L: 115,
7227
+ L: 121,
7205
7228
  S: this,
7206
7229
  A: [
7207
7230
  "this._edgeHttpClient",
@@ -7211,7 +7234,7 @@ var EdgeAgentManager = class extends Resource6 {
7211
7234
  try {
7212
7235
  log22("fetching agent status", void 0, {
7213
7236
  F: __dxlog_file26,
7214
- L: 117,
7237
+ L: 123,
7215
7238
  S: this,
7216
7239
  C: (f, a) => f(...a)
7217
7240
  });
@@ -7230,7 +7253,7 @@ var EdgeAgentManager = class extends Resource6 {
7230
7253
  err
7231
7254
  }, {
7232
7255
  F: __dxlog_file26,
7233
- L: 127,
7256
+ L: 133,
7234
7257
  S: this,
7235
7258
  C: (f, a) => f(...a)
7236
7259
  });
@@ -7243,7 +7266,7 @@ var EdgeAgentManager = class extends Resource6 {
7243
7266
  retryAfterMs
7244
7267
  }, {
7245
7268
  F: __dxlog_file26,
7246
- L: 132,
7269
+ L: 138,
7247
7270
  S: this,
7248
7271
  C: (f, a) => f(...a)
7249
7272
  });
@@ -7279,7 +7302,7 @@ var EdgeAgentManager = class extends Resource6 {
7279
7302
  spaceId: space.id
7280
7303
  }, {
7281
7304
  F: __dxlog_file26,
7282
- L: 159,
7305
+ L: 165,
7283
7306
  S: this,
7284
7307
  C: (f, a) => f(...a)
7285
7308
  });
@@ -7299,7 +7322,7 @@ var EdgeAgentManager = class extends Resource6 {
7299
7322
  status
7300
7323
  }, {
7301
7324
  F: __dxlog_file26,
7302
- L: 175,
7325
+ L: 181,
7303
7326
  S: this,
7304
7327
  C: (f, a) => f(...a)
7305
7328
  });
@@ -7405,7 +7428,7 @@ var EdgeIdentityRecoveryManager = class {
7405
7428
  this._identityProvider = _identityProvider;
7406
7429
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7407
7430
  }
7408
- async createRecoveryCredential({ recoveryKey, algorithm }) {
7431
+ async createRecoveryCredential({ recoveryKey, lookupKey, algorithm }) {
7409
7432
  const identity = this._identityProvider();
7410
7433
  invariant19(identity, void 0, {
7411
7434
  F: __dxlog_file27,
@@ -7417,15 +7440,16 @@ var EdgeIdentityRecoveryManager = class {
7417
7440
  ]
7418
7441
  });
7419
7442
  let recoveryCode;
7420
- if (!recoveryKey) {
7443
+ if (!recoveryKey || !lookupKey) {
7421
7444
  recoveryCode = generateSeedPhrase();
7422
7445
  const keypair = keyPairFromSeedPhrase(recoveryCode);
7423
7446
  recoveryKey = PublicKey14.from(keypair.publicKey);
7424
- algorithm = -8;
7447
+ lookupKey = PublicKey14.random();
7448
+ algorithm = "ED25519";
7425
7449
  }
7426
7450
  invariant19(algorithm, "Algorithm is required.", {
7427
7451
  F: __dxlog_file27,
7428
- L: 47,
7452
+ L: 48,
7429
7453
  S: this,
7430
7454
  A: [
7431
7455
  "algorithm",
@@ -7439,7 +7463,8 @@ var EdgeIdentityRecoveryManager = class {
7439
7463
  "@type": "dxos.halo.credentials.IdentityRecovery",
7440
7464
  recoveryKey,
7441
7465
  identityKey,
7442
- algorithm
7466
+ algorithm,
7467
+ lookupKey
7443
7468
  }
7444
7469
  });
7445
7470
  const receipt = await identity.controlPipeline.writer.write({
@@ -7457,10 +7482,71 @@ var EdgeIdentityRecoveryManager = class {
7457
7482
  recoveryCode
7458
7483
  };
7459
7484
  }
7485
+ async requestRecoveryChallenge() {
7486
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7487
+ F: __dxlog_file27,
7488
+ L: 68,
7489
+ S: this,
7490
+ A: [
7491
+ "this._edgeClient",
7492
+ "'Not connected to EDGE.'"
7493
+ ]
7494
+ });
7495
+ const deviceKey = await this._keyring.createKey();
7496
+ const controlFeedKey = await this._keyring.createKey();
7497
+ const request = {
7498
+ deviceKey: deviceKey.toHex(),
7499
+ controlFeedKey: controlFeedKey.toHex()
7500
+ };
7501
+ try {
7502
+ await this._edgeClient.recoverIdentity(request);
7503
+ throw new Error("No challenge received.");
7504
+ } catch (error) {
7505
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7506
+ throw error;
7507
+ }
7508
+ return {
7509
+ deviceKey,
7510
+ controlFeedKey,
7511
+ challenge: error.challenge
7512
+ };
7513
+ }
7514
+ }
7515
+ async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7516
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7517
+ F: __dxlog_file27,
7518
+ L: 100,
7519
+ S: this,
7520
+ A: [
7521
+ "this._edgeClient",
7522
+ "'Not connected to EDGE.'"
7523
+ ]
7524
+ });
7525
+ const request = {
7526
+ lookupKey: lookupKey.toHex(),
7527
+ deviceKey: deviceKey.toHex(),
7528
+ controlFeedKey: controlFeedKey.toHex(),
7529
+ signature: clientDataJson && authenticatorData ? {
7530
+ signature: Buffer.from(signature).toString("base64"),
7531
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7532
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7533
+ } : Buffer.from(signature).toString("base64")
7534
+ };
7535
+ const response = await this._edgeClient.recoverIdentity(request);
7536
+ await this._acceptRecoveredIdentity({
7537
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7538
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7539
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7540
+ identityKey: PublicKey14.fromHex(response.identityKey),
7541
+ deviceKey,
7542
+ controlFeedKey,
7543
+ dataFeedKey: await this._keyring.createKey()
7544
+ });
7545
+ }
7460
7546
  async recoverIdentity({ recoveryCode }) {
7461
7547
  invariant19(this._edgeClient, "Not connected to EDGE.", {
7462
7548
  F: __dxlog_file27,
7463
- L: 66,
7549
+ L: 130,
7464
7550
  S: this,
7465
7551
  A: [
7466
7552
  "this._edgeClient",
@@ -7472,7 +7558,7 @@ var EdgeIdentityRecoveryManager = class {
7472
7558
  const deviceKey = await this._keyring.createKey();
7473
7559
  const controlFeedKey = await this._keyring.createKey();
7474
7560
  const request = {
7475
- recoveryKey: recoveryKey.toHex(),
7561
+ lookupKey: recoveryKey.toHex(),
7476
7562
  deviceKey: deviceKey.toHex(),
7477
7563
  controlFeedKey: controlFeedKey.toHex()
7478
7564
  };
@@ -7491,7 +7577,7 @@ var EdgeIdentityRecoveryManager = class {
7491
7577
  }
7492
7578
  log23.info("recovering identity", response, {
7493
7579
  F: __dxlog_file27,
7494
- L: 92,
7580
+ L: 156,
7495
7581
  S: this,
7496
7582
  C: (f, a) => f(...a)
7497
7583
  });
@@ -9093,4 +9179,4 @@ export {
9093
9179
  importProfileData,
9094
9180
  ClientServicesHost
9095
9181
  };
9096
- //# sourceMappingURL=chunk-OHBCYJRF.mjs.map
9182
+ //# sourceMappingURL=chunk-VWZJYGCJ.mjs.map