@dxos/client-services 0.7.5-main.2567c87 → 0.7.5-main.5ae2ba8

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 (95) hide show
  1. package/dist/lib/browser/{chunk-443F7E4C.mjs → chunk-C6HAFZX6.mjs} +276 -195
  2. package/dist/lib/browser/chunk-C6HAFZX6.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-LKVY5GQC.cjs → chunk-F7R4IRLD.cjs} +303 -222
  7. package/dist/lib/node/chunk-F7R4IRLD.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-RZEXZLYL.mjs → chunk-EBNDRSDP.mjs} +276 -195
  12. package/dist/lib/node-esm/chunk-EBNDRSDP.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/agents/edge-agent-service.d.ts +1 -1
  18. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  19. package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
  20. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
  22. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  23. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  24. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  25. package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
  26. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  27. package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
  28. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  30. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  31. package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
  32. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  33. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
  34. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  36. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  37. package/dist/types/src/packlets/identity/identity-manager.d.ts +0 -3
  38. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  39. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +12 -4
  40. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  41. package/dist/types/src/packlets/identity/identity-service.d.ts +9 -4
  42. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  43. package/dist/types/src/packlets/identity/identity.d.ts +3 -1
  44. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  47. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  48. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
  50. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  51. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  52. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  53. package/dist/types/src/packlets/network/network-service.d.ts +1 -1
  54. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  55. package/dist/types/src/packlets/services/service-host.d.ts +1 -1
  56. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  57. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  58. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  59. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  60. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  61. package/dist/types/src/version.d.ts +1 -1
  62. package/package.json +39 -38
  63. package/src/packlets/agents/edge-agent-manager.ts +6 -0
  64. package/src/packlets/agents/edge-agent-service.ts +1 -1
  65. package/src/packlets/devices/devices-service.ts +1 -1
  66. package/src/packlets/devtools/devtools.ts +1 -1
  67. package/src/packlets/devtools/feeds.ts +1 -1
  68. package/src/packlets/devtools/keys.ts +1 -1
  69. package/src/packlets/devtools/metadata.ts +1 -1
  70. package/src/packlets/devtools/network.ts +1 -1
  71. package/src/packlets/devtools/spaces.ts +1 -1
  72. package/src/packlets/diagnostics/diagnostics-collector.ts +2 -2
  73. package/src/packlets/diagnostics/diagnostics.ts +17 -13
  74. package/src/packlets/identity/contacts-service.ts +1 -1
  75. package/src/packlets/identity/identity-manager.ts +3 -29
  76. package/src/packlets/identity/identity-recovery-manager.ts +86 -9
  77. package/src/packlets/identity/identity-service.ts +17 -4
  78. package/src/packlets/identity/identity.test.ts +2 -1
  79. package/src/packlets/identity/identity.ts +4 -1
  80. package/src/packlets/invitations/invitations-handler.ts +15 -6
  81. package/src/packlets/invitations/invitations-manager.ts +1 -1
  82. package/src/packlets/invitations/invitations-service.ts +1 -1
  83. package/src/packlets/invitations/space-invitation-protocol.ts +2 -3
  84. package/src/packlets/invitations/utils.ts +7 -0
  85. package/src/packlets/logging/logging-service.ts +1 -1
  86. package/src/packlets/network/network-service.ts +1 -1
  87. package/src/packlets/spaces/data-space-manager.ts +3 -3
  88. package/src/packlets/spaces/data-space.ts +2 -2
  89. package/src/packlets/spaces/edge-feed-replicator.ts +8 -8
  90. package/src/packlets/spaces/spaces-service.ts +31 -21
  91. package/src/packlets/system/system-service.ts +1 -1
  92. package/src/version.ts +1 -1
  93. package/dist/lib/browser/chunk-443F7E4C.mjs.map +0 -7
  94. package/dist/lib/node/chunk-LKVY5GQC.cjs.map +0 -7
  95. package/dist/lib/node-esm/chunk-RZEXZLYL.mjs.map +0 -7
