@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
@@ -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_TVKZUCQN = require("../chunk-TVKZUCQN.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_TVKZUCQN.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_TVKZUCQN.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_TVKZUCQN.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_TVKZUCQN.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_TVKZUCQN.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_TVKZUCQN.InvitationsManager(new import_chunk_TVKZUCQN.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_TVKZUCQN.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.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";
@@ -571,7 +571,7 @@ import { ClientServicesProviderResource } from "@dxos/client-protocol";
571
571
  import { ConfigResource } from "@dxos/config";
572
572
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
573
573
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
574
- import { jsonKeyReplacer, nonNullable } from "@dxos/util";
574
+ import { jsonKeyReplacer, isNonNullable } from "@dxos/util";
575
575
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
576
576
  var DiagnosticsCollector = class {
577
577
  static {
@@ -604,7 +604,7 @@ var findSystemServiceProvider = () => {
604
604
  };
605
605
  var findConfigs = () => {
606
606
  const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
607
- return configs.map((r) => r.instance.deref()).filter(nonNullable);
607
+ return configs.map((r) => r.instance.deref()).filter(isNonNullable);
608
608
  };
609
609
 
610
610
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
@@ -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
  });
@@ -7262,7 +7285,7 @@ var EdgeIdentityRecoveryManager = class {
7262
7285
  this._identityProvider = _identityProvider;
7263
7286
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7264
7287
  }
7265
- async createRecoveryCredential({ recoveryKey, algorithm }) {
7288
+ async createRecoveryCredential({ recoveryKey, lookupKey, algorithm }) {
7266
7289
  const identity = this._identityProvider();
7267
7290
  invariant20(identity, void 0, {
7268
7291
  F: __dxlog_file26,
@@ -7274,15 +7297,16 @@ var EdgeIdentityRecoveryManager = class {
7274
7297
  ]
7275
7298
  });
7276
7299
  let recoveryCode;
7277
- if (!recoveryKey) {
7300
+ if (!recoveryKey || !lookupKey) {
7278
7301
  recoveryCode = generateSeedPhrase();
7279
7302
  const keypair = keyPairFromSeedPhrase(recoveryCode);
7280
7303
  recoveryKey = PublicKey14.from(keypair.publicKey);
7281
- algorithm = -8;
7304
+ lookupKey = PublicKey14.random();
7305
+ algorithm = "ED25519";
7282
7306
  }
7283
7307
  invariant20(algorithm, "Algorithm is required.", {
7284
7308
  F: __dxlog_file26,
7285
- L: 47,
7309
+ L: 48,
7286
7310
  S: this,
7287
7311
  A: [
7288
7312
  "algorithm",
@@ -7296,7 +7320,8 @@ var EdgeIdentityRecoveryManager = class {
7296
7320
  "@type": "dxos.halo.credentials.IdentityRecovery",
7297
7321
  recoveryKey,
7298
7322
  identityKey,
7299
- algorithm
7323
+ algorithm,
7324
+ lookupKey
7300
7325
  }
7301
7326
  });
7302
7327
  const receipt = await identity.controlPipeline.writer.write({
@@ -7314,10 +7339,71 @@ var EdgeIdentityRecoveryManager = class {
7314
7339
  recoveryCode
7315
7340
  };
7316
7341
  }
7342
+ async requestRecoveryChallenge() {
7343
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7344
+ F: __dxlog_file26,
7345
+ L: 68,
7346
+ S: this,
7347
+ A: [
7348
+ "this._edgeClient",
7349
+ "'Not connected to EDGE.'"
7350
+ ]
7351
+ });
7352
+ const deviceKey = await this._keyring.createKey();
7353
+ const controlFeedKey = await this._keyring.createKey();
7354
+ const request = {
7355
+ deviceKey: deviceKey.toHex(),
7356
+ controlFeedKey: controlFeedKey.toHex()
7357
+ };
7358
+ try {
7359
+ await this._edgeClient.recoverIdentity(request);
7360
+ throw new Error("No challenge received.");
7361
+ } catch (error) {
7362
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7363
+ throw error;
7364
+ }
7365
+ return {
7366
+ deviceKey,
7367
+ controlFeedKey,
7368
+ challenge: error.challenge
7369
+ };
7370
+ }
7371
+ }
7372
+ async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7373
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7374
+ F: __dxlog_file26,
7375
+ L: 100,
7376
+ S: this,
7377
+ A: [
7378
+ "this._edgeClient",
7379
+ "'Not connected to EDGE.'"
7380
+ ]
7381
+ });
7382
+ const request = {
7383
+ lookupKey: lookupKey.toHex(),
7384
+ deviceKey: deviceKey.toHex(),
7385
+ controlFeedKey: controlFeedKey.toHex(),
7386
+ signature: clientDataJson && authenticatorData ? {
7387
+ signature: Buffer.from(signature).toString("base64"),
7388
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7389
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7390
+ } : Buffer.from(signature).toString("base64")
7391
+ };
7392
+ const response = await this._edgeClient.recoverIdentity(request);
7393
+ await this._acceptRecoveredIdentity({
7394
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7395
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7396
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7397
+ identityKey: PublicKey14.fromHex(response.identityKey),
7398
+ deviceKey,
7399
+ controlFeedKey,
7400
+ dataFeedKey: await this._keyring.createKey()
7401
+ });
7402
+ }
7317
7403
  async recoverIdentity({ recoveryCode }) {
7318
7404
  invariant20(this._edgeClient, "Not connected to EDGE.", {
7319
7405
  F: __dxlog_file26,
7320
- L: 66,
7406
+ L: 130,
7321
7407
  S: this,
7322
7408
  A: [
7323
7409
  "this._edgeClient",
@@ -7329,7 +7415,7 @@ var EdgeIdentityRecoveryManager = class {
7329
7415
  const deviceKey = await this._keyring.createKey();
7330
7416
  const controlFeedKey = await this._keyring.createKey();
7331
7417
  const request = {
7332
- recoveryKey: recoveryKey.toHex(),
7418
+ lookupKey: recoveryKey.toHex(),
7333
7419
  deviceKey: deviceKey.toHex(),
7334
7420
  controlFeedKey: controlFeedKey.toHex()
7335
7421
  };
@@ -7348,7 +7434,7 @@ var EdgeIdentityRecoveryManager = class {
7348
7434
  }
7349
7435
  log22.info("recovering identity", response, {
7350
7436
  F: __dxlog_file26,
7351
- L: 92,
7437
+ L: 156,
7352
7438
  S: this,
7353
7439
  C: (f, a) => f(...a)
7354
7440
  });
@@ -8950,4 +9036,4 @@ export {
8950
9036
  importProfileData,
8951
9037
  ClientServicesHost
8952
9038
  };
8953
- //# sourceMappingURL=chunk-U5S4G236.mjs.map
9039
+ //# sourceMappingURL=chunk-OEO5PHCK.mjs.map