@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
@@ -6,7 +6,7 @@ import {
6
6
  InvitationsManager,
7
7
  ServiceContext,
8
8
  SpaceInvitationProtocol
9
- } from "../chunk-OHBCYJRF.mjs";
9
+ } from "../chunk-VWZJYGCJ.mjs";
10
10
 
11
11
  // packages/sdk/client-services/src/packlets/testing/credential-utils.ts
12
12
  import { createCredential } from "@dxos/credentials";
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_X3IYGB6Q_exports = {};
30
- __export(chunk_X3IYGB6Q_exports, {
29
+ var chunk_TVKZUCQN_exports = {};
30
+ __export(chunk_TVKZUCQN_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,7 +72,7 @@ __export(chunk_X3IYGB6Q_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_X3IYGB6Q_exports);
75
+ module.exports = __toCommonJS(chunk_TVKZUCQN_exports);
76
76
  var import_async = require("@dxos/async");
77
77
  var import_stream = require("@dxos/codec-protobuf/stream");
78
78
  var import_feed_store = require("@dxos/feed-store");
@@ -735,7 +735,7 @@ var DevtoolsServiceImpl = class {
735
735
  });
736
736
  }
737
737
  };
738
- var DXOS_VERSION = "0.7.5-labs.e27f9b9";
738
+ var DXOS_VERSION = "0.7.5-labs.f400bbc";
739
739
  var getPlatform = () => {
740
740
  if (process.browser) {
741
741
  if (typeof window !== "undefined") {
@@ -928,7 +928,7 @@ var findSystemServiceProvider = () => {
928
928
  };
929
929
  var findConfigs = () => {
930
930
  const configs = import_tracing2.TRACE_PROCESSOR.findResourcesByAnnotation(import_config.ConfigResource);
931
- return configs.map((r) => r.instance.deref()).filter(import_util2.nonNullable);
931
+ return configs.map((r) => r.instance.deref()).filter(import_util2.isNonNullable);
932
932
  };
933
933
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
934
934
  var Credential = import_proto.schema.getCodecForType("dxos.halo.credentials.Credential");
@@ -2666,7 +2666,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2666
2666
  });
2667
2667
  dataSpace.postOpen.append(async () => {
2668
2668
  const setting = dataSpace.getEdgeReplicationSetting();
2669
- if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2669
+ if (!setting || setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2670
2670
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2671
2671
  } else if (this._echoEdgeReplicator) {
2672
2672
  (0, import_log8.log)("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
@@ -2681,7 +2681,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2681
2681
  });
2682
2682
  dataSpace.preClose.append(async () => {
2683
2683
  const setting = dataSpace.getEdgeReplicationSetting();
2684
- if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2684
+ if (!setting || setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2685
2685
  await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2686
2686
  }
2687
2687
  });
@@ -3910,15 +3910,26 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3910
3910
  async createRecoveryCredential(request) {
3911
3911
  return this._recoveryManager.createRecoveryCredential(request);
3912
3912
  }
3913
+ async requestRecoveryChallenge() {
3914
+ return this._recoveryManager.requestRecoveryChallenge();
3915
+ }
3913
3916
  async recoverIdentity(request) {
3914
- await this._recoveryManager.recoverIdentity(request);
3917
+ if (request.recoveryCode) {
3918
+ await this._recoveryManager.recoverIdentity({
3919
+ recoveryCode: request.recoveryCode
3920
+ });
3921
+ } else if (request.external) {
3922
+ await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
3923
+ } else {
3924
+ throw new Error("Invalid request.");
3925
+ }
3915
3926
  return this._getIdentity();
3916
3927
  }
3917
3928
  // TODO(burdon): Rename createPresentation?
3918
3929
  async signPresentation({ presentation, nonce }) {
3919
3930
  (0, import_invariant10.invariant)(this._identityManager.identity, "Identity not initialized.", {
3920
3931
  F: __dxlog_file13,
3921
- L: 105,
3932
+ L: 116,
3922
3933
  S: this,
3923
3934
  A: [
3924
3935
  "this._identityManager.identity",
@@ -3937,7 +3948,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3937
3948
  const identity = this._identityManager.identity;
3938
3949
  (0, import_invariant10.invariant)(identity, "Identity not initialized.", {
3939
3950
  F: __dxlog_file13,
3940
- L: 119,
3951
+ L: 130,
3941
3952
  S: this,
3942
3953
  A: [
3943
3954
  "identity",
@@ -3975,7 +3986,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3975
3986
  duplicate: space.id
3976
3987
  }, {
3977
3988
  F: __dxlog_file13,
3978
- L: 153,
3989
+ L: 164,
3979
3990
  S: this,
3980
3991
  C: (f, a) => f(...a)
3981
3992
  });
@@ -3989,7 +4000,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3989
4000
  }, (err) => {
3990
4001
  import_log11.log.catch(err, void 0, {
3991
4002
  F: __dxlog_file13,
3992
- L: 164,
4003
+ L: 175,
3993
4004
  S: this,
3994
4005
  C: (f, a) => f(...a)
3995
4006
  });
@@ -7051,6 +7062,18 @@ var EdgeAgentManager = class extends import_context15.Resource {
7051
7062
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7052
7063
  });
7053
7064
  const deviceKey = import_keys15.PublicKey.fromHex(response.deviceKey);
7065
+ if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7066
+ import_log21.log.info("agent was already added to HALO, ignoring response", {
7067
+ response
7068
+ }, {
7069
+ F: __dxlog_file25,
7070
+ L: 67,
7071
+ S: this,
7072
+ C: (f, a) => f(...a)
7073
+ });
7074
+ this._updateStatus(import_protocols14.EdgeAgentStatus.ACTIVE, deviceKey);
7075
+ return;
7076
+ }
7054
7077
  await this._identity.admitDevice({
7055
7078
  deviceKey,
7056
7079
  controlFeedKey: import_keys15.PublicKey.fromHex(response.feedKey),
@@ -7059,7 +7082,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7059
7082
  });
7060
7083
  (0, import_log21.log)("agent created", response, {
7061
7084
  F: __dxlog_file25,
7062
- L: 73,
7085
+ L: 79,
7063
7086
  S: this,
7064
7087
  C: (f, a) => f(...a)
7065
7088
  });
@@ -7071,7 +7094,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7071
7094
  isEnabled
7072
7095
  }, {
7073
7096
  F: __dxlog_file25,
7074
- L: 81,
7097
+ L: 87,
7075
7098
  S: this,
7076
7099
  C: (f, a) => f(...a)
7077
7100
  });
@@ -7104,7 +7127,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7104
7127
  async _fetchAgentStatus() {
7105
7128
  (0, import_invariant20.invariant)(this._edgeHttpClient, void 0, {
7106
7129
  F: __dxlog_file25,
7107
- L: 115,
7130
+ L: 121,
7108
7131
  S: this,
7109
7132
  A: [
7110
7133
  "this._edgeHttpClient",
@@ -7114,7 +7137,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7114
7137
  try {
7115
7138
  (0, import_log21.log)("fetching agent status", void 0, {
7116
7139
  F: __dxlog_file25,
7117
- L: 117,
7140
+ L: 123,
7118
7141
  S: this,
7119
7142
  C: (f, a) => f(...a)
7120
7143
  });
@@ -7133,7 +7156,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7133
7156
  err
7134
7157
  }, {
7135
7158
  F: __dxlog_file25,
7136
- L: 127,
7159
+ L: 133,
7137
7160
  S: this,
7138
7161
  C: (f, a) => f(...a)
7139
7162
  });
@@ -7146,7 +7169,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7146
7169
  retryAfterMs
7147
7170
  }, {
7148
7171
  F: __dxlog_file25,
7149
- L: 132,
7172
+ L: 138,
7150
7173
  S: this,
7151
7174
  C: (f, a) => f(...a)
7152
7175
  });
@@ -7182,7 +7205,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7182
7205
  spaceId: space.id
7183
7206
  }, {
7184
7207
  F: __dxlog_file25,
7185
- L: 159,
7208
+ L: 165,
7186
7209
  S: this,
7187
7210
  C: (f, a) => f(...a)
7188
7211
  });
@@ -7202,7 +7225,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7202
7225
  status
7203
7226
  }, {
7204
7227
  F: __dxlog_file25,
7205
- L: 175,
7228
+ L: 181,
7206
7229
  S: this,
7207
7230
  C: (f, a) => f(...a)
7208
7231
  });
@@ -7275,7 +7298,7 @@ var EdgeIdentityRecoveryManager = class {
7275
7298
  this._identityProvider = _identityProvider;
7276
7299
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7277
7300
  }
7278
- async createRecoveryCredential({ recoveryKey, algorithm }) {
7301
+ async createRecoveryCredential({ recoveryKey, lookupKey, algorithm }) {
7279
7302
  const identity = this._identityProvider();
7280
7303
  (0, import_invariant22.invariant)(identity, void 0, {
7281
7304
  F: __dxlog_file26,
@@ -7287,15 +7310,16 @@ var EdgeIdentityRecoveryManager = class {
7287
7310
  ]
7288
7311
  });
7289
7312
  let recoveryCode;
7290
- if (!recoveryKey) {
7313
+ if (!recoveryKey || !lookupKey) {
7291
7314
  recoveryCode = (0, import_credentials23.generateSeedPhrase)();
7292
7315
  const keypair = (0, import_credentials23.keyPairFromSeedPhrase)(recoveryCode);
7293
7316
  recoveryKey = import_keys17.PublicKey.from(keypair.publicKey);
7294
- algorithm = -8;
7317
+ lookupKey = import_keys17.PublicKey.random();
7318
+ algorithm = "ED25519";
7295
7319
  }
7296
7320
  (0, import_invariant22.invariant)(algorithm, "Algorithm is required.", {
7297
7321
  F: __dxlog_file26,
7298
- L: 47,
7322
+ L: 48,
7299
7323
  S: this,
7300
7324
  A: [
7301
7325
  "algorithm",
@@ -7309,7 +7333,8 @@ var EdgeIdentityRecoveryManager = class {
7309
7333
  "@type": "dxos.halo.credentials.IdentityRecovery",
7310
7334
  recoveryKey,
7311
7335
  identityKey,
7312
- algorithm
7336
+ algorithm,
7337
+ lookupKey
7313
7338
  }
7314
7339
  });
7315
7340
  const receipt = await identity.controlPipeline.writer.write({
@@ -7327,10 +7352,71 @@ var EdgeIdentityRecoveryManager = class {
7327
7352
  recoveryCode
7328
7353
  };
7329
7354
  }
7355
+ async requestRecoveryChallenge() {
7356
+ (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7357
+ F: __dxlog_file26,
7358
+ L: 68,
7359
+ S: this,
7360
+ A: [
7361
+ "this._edgeClient",
7362
+ "'Not connected to EDGE.'"
7363
+ ]
7364
+ });
7365
+ const deviceKey = await this._keyring.createKey();
7366
+ const controlFeedKey = await this._keyring.createKey();
7367
+ const request = {
7368
+ deviceKey: deviceKey.toHex(),
7369
+ controlFeedKey: controlFeedKey.toHex()
7370
+ };
7371
+ try {
7372
+ await this._edgeClient.recoverIdentity(request);
7373
+ throw new Error("No challenge received.");
7374
+ } catch (error) {
7375
+ if (!(error instanceof import_protocols17.EdgeAuthChallengeError)) {
7376
+ throw error;
7377
+ }
7378
+ return {
7379
+ deviceKey,
7380
+ controlFeedKey,
7381
+ challenge: error.challenge
7382
+ };
7383
+ }
7384
+ }
7385
+ async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7386
+ (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7387
+ F: __dxlog_file26,
7388
+ L: 100,
7389
+ S: this,
7390
+ A: [
7391
+ "this._edgeClient",
7392
+ "'Not connected to EDGE.'"
7393
+ ]
7394
+ });
7395
+ const request = {
7396
+ lookupKey: lookupKey.toHex(),
7397
+ deviceKey: deviceKey.toHex(),
7398
+ controlFeedKey: controlFeedKey.toHex(),
7399
+ signature: clientDataJson && authenticatorData ? {
7400
+ signature: Buffer.from(signature).toString("base64"),
7401
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7402
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7403
+ } : Buffer.from(signature).toString("base64")
7404
+ };
7405
+ const response = await this._edgeClient.recoverIdentity(request);
7406
+ await this._acceptRecoveredIdentity({
7407
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7408
+ haloGenesisFeedKey: import_keys17.PublicKey.fromHex(response.genesisFeedKey),
7409
+ haloSpaceKey: import_keys17.PublicKey.fromHex(response.haloSpaceKey),
7410
+ identityKey: import_keys17.PublicKey.fromHex(response.identityKey),
7411
+ deviceKey,
7412
+ controlFeedKey,
7413
+ dataFeedKey: await this._keyring.createKey()
7414
+ });
7415
+ }
7330
7416
  async recoverIdentity({ recoveryCode }) {
7331
7417
  (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7332
7418
  F: __dxlog_file26,
7333
- L: 66,
7419
+ L: 130,
7334
7420
  S: this,
7335
7421
  A: [
7336
7422
  "this._edgeClient",
@@ -7342,7 +7428,7 @@ var EdgeIdentityRecoveryManager = class {
7342
7428
  const deviceKey = await this._keyring.createKey();
7343
7429
  const controlFeedKey = await this._keyring.createKey();
7344
7430
  const request = {
7345
- recoveryKey: recoveryKey.toHex(),
7431
+ lookupKey: recoveryKey.toHex(),
7346
7432
  deviceKey: deviceKey.toHex(),
7347
7433
  controlFeedKey: controlFeedKey.toHex()
7348
7434
  };
@@ -7361,7 +7447,7 @@ var EdgeIdentityRecoveryManager = class {
7361
7447
  }
7362
7448
  import_log23.log.info("recovering identity", response, {
7363
7449
  F: __dxlog_file26,
7364
- L: 92,
7450
+ L: 156,
7365
7451
  S: this,
7366
7452
  C: (f, a) => f(...a)
7367
7453
  });
@@ -8890,4 +8976,4 @@ ClientServicesHost = _ts_decorate11([
8890
8976
  subscribeToSpaces,
8891
8977
  subscribeToSwarmInfo
8892
8978
  });
8893
- //# sourceMappingURL=chunk-X3IYGB6Q.cjs.map
8979
+ //# sourceMappingURL=chunk-TVKZUCQN.cjs.map