@@ -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_LKVY5GQC_exports = {};
30
- __export(chunk_LKVY5GQC_exports, {
29
+ var chunk_F7R4IRLD_exports = {};
30
+ __export(chunk_F7R4IRLD_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,24 +72,24 @@ __export(chunk_LKVY5GQC_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_LKVY5GQC_exports);
75
+ module.exports = __toCommonJS(chunk_F7R4IRLD_exports);
76
76
  var import_async = require("@dxos/async");
77
- var import_codec_protobuf = require("@dxos/codec-protobuf");
77
+ var import_stream = require("@dxos/codec-protobuf/stream");
78
78
  var import_feed_store = require("@dxos/feed-store");
79
79
  var import_keys = require("@dxos/keys");
80
80
  var import_log = require("@dxos/log");
81
81
  var import_util = require("@dxos/util");
82
- var import_codec_protobuf2 = require("@dxos/codec-protobuf");
82
+ var import_stream2 = require("@dxos/codec-protobuf/stream");
83
83
  var import_context = require("@dxos/context");
84
84
  var import_keys2 = require("@dxos/keys");
85
- var import_codec_protobuf3 = require("@dxos/codec-protobuf");
85
+ var import_stream3 = require("@dxos/codec-protobuf/stream");
86
86
  var import_async2 = require("@dxos/async");
87
- var import_codec_protobuf4 = require("@dxos/codec-protobuf");
87
+ var import_stream4 = require("@dxos/codec-protobuf/stream");
88
88
  var import_async3 = require("@dxos/async");
89
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
90
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
89
+ var import_stream5 = require("@dxos/codec-protobuf/stream");
90
+ var import_stream6 = require("@dxos/codec-protobuf/stream");
91
91
  var import_async4 = require("@dxos/async");
92
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
92
+ var import_codec_protobuf = require("@dxos/codec-protobuf");
93
93
  var import_credentials = require("@dxos/credentials");
94
94
  var import_invariant = require("@dxos/invariant");
95
95
  var import_protocols = require("@dxos/protocols");
@@ -184,7 +184,7 @@ var import_debug2 = require("@dxos/debug");
184
184
  var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
185
185
  var import_timeframe3 = require("@dxos/timeframe");
186
186
  var import_async12 = require("@dxos/async");
187
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
187
+ var import_stream7 = require("@dxos/codec-protobuf/stream");
188
188
  var import_credentials13 = require("@dxos/credentials");
189
189
  var import_debug3 = require("@dxos/debug");
190
190
  var import_feed_store4 = require("@dxos/feed-store");
@@ -208,7 +208,7 @@ var import_timeframe4 = require("@dxos/timeframe");
208
208
  var import_tracing7 = require("@dxos/tracing");
209
209
  var import_util8 = require("@dxos/util");
210
210
  var import_async14 = require("@dxos/async");
211
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
211
+ var import_stream8 = require("@dxos/codec-protobuf/stream");
212
212
  var import_context9 = require("@dxos/context");
213
213
  var import_credentials16 = require("@dxos/credentials");
214
214
  var import_invariant10 = require("@dxos/invariant");
@@ -270,7 +270,7 @@ var import_keys13 = require("@dxos/keys");
270
270
  var import_log17 = require("@dxos/log");
271
271
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
272
272
  var import_util11 = require("@dxos/util");
273
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
273
+ var import_stream9 = require("@dxos/codec-protobuf/stream");
274
274
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
275
275
  var import_tracing9 = require("@dxos/tracing");
276
276
  var import_credentials18 = require("@dxos/credentials");
@@ -293,7 +293,7 @@ var import_credentials21 = require("@dxos/protocols/proto/dxos/halo/credentials"
293
293
  var import_invariant19 = require("@dxos/invariant");
294
294
  var import_lock_file = require("@dxos/lock-file");
295
295
  var import_log20 = require("@dxos/log");
296
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
296
+ var import_codec_protobuf2 = require("@dxos/codec-protobuf");
297
297
  var import_debug4 = require("@dxos/debug");
298
298
  var import_rpc = require("@dxos/rpc");
299
299
  var import_tracing10 = require("@dxos/tracing");
@@ -305,7 +305,7 @@ var import_log21 = require("@dxos/log");
305
305
  var import_protocols14 = require("@dxos/protocols");
306
306
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
307
307
  var import_metadata2 = require("@dxos/protocols/proto/dxos/echo/metadata");
308
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
308
+ var import_stream10 = require("@dxos/codec-protobuf/stream");
309
309
  var import_protocols15 = require("@dxos/protocols");
310
310
  var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
311
311
  var import_async22 = require("@dxos/async");
@@ -360,26 +360,26 @@ var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
360
360
  var import_tracing12 = require("@dxos/tracing");
361
361
  var import_websocket_rpc = require("@dxos/websocket-rpc");
362
362
  var import_async24 = require("@dxos/async");
363
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
363
+ var import_stream11 = require("@dxos/codec-protobuf/stream");
364
364
  var import_invariant25 = require("@dxos/invariant");
365
365
  var import_services23 = require("@dxos/protocols/proto/dxos/client/services");
366
366
  var import_async25 = require("@dxos/async");
367
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
367
+ var import_stream12 = require("@dxos/codec-protobuf/stream");
368
368
  var import_keys20 = require("@dxos/keys");
369
369
  var import_util15 = require("@dxos/util");
370
370
  var import_async26 = require("@dxos/async");
371
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
371
+ var import_stream13 = require("@dxos/codec-protobuf/stream");
372
372
  var import_keys21 = require("@dxos/keys");
373
373
  var import_log26 = require("@dxos/log");
374
374
  var import_services24 = require("@dxos/protocols/proto/dxos/client/services");
375
375
  var import_util16 = require("@dxos/util");
376
- var import_codec_protobuf16 = require("@dxos/codec-protobuf");
377
- var import_codec_protobuf17 = require("@dxos/codec-protobuf");
376
+ var import_stream14 = require("@dxos/codec-protobuf/stream");
377
+ var import_stream15 = require("@dxos/codec-protobuf/stream");
378
378
  var import_services25 = require("@dxos/protocols/proto/dxos/client/services");
379
379
  var import_util17 = require("@dxos/util");
380
380
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/feeds.ts";
381
381
  var subscribeToFeeds = ({ feedStore, spaceManager }, { feedKeys }) => {
382
- return new import_codec_protobuf.Stream(({ next }) => {
382
+ return new import_stream.Stream(({ next }) => {
383
383
  const subscriptions = new import_async.EventSubscriptions();
384
384
  const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
385
385
  const update = () => {
@@ -438,7 +438,7 @@ var findFeedOwner = (spaceManager, feedKey) => {
438
438
  };
439
439
  };
440
440
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
441
- return new import_codec_protobuf.Stream(({ next }) => {
441
+ return new import_stream.Stream(({ next }) => {
442
442
  if (!feedKey) {
443
443
  return;
444
444
  }
@@ -482,7 +482,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
482
482
  });
483
483
  };
484
484
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
485
- var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
485
+ var subscribeToNetworkStatus = ({ signalManager }) => new import_stream2.Stream(({ next, close }) => {
486
486
  const update = () => {
487
487
  try {
488
488
  const status = signalManager.getStatus?.();
@@ -496,7 +496,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
496
496
  signalManager.statusChanged?.on(() => update());
497
497
  update();
498
498
  });
499
- var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
499
+ var subscribeToSignal = ({ signalManager }) => new import_stream2.Stream(({ next }) => {
500
500
  const ctx = new import_context.Context(void 0, {
501
501
  F: __dxlog_file2,
502
502
  L: 36
@@ -531,7 +531,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream
531
531
  return ctx.dispose();
532
532
  };
533
533
  });
534
- var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
534
+ var subscribeToNetworkTopics = ({ networkManager }) => new import_stream2.Stream(({ next, close }) => {
535
535
  const update = () => {
536
536
  try {
537
537
  const topics = networkManager.topics;
@@ -549,7 +549,7 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
549
549
  networkManager.topicsUpdated.on(update);
550
550
  update();
551
551
  });
552
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf2.Stream(({ next }) => {
552
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_stream2.Stream(({ next }) => {
553
553
  const update = () => {
554
554
  const info = networkManager.connectionLog?.swarms;
555
555
  if (info) {
@@ -574,7 +574,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
574
574
  };
575
575
  };
576
576
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
577
- return new import_codec_protobuf3.Stream(({ next }) => {
577
+ return new import_stream3.Stream(({ next }) => {
578
578
  let unsubscribe;
579
579
  const update = async () => {
580
580
  const spaces = [
@@ -606,7 +606,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
606
606
  };
607
607
  });
608
608
  };
609
- var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf5.Stream(({ next, ctx }) => {
609
+ var subscribeToKeyringKeys = ({ keyring }) => new import_stream5.Stream(({ next, ctx }) => {
610
610
  const update = async () => {
611
611
  next({
612
612
  keys: await keyring.list()
@@ -615,7 +615,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf5.Stream(
615
615
  keyring.keysUpdate.on(ctx, update);
616
616
  (0, import_async3.scheduleTask)(ctx, update);
617
617
  });
618
- var subscribeToMetadata = ({ context }) => new import_codec_protobuf6.Stream(({ next, ctx }) => {
618
+ var subscribeToMetadata = ({ context }) => new import_stream6.Stream(({ next, ctx }) => {
619
619
  context.metadataStore.update.on(ctx, (data) => next({
620
620
  metadata: data
621
621
  }));
@@ -633,7 +633,7 @@ var DevtoolsServiceImpl = class {
633
633
  this.params = params;
634
634
  }
635
635
  events(request) {
636
- return new import_codec_protobuf4.Stream(({ next }) => {
636
+ return new import_stream4.Stream(({ next }) => {
637
637
  this.params.events.ready.on(() => {
638
638
  next({
639
639
  ready: {}
@@ -735,7 +735,7 @@ var DevtoolsServiceImpl = class {
735
735
  });
736
736
  }
737
737
  };
738
- var DXOS_VERSION = "0.7.5-main.2567c87";
738
+ var DXOS_VERSION = "0.7.5-main.5ae2ba8";
739
739
  var getPlatform = () => {
740
740
  if (process.browser) {
741
741
  if (typeof window !== "undefined") {
@@ -788,7 +788,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
788
788
  "'SystemService is not available.'"
789
789
  ]
790
790
  });
791
- diagnostics.metrics = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
791
+ diagnostics.metrics = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
792
792
  timeout: DEFAULT_TIMEOUT
793
793
  }).catch(() => void 0);
794
794
  })(),
@@ -799,18 +799,19 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
799
799
  const identity = serviceContext.identityManager.identity;
800
800
  if (identity) {
801
801
  diagnostics.identity = {
802
+ did: identity.did,
802
803
  identityKey: identity.identityKey,
803
804
  spaceKey: identity.space.key,
804
805
  profile: identity.profileDocument
805
806
  };
806
- const { devices } = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
807
+ const { devices } = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
807
808
  timeout: DEFAULT_TIMEOUT
808
809
  }).catch(() => void 0) ?? {};
809
810
  diagnostics.devices = devices;
810
811
  if (serviceContext.dataSpaceManager) {
811
812
  diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
812
813
  }
813
- const { feeds = [] } = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
814
+ const { feeds = [] } = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
814
815
  timeout: DEFAULT_TIMEOUT
815
816
  }).catch(() => void 0) ?? {};
816
817
  diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
@@ -818,7 +819,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
818
819
  bytes,
819
820
  length
820
821
  }));
821
- const status = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
822
+ const status = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
822
823
  timeout: DEFAULT_TIMEOUT
823
824
  }).catch(() => void 0);
824
825
  diagnostics.networkStatus = status;
@@ -837,16 +838,17 @@ var getSpaceStats = async (space) => {
837
838
  ...credential.subject.assertion,
838
839
  id: credential.id
839
840
  })),
840
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
841
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => ({
841
842
  role: member.role,
842
843
  identity: {
844
+ did: await (0, import_credentials.createDidFromIdentityKey)(member.key),
843
845
  identityKey: member.key,
844
846
  profile: {
845
847
  displayName: member.assertion.profile?.displayName
846
848
  }
847
849
  },
848
850
  presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
849
- })),
851
+ }))),
850
852
  pipeline: {
851
853
  // TODO(burdon): Pick properties from credentials if needed.
852
854
  currentEpoch: space.automergeSpaceState.lastEpoch,
@@ -926,7 +928,7 @@ var findSystemServiceProvider = () => {
926
928
  };
927
929
  var findConfigs = () => {
928
930
  const configs = import_tracing2.TRACE_PROCESSOR.findResourcesByAnnotation(import_config.ConfigResource);
929
- return configs.map((r) => r.instance.deref()).filter(import_util2.nonNullable);
931
+ return configs.map((r) => r.instance.deref()).filter(import_util2.isNonNullable);
930
932
  };
931
933
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
932
934
  var Credential = import_proto.schema.getCodecForType("dxos.halo.credentials.Credential");
@@ -1211,7 +1213,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1211
1213
  this._remoteLength.clear();
1212
1214
  }
1213
1215
  async addFeed(feed) {
1214
- import_log3.log.info("addFeed", {
1216
+ (0, import_log3.log)("addFeed", {
1215
1217
  key: feed.key,
1216
1218
  connected: this._connected,
1217
1219
  hasConnectionCtx: !!this._connectionCtx
@@ -1248,7 +1250,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1248
1250
  }
1249
1251
  async _sendMessage(message) {
1250
1252
  if (!this._connectionCtx) {
1251
- import_log3.log.info("message dropped because connection was disposed", void 0, {
1253
+ (0, import_log3.log)("message dropped because connection was disposed", void 0, {
1252
1254
  F: __dxlog_file5,
1253
1255
  L: 146,
1254
1256
  S: this,
@@ -1257,7 +1259,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1257
1259
  return;
1258
1260
  }
1259
1261
  if (message.type === "data") {
1260
- import_log3.log.info("sending blocks", {
1262
+ (0, import_log3.log)("sending blocks", {
1261
1263
  feedKey: message.feedKey,
1262
1264
  blocks: message.blocks.map((b) => b.index)
1263
1265
  }, {
@@ -1332,7 +1334,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1332
1334
  feedKey
1333
1335
  };
1334
1336
  if (message.length > feed.length) {
1335
- import_log3.log.info("requesting missing blocks", logMeta, {
1337
+ (0, import_log3.log)("requesting missing blocks", logMeta, {
1336
1338
  F: __dxlog_file5,
1337
1339
  L: 194,
1338
1340
  S: this,
@@ -1347,7 +1349,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1347
1349
  }
1348
1350
  });
1349
1351
  } else if (message.length < feed.length) {
1350
- import_log3.log.info("pushing blocks to remote", logMeta, {
1352
+ (0, import_log3.log)("pushing blocks to remote", logMeta, {
1351
1353
  F: __dxlog_file5,
1352
1354
  L: 202,
1353
1355
  S: this,
@@ -1363,7 +1365,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1363
1365
  }
1364
1366
  }
1365
1367
  case "data": {
1366
- import_log3.log.info("received data", {
1368
+ (0, import_log3.log)("received data", {
1367
1369
  feed: message.feedKey,
1368
1370
  blocks: message.blocks.map((b) => b.index)
1369
1371
  }, {
@@ -1402,7 +1404,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1402
1404
  });
1403
1405
  }
1404
1406
  async _pushBlocks(feed, from, to) {
1405
- import_log3.log.info("pushing blocks", {
1407
+ (0, import_log3.log)("pushing blocks", {
1406
1408
  feed: feed.key.toHex(),
1407
1409
  from,
1408
1410
  to
@@ -1441,7 +1443,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1441
1443
  this._remoteLength.set(feed.key, to);
1442
1444
  }
1443
1445
  async _integrateBlocks(feed, blocks) {
1444
- import_log3.log.info("integrating blocks", {
1446
+ (0, import_log3.log)("integrating blocks", {
1445
1447
  feed: feed.key.toHex(),
1446
1448
  blocks: blocks.length
1447
1449
  }, {
@@ -2664,7 +2666,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2664
2666
  });
2665
2667
  dataSpace.postOpen.append(async () => {
2666
2668
  const setting = dataSpace.getEdgeReplicationSetting();
2667
- if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2669
+ if (!setting || setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2668
2670
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2669
2671
  } else if (this._echoEdgeReplicator) {
2670
2672
  (0, import_log8.log)("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
@@ -2679,7 +2681,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2679
2681
  });
2680
2682
  dataSpace.preClose.append(async () => {
2681
2683
  const setting = dataSpace.getEdgeReplicationSetting();
2682
- if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2684
+ if (!setting || setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2683
2685
  await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2684
2686
  }
2685
2687
  });
@@ -2784,7 +2786,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2784
2786
  guestKeypair: invitation.guestKey ? {
2785
2787
  publicKey: invitation.guestKey
2786
2788
  } : void 0,
2787
- lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
2789
+ lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
2788
2790
  multiUse: invitation.multiUse,
2789
2791
  delegationCredentialId: credentialId,
2790
2792
  persistent: false
@@ -2856,7 +2858,7 @@ var SpacesServiceImpl = class {
2856
2858
  const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2857
2859
  (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2858
2860
  F: __dxlog_file10,
2859
- L: 106,
2861
+ L: 111,
2860
2862
  S: this,
2861
2863
  A: [
2862
2864
  "credentials[0].credential",
@@ -2866,7 +2868,7 @@ var SpacesServiceImpl = class {
2866
2868
  const spaceMemberCredential = credentials[0].credential.credential;
2867
2869
  (0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2868
2870
  F: __dxlog_file10,
2869
- L: 108,
2871
+ L: 113,
2870
2872
  S: this,
2871
2873
  A: [
2872
2874
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2876,15 +2878,15 @@ var SpacesServiceImpl = class {
2876
2878
  await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
2877
2879
  }
2878
2880
  querySpaces() {
2879
- return new import_codec_protobuf8.Stream(({ next, ctx }) => {
2881
+ return new import_stream7.Stream(({ next, ctx }) => {
2880
2882
  const scheduler = new import_async12.UpdateScheduler(ctx, async () => {
2881
2883
  const dataSpaceManager = await this._getDataSpaceManager();
2882
- const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2884
+ const spaces = await Promise.all(Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space)));
2883
2885
  (0, import_log9.log)("update", () => ({
2884
2886
  ids: spaces.map((space) => space.id)
2885
2887
  }), {
2886
2888
  F: __dxlog_file10,
2887
- L: 119,
2889
+ L: 126,
2888
2890
  S: this,
2889
2891
  C: (f, a) => f(...a)
2890
2892
  });
@@ -2936,7 +2938,7 @@ var SpacesServiceImpl = class {
2936
2938
  await space.postMessage(getChannelId(channel), message);
2937
2939
  }
2938
2940
  subscribeMessages({ spaceKey, channel }) {
2939
- return new import_codec_protobuf8.Stream(({ ctx, next }) => {
2941
+ return new import_stream7.Stream(({ ctx, next }) => {
2940
2942
  (0, import_async12.scheduleTask)(ctx, async () => {
2941
2943
  const dataSpaceManager = await this._getDataSpaceManager();
2942
2944
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
@@ -2948,7 +2950,7 @@ var SpacesServiceImpl = class {
2948
2950
  });
2949
2951
  }
2950
2952
  queryCredentials({ spaceKey, noTail }) {
2951
- return new import_codec_protobuf8.Stream(({ ctx, next, close }) => {
2953
+ return new import_stream7.Stream(({ ctx, next, close }) => {
2952
2954
  const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2953
2955
  const processor = {
2954
2956
  processCredential: async (credential) => {
@@ -2976,7 +2978,7 @@ var SpacesServiceImpl = class {
2976
2978
  } else {
2977
2979
  (0, import_invariant8.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
2978
2980
  F: __dxlog_file10,
2979
- L: 217,
2981
+ L: 224,
2980
2982
  S: this,
2981
2983
  A: [
2982
2984
  "!credential.id",
@@ -2985,7 +2987,7 @@ var SpacesServiceImpl = class {
2985
2987
  });
2986
2988
  (0, import_invariant8.invariant)(this._identityManager.identity, "Identity is not available", {
2987
2989
  F: __dxlog_file10,
2988
- L: 218,
2990
+ L: 225,
2989
2991
  S: this,
2990
2992
  A: [
2991
2993
  "this._identityManager.identity",
@@ -2995,7 +2997,7 @@ var SpacesServiceImpl = class {
2995
2997
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2996
2998
  (0, import_invariant8.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
2997
2999
  F: __dxlog_file10,
2998
- L: 220,
3000
+ L: 227,
2999
3001
  S: this,
3000
3002
  A: [
3001
3003
  "credential.issuer.equals(signer.getIssuer())",
@@ -3045,7 +3047,7 @@ var SpacesServiceImpl = class {
3045
3047
  const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
3046
3048
  (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3047
3049
  F: __dxlog_file10,
3048
- L: 254,
3050
+ L: 261,
3049
3051
  S: this,
3050
3052
  A: [
3051
3053
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3055,7 +3057,7 @@ var SpacesServiceImpl = class {
3055
3057
  const myIdentity = this._identityManager.identity;
3056
3058
  (0, import_invariant8.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3057
3059
  F: __dxlog_file10,
3058
- L: 256,
3060
+ L: 263,
3059
3061
  S: this,
3060
3062
  A: [
3061
3063
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3076,10 +3078,10 @@ var SpacesServiceImpl = class {
3076
3078
  });
3077
3079
  }
3078
3080
  return {
3079
- space: this._serializeSpace(dataSpace)
3081
+ space: await this._serializeSpace(dataSpace)
3080
3082
  };
3081
3083
  }
3082
- _serializeSpace(space) {
3084
+ async _serializeSpace(space) {
3083
3085
  return {
3084
3086
  id: space.id,
3085
3087
  spaceKey: space.key,
@@ -3099,7 +3101,7 @@ var SpacesServiceImpl = class {
3099
3101
  totalDataTimeframe: void 0,
3100
3102
  spaceRootUrl: space.databaseRoot?.url
3101
3103
  },
3102
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3104
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => {
3103
3105
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3104
3106
  const isMe = this._identityManager.identity?.identityKey.equals(member.key);
3105
3107
  if (isMe) {
@@ -3107,6 +3109,7 @@ var SpacesServiceImpl = class {
3107
3109
  }
3108
3110
  return {
3109
3111
  identity: {
3112
+ did: await (0, import_credentials13.createDidFromIdentityKey)(member.key),
3110
3113
  identityKey: member.key,
3111
3114
  profile: member.profile ?? {}
3112
3115
  },
@@ -3114,7 +3117,7 @@ var SpacesServiceImpl = class {
3114
3117
  presence: peers.length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE,
3115
3118
  peerStates: peers
3116
3119
  };
3117
- }),
3120
+ })),
3118
3121
  creator: space.inner.spaceState.creator?.key,
3119
3122
  cache: space.cache,
3120
3123
  metrics: space.metrics,
@@ -3157,13 +3160,14 @@ var Identity = class {
3157
3160
  this.space = params.space;
3158
3161
  this._signer = params.signer;
3159
3162
  this._presence = params.presence;
3163
+ this.did = params.did;
3160
3164
  this.identityKey = params.identityKey;
3161
3165
  this.deviceKey = params.deviceKey;
3162
3166
  import_log6.log.trace("dxos.halo.device", {
3163
3167
  deviceKey: params.deviceKey
3164
3168
  }, {
3165
3169
  F: __dxlog_file11,
3166
- L: 79,
3170
+ L: 82,
3167
3171
  S: this,
3168
3172
  C: (f, a) => f(...a)
3169
3173
  });
@@ -3265,7 +3269,7 @@ var Identity = class {
3265
3269
  getIdentityCredentialSigner() {
3266
3270
  (0, import_invariant6.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3267
3271
  F: __dxlog_file11,
3268
- L: 195,
3272
+ L: 198,
3269
3273
  S: this,
3270
3274
  A: [
3271
3275
  "this._deviceStateMachine.deviceCredentialChain",
@@ -3309,7 +3313,7 @@ var Identity = class {
3309
3313
  dataFeedKey
3310
3314
  }, {
3311
3315
  F: __dxlog_file11,
3312
- L: 220,
3316
+ L: 223,
3313
3317
  S: this,
3314
3318
  C: (f, a) => f(...a)
3315
3319
  });
@@ -3392,7 +3396,7 @@ var IdentityManager = class {
3392
3396
  id: traceId
3393
3397
  }), {
3394
3398
  F: __dxlog_file12,
3395
- L: 121,
3399
+ L: 116,
3396
3400
  S: this,
3397
3401
  C: (f, a) => f(...a)
3398
3402
  });
@@ -3401,7 +3405,7 @@ var IdentityManager = class {
3401
3405
  identityRecord
3402
3406
  }, {
3403
3407
  F: __dxlog_file12,
3404
- L: 124,
3408
+ L: 119,
3405
3409
  S: this,
3406
3410
  C: (f, a) => f(...a)
3407
3411
  });
@@ -3414,7 +3418,7 @@ var IdentityManager = class {
3414
3418
  displayName: this._identity.profileDocument?.displayName
3415
3419
  }, {
3416
3420
  F: __dxlog_file12,
3417
- L: 129,
3421
+ L: 124,
3418
3422
  S: this,
3419
3423
  C: (f, a) => f(...a)
3420
3424
  });
@@ -3424,7 +3428,7 @@ var IdentityManager = class {
3424
3428
  id: traceId
3425
3429
  }), {
3426
3430
  F: __dxlog_file12,
3427
- L: 136,
3431
+ L: 131,
3428
3432
  S: this,
3429
3433
  C: (f, a) => f(...a)
3430
3434
  });
@@ -3432,13 +3436,13 @@ var IdentityManager = class {
3432
3436
  async close() {
3433
3437
  await this._identity?.close(new import_context8.Context(void 0, {
3434
3438
  F: __dxlog_file12,
3435
- L: 140
3439
+ L: 135
3436
3440
  }));
3437
3441
  }
3438
3442
  async createIdentity({ displayName, deviceProfile } = {}) {
3439
3443
  (0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
3440
3444
  F: __dxlog_file12,
3441
- L: 145,
3445
+ L: 140,
3442
3446
  S: this,
3443
3447
  A: [
3444
3448
  "!this._identity",
@@ -3447,7 +3451,7 @@ var IdentityManager = class {
3447
3451
  });
3448
3452
  (0, import_log10.log)("creating identity...", void 0, {
3449
3453
  F: __dxlog_file12,
3450
- L: 146,
3454
+ L: 141,
3451
3455
  S: this,
3452
3456
  C: (f, a) => f(...a)
3453
3457
  });
@@ -3465,13 +3469,13 @@ var IdentityManager = class {
3465
3469
  const identity = await this._constructIdentity(identityRecord);
3466
3470
  await identity.open(new import_context8.Context(void 0, {
3467
3471
  F: __dxlog_file12,
3468
- L: 161
3472
+ L: 156
3469
3473
  }));
3470
3474
  {
3471
3475
  const generator = new import_credentials14.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3472
3476
  (0, import_invariant9.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3473
3477
  F: __dxlog_file12,
3474
- L: 165,
3478
+ L: 160,
3475
3479
  S: this,
3476
3480
  A: [
3477
3481
  "identityRecord.haloSpace.genesisFeedKey",
@@ -3480,7 +3484,7 @@ var IdentityManager = class {
3480
3484
  });
3481
3485
  (0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3482
3486
  F: __dxlog_file12,
3483
- L: 166,
3487
+ L: 161,
3484
3488
  S: this,
3485
3489
  A: [
3486
3490
  "identityRecord.haloSpace.dataFeedKey",
@@ -3519,7 +3523,7 @@ var IdentityManager = class {
3519
3523
  displayName: this._identity.profileDocument?.displayName
3520
3524
  }, {
3521
3525
  F: __dxlog_file12,
3522
- L: 204,
3526
+ L: 199,
3523
3527
  S: this,
3524
3528
  C: (f, a) => f(...a)
3525
3529
  });
@@ -3530,7 +3534,7 @@ var IdentityManager = class {
3530
3534
  profile: identity.profileDocument
3531
3535
  }, {
3532
3536
  F: __dxlog_file12,
3533
- L: 210,
3537
+ L: 205,
3534
3538
  S: this,
3535
3539
  C: (f, a) => f(...a)
3536
3540
  });
@@ -3567,13 +3571,13 @@ var IdentityManager = class {
3567
3571
  params
3568
3572
  }, {
3569
3573
  F: __dxlog_file12,
3570
- L: 249,
3574
+ L: 244,
3571
3575
  S: this,
3572
3576
  C: (f, a) => f(...a)
3573
3577
  });
3574
3578
  (0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
3575
3579
  F: __dxlog_file12,
3576
- L: 250,
3580
+ L: 245,
3577
3581
  S: this,
3578
3582
  A: [
3579
3583
  "!this._identity",
@@ -3594,7 +3598,7 @@ var IdentityManager = class {
3594
3598
  const identity = await this._constructIdentity(identityRecord);
3595
3599
  await identity.open(new import_context8.Context(void 0, {
3596
3600
  F: __dxlog_file12,
3597
- L: 264
3601
+ L: 259
3598
3602
  }));
3599
3603
  return {
3600
3604
  identity,
@@ -3613,7 +3617,7 @@ var IdentityManager = class {
3613
3617
  displayName: this._identity.profileDocument?.displayName
3614
3618
  }, {
3615
3619
  F: __dxlog_file12,
3616
- L: 278,
3620
+ L: 273,
3617
3621
  S: this,
3618
3622
  C: (f, a) => f(...a)
3619
3623
  });
@@ -3627,7 +3631,7 @@ var IdentityManager = class {
3627
3631
  deviceKey: identity.deviceKey
3628
3632
  }, {
3629
3633
  F: __dxlog_file12,
3630
- L: 289,
3634
+ L: 284,
3631
3635
  S: this,
3632
3636
  C: (f, a) => f(...a)
3633
3637
  });
@@ -3638,7 +3642,7 @@ var IdentityManager = class {
3638
3642
  async updateProfile(profile) {
3639
3643
  (0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
3640
3644
  F: __dxlog_file12,
3641
- L: 296,
3645
+ L: 291,
3642
3646
  S: this,
3643
3647
  A: [
3644
3648
  "this._identity",
@@ -3669,7 +3673,7 @@ var IdentityManager = class {
3669
3673
  async updateDeviceProfile(profile) {
3670
3674
  (0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
3671
3675
  F: __dxlog_file12,
3672
- L: 313,
3676
+ L: 308,
3673
3677
  S: this,
3674
3678
  A: [
3675
3679
  "this._identity",
@@ -3702,48 +3706,10 @@ var IdentityManager = class {
3702
3706
  profile
3703
3707
  };
3704
3708
  }
3705
- async createRecoveryPhrase() {
3706
- const identity = this._identity;
3707
- (0, import_invariant9.invariant)(identity, void 0, {
3708
- F: __dxlog_file12,
3709
- L: 340,
3710
- S: this,
3711
- A: [
3712
- "identity",
3713
- ""
3714
- ]
3715
- });
3716
- const seedphrase = (0, import_credentials14.generateSeedPhrase)();
3717
- const keypair = (0, import_credentials14.keyPairFromSeedPhrase)(seedphrase);
3718
- const recoveryKey = import_keys9.PublicKey.from(keypair.publicKey);
3719
- const identityKey = identity.identityKey;
3720
- const credential = await identity.getIdentityCredentialSigner().createCredential({
3721
- subject: identityKey,
3722
- assertion: {
3723
- "@type": "dxos.halo.credentials.IdentityRecovery",
3724
- recoveryKey,
3725
- identityKey
3726
- }
3727
- });
3728
- const receipt = await identity.controlPipeline.writer.write({
3729
- credential: {
3730
- credential
3731
- }
3732
- });
3733
- await identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe4.Timeframe([
3734
- [
3735
- receipt.feedKey,
3736
- receipt.seq
3737
- ]
3738
- ]));
3739
- return {
3740
- seedphrase
3741
- };
3742
- }
3743
3709
  async _constructIdentity(identityRecord) {
3744
3710
  (0, import_invariant9.invariant)(!this._identity, void 0, {
3745
3711
  F: __dxlog_file12,
3746
- L: 362,
3712
+ L: 334,
3747
3713
  S: this,
3748
3714
  A: [
3749
3715
  "!this._identity",
@@ -3754,7 +3720,7 @@ var IdentityManager = class {
3754
3720
  identityRecord
3755
3721
  }, {
3756
3722
  F: __dxlog_file12,
3757
- L: 363,
3723
+ L: 335,
3758
3724
  S: this,
3759
3725
  C: (f, a) => f(...a)
3760
3726
  });
@@ -3769,7 +3735,7 @@ var IdentityManager = class {
3769
3735
  });
3770
3736
  (0, import_invariant9.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
3771
3737
  F: __dxlog_file12,
3772
- L: 376,
3738
+ L: 348,
3773
3739
  S: this,
3774
3740
  A: [
3775
3741
  "identityRecord.haloSpace.controlFeedKey",
@@ -3781,7 +3747,7 @@ var IdentityManager = class {
3781
3747
  });
3782
3748
  (0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
3783
3749
  F: __dxlog_file12,
3784
- L: 380,
3750
+ L: 352,
3785
3751
  S: this,
3786
3752
  A: [
3787
3753
  "identityRecord.haloSpace.dataFeedKey",
@@ -3805,10 +3771,12 @@ var IdentityManager = class {
3805
3771
  });
3806
3772
  await space.setControlFeed(controlFeed);
3807
3773
  await space.setDataFeed(dataFeed);
3774
+ const did = await (0, import_credentials14.createDidFromIdentityKey)(identityRecord.identityKey);
3808
3775
  const identity = new Identity({
3809
3776
  space,
3810
3777
  presence,
3811
3778
  signer: this._keyring,
3779
+ did,
3812
3780
  identityKey: identityRecord.identityKey,
3813
3781
  deviceKey: identityRecord.deviceKey,
3814
3782
  edgeConnection: this._edgeConnection,
@@ -3818,7 +3786,7 @@ var IdentityManager = class {
3818
3786
  identityKey: identityRecord.identityKey
3819
3787
  }, {
3820
3788
  F: __dxlog_file12,
3821
- L: 409,
3789
+ L: 383,
3822
3790
  S: this,
3823
3791
  C: (f, a) => f(...a)
3824
3792
  });
@@ -3843,7 +3811,7 @@ var IdentityManager = class {
3843
3811
  onAuthFailure: () => {
3844
3812
  import_log10.log.warn("auth failure", void 0, {
3845
3813
  F: __dxlog_file12,
3846
- L: 434,
3814
+ L: 408,
3847
3815
  S: this,
3848
3816
  C: (f, a) => f(...a)
3849
3817
  });
@@ -3896,7 +3864,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3896
3864
  const identity = this._identityManager.identity;
3897
3865
  (0, import_invariant10.invariant)(identity, void 0, {
3898
3866
  F: __dxlog_file13,
3899
- L: 60,
3867
+ L: 61,
3900
3868
  S: this,
3901
3869
  A: [
3902
3870
  "identity",
@@ -3906,7 +3874,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3906
3874
  await identity.updateDefaultSpace(space.id);
3907
3875
  }
3908
3876
  queryIdentity() {
3909
- return new import_codec_protobuf9.Stream(({ next }) => {
3877
+ return new import_stream8.Stream(({ next }) => {
3910
3878
  const emitNext = () => next({
3911
3879
  identity: this._getIdentity()
3912
3880
  });
@@ -3919,6 +3887,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3919
3887
  return void 0;
3920
3888
  }
3921
3889
  return {
3890
+ did: this._identityManager.identity.did,
3922
3891
  identityKey: this._identityManager.identity.identityKey,
3923
3892
  spaceKey: this._identityManager.identity.space.key,
3924
3893
  profile: this._identityManager.identity.profileDocument
@@ -3927,7 +3896,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3927
3896
  async updateProfile(profile) {
3928
3897
  (0, import_invariant10.invariant)(this._identityManager.identity, "Identity not initialized.", {
3929
3898
  F: __dxlog_file13,
3930
- L: 86,
3899
+ L: 88,
3931
3900
  S: this,
3932
3901
  A: [
3933
3902
  "this._identityManager.identity",
@@ -3938,18 +3907,29 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3938
3907
  await this._onProfileUpdate?.(this._identityManager.identity.profileDocument);
3939
3908
  return this._getIdentity();
3940
3909
  }
3941
- async createRecoveryPhrase() {
3942
- return this._recoveryManager.createRecoveryPhrase();
3910
+ async createRecoveryCredential(request) {
3911
+ return this._recoveryManager.createRecoveryCredential(request);
3912
+ }
3913
+ async requestRecoveryChallenge() {
3914
+ return this._recoveryManager.requestRecoveryChallenge();
3943
3915
  }
3944
3916
  async recoverIdentity(request) {
3945
- 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
+ }
3946
3926
  return this._getIdentity();
3947
3927
  }
3948
3928
  // TODO(burdon): Rename createPresentation?
3949
3929
  async signPresentation({ presentation, nonce }) {
3950
3930
  (0, import_invariant10.invariant)(this._identityManager.identity, "Identity not initialized.", {
3951
3931
  F: __dxlog_file13,
3952
- L: 103,
3932
+ L: 116,
3953
3933
  S: this,
3954
3934
  A: [
3955
3935
  "this._identityManager.identity",
@@ -3968,7 +3948,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3968
3948
  const identity = this._identityManager.identity;
3969
3949
  (0, import_invariant10.invariant)(identity, "Identity not initialized.", {
3970
3950
  F: __dxlog_file13,
3971
- L: 117,
3951
+ L: 130,
3972
3952
  S: this,
3973
3953
  A: [
3974
3954
  "identity",
@@ -4006,7 +3986,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
4006
3986
  duplicate: space.id
4007
3987
  }, {
4008
3988
  F: __dxlog_file13,
4009
- L: 151,
3989
+ L: 164,
4010
3990
  S: this,
4011
3991
  C: (f, a) => f(...a)
4012
3992
  });
@@ -4020,7 +4000,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
4020
4000
  }, (err) => {
4021
4001
  import_log11.log.catch(err, void 0, {
4022
4002
  F: __dxlog_file13,
4023
- L: 162,
4003
+ L: 175,
4024
4004
  S: this,
4025
4005
  C: (f, a) => f(...a)
4026
4006
  });
@@ -4789,6 +4769,12 @@ var DeviceInvitationProtocol = class {
4789
4769
  var stateToString = (state) => {
4790
4770
  return Object.entries(import_services13.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4791
4771
  };
4772
+ var computeExpirationTime = (invitation) => {
4773
+ if (!invitation.lifetime) {
4774
+ return;
4775
+ }
4776
+ return new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime * 1e3);
4777
+ };
4792
4778
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4793
4779
  let guard;
4794
4780
  return (0, import_context11.cancelWithContext)(ctx, (async () => {
@@ -5765,18 +5751,19 @@ var InvitationsHandler = class {
5765
5751
  });
5766
5752
  return extension;
5767
5753
  };
5768
- if (invitation.lifetime && invitation.created) {
5769
- if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5754
+ const expiresOn = (0, import_client_protocol5.getExpirationTime)(invitation);
5755
+ if (expiresOn) {
5756
+ if (expiresOn.getTime() < Date.now()) {
5770
5757
  import_log12.log.warn("invitation has already expired", void 0, {
5771
5758
  F: __dxlog_file21,
5772
- L: 193,
5759
+ L: 194,
5773
5760
  S: this,
5774
5761
  C: (f, a) => f(...a)
5775
5762
  });
5776
5763
  guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5777
5764
  void ctx.dispose().catch((err) => import_log12.log.catch(err, void 0, {
5778
5765
  F: __dxlog_file21,
5779
- L: 195,
5766
+ L: 196,
5780
5767
  S: this,
5781
5768
  C: (f, a) => f(...a)
5782
5769
  }));
@@ -5787,7 +5774,7 @@ var InvitationsHandler = class {
5787
5774
  guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5788
5775
  metrics.increment("dxos.invitation.expired");
5789
5776
  await ctx.dispose();
5790
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5777
+ }, expiresOn.getTime() - Date.now());
5791
5778
  }
5792
5779
  let swarmConnection;
5793
5780
  (0, import_async15.scheduleTask)(ctx, async () => {
@@ -5803,7 +5790,7 @@ var InvitationsHandler = class {
5803
5790
  type: invitation.type
5804
5791
  }, {
5805
5792
  F: __dxlog_file21,
5806
- L: 226,
5793
+ L: 227,
5807
5794
  S: this,
5808
5795
  C: (f, a) => f(...a)
5809
5796
  });
@@ -5811,7 +5798,7 @@ var InvitationsHandler = class {
5811
5798
  if (deviceProfile) {
5812
5799
  (0, import_invariant12.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5813
5800
  F: __dxlog_file21,
5814
- L: 235,
5801
+ L: 236,
5815
5802
  S: this,
5816
5803
  A: [
5817
5804
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5829,7 +5816,7 @@ var InvitationsHandler = class {
5829
5816
  triedPeers: triedPeersIds.size
5830
5817
  }, {
5831
5818
  F: __dxlog_file21,
5832
- L: 243,
5819
+ L: 244,
5833
5820
  S: this,
5834
5821
  C: (f, a) => f(...a)
5835
5822
  });
@@ -5856,7 +5843,7 @@ var InvitationsHandler = class {
5856
5843
  currentState: guardedState.current.state
5857
5844
  }, {
5858
5845
  F: __dxlog_file21,
5859
- L: 271,
5846
+ L: 272,
5860
5847
  S: this,
5861
5848
  C: (f, a) => f(...a)
5862
5849
  });
@@ -5874,7 +5861,7 @@ var InvitationsHandler = class {
5874
5861
  id: traceId
5875
5862
  }), {
5876
5863
  F: __dxlog_file21,
5877
- L: 283,
5864
+ L: 284,
5878
5865
  S: this,
5879
5866
  C: (f, a) => f(...a)
5880
5867
  });
@@ -5886,7 +5873,7 @@ var InvitationsHandler = class {
5886
5873
  ...protocol.toJSON()
5887
5874
  }, {
5888
5875
  F: __dxlog_file21,
5889
- L: 294,
5876
+ L: 295,
5890
5877
  S: this,
5891
5878
  C: (f, a) => f(...a)
5892
5879
  });
@@ -5896,7 +5883,7 @@ var InvitationsHandler = class {
5896
5883
  ...protocol.toJSON()
5897
5884
  }, {
5898
5885
  F: __dxlog_file21,
5899
- L: 298,
5886
+ L: 299,
5900
5887
  S: this,
5901
5888
  C: (f, a) => f(...a)
5902
5889
  });
@@ -5910,7 +5897,7 @@ var InvitationsHandler = class {
5910
5897
  authMethod: introductionResponse.authMethod
5911
5898
  }, {
5912
5899
  F: __dxlog_file21,
5913
- L: 306,
5900
+ L: 307,
5914
5901
  S: this,
5915
5902
  C: (f, a) => f(...a)
5916
5903
  });
@@ -5932,7 +5919,7 @@ var InvitationsHandler = class {
5932
5919
  ...protocol.toJSON()
5933
5920
  }, {
5934
5921
  F: __dxlog_file21,
5935
- L: 336,
5922
+ L: 337,
5936
5923
  S: this,
5937
5924
  C: (f, a) => f(...a)
5938
5925
  });
@@ -5945,7 +5932,7 @@ var InvitationsHandler = class {
5945
5932
  ...protocol.toJSON()
5946
5933
  }, {
5947
5934
  F: __dxlog_file21,
5948
- L: 350,
5935
+ L: 351,
5949
5936
  S: this,
5950
5937
  C: (f, a) => f(...a)
5951
5938
  });
@@ -5958,7 +5945,7 @@ var InvitationsHandler = class {
5958
5945
  id: traceId
5959
5946
  }), {
5960
5947
  F: __dxlog_file21,
5961
- L: 359,
5948
+ L: 360,
5962
5949
  S: this,
5963
5950
  C: (f, a) => f(...a)
5964
5951
  });
@@ -5968,7 +5955,7 @@ var InvitationsHandler = class {
5968
5955
  ...protocol.toJSON()
5969
5956
  }, {
5970
5957
  F: __dxlog_file21,
5971
- L: 362,
5958
+ L: 363,
5972
5959
  S: this,
5973
5960
  C: (f, a) => f(...a)
5974
5961
  });
@@ -5976,7 +5963,7 @@ var InvitationsHandler = class {
5976
5963
  } else {
5977
5964
  import_log12.log.verbose("auth failed", err, {
5978
5965
  F: __dxlog_file21,
5979
- L: 365,
5966
+ L: 366,
5980
5967
  S: this,
5981
5968
  C: (f, a) => f(...a)
5982
5969
  });
@@ -5988,7 +5975,7 @@ var InvitationsHandler = class {
5988
5975
  error: err
5989
5976
  }), {
5990
5977
  F: __dxlog_file21,
5991
- L: 369,
5978
+ L: 370,
5992
5979
  S: this,
5993
5980
  C: (f, a) => f(...a)
5994
5981
  });
@@ -6004,7 +5991,7 @@ var InvitationsHandler = class {
6004
5991
  ...protocol.toJSON()
6005
5992
  }, {
6006
5993
  F: __dxlog_file21,
6007
- L: 378,
5994
+ L: 379,
6008
5995
  S: this,
6009
5996
  C: (f, a) => f(...a)
6010
5997
  });
@@ -6012,7 +5999,7 @@ var InvitationsHandler = class {
6012
5999
  } else {
6013
6000
  import_log12.log.verbose("auth failed", err, {
6014
6001
  F: __dxlog_file21,
6015
- L: 381,
6002
+ L: 382,
6016
6003
  S: this,
6017
6004
  C: (f, a) => f(...a)
6018
6005
  });
@@ -6029,7 +6016,7 @@ var InvitationsHandler = class {
6029
6016
  ...protocol.toJSON()
6030
6017
  }, {
6031
6018
  F: __dxlog_file21,
6032
- L: 393,
6019
+ L: 394,
6033
6020
  S: this,
6034
6021
  C: (f, a) => f(...a)
6035
6022
  });
@@ -6042,14 +6029,14 @@ var InvitationsHandler = class {
6042
6029
  });
6043
6030
  edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
6044
6031
  (0, import_async15.scheduleTask)(ctx, async () => {
6045
- const error = protocol.checkInvitation(invitation);
6032
+ const error = checkInvitation(protocol, invitation);
6046
6033
  if (error) {
6047
6034
  stream.error(error);
6048
6035
  await ctx.dispose();
6049
6036
  } else {
6050
6037
  (0, import_invariant12.invariant)(invitation.swarmKey, void 0, {
6051
6038
  F: __dxlog_file21,
6052
- L: 405,
6039
+ L: 406,
6053
6040
  S: this,
6054
6041
  A: [
6055
6042
  "invitation.swarmKey",
@@ -6093,7 +6080,7 @@ var InvitationsHandler = class {
6093
6080
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6094
6081
  (0, import_log12.log)("guest waiting for authentication code...", void 0, {
6095
6082
  F: __dxlog_file21,
6096
- L: 457,
6083
+ L: 458,
6097
6084
  S: this,
6098
6085
  C: (f, a) => f(...a)
6099
6086
  });
@@ -6101,7 +6088,7 @@ var InvitationsHandler = class {
6101
6088
  const authCode = await authenticated.wait(options);
6102
6089
  (0, import_log12.log)("sending authentication request", void 0, {
6103
6090
  F: __dxlog_file21,
6104
- L: 461,
6091
+ L: 462,
6105
6092
  S: this,
6106
6093
  C: (f, a) => f(...a)
6107
6094
  });
@@ -6120,7 +6107,7 @@ var InvitationsHandler = class {
6120
6107
  attempt
6121
6108
  }, {
6122
6109
  F: __dxlog_file21,
6123
- L: 472,
6110
+ L: 473,
6124
6111
  S: this,
6125
6112
  C: (f, a) => f(...a)
6126
6113
  });
@@ -6138,7 +6125,7 @@ var InvitationsHandler = class {
6138
6125
  }
6139
6126
  (0, import_log12.log)("sending authentication request", void 0, {
6140
6127
  F: __dxlog_file21,
6141
- L: 491,
6128
+ L: 492,
6142
6129
  S: this,
6143
6130
  C: (f, a) => f(...a)
6144
6131
  });
@@ -6151,6 +6138,13 @@ var InvitationsHandler = class {
6151
6138
  }
6152
6139
  }
6153
6140
  };
6141
+ var checkInvitation = (protocol, invitation) => {
6142
+ const expiresOn = (0, import_client_protocol5.getExpirationTime)(invitation);
6143
+ if (expiresOn && expiresOn.getTime() < Date.now()) {
6144
+ return new import_protocols9.InvalidInvitationError("Invitation already expired.");
6145
+ }
6146
+ return protocol.checkInvitation(invitation);
6147
+ };
6154
6148
  var createAdmissionKeypair = () => {
6155
6149
  const keypair = (0, import_crypto.createKeyPair)();
6156
6150
  return {
@@ -6167,7 +6161,7 @@ var InvitationsServiceImpl = class {
6167
6161
  return {};
6168
6162
  }
6169
6163
  createInvitation(options) {
6170
- return new import_codec_protobuf10.Stream(({ next, close }) => {
6164
+ return new import_stream9.Stream(({ next, close }) => {
6171
6165
  void this._invitationsManager.createInvitation(options).then((invitation) => {
6172
6166
  import_tracing9.trace.metrics.increment("dxos.invitation.created");
6173
6167
  invitation.subscribe(next, close, close);
@@ -6176,7 +6170,7 @@ var InvitationsServiceImpl = class {
6176
6170
  }
6177
6171
  acceptInvitation(request) {
6178
6172
  const invitation = this._invitationsManager.acceptInvitation(request);
6179
- return new import_codec_protobuf10.Stream(({ next, close }) => {
6173
+ return new import_stream9.Stream(({ next, close }) => {
6180
6174
  invitation.subscribe(next, close, close);
6181
6175
  });
6182
6176
  }
@@ -6187,7 +6181,7 @@ var InvitationsServiceImpl = class {
6187
6181
  return this._invitationsManager.cancelInvitation(request);
6188
6182
  }
6189
6183
  queryInvitations() {
6190
- return new import_codec_protobuf10.Stream(({ next, ctx }) => {
6184
+ return new import_stream9.Stream(({ next, ctx }) => {
6191
6185
  this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
6192
6186
  next({
6193
6187
  action: import_services16.QueryInvitationsResponse.Action.ADDED,
@@ -6285,7 +6279,7 @@ var SpaceInvitationProtocol = class {
6285
6279
  getInvitationContext() {
6286
6280
  (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6287
6281
  F: __dxlog_file22,
6288
- L: 64,
6282
+ L: 65,
6289
6283
  S: this,
6290
6284
  A: [
6291
6285
  "this._spaceKey",
@@ -6295,7 +6289,7 @@ var SpaceInvitationProtocol = class {
6295
6289
  const space = this._spaceManager.spaces.get(this._spaceKey);
6296
6290
  (0, import_invariant17.invariant)(space, void 0, {
6297
6291
  F: __dxlog_file22,
6298
- L: 66,
6292
+ L: 67,
6299
6293
  S: this,
6300
6294
  A: [
6301
6295
  "space",
@@ -6311,7 +6305,7 @@ var SpaceInvitationProtocol = class {
6311
6305
  async admit(invitation, request, guestProfile) {
6312
6306
  (0, import_invariant17.invariant)(this._spaceKey && request.space, void 0, {
6313
6307
  F: __dxlog_file22,
6314
- L: 79,
6308
+ L: 80,
6315
6309
  S: this,
6316
6310
  A: [
6317
6311
  "this._spaceKey && request.space",
@@ -6323,7 +6317,7 @@ var SpaceInvitationProtocol = class {
6323
6317
  guest: request.space.deviceKey
6324
6318
  }, {
6325
6319
  F: __dxlog_file22,
6326
- L: 80,
6320
+ L: 81,
6327
6321
  S: this,
6328
6322
  C: (f, a) => f(...a)
6329
6323
  });
@@ -6345,7 +6339,7 @@ var SpaceInvitationProtocol = class {
6345
6339
  async delegate(invitation) {
6346
6340
  (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6347
6341
  F: __dxlog_file22,
6348
- L: 100,
6342
+ L: 101,
6349
6343
  S: this,
6350
6344
  A: [
6351
6345
  "this._spaceKey",
@@ -6355,7 +6349,7 @@ var SpaceInvitationProtocol = class {
6355
6349
  const space = this._spaceManager.spaces.get(this._spaceKey);
6356
6350
  (0, import_invariant17.invariant)(space, void 0, {
6357
6351
  F: __dxlog_file22,
6358
- L: 102,
6352
+ L: 103,
6359
6353
  S: this,
6360
6354
  A: [
6361
6355
  "space",
@@ -6365,7 +6359,7 @@ var SpaceInvitationProtocol = class {
6365
6359
  if (invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
6366
6360
  (0, import_invariant17.invariant)(invitation.guestKeypair?.publicKey, void 0, {
6367
6361
  F: __dxlog_file22,
6368
- L: 104,
6362
+ L: 105,
6369
6363
  S: this,
6370
6364
  A: [
6371
6365
  "invitation.guestKeypair?.publicKey",
@@ -6378,7 +6372,7 @@ var SpaceInvitationProtocol = class {
6378
6372
  id: invitation.invitationId
6379
6373
  }, {
6380
6374
  F: __dxlog_file22,
6381
- L: 107,
6375
+ L: 108,
6382
6376
  S: this,
6383
6377
  C: (f, a) => f(...a)
6384
6378
  });
@@ -6387,13 +6381,13 @@ var SpaceInvitationProtocol = class {
6387
6381
  authMethod: invitation.authMethod,
6388
6382
  swarmKey: invitation.swarmKey,
6389
6383
  role: invitation.role ?? import_credentials19.SpaceMember.Role.ADMIN,
6390
- expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
6384
+ expiresOn: computeExpirationTime(invitation),
6391
6385
  multiUse: invitation.multiUse ?? false,
6392
6386
  guestKey: invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6393
6387
  });
6394
6388
  (0, import_invariant17.invariant)(credential.credential, void 0, {
6395
6389
  F: __dxlog_file22,
6396
- L: 127,
6390
+ L: 126,
6397
6391
  S: this,
6398
6392
  A: [
6399
6393
  "credential.credential",
@@ -6408,7 +6402,7 @@ var SpaceInvitationProtocol = class {
6408
6402
  async cancelDelegation(invitation) {
6409
6403
  (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6410
6404
  F: __dxlog_file22,
6411
- L: 133,
6405
+ L: 132,
6412
6406
  S: this,
6413
6407
  A: [
6414
6408
  "this._spaceKey",
@@ -6417,7 +6411,7 @@ var SpaceInvitationProtocol = class {
6417
6411
  });
6418
6412
  (0, import_invariant17.invariant)(invitation.type === import_services17.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6419
6413
  F: __dxlog_file22,
6420
- L: 134,
6414
+ L: 133,
6421
6415
  S: this,
6422
6416
  A: [
6423
6417
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6427,7 +6421,7 @@ var SpaceInvitationProtocol = class {
6427
6421
  const space = this._spaceManager.spaces.get(this._spaceKey);
6428
6422
  (0, import_invariant17.invariant)(space, void 0, {
6429
6423
  F: __dxlog_file22,
6430
- L: 136,
6424
+ L: 135,
6431
6425
  S: this,
6432
6426
  A: [
6433
6427
  "space",
@@ -6439,14 +6433,14 @@ var SpaceInvitationProtocol = class {
6439
6433
  id: invitation.invitationId
6440
6434
  }, {
6441
6435
  F: __dxlog_file22,
6442
- L: 138,
6436
+ L: 137,
6443
6437
  S: this,
6444
6438
  C: (f, a) => f(...a)
6445
6439
  });
6446
6440
  const credential = await (0, import_credentials18.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6447
6441
  (0, import_invariant17.invariant)(credential.credential, void 0, {
6448
6442
  F: __dxlog_file22,
6449
- L: 145,
6443
+ L: 144,
6450
6444
  S: this,
6451
6445
  A: [
6452
6446
  "credential.credential",
@@ -6485,7 +6479,7 @@ var SpaceInvitationProtocol = class {
6485
6479
  async accept(response) {
6486
6480
  (0, import_invariant17.invariant)(response.space, void 0, {
6487
6481
  F: __dxlog_file22,
6488
- L: 180,
6482
+ L: 179,
6489
6483
  S: this,
6490
6484
  A: [
6491
6485
  "response.space",
@@ -6496,7 +6490,7 @@ var SpaceInvitationProtocol = class {
6496
6490
  const assertion = (0, import_credentials18.getCredentialAssertion)(credential);
6497
6491
  (0, import_invariant17.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6498
6492
  F: __dxlog_file22,
6499
- L: 183,
6493
+ L: 182,
6500
6494
  S: this,
6501
6495
  A: [
6502
6496
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -6505,7 +6499,7 @@ var SpaceInvitationProtocol = class {
6505
6499
  });
6506
6500
  (0, import_invariant17.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6507
6501
  F: __dxlog_file22,
6508
- L: 184,
6502
+ L: 183,
6509
6503
  S: this,
6510
6504
  A: [
6511
6505
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6729,7 +6723,7 @@ var InvitationsManager = class {
6729
6723
  }
6730
6724
  }
6731
6725
  _createInvitation(protocol, _options) {
6732
- const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = _options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false, ...options } = _options ?? {};
6726
+ const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = _options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
6733
6727
  const authCode = options?.authCode ?? (authMethod === import_services18.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials20.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6734
6728
  return {
6735
6729
  invitationId,
@@ -6968,7 +6962,7 @@ var ClientRpcServer = class {
6968
6962
  const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
6969
6963
  this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
6970
6964
  if (this._handleStream) {
6971
- return import_codec_protobuf11.Stream.map(import_codec_protobuf11.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
6965
+ return import_codec_protobuf2.Stream.map(import_codec_protobuf2.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
6972
6966
  this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
6973
6967
  return data;
6974
6968
  });
@@ -7068,6 +7062,18 @@ var EdgeAgentManager = class extends import_context15.Resource {
7068
7062
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7069
7063
  });
7070
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
+ }
7071
7077
  await this._identity.admitDevice({
7072
7078
  deviceKey,
7073
7079
  controlFeedKey: import_keys15.PublicKey.fromHex(response.feedKey),
@@ -7076,7 +7082,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7076
7082
  });
7077
7083
  (0, import_log21.log)("agent created", response, {
7078
7084
  F: __dxlog_file25,
7079
- L: 73,
7085
+ L: 79,
7080
7086
  S: this,
7081
7087
  C: (f, a) => f(...a)
7082
7088
  });
@@ -7088,7 +7094,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7088
7094
  isEnabled
7089
7095
  }, {
7090
7096
  F: __dxlog_file25,
7091
- L: 81,
7097
+ L: 87,
7092
7098
  S: this,
7093
7099
  C: (f, a) => f(...a)
7094
7100
  });
@@ -7121,7 +7127,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7121
7127
  async _fetchAgentStatus() {
7122
7128
  (0, import_invariant20.invariant)(this._edgeHttpClient, void 0, {
7123
7129
  F: __dxlog_file25,
7124
- L: 115,
7130
+ L: 121,
7125
7131
  S: this,
7126
7132
  A: [
7127
7133
  "this._edgeHttpClient",
@@ -7131,7 +7137,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7131
7137
  try {
7132
7138
  (0, import_log21.log)("fetching agent status", void 0, {
7133
7139
  F: __dxlog_file25,
7134
- L: 117,
7140
+ L: 123,
7135
7141
  S: this,
7136
7142
  C: (f, a) => f(...a)
7137
7143
  });
@@ -7150,7 +7156,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7150
7156
  err
7151
7157
  }, {
7152
7158
  F: __dxlog_file25,
7153
- L: 127,
7159
+ L: 133,
7154
7160
  S: this,
7155
7161
  C: (f, a) => f(...a)
7156
7162
  });
@@ -7163,7 +7169,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7163
7169
  retryAfterMs
7164
7170
  }, {
7165
7171
  F: __dxlog_file25,
7166
- L: 132,
7172
+ L: 138,
7167
7173
  S: this,
7168
7174
  C: (f, a) => f(...a)
7169
7175
  });
@@ -7199,7 +7205,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7199
7205
  spaceId: space.id
7200
7206
  }, {
7201
7207
  F: __dxlog_file25,
7202
- L: 159,
7208
+ L: 165,
7203
7209
  S: this,
7204
7210
  C: (f, a) => f(...a)
7205
7211
  });
@@ -7219,7 +7225,7 @@ var EdgeAgentManager = class extends import_context15.Resource {
7219
7225
  status
7220
7226
  }, {
7221
7227
  F: __dxlog_file25,
7222
- L: 175,
7228
+ L: 181,
7223
7229
  S: this,
7224
7230
  C: (f, a) => f(...a)
7225
7231
  });
@@ -7234,7 +7240,7 @@ var EdgeAgentServiceImpl = class {
7234
7240
  this._edgeConnection = _edgeConnection;
7235
7241
  }
7236
7242
  queryEdgeStatus() {
7237
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
7243
+ return new import_stream10.Stream(({ ctx, next }) => {
7238
7244
  next({
7239
7245
  status: import_services20.QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED
7240
7246
  });
@@ -7255,7 +7261,7 @@ var EdgeAgentServiceImpl = class {
7255
7261
  return (await this._agentManagerProvider()).createAgent();
7256
7262
  }
7257
7263
  queryAgentStatus() {
7258
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
7264
+ return new import_stream10.Stream(({ ctx, next }) => {
7259
7265
  next({
7260
7266
  status: import_services20.QueryAgentStatusResponse.AgentStatus.UNKNOWN
7261
7267
  });
@@ -7292,27 +7298,41 @@ var EdgeIdentityRecoveryManager = class {
7292
7298
  this._identityProvider = _identityProvider;
7293
7299
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7294
7300
  }
7295
- async createRecoveryPhrase() {
7301
+ async createRecoveryCredential({ recoveryKey, algorithm }) {
7296
7302
  const identity = this._identityProvider();
7297
7303
  (0, import_invariant22.invariant)(identity, void 0, {
7298
7304
  F: __dxlog_file26,
7299
- L: 29,
7305
+ L: 37,
7300
7306
  S: this,
7301
7307
  A: [
7302
7308
  "identity",
7303
7309
  ""
7304
7310
  ]
7305
7311
  });
7306
- const seedphrase = (0, import_credentials23.generateSeedPhrase)();
7307
- const keypair = (0, import_credentials23.keyPairFromSeedPhrase)(seedphrase);
7308
- const recoveryKey = import_keys17.PublicKey.from(keypair.publicKey);
7312
+ let recoveryCode;
7313
+ if (!recoveryKey) {
7314
+ recoveryCode = (0, import_credentials23.generateSeedPhrase)();
7315
+ const keypair = (0, import_credentials23.keyPairFromSeedPhrase)(recoveryCode);
7316
+ recoveryKey = import_keys17.PublicKey.from(keypair.publicKey);
7317
+ algorithm = "ED25519";
7318
+ }
7319
+ (0, import_invariant22.invariant)(algorithm, "Algorithm is required.", {
7320
+ F: __dxlog_file26,
7321
+ L: 47,
7322
+ S: this,
7323
+ A: [
7324
+ "algorithm",
7325
+ "'Algorithm is required.'"
7326
+ ]
7327
+ });
7309
7328
  const identityKey = identity.identityKey;
7310
7329
  const credential = await identity.getIdentityCredentialSigner().createCredential({
7311
7330
  subject: identityKey,
7312
7331
  assertion: {
7313
7332
  "@type": "dxos.halo.credentials.IdentityRecovery",
7314
7333
  recoveryKey,
7315
- identityKey
7334
+ identityKey,
7335
+ algorithm
7316
7336
  }
7317
7337
  });
7318
7338
  const receipt = await identity.controlPipeline.writer.write({
@@ -7327,20 +7347,81 @@ var EdgeIdentityRecoveryManager = class {
7327
7347
  ]
7328
7348
  ]));
7329
7349
  return {
7330
- seedphrase
7350
+ recoveryCode
7331
7351
  };
7332
7352
  }
7333
- async recoverIdentity(args) {
7353
+ async requestRecoveryChallenge() {
7334
7354
  (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7335
7355
  F: __dxlog_file26,
7336
- L: 51,
7356
+ L: 66,
7337
7357
  S: this,
7338
7358
  A: [
7339
7359
  "this._edgeClient",
7340
7360
  "'Not connected to EDGE.'"
7341
7361
  ]
7342
7362
  });
7343
- const recoveryKeypair = (0, import_credentials23.keyPairFromSeedPhrase)(args.seedphrase);
7363
+ const deviceKey = await this._keyring.createKey();
7364
+ const controlFeedKey = await this._keyring.createKey();
7365
+ const request = {
7366
+ deviceKey: deviceKey.toHex(),
7367
+ controlFeedKey: controlFeedKey.toHex()
7368
+ };
7369
+ try {
7370
+ await this._edgeClient.recoverIdentity(request);
7371
+ throw new Error("No challenge received.");
7372
+ } catch (error) {
7373
+ if (!(error instanceof import_protocols17.EdgeAuthChallengeError)) {
7374
+ throw error;
7375
+ }
7376
+ return {
7377
+ deviceKey,
7378
+ controlFeedKey,
7379
+ challenge: error.challenge
7380
+ };
7381
+ }
7382
+ }
7383
+ async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7384
+ (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7385
+ F: __dxlog_file26,
7386
+ L: 98,
7387
+ S: this,
7388
+ A: [
7389
+ "this._edgeClient",
7390
+ "'Not connected to EDGE.'"
7391
+ ]
7392
+ });
7393
+ const request = {
7394
+ identityDid,
7395
+ deviceKey: deviceKey.toHex(),
7396
+ controlFeedKey: controlFeedKey.toHex(),
7397
+ signature: clientDataJson && authenticatorData ? {
7398
+ signature: Buffer.from(signature).toString("base64"),
7399
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7400
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7401
+ } : Buffer.from(signature).toString("base64")
7402
+ };
7403
+ const response = await this._edgeClient.recoverIdentity(request);
7404
+ await this._acceptRecoveredIdentity({
7405
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7406
+ haloGenesisFeedKey: import_keys17.PublicKey.fromHex(response.genesisFeedKey),
7407
+ haloSpaceKey: import_keys17.PublicKey.fromHex(response.haloSpaceKey),
7408
+ identityKey: import_keys17.PublicKey.fromHex(response.identityKey),
7409
+ deviceKey,
7410
+ controlFeedKey,
7411
+ dataFeedKey: await this._keyring.createKey()
7412
+ });
7413
+ }
7414
+ async recoverIdentity({ recoveryCode }) {
7415
+ (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7416
+ F: __dxlog_file26,
7417
+ L: 128,
7418
+ S: this,
7419
+ A: [
7420
+ "this._edgeClient",
7421
+ "'Not connected to EDGE.'"
7422
+ ]
7423
+ });
7424
+ const recoveryKeypair = (0, import_credentials23.keyPairFromSeedPhrase)(recoveryCode);
7344
7425
  const recoveryKey = import_keys17.PublicKey.from(recoveryKeypair.publicKey);
7345
7426
  const deviceKey = await this._keyring.createKey();
7346
7427
  const controlFeedKey = await this._keyring.createKey();
@@ -7364,7 +7445,7 @@ var EdgeIdentityRecoveryManager = class {
7364
7445
  }
7365
7446
  import_log23.log.info("recovering identity", response, {
7366
7447
  F: __dxlog_file26,
7367
- L: 77,
7448
+ L: 154,
7368
7449
  S: this,
7369
7450
  C: (f, a) => f(...a)
7370
7451
  });
@@ -8068,7 +8149,7 @@ var DevicesServiceImpl = class {
8068
8149
  return this._identityManager.updateDeviceProfile(profile);
8069
8150
  }
8070
8151
  queryDevices() {
8071
- return new import_codec_protobuf13.Stream(({ next }) => {
8152
+ return new import_stream11.Stream(({ next }) => {
8072
8153
  const update = () => {
8073
8154
  const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
8074
8155
  if (!deviceKeys) {
@@ -8190,7 +8271,7 @@ var ContactsServiceImpl = class {
8190
8271
  }
8191
8272
  queryContacts() {
8192
8273
  const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys20.PublicKey.hash);
8193
- return new import_codec_protobuf14.Stream(({ next, ctx }) => {
8274
+ return new import_stream12.Stream(({ next, ctx }) => {
8194
8275
  const pushUpdateTask = new import_async25.UpdateScheduler(ctx, async () => {
8195
8276
  const contacts = await this.getContacts();
8196
8277
  next(contacts);
@@ -8259,7 +8340,7 @@ var LoggingServiceImpl = class {
8259
8340
  stats: (0, import_util16.numericalValues)(events, "duration")
8260
8341
  };
8261
8342
  };
8262
- return new import_codec_protobuf15.Stream(({ next }) => {
8343
+ return new import_stream13.Stream(({ next }) => {
8263
8344
  const update = () => {
8264
8345
  const metrics2 = {
8265
8346
  timestamp: /* @__PURE__ */ new Date(),
@@ -8281,7 +8362,7 @@ var LoggingServiceImpl = class {
8281
8362
  });
8282
8363
  }
8283
8364
  queryLogs(request) {
8284
- return new import_codec_protobuf15.Stream(({ ctx, next }) => {
8365
+ return new import_stream13.Stream(({ ctx, next }) => {
8285
8366
  const handler = (entry2) => {
8286
8367
  if (LOG_PROCESSING > 0) {
8287
8368
  return;
@@ -8341,7 +8422,7 @@ var NetworkServiceImpl = class {
8341
8422
  this.signalManager = signalManager;
8342
8423
  }
8343
8424
  queryStatus() {
8344
- return new import_codec_protobuf16.Stream(({ next }) => {
8425
+ return new import_stream14.Stream(({ next }) => {
8345
8426
  const update = () => {
8346
8427
  next({
8347
8428
  swarm: this.networkManager.connectionState,
@@ -8371,7 +8452,7 @@ var NetworkServiceImpl = class {
8371
8452
  return this.signalManager.leave(request);
8372
8453
  }
8373
8454
  subscribeSwarmState(request) {
8374
- return new import_codec_protobuf16.Stream(({ next }) => {
8455
+ return new import_stream14.Stream(({ next }) => {
8375
8456
  const unsubscribe = this.signalManager.swarmState?.on((state) => {
8376
8457
  if (request.topic.equals(state.swarmKey)) {
8377
8458
  next(state);
@@ -8384,7 +8465,7 @@ var NetworkServiceImpl = class {
8384
8465
  return this.signalManager.sendMessage(message);
8385
8466
  }
8386
8467
  subscribeMessages(peer) {
8387
- return new import_codec_protobuf16.Stream(({ next }) => {
8468
+ return new import_stream14.Stream(({ next }) => {
8388
8469
  const unsubscribe = this.signalManager.onMessage.on((message) => {
8389
8470
  if (message.recipient.peerKey === peer.peerKey) {
8390
8471
  next(message);
@@ -8427,7 +8508,7 @@ var SystemServiceImpl = class {
8427
8508
  }
8428
8509
  // TODO(burdon): Standardize interval option in stream request?
8429
8510
  queryStatus({ interval = 3e3 } = {}) {
8430
- return new import_codec_protobuf17.Stream(({ next }) => {
8511
+ return new import_stream15.Stream(({ next }) => {
8431
8512
  const update = () => {
8432
8513
  next({
8433
8514
  status: this._getCurrentStatus()
@@ -8893,4 +8974,4 @@ ClientServicesHost = _ts_decorate11([
8893
8974
  subscribeToSpaces,
8894
8975
  subscribeToSwarmInfo
8895
8976
  });
8896
- //# sourceMappingURL=chunk-LKVY5GQC.cjs.map
8977
+ //# sourceMappingURL=chunk-F7R4IRLD.cjs.map