@dxos/client-services 0.7.4 → 0.7.5-labs.071a3e2

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 (96) hide show
  1. package/dist/lib/browser/{chunk-423GRVVV.mjs → chunk-SKOL3Q2R.mjs} +379 -267
  2. package/dist/lib/browser/chunk-SKOL3Q2R.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-ZS24HRVA.cjs → chunk-XTM3FUCM.cjs} +405 -293
  7. package/dist/lib/node/chunk-XTM3FUCM.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-OQOXRHWF.mjs → chunk-EQU6BG5J.mjs} +379 -267
  12. package/dist/lib/node-esm/chunk-EQU6BG5J.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-service.d.ts +1 -1
  17. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
  19. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
  21. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  22. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  23. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  24. package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
  25. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
  27. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  28. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  30. package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
  31. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  32. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  33. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  34. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/identity-manager.d.ts +0 -3
  36. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  37. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +12 -4
  38. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  39. package/dist/types/src/packlets/identity/identity-service.d.ts +9 -4
  40. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  41. package/dist/types/src/packlets/identity/identity.d.ts +3 -1
  42. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  43. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  45. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  47. package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
  48. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  49. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  50. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  51. package/dist/types/src/packlets/network/network-service.d.ts +9 -2
  52. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  53. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  54. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  55. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
  56. package/dist/types/src/packlets/spaces/notarization-plugin.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/dist/types/src/version.d.ts.map +1 -1
  63. package/dist/types/tsconfig.tsbuildinfo +1 -0
  64. package/package.json +38 -38
  65. package/src/packlets/agents/edge-agent-service.ts +1 -1
  66. package/src/packlets/devices/devices-service.ts +1 -1
  67. package/src/packlets/devtools/devtools.ts +1 -1
  68. package/src/packlets/devtools/feeds.ts +1 -1
  69. package/src/packlets/devtools/keys.ts +1 -1
  70. package/src/packlets/devtools/metadata.ts +1 -1
  71. package/src/packlets/devtools/network.ts +1 -1
  72. package/src/packlets/devtools/spaces.ts +1 -1
  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 +39 -1
  87. package/src/packlets/services/service-context.ts +3 -1
  88. package/src/packlets/spaces/data-space-manager.ts +1 -1
  89. package/src/packlets/spaces/edge-feed-replicator.ts +16 -10
  90. package/src/packlets/spaces/notarization-plugin.ts +32 -17
  91. package/src/packlets/spaces/spaces-service.ts +31 -21
  92. package/src/packlets/system/system-service.ts +1 -1
  93. package/src/version.ts +1 -5
  94. package/dist/lib/browser/chunk-423GRVVV.mjs.map +0 -7
  95. package/dist/lib/node/chunk-ZS24HRVA.cjs.map +0 -7
  96. package/dist/lib/node-esm/chunk-OQOXRHWF.mjs.map +0 -7
@@ -2,7 +2,7 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
4
4
  import { EventSubscriptions } from "@dxos/async";
5
- import { Stream } from "@dxos/codec-protobuf";
5
+ import { Stream } from "@dxos/codec-protobuf/stream";
6
6
  import { FeedIterator } from "@dxos/feed-store";
7
7
  import { PublicKey } from "@dxos/keys";
8
8
  import { log } from "@dxos/log";
@@ -113,7 +113,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
113
113
  };
114
114
 
115
115
  // packages/sdk/client-services/src/packlets/devtools/network.ts
116
- import { Stream as Stream2 } from "@dxos/codec-protobuf";
116
+ import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
117
117
  import { Context } from "@dxos/context";
118
118
  import { PublicKey as PublicKey2 } from "@dxos/keys";
119
119
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
@@ -210,7 +210,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
210
210
  };
211
211
 
212
212
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
213
- import { Stream as Stream3 } from "@dxos/codec-protobuf";
213
+ import { Stream as Stream3 } from "@dxos/codec-protobuf/stream";
214
214
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
215
215
  return new Stream3(({ next }) => {
216
216
  let unsubscribe;
@@ -247,11 +247,11 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
247
247
 
248
248
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
249
249
  import { Event as AsyncEvent } from "@dxos/async";
250
- import { Stream as Stream6 } from "@dxos/codec-protobuf";
250
+ import { Stream as Stream6 } from "@dxos/codec-protobuf/stream";
251
251
 
252
252
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
253
253
  import { scheduleTask } from "@dxos/async";
254
- import { Stream as Stream4 } from "@dxos/codec-protobuf";
254
+ import { Stream as Stream4 } from "@dxos/codec-protobuf/stream";
255
255
  var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
256
256
  const update = async () => {
257
257
  next({
@@ -263,7 +263,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
263
263
  });
264
264
 
265
265
  // packages/sdk/client-services/src/packlets/devtools/metadata.ts
266
- import { Stream as Stream5 } from "@dxos/codec-protobuf";
266
+ import { Stream as Stream5 } from "@dxos/codec-protobuf/stream";
267
267
  var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
268
268
  context.metadataStore.update.on(ctx, (data) => next({
269
269
  metadata: data
@@ -390,14 +390,14 @@ var DevtoolsServiceImpl = class {
390
390
  // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
391
391
  import { asyncTimeout } from "@dxos/async";
392
392
  import { getFirstStreamValue } from "@dxos/codec-protobuf";
393
- import { credentialTypeFilter } from "@dxos/credentials";
393
+ import { createDidFromIdentityKey, credentialTypeFilter } from "@dxos/credentials";
394
394
  import { invariant } from "@dxos/invariant";
395
395
  import { STORAGE_VERSION } from "@dxos/protocols";
396
396
  import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.7.4";
400
+ var DXOS_VERSION = "0.7.5-labs.071a3e2";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -466,6 +466,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
466
466
  const identity = serviceContext.identityManager.identity;
467
467
  if (identity) {
468
468
  diagnostics.identity = {
469
+ did: identity.did,
469
470
  identityKey: identity.identityKey,
470
471
  spaceKey: identity.space.key,
471
472
  profile: identity.profileDocument
@@ -504,16 +505,17 @@ var getSpaceStats = async (space) => {
504
505
  ...credential.subject.assertion,
505
506
  id: credential.id
506
507
  })),
507
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
508
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => ({
508
509
  role: member.role,
509
510
  identity: {
511
+ did: await createDidFromIdentityKey(member.key),
510
512
  identityKey: member.key,
511
513
  profile: {
512
514
  displayName: member.assertion.profile?.displayName
513
515
  }
514
516
  },
515
517
  presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
516
- })),
518
+ }))),
517
519
  pipeline: {
518
520
  // TODO(burdon): Pick properties from credentials if needed.
519
521
  currentEpoch: space.automergeSpaceState.lastEpoch,
@@ -991,7 +993,7 @@ var EdgeFeedReplicator = class extends Resource {
991
993
  this._remoteLength.clear();
992
994
  }
993
995
  async addFeed(feed) {
994
- log4.info("addFeed", {
996
+ log4("addFeed", {
995
997
  key: feed.key,
996
998
  connected: this._connected,
997
999
  hasConnectionCtx: !!this._connectionCtx
@@ -1028,7 +1030,7 @@ var EdgeFeedReplicator = class extends Resource {
1028
1030
  }
1029
1031
  async _sendMessage(message) {
1030
1032
  if (!this._connectionCtx) {
1031
- log4.info("message dropped because connection was disposed", void 0, {
1033
+ log4("message dropped because connection was disposed", void 0, {
1032
1034
  F: __dxlog_file6,
1033
1035
  L: 146,
1034
1036
  S: this,
@@ -1036,21 +1038,20 @@ var EdgeFeedReplicator = class extends Resource {
1036
1038
  });
1037
1039
  return;
1038
1040
  }
1039
- const logPayload = message.type === "data" ? {
1040
- feedKey: message.feedKey,
1041
- blocks: message.blocks.map((b) => b.index)
1042
- } : {
1043
- message
1044
- };
1045
- log4.info("sending message", logPayload, {
1046
- F: __dxlog_file6,
1047
- L: 152,
1048
- S: this,
1049
- C: (f, a) => f(...a)
1050
- });
1041
+ if (message.type === "data") {
1042
+ log4("sending blocks", {
1043
+ feedKey: message.feedKey,
1044
+ blocks: message.blocks.map((b) => b.index)
1045
+ }, {
1046
+ F: __dxlog_file6,
1047
+ L: 151,
1048
+ S: this,
1049
+ C: (f, a) => f(...a)
1050
+ });
1051
+ }
1051
1052
  invariant2(message.feedKey, void 0, {
1052
1053
  F: __dxlog_file6,
1053
- L: 154,
1054
+ L: 157,
1054
1055
  S: this,
1055
1056
  A: [
1056
1057
  "message.feedKey",
@@ -1062,7 +1063,7 @@ var EdgeFeedReplicator = class extends Resource {
1062
1063
  type: message.type
1063
1064
  }, {
1064
1065
  F: __dxlog_file6,
1065
- L: 157,
1066
+ L: 160,
1066
1067
  S: this,
1067
1068
  C: (f, a) => f(...a)
1068
1069
  });
@@ -1081,7 +1082,7 @@ var EdgeFeedReplicator = class extends Resource {
1081
1082
  if (!this._connectionCtx) {
1082
1083
  log4.warn("received message after connection context was disposed", void 0, {
1083
1084
  F: __dxlog_file6,
1084
- L: 172,
1085
+ L: 175,
1085
1086
  S: this,
1086
1087
  C: (f, a) => f(...a)
1087
1088
  });
@@ -1092,14 +1093,6 @@ var EdgeFeedReplicator = class extends Resource {
1092
1093
  case "metadata": {
1093
1094
  try {
1094
1095
  var _usingCtx = _using_ctx();
1095
- log4.info("received metadata", {
1096
- message
1097
- }, {
1098
- F: __dxlog_file6,
1099
- L: 178,
1100
- S: this,
1101
- C: (f, a) => f(...a)
1102
- });
1103
1096
  const feedKey = PublicKey3.fromHex(message.feedKey);
1104
1097
  const feed = this._feeds.get(feedKey);
1105
1098
  if (!feed) {
@@ -1107,7 +1100,7 @@ var EdgeFeedReplicator = class extends Resource {
1107
1100
  feedKey
1108
1101
  }, {
1109
1102
  F: __dxlog_file6,
1110
- L: 183,
1103
+ L: 184,
1111
1104
  S: this,
1112
1105
  C: (f, a) => f(...a)
1113
1106
  });
@@ -1115,7 +1108,18 @@ var EdgeFeedReplicator = class extends Resource {
1115
1108
  }
1116
1109
  const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1117
1110
  this._remoteLength.set(feedKey, message.length);
1111
+ const logMeta = {
1112
+ localLength: feed.length,
1113
+ remoteLength: message.length,
1114
+ feedKey
1115
+ };
1118
1116
  if (message.length > feed.length) {
1117
+ log4("requesting missing blocks", logMeta, {
1118
+ F: __dxlog_file6,
1119
+ L: 194,
1120
+ S: this,
1121
+ C: (f, a) => f(...a)
1122
+ });
1119
1123
  await this._sendMessage({
1120
1124
  type: "request",
1121
1125
  feedKey: feedKey.toHex(),
@@ -1125,6 +1129,12 @@ var EdgeFeedReplicator = class extends Resource {
1125
1129
  }
1126
1130
  });
1127
1131
  } else if (message.length < feed.length) {
1132
+ log4("pushing blocks to remote", logMeta, {
1133
+ F: __dxlog_file6,
1134
+ L: 202,
1135
+ S: this,
1136
+ C: (f, a) => f(...a)
1137
+ });
1128
1138
  await this._pushBlocks(feed, message.length, feed.length);
1129
1139
  }
1130
1140
  break;
@@ -1135,12 +1145,12 @@ var EdgeFeedReplicator = class extends Resource {
1135
1145
  }
1136
1146
  }
1137
1147
  case "data": {
1138
- log4.info("received data", {
1148
+ log4("received data", {
1139
1149
  feed: message.feedKey,
1140
1150
  blocks: message.blocks.map((b) => b.index)
1141
1151
  }, {
1142
1152
  F: __dxlog_file6,
1143
- L: 205,
1153
+ L: 211,
1144
1154
  S: this,
1145
1155
  C: (f, a) => f(...a)
1146
1156
  });
@@ -1151,7 +1161,7 @@ var EdgeFeedReplicator = class extends Resource {
1151
1161
  feedKey
1152
1162
  }, {
1153
1163
  F: __dxlog_file6,
1154
- L: 210,
1164
+ L: 216,
1155
1165
  S: this,
1156
1166
  C: (f, a) => f(...a)
1157
1167
  });
@@ -1165,7 +1175,7 @@ var EdgeFeedReplicator = class extends Resource {
1165
1175
  ...message
1166
1176
  }, {
1167
1177
  F: __dxlog_file6,
1168
- L: 219,
1178
+ L: 225,
1169
1179
  S: this,
1170
1180
  C: (f, a) => f(...a)
1171
1181
  });
@@ -1174,13 +1184,13 @@ var EdgeFeedReplicator = class extends Resource {
1174
1184
  });
1175
1185
  }
1176
1186
  async _pushBlocks(feed, from, to) {
1177
- log4.info("pushing blocks", {
1187
+ log4("pushing blocks", {
1178
1188
  feed: feed.key.toHex(),
1179
1189
  from,
1180
1190
  to
1181
1191
  }, {
1182
1192
  F: __dxlog_file6,
1183
- L: 226,
1193
+ L: 232,
1184
1194
  S: this,
1185
1195
  C: (f, a) => f(...a)
1186
1196
  });
@@ -1190,7 +1200,7 @@ var EdgeFeedReplicator = class extends Resource {
1190
1200
  });
1191
1201
  invariant2(data instanceof Uint8Array, void 0, {
1192
1202
  F: __dxlog_file6,
1193
- L: 231,
1203
+ L: 237,
1194
1204
  S: this,
1195
1205
  A: [
1196
1206
  "data instanceof Uint8Array",
@@ -1213,12 +1223,12 @@ var EdgeFeedReplicator = class extends Resource {
1213
1223
  this._remoteLength.set(feed.key, to);
1214
1224
  }
1215
1225
  async _integrateBlocks(feed, blocks) {
1216
- log4.info("integrating blocks", {
1226
+ log4("integrating blocks", {
1217
1227
  feed: feed.key.toHex(),
1218
1228
  blocks: blocks.length
1219
1229
  }, {
1220
1230
  F: __dxlog_file6,
1221
- L: 252,
1231
+ L: 258,
1222
1232
  S: this,
1223
1233
  C: (f, a) => f(...a)
1224
1234
  });
@@ -1240,7 +1250,7 @@ var EdgeFeedReplicator = class extends Resource {
1240
1250
  if (!this._remoteLength.has(feed.key)) {
1241
1251
  log4("blocks not pushed because remote length is unknown", void 0, {
1242
1252
  F: __dxlog_file6,
1243
- L: 273,
1253
+ L: 279,
1244
1254
  S: this,
1245
1255
  C: (f, a) => f(...a)
1246
1256
  });
@@ -1265,7 +1275,7 @@ var EdgeFeedReplicator = class extends Resource {
1265
1275
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1266
1276
  log4("resetting on reconnect", void 0, {
1267
1277
  F: __dxlog_file6,
1268
- L: 290,
1278
+ L: 296,
1269
1279
  S: this,
1270
1280
  C: (f, a) => f(...a)
1271
1281
  });
@@ -1276,7 +1286,7 @@ var EdgeFeedReplicator = class extends Resource {
1276
1286
  }
1277
1287
  }, {
1278
1288
  F: __dxlog_file6,
1279
- L: 284
1289
+ L: 290
1280
1290
  });
1281
1291
  return connectionCtx;
1282
1292
  }
@@ -1443,6 +1453,7 @@ var NotarizationPlugin = class extends Resource3 {
1443
1453
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1444
1454
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1445
1455
  this._activeEdgePollingIntervalHandle = void 0;
1456
+ this._activeEdgePollingEnabled = false;
1446
1457
  this._spaceId = params.spaceId;
1447
1458
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1448
1459
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1450,15 +1461,6 @@ var NotarizationPlugin = class extends Resource3 {
1450
1461
  }
1451
1462
  }
1452
1463
  setActiveEdgePollingEnabled(enabled) {
1453
- invariant4(this.isOpen, void 0, {
1454
- F: __dxlog_file8,
1455
- L: 109,
1456
- S: this,
1457
- A: [
1458
- "this.isOpen",
1459
- ""
1460
- ]
1461
- });
1462
1464
  const client = this._edgeClient;
1463
1465
  invariant4(client, void 0, {
1464
1466
  F: __dxlog_file8,
@@ -1469,30 +1471,30 @@ var NotarizationPlugin = class extends Resource3 {
1469
1471
  ""
1470
1472
  ]
1471
1473
  });
1472
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1473
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1474
- if (this._writer) {
1475
- this._notarizePendingEdgeCredentials(client, this._writer);
1476
- }
1477
- }, this._activeEdgePollingInterval);
1478
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1479
- clearInterval(this._activeEdgePollingIntervalHandle);
1480
- this._activeEdgePollingIntervalHandle = void 0;
1474
+ this._activeEdgePollingEnabled = enabled;
1475
+ if (this.isOpen) {
1476
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1477
+ this._startPeriodicEdgePolling(client);
1478
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1479
+ this._stopPeriodicEdgePolling();
1480
+ }
1481
1481
  }
1482
1482
  }
1483
1483
  get hasWriter() {
1484
1484
  return !!this._writer;
1485
1485
  }
1486
1486
  async _open() {
1487
- if (this._edgeClient && this._writer) {
1488
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1487
+ if (this._edgeClient) {
1488
+ if (this._activeEdgePollingEnabled) {
1489
+ this._startPeriodicEdgePolling(this._edgeClient);
1490
+ }
1491
+ if (this._writer) {
1492
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1493
+ }
1489
1494
  }
1490
1495
  }
1491
1496
  async _close() {
1492
- if (this._activeEdgePollingIntervalHandle) {
1493
- clearInterval(this._activeEdgePollingIntervalHandle);
1494
- this._activeEdgePollingIntervalHandle = void 0;
1495
- }
1497
+ this._stopPeriodicEdgePolling();
1496
1498
  await this._ctx.dispose();
1497
1499
  }
1498
1500
  /**
@@ -1670,10 +1672,23 @@ var NotarizationPlugin = class extends Resource3 {
1670
1672
  ]
1671
1673
  });
1672
1674
  this._writer = writer;
1673
- if (this._edgeClient) {
1675
+ if (this._edgeClient && this.isOpen) {
1674
1676
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1675
1677
  }
1676
1678
  }
1679
+ _startPeriodicEdgePolling(client) {
1680
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1681
+ if (this._writer) {
1682
+ this._notarizePendingEdgeCredentials(client, this._writer);
1683
+ }
1684
+ }, this._activeEdgePollingInterval);
1685
+ }
1686
+ _stopPeriodicEdgePolling() {
1687
+ if (this._activeEdgePollingIntervalHandle) {
1688
+ clearInterval(this._activeEdgePollingIntervalHandle);
1689
+ this._activeEdgePollingIntervalHandle = void 0;
1690
+ }
1691
+ }
1677
1692
  /**
1678
1693
  * The method is used only for adding agent feeds to spaces.
1679
1694
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1692,7 +1707,7 @@ var NotarizationPlugin = class extends Resource3 {
1692
1707
  if (!credentials.length) {
1693
1708
  log5("edge did not return credentials for notarization", void 0, {
1694
1709
  F: __dxlog_file8,
1695
- L: 296,
1710
+ L: 311,
1696
1711
  S: this,
1697
1712
  C: (f, a) => f(...a)
1698
1713
  });
@@ -1702,7 +1717,7 @@ var NotarizationPlugin = class extends Resource3 {
1702
1717
  count: credentials.length
1703
1718
  }, {
1704
1719
  F: __dxlog_file8,
1705
- L: 300,
1720
+ L: 315,
1706
1721
  S: this,
1707
1722
  C: (f, a) => f(...a)
1708
1723
  });
@@ -1715,7 +1730,7 @@ var NotarizationPlugin = class extends Resource3 {
1715
1730
  count: decodedCredentials.length
1716
1731
  }, {
1717
1732
  F: __dxlog_file8,
1718
- L: 309,
1733
+ L: 324,
1719
1734
  S: this,
1720
1735
  C: (f, a) => f(...a)
1721
1736
  });
@@ -1743,7 +1758,7 @@ var NotarizationPlugin = class extends Resource3 {
1743
1758
  for (const credential of credentials) {
1744
1759
  invariant4(credential.id, "Credential must have an id", {
1745
1760
  F: __dxlog_file8,
1746
- L: 335,
1761
+ L: 350,
1747
1762
  S: this,
1748
1763
  A: [
1749
1764
  "credential.id",
@@ -1767,7 +1782,7 @@ var NotarizationPlugin = class extends Resource3 {
1767
1782
  peer: extension.localPeerId
1768
1783
  }, {
1769
1784
  F: __dxlog_file8,
1770
- L: 350,
1785
+ L: 365,
1771
1786
  S: this,
1772
1787
  C: (f, a) => f(...a)
1773
1788
  });
@@ -1779,7 +1794,7 @@ var NotarizationPlugin = class extends Resource3 {
1779
1794
  peer: extension.localPeerId
1780
1795
  }, {
1781
1796
  F: __dxlog_file8,
1782
- L: 355,
1797
+ L: 370,
1783
1798
  S: this,
1784
1799
  C: (f, a) => f(...a)
1785
1800
  });
@@ -1796,7 +1811,7 @@ var NotarizationPlugin = class extends Resource3 {
1796
1811
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1797
1812
  }, {
1798
1813
  F: __dxlog_file8,
1799
- L: 367,
1814
+ L: 382,
1800
1815
  S: this,
1801
1816
  C: (f, a) => f(...a)
1802
1817
  });
@@ -1812,7 +1827,7 @@ var handleEdgeError = (error) => {
1812
1827
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1813
1828
  log5.catch(error, void 0, {
1814
1829
  F: __dxlog_file8,
1815
- L: 381,
1830
+ L: 396,
1816
1831
  S: void 0,
1817
1832
  C: (f, a) => f(...a)
1818
1833
  });
@@ -1821,7 +1836,7 @@ var handleEdgeError = (error) => {
1821
1836
  reason: error.reason
1822
1837
  }, {
1823
1838
  F: __dxlog_file8,
1824
- L: 383,
1839
+ L: 398,
1825
1840
  S: void 0,
1826
1841
  C: (f, a) => f(...a)
1827
1842
  });
@@ -2635,7 +2650,7 @@ var DataSpaceManager = class extends Resource4 {
2635
2650
  guestKeypair: invitation.guestKey ? {
2636
2651
  publicKey: invitation.guestKey
2637
2652
  } : void 0,
2638
- lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
2653
+ lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
2639
2654
  multiUse: invitation.multiUse,
2640
2655
  delegationCredentialId: credentialId,
2641
2656
  persistent: false
@@ -2662,8 +2677,8 @@ DataSpaceManager = _ts_decorate3([
2662
2677
 
2663
2678
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2664
2679
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
2665
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
2666
- import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2680
+ import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
2681
+ import { createAdmissionCredentials as createAdmissionCredentials2, createDidFromIdentityKey as createDidFromIdentityKey2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2667
2682
  import { raise } from "@dxos/debug";
2668
2683
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2669
2684
  import { invariant as invariant6 } from "@dxos/invariant";
@@ -2719,7 +2734,7 @@ var SpacesServiceImpl = class {
2719
2734
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2720
2735
  invariant6(credentials[0].credential, void 0, {
2721
2736
  F: __dxlog_file11,
2722
- L: 106,
2737
+ L: 111,
2723
2738
  S: this,
2724
2739
  A: [
2725
2740
  "credentials[0].credential",
@@ -2729,7 +2744,7 @@ var SpacesServiceImpl = class {
2729
2744
  const spaceMemberCredential = credentials[0].credential.credential;
2730
2745
  invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2731
2746
  F: __dxlog_file11,
2732
- L: 108,
2747
+ L: 113,
2733
2748
  S: this,
2734
2749
  A: [
2735
2750
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2742,12 +2757,12 @@ var SpacesServiceImpl = class {
2742
2757
  return new Stream7(({ next, ctx }) => {
2743
2758
  const scheduler = new UpdateScheduler(ctx, async () => {
2744
2759
  const dataSpaceManager = await this._getDataSpaceManager();
2745
- const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2760
+ const spaces = await Promise.all(Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space)));
2746
2761
  log8("update", () => ({
2747
2762
  ids: spaces.map((space) => space.id)
2748
2763
  }), {
2749
2764
  F: __dxlog_file11,
2750
- L: 119,
2765
+ L: 126,
2751
2766
  S: this,
2752
2767
  C: (f, a) => f(...a)
2753
2768
  });
@@ -2839,7 +2854,7 @@ var SpacesServiceImpl = class {
2839
2854
  } else {
2840
2855
  invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
2841
2856
  F: __dxlog_file11,
2842
- L: 217,
2857
+ L: 224,
2843
2858
  S: this,
2844
2859
  A: [
2845
2860
  "!credential.id",
@@ -2848,7 +2863,7 @@ var SpacesServiceImpl = class {
2848
2863
  });
2849
2864
  invariant6(this._identityManager.identity, "Identity is not available", {
2850
2865
  F: __dxlog_file11,
2851
- L: 218,
2866
+ L: 225,
2852
2867
  S: this,
2853
2868
  A: [
2854
2869
  "this._identityManager.identity",
@@ -2858,7 +2873,7 @@ var SpacesServiceImpl = class {
2858
2873
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2859
2874
  invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
2860
2875
  F: __dxlog_file11,
2861
- L: 220,
2876
+ L: 227,
2862
2877
  S: this,
2863
2878
  A: [
2864
2879
  "credential.issuer.equals(signer.getIssuer())",
@@ -2908,7 +2923,7 @@ var SpacesServiceImpl = class {
2908
2923
  const assertion = getCredentialAssertion3(credential);
2909
2924
  invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2910
2925
  F: __dxlog_file11,
2911
- L: 254,
2926
+ L: 261,
2912
2927
  S: this,
2913
2928
  A: [
2914
2929
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2918,7 +2933,7 @@ var SpacesServiceImpl = class {
2918
2933
  const myIdentity = this._identityManager.identity;
2919
2934
  invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2920
2935
  F: __dxlog_file11,
2921
- L: 256,
2936
+ L: 263,
2922
2937
  S: this,
2923
2938
  A: [
2924
2939
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2939,10 +2954,10 @@ var SpacesServiceImpl = class {
2939
2954
  });
2940
2955
  }
2941
2956
  return {
2942
- space: this._serializeSpace(dataSpace)
2957
+ space: await this._serializeSpace(dataSpace)
2943
2958
  };
2944
2959
  }
2945
- _serializeSpace(space) {
2960
+ async _serializeSpace(space) {
2946
2961
  return {
2947
2962
  id: space.id,
2948
2963
  spaceKey: space.key,
@@ -2962,7 +2977,7 @@ var SpacesServiceImpl = class {
2962
2977
  totalDataTimeframe: void 0,
2963
2978
  spaceRootUrl: space.databaseRoot?.url
2964
2979
  },
2965
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2980
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => {
2966
2981
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
2967
2982
  const isMe = this._identityManager.identity?.identityKey.equals(member.key);
2968
2983
  if (isMe) {
@@ -2970,6 +2985,7 @@ var SpacesServiceImpl = class {
2970
2985
  }
2971
2986
  return {
2972
2987
  identity: {
2988
+ did: await createDidFromIdentityKey2(member.key),
2973
2989
  identityKey: member.key,
2974
2990
  profile: member.profile ?? {}
2975
2991
  },
@@ -2977,7 +2993,7 @@ var SpacesServiceImpl = class {
2977
2993
  presence: peers.length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE,
2978
2994
  peerStates: peers
2979
2995
  };
2980
- }),
2996
+ })),
2981
2997
  creator: space.inner.spaceState.creator?.key,
2982
2998
  cache: space.cache,
2983
2999
  metrics: space.metrics,
@@ -3022,13 +3038,14 @@ var Identity = class {
3022
3038
  this.space = params.space;
3023
3039
  this._signer = params.signer;
3024
3040
  this._presence = params.presence;
3041
+ this.did = params.did;
3025
3042
  this.identityKey = params.identityKey;
3026
3043
  this.deviceKey = params.deviceKey;
3027
3044
  log9.trace("dxos.halo.device", {
3028
3045
  deviceKey: params.deviceKey
3029
3046
  }, {
3030
3047
  F: __dxlog_file12,
3031
- L: 79,
3048
+ L: 82,
3032
3049
  S: this,
3033
3050
  C: (f, a) => f(...a)
3034
3051
  });
@@ -3130,7 +3147,7 @@ var Identity = class {
3130
3147
  getIdentityCredentialSigner() {
3131
3148
  invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3132
3149
  F: __dxlog_file12,
3133
- L: 195,
3150
+ L: 198,
3134
3151
  S: this,
3135
3152
  A: [
3136
3153
  "this._deviceStateMachine.deviceCredentialChain",
@@ -3174,7 +3191,7 @@ var Identity = class {
3174
3191
  dataFeedKey
3175
3192
  }, {
3176
3193
  F: __dxlog_file12,
3177
- L: 220,
3194
+ L: 223,
3178
3195
  S: this,
3179
3196
  C: (f, a) => f(...a)
3180
3197
  });
@@ -3231,7 +3248,7 @@ Identity = _ts_decorate4([
3231
3248
  import platform from "platform";
3232
3249
  import { Event as Event6 } from "@dxos/async";
3233
3250
  import { Context as Context4 } from "@dxos/context";
3234
- import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator, generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
3251
+ import { createCredentialSignerWithKey as createCredentialSignerWithKey2, createDidFromIdentityKey as createDidFromIdentityKey3, CredentialGenerator } from "@dxos/credentials";
3235
3252
  import { invariant as invariant8 } from "@dxos/invariant";
3236
3253
  import { PublicKey as PublicKey7 } from "@dxos/keys";
3237
3254
  import { log as log10 } from "@dxos/log";
@@ -3273,7 +3290,7 @@ var IdentityManager = class {
3273
3290
  id: traceId
3274
3291
  }), {
3275
3292
  F: __dxlog_file13,
3276
- L: 121,
3293
+ L: 116,
3277
3294
  S: this,
3278
3295
  C: (f, a) => f(...a)
3279
3296
  });
@@ -3282,7 +3299,7 @@ var IdentityManager = class {
3282
3299
  identityRecord
3283
3300
  }, {
3284
3301
  F: __dxlog_file13,
3285
- L: 124,
3302
+ L: 119,
3286
3303
  S: this,
3287
3304
  C: (f, a) => f(...a)
3288
3305
  });
@@ -3295,7 +3312,7 @@ var IdentityManager = class {
3295
3312
  displayName: this._identity.profileDocument?.displayName
3296
3313
  }, {
3297
3314
  F: __dxlog_file13,
3298
- L: 129,
3315
+ L: 124,
3299
3316
  S: this,
3300
3317
  C: (f, a) => f(...a)
3301
3318
  });
@@ -3305,7 +3322,7 @@ var IdentityManager = class {
3305
3322
  id: traceId
3306
3323
  }), {
3307
3324
  F: __dxlog_file13,
3308
- L: 136,
3325
+ L: 131,
3309
3326
  S: this,
3310
3327
  C: (f, a) => f(...a)
3311
3328
  });
@@ -3313,13 +3330,13 @@ var IdentityManager = class {
3313
3330
  async close() {
3314
3331
  await this._identity?.close(new Context4(void 0, {
3315
3332
  F: __dxlog_file13,
3316
- L: 140
3333
+ L: 135
3317
3334
  }));
3318
3335
  }
3319
3336
  async createIdentity({ displayName, deviceProfile } = {}) {
3320
3337
  invariant8(!this._identity, "Identity already exists.", {
3321
3338
  F: __dxlog_file13,
3322
- L: 145,
3339
+ L: 140,
3323
3340
  S: this,
3324
3341
  A: [
3325
3342
  "!this._identity",
@@ -3328,7 +3345,7 @@ var IdentityManager = class {
3328
3345
  });
3329
3346
  log10("creating identity...", void 0, {
3330
3347
  F: __dxlog_file13,
3331
- L: 146,
3348
+ L: 141,
3332
3349
  S: this,
3333
3350
  C: (f, a) => f(...a)
3334
3351
  });
@@ -3346,13 +3363,13 @@ var IdentityManager = class {
3346
3363
  const identity = await this._constructIdentity(identityRecord);
3347
3364
  await identity.open(new Context4(void 0, {
3348
3365
  F: __dxlog_file13,
3349
- L: 161
3366
+ L: 156
3350
3367
  }));
3351
3368
  {
3352
3369
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3353
3370
  invariant8(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3354
3371
  F: __dxlog_file13,
3355
- L: 165,
3372
+ L: 160,
3356
3373
  S: this,
3357
3374
  A: [
3358
3375
  "identityRecord.haloSpace.genesisFeedKey",
@@ -3361,7 +3378,7 @@ var IdentityManager = class {
3361
3378
  });
3362
3379
  invariant8(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3363
3380
  F: __dxlog_file13,
3364
- L: 166,
3381
+ L: 161,
3365
3382
  S: this,
3366
3383
  A: [
3367
3384
  "identityRecord.haloSpace.dataFeedKey",
@@ -3400,7 +3417,7 @@ var IdentityManager = class {
3400
3417
  displayName: this._identity.profileDocument?.displayName
3401
3418
  }, {
3402
3419
  F: __dxlog_file13,
3403
- L: 204,
3420
+ L: 199,
3404
3421
  S: this,
3405
3422
  C: (f, a) => f(...a)
3406
3423
  });
@@ -3411,7 +3428,7 @@ var IdentityManager = class {
3411
3428
  profile: identity.profileDocument
3412
3429
  }, {
3413
3430
  F: __dxlog_file13,
3414
- L: 210,
3431
+ L: 205,
3415
3432
  S: this,
3416
3433
  C: (f, a) => f(...a)
3417
3434
  });
@@ -3448,13 +3465,13 @@ var IdentityManager = class {
3448
3465
  params
3449
3466
  }, {
3450
3467
  F: __dxlog_file13,
3451
- L: 249,
3468
+ L: 244,
3452
3469
  S: this,
3453
3470
  C: (f, a) => f(...a)
3454
3471
  });
3455
3472
  invariant8(!this._identity, "Identity already exists.", {
3456
3473
  F: __dxlog_file13,
3457
- L: 250,
3474
+ L: 245,
3458
3475
  S: this,
3459
3476
  A: [
3460
3477
  "!this._identity",
@@ -3475,7 +3492,7 @@ var IdentityManager = class {
3475
3492
  const identity = await this._constructIdentity(identityRecord);
3476
3493
  await identity.open(new Context4(void 0, {
3477
3494
  F: __dxlog_file13,
3478
- L: 264
3495
+ L: 259
3479
3496
  }));
3480
3497
  return {
3481
3498
  identity,
@@ -3494,7 +3511,7 @@ var IdentityManager = class {
3494
3511
  displayName: this._identity.profileDocument?.displayName
3495
3512
  }, {
3496
3513
  F: __dxlog_file13,
3497
- L: 278,
3514
+ L: 273,
3498
3515
  S: this,
3499
3516
  C: (f, a) => f(...a)
3500
3517
  });
@@ -3508,7 +3525,7 @@ var IdentityManager = class {
3508
3525
  deviceKey: identity.deviceKey
3509
3526
  }, {
3510
3527
  F: __dxlog_file13,
3511
- L: 289,
3528
+ L: 284,
3512
3529
  S: this,
3513
3530
  C: (f, a) => f(...a)
3514
3531
  });
@@ -3519,7 +3536,7 @@ var IdentityManager = class {
3519
3536
  async updateProfile(profile) {
3520
3537
  invariant8(this._identity, "Identity not initialized.", {
3521
3538
  F: __dxlog_file13,
3522
- L: 296,
3539
+ L: 291,
3523
3540
  S: this,
3524
3541
  A: [
3525
3542
  "this._identity",
@@ -3550,7 +3567,7 @@ var IdentityManager = class {
3550
3567
  async updateDeviceProfile(profile) {
3551
3568
  invariant8(this._identity, "Identity not initialized.", {
3552
3569
  F: __dxlog_file13,
3553
- L: 313,
3570
+ L: 308,
3554
3571
  S: this,
3555
3572
  A: [
3556
3573
  "this._identity",
@@ -3583,48 +3600,10 @@ var IdentityManager = class {
3583
3600
  profile
3584
3601
  };
3585
3602
  }
3586
- async createRecoveryPhrase() {
3587
- const identity = this._identity;
3588
- invariant8(identity, void 0, {
3589
- F: __dxlog_file13,
3590
- L: 340,
3591
- S: this,
3592
- A: [
3593
- "identity",
3594
- ""
3595
- ]
3596
- });
3597
- const seedphrase = generateSeedPhrase();
3598
- const keypair = keyPairFromSeedPhrase(seedphrase);
3599
- const recoveryKey = PublicKey7.from(keypair.publicKey);
3600
- const identityKey = identity.identityKey;
3601
- const credential = await identity.getIdentityCredentialSigner().createCredential({
3602
- subject: identityKey,
3603
- assertion: {
3604
- "@type": "dxos.halo.credentials.IdentityRecovery",
3605
- recoveryKey,
3606
- identityKey
3607
- }
3608
- });
3609
- const receipt = await identity.controlPipeline.writer.write({
3610
- credential: {
3611
- credential
3612
- }
3613
- });
3614
- await identity.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
3615
- [
3616
- receipt.feedKey,
3617
- receipt.seq
3618
- ]
3619
- ]));
3620
- return {
3621
- seedphrase
3622
- };
3623
- }
3624
3603
  async _constructIdentity(identityRecord) {
3625
3604
  invariant8(!this._identity, void 0, {
3626
3605
  F: __dxlog_file13,
3627
- L: 362,
3606
+ L: 334,
3628
3607
  S: this,
3629
3608
  A: [
3630
3609
  "!this._identity",
@@ -3635,7 +3614,7 @@ var IdentityManager = class {
3635
3614
  identityRecord
3636
3615
  }, {
3637
3616
  F: __dxlog_file13,
3638
- L: 363,
3617
+ L: 335,
3639
3618
  S: this,
3640
3619
  C: (f, a) => f(...a)
3641
3620
  });
@@ -3650,7 +3629,7 @@ var IdentityManager = class {
3650
3629
  });
3651
3630
  invariant8(identityRecord.haloSpace.controlFeedKey, void 0, {
3652
3631
  F: __dxlog_file13,
3653
- L: 376,
3632
+ L: 348,
3654
3633
  S: this,
3655
3634
  A: [
3656
3635
  "identityRecord.haloSpace.controlFeedKey",
@@ -3662,7 +3641,7 @@ var IdentityManager = class {
3662
3641
  });
3663
3642
  invariant8(identityRecord.haloSpace.dataFeedKey, void 0, {
3664
3643
  F: __dxlog_file13,
3665
- L: 380,
3644
+ L: 352,
3666
3645
  S: this,
3667
3646
  A: [
3668
3647
  "identityRecord.haloSpace.dataFeedKey",
@@ -3686,10 +3665,12 @@ var IdentityManager = class {
3686
3665
  });
3687
3666
  await space.setControlFeed(controlFeed);
3688
3667
  await space.setDataFeed(dataFeed);
3668
+ const did = await createDidFromIdentityKey3(identityRecord.identityKey);
3689
3669
  const identity = new Identity({
3690
3670
  space,
3691
3671
  presence,
3692
3672
  signer: this._keyring,
3673
+ did,
3693
3674
  identityKey: identityRecord.identityKey,
3694
3675
  deviceKey: identityRecord.deviceKey,
3695
3676
  edgeConnection: this._edgeConnection,
@@ -3699,7 +3680,7 @@ var IdentityManager = class {
3699
3680
  identityKey: identityRecord.identityKey
3700
3681
  }, {
3701
3682
  F: __dxlog_file13,
3702
- L: 409,
3683
+ L: 383,
3703
3684
  S: this,
3704
3685
  C: (f, a) => f(...a)
3705
3686
  });
@@ -3724,7 +3705,7 @@ var IdentityManager = class {
3724
3705
  onAuthFailure: () => {
3725
3706
  log10.warn("auth failure", void 0, {
3726
3707
  F: __dxlog_file13,
3727
- L: 434,
3708
+ L: 408,
3728
3709
  S: this,
3729
3710
  C: (f, a) => f(...a)
3730
3711
  });
@@ -3748,7 +3729,7 @@ IdentityManager = _ts_decorate5([
3748
3729
 
3749
3730
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
3750
3731
  import { Trigger as Trigger4, sleep as sleep2 } from "@dxos/async";
3751
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
3732
+ import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
3752
3733
  import { Resource as Resource5 } from "@dxos/context";
3753
3734
  import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
3754
3735
  import { invariant as invariant9 } from "@dxos/invariant";
@@ -3787,7 +3768,7 @@ var IdentityServiceImpl = class extends Resource5 {
3787
3768
  const identity = this._identityManager.identity;
3788
3769
  invariant9(identity, void 0, {
3789
3770
  F: __dxlog_file14,
3790
- L: 60,
3771
+ L: 61,
3791
3772
  S: this,
3792
3773
  A: [
3793
3774
  "identity",
@@ -3810,6 +3791,7 @@ var IdentityServiceImpl = class extends Resource5 {
3810
3791
  return void 0;
3811
3792
  }
3812
3793
  return {
3794
+ did: this._identityManager.identity.did,
3813
3795
  identityKey: this._identityManager.identity.identityKey,
3814
3796
  spaceKey: this._identityManager.identity.space.key,
3815
3797
  profile: this._identityManager.identity.profileDocument
@@ -3818,7 +3800,7 @@ var IdentityServiceImpl = class extends Resource5 {
3818
3800
  async updateProfile(profile) {
3819
3801
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3820
3802
  F: __dxlog_file14,
3821
- L: 86,
3803
+ L: 88,
3822
3804
  S: this,
3823
3805
  A: [
3824
3806
  "this._identityManager.identity",
@@ -3829,18 +3811,29 @@ var IdentityServiceImpl = class extends Resource5 {
3829
3811
  await this._onProfileUpdate?.(this._identityManager.identity.profileDocument);
3830
3812
  return this._getIdentity();
3831
3813
  }
3832
- async createRecoveryPhrase() {
3833
- return this._recoveryManager.createRecoveryPhrase();
3814
+ async createRecoveryCredential(request) {
3815
+ return this._recoveryManager.createRecoveryCredential(request);
3816
+ }
3817
+ async requestRecoveryChallenge() {
3818
+ return this._recoveryManager.requestRecoveryChallenge();
3834
3819
  }
3835
3820
  async recoverIdentity(request) {
3836
- await this._recoveryManager.recoverIdentity(request);
3821
+ if (request.recoveryCode) {
3822
+ await this._recoveryManager.recoverIdentity({
3823
+ recoveryCode: request.recoveryCode
3824
+ });
3825
+ } else if (request.external) {
3826
+ await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
3827
+ } else {
3828
+ throw new Error("Invalid request.");
3829
+ }
3837
3830
  return this._getIdentity();
3838
3831
  }
3839
3832
  // TODO(burdon): Rename createPresentation?
3840
3833
  async signPresentation({ presentation, nonce }) {
3841
3834
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3842
3835
  F: __dxlog_file14,
3843
- L: 103,
3836
+ L: 116,
3844
3837
  S: this,
3845
3838
  A: [
3846
3839
  "this._identityManager.identity",
@@ -3859,7 +3852,7 @@ var IdentityServiceImpl = class extends Resource5 {
3859
3852
  const identity = this._identityManager.identity;
3860
3853
  invariant9(identity, "Identity not initialized.", {
3861
3854
  F: __dxlog_file14,
3862
- L: 117,
3855
+ L: 130,
3863
3856
  S: this,
3864
3857
  A: [
3865
3858
  "identity",
@@ -3897,7 +3890,7 @@ var IdentityServiceImpl = class extends Resource5 {
3897
3890
  duplicate: space.id
3898
3891
  }, {
3899
3892
  F: __dxlog_file14,
3900
- L: 151,
3893
+ L: 164,
3901
3894
  S: this,
3902
3895
  C: (f, a) => f(...a)
3903
3896
  });
@@ -3911,7 +3904,7 @@ var IdentityServiceImpl = class extends Resource5 {
3911
3904
  }, (err) => {
3912
3905
  log11.catch(err, void 0, {
3913
3906
  F: __dxlog_file14,
3914
- L: 162,
3907
+ L: 175,
3915
3908
  S: this,
3916
3909
  C: (f, a) => f(...a)
3917
3910
  });
@@ -4692,14 +4685,14 @@ var DeviceInvitationProtocol = class {
4692
4685
 
4693
4686
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
4694
4687
  import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
4695
- import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
4688
+ import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
4696
4689
  import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
4697
4690
  import { createKeyPair, sign as sign2 } from "@dxos/crypto";
4698
4691
  import { invariant as invariant15 } from "@dxos/invariant";
4699
4692
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4700
4693
  import { log as log18 } from "@dxos/log";
4701
4694
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
4702
- import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4695
+ import { InvalidInvitationError, InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4703
4696
  import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
4704
4697
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
4705
4698
  import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
@@ -4722,6 +4715,12 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
4722
4715
  var stateToString = (state) => {
4723
4716
  return Object.entries(Invitation3.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4724
4717
  };
4718
+ var computeExpirationTime = (invitation) => {
4719
+ if (!invitation.lifetime) {
4720
+ return;
4721
+ }
4722
+ return new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime * 1e3);
4723
+ };
4725
4724
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4726
4725
  let guard;
4727
4726
  return cancelWithContext3(ctx, (async () => {
@@ -5737,18 +5736,19 @@ var InvitationsHandler = class {
5737
5736
  });
5738
5737
  return extension;
5739
5738
  };
5740
- if (invitation.lifetime && invitation.created) {
5741
- if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5739
+ const expiresOn = getExpirationTime(invitation);
5740
+ if (expiresOn) {
5741
+ if (expiresOn.getTime() < Date.now()) {
5742
5742
  log18.warn("invitation has already expired", void 0, {
5743
5743
  F: __dxlog_file22,
5744
- L: 193,
5744
+ L: 194,
5745
5745
  S: this,
5746
5746
  C: (f, a) => f(...a)
5747
5747
  });
5748
5748
  guardedState.set(null, Invitation7.State.EXPIRED);
5749
5749
  void ctx.dispose().catch((err) => log18.catch(err, void 0, {
5750
5750
  F: __dxlog_file22,
5751
- L: 195,
5751
+ L: 196,
5752
5752
  S: this,
5753
5753
  C: (f, a) => f(...a)
5754
5754
  }));
@@ -5759,7 +5759,7 @@ var InvitationsHandler = class {
5759
5759
  guardedState.set(null, Invitation7.State.EXPIRED);
5760
5760
  metrics.increment("dxos.invitation.expired");
5761
5761
  await ctx.dispose();
5762
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5762
+ }, expiresOn.getTime() - Date.now());
5763
5763
  }
5764
5764
  let swarmConnection;
5765
5765
  scheduleTask7(ctx, async () => {
@@ -5775,7 +5775,7 @@ var InvitationsHandler = class {
5775
5775
  type: invitation.type
5776
5776
  }, {
5777
5777
  F: __dxlog_file22,
5778
- L: 226,
5778
+ L: 227,
5779
5779
  S: this,
5780
5780
  C: (f, a) => f(...a)
5781
5781
  });
@@ -5783,7 +5783,7 @@ var InvitationsHandler = class {
5783
5783
  if (deviceProfile) {
5784
5784
  invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5785
5785
  F: __dxlog_file22,
5786
- L: 235,
5786
+ L: 236,
5787
5787
  S: this,
5788
5788
  A: [
5789
5789
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5801,7 +5801,7 @@ var InvitationsHandler = class {
5801
5801
  triedPeers: triedPeersIds.size
5802
5802
  }, {
5803
5803
  F: __dxlog_file22,
5804
- L: 243,
5804
+ L: 244,
5805
5805
  S: this,
5806
5806
  C: (f, a) => f(...a)
5807
5807
  });
@@ -5828,7 +5828,7 @@ var InvitationsHandler = class {
5828
5828
  currentState: guardedState.current.state
5829
5829
  }, {
5830
5830
  F: __dxlog_file22,
5831
- L: 271,
5831
+ L: 272,
5832
5832
  S: this,
5833
5833
  C: (f, a) => f(...a)
5834
5834
  });
@@ -5846,7 +5846,7 @@ var InvitationsHandler = class {
5846
5846
  id: traceId
5847
5847
  }), {
5848
5848
  F: __dxlog_file22,
5849
- L: 283,
5849
+ L: 284,
5850
5850
  S: this,
5851
5851
  C: (f, a) => f(...a)
5852
5852
  });
@@ -5858,7 +5858,7 @@ var InvitationsHandler = class {
5858
5858
  ...protocol.toJSON()
5859
5859
  }, {
5860
5860
  F: __dxlog_file22,
5861
- L: 294,
5861
+ L: 295,
5862
5862
  S: this,
5863
5863
  C: (f, a) => f(...a)
5864
5864
  });
@@ -5868,7 +5868,7 @@ var InvitationsHandler = class {
5868
5868
  ...protocol.toJSON()
5869
5869
  }, {
5870
5870
  F: __dxlog_file22,
5871
- L: 298,
5871
+ L: 299,
5872
5872
  S: this,
5873
5873
  C: (f, a) => f(...a)
5874
5874
  });
@@ -5882,7 +5882,7 @@ var InvitationsHandler = class {
5882
5882
  authMethod: introductionResponse.authMethod
5883
5883
  }, {
5884
5884
  F: __dxlog_file22,
5885
- L: 306,
5885
+ L: 307,
5886
5886
  S: this,
5887
5887
  C: (f, a) => f(...a)
5888
5888
  });
@@ -5904,7 +5904,7 @@ var InvitationsHandler = class {
5904
5904
  ...protocol.toJSON()
5905
5905
  }, {
5906
5906
  F: __dxlog_file22,
5907
- L: 336,
5907
+ L: 337,
5908
5908
  S: this,
5909
5909
  C: (f, a) => f(...a)
5910
5910
  });
@@ -5917,7 +5917,7 @@ var InvitationsHandler = class {
5917
5917
  ...protocol.toJSON()
5918
5918
  }, {
5919
5919
  F: __dxlog_file22,
5920
- L: 350,
5920
+ L: 351,
5921
5921
  S: this,
5922
5922
  C: (f, a) => f(...a)
5923
5923
  });
@@ -5930,7 +5930,7 @@ var InvitationsHandler = class {
5930
5930
  id: traceId
5931
5931
  }), {
5932
5932
  F: __dxlog_file22,
5933
- L: 359,
5933
+ L: 360,
5934
5934
  S: this,
5935
5935
  C: (f, a) => f(...a)
5936
5936
  });
@@ -5940,7 +5940,7 @@ var InvitationsHandler = class {
5940
5940
  ...protocol.toJSON()
5941
5941
  }, {
5942
5942
  F: __dxlog_file22,
5943
- L: 362,
5943
+ L: 363,
5944
5944
  S: this,
5945
5945
  C: (f, a) => f(...a)
5946
5946
  });
@@ -5948,7 +5948,7 @@ var InvitationsHandler = class {
5948
5948
  } else {
5949
5949
  log18.verbose("auth failed", err, {
5950
5950
  F: __dxlog_file22,
5951
- L: 365,
5951
+ L: 366,
5952
5952
  S: this,
5953
5953
  C: (f, a) => f(...a)
5954
5954
  });
@@ -5960,7 +5960,7 @@ var InvitationsHandler = class {
5960
5960
  error: err
5961
5961
  }), {
5962
5962
  F: __dxlog_file22,
5963
- L: 369,
5963
+ L: 370,
5964
5964
  S: this,
5965
5965
  C: (f, a) => f(...a)
5966
5966
  });
@@ -5976,7 +5976,7 @@ var InvitationsHandler = class {
5976
5976
  ...protocol.toJSON()
5977
5977
  }, {
5978
5978
  F: __dxlog_file22,
5979
- L: 378,
5979
+ L: 379,
5980
5980
  S: this,
5981
5981
  C: (f, a) => f(...a)
5982
5982
  });
@@ -5984,7 +5984,7 @@ var InvitationsHandler = class {
5984
5984
  } else {
5985
5985
  log18.verbose("auth failed", err, {
5986
5986
  F: __dxlog_file22,
5987
- L: 381,
5987
+ L: 382,
5988
5988
  S: this,
5989
5989
  C: (f, a) => f(...a)
5990
5990
  });
@@ -6001,7 +6001,7 @@ var InvitationsHandler = class {
6001
6001
  ...protocol.toJSON()
6002
6002
  }, {
6003
6003
  F: __dxlog_file22,
6004
- L: 393,
6004
+ L: 394,
6005
6005
  S: this,
6006
6006
  C: (f, a) => f(...a)
6007
6007
  });
@@ -6014,14 +6014,14 @@ var InvitationsHandler = class {
6014
6014
  });
6015
6015
  edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
6016
6016
  scheduleTask7(ctx, async () => {
6017
- const error = protocol.checkInvitation(invitation);
6017
+ const error = checkInvitation(protocol, invitation);
6018
6018
  if (error) {
6019
6019
  stream.error(error);
6020
6020
  await ctx.dispose();
6021
6021
  } else {
6022
6022
  invariant15(invitation.swarmKey, void 0, {
6023
6023
  F: __dxlog_file22,
6024
- L: 405,
6024
+ L: 406,
6025
6025
  S: this,
6026
6026
  A: [
6027
6027
  "invitation.swarmKey",
@@ -6065,7 +6065,7 @@ var InvitationsHandler = class {
6065
6065
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6066
6066
  log18("guest waiting for authentication code...", void 0, {
6067
6067
  F: __dxlog_file22,
6068
- L: 457,
6068
+ L: 458,
6069
6069
  S: this,
6070
6070
  C: (f, a) => f(...a)
6071
6071
  });
@@ -6073,7 +6073,7 @@ var InvitationsHandler = class {
6073
6073
  const authCode = await authenticated.wait(options);
6074
6074
  log18("sending authentication request", void 0, {
6075
6075
  F: __dxlog_file22,
6076
- L: 461,
6076
+ L: 462,
6077
6077
  S: this,
6078
6078
  C: (f, a) => f(...a)
6079
6079
  });
@@ -6092,7 +6092,7 @@ var InvitationsHandler = class {
6092
6092
  attempt
6093
6093
  }, {
6094
6094
  F: __dxlog_file22,
6095
- L: 472,
6095
+ L: 473,
6096
6096
  S: this,
6097
6097
  C: (f, a) => f(...a)
6098
6098
  });
@@ -6110,7 +6110,7 @@ var InvitationsHandler = class {
6110
6110
  }
6111
6111
  log18("sending authentication request", void 0, {
6112
6112
  F: __dxlog_file22,
6113
- L: 491,
6113
+ L: 492,
6114
6114
  S: this,
6115
6115
  C: (f, a) => f(...a)
6116
6116
  });
@@ -6123,6 +6123,13 @@ var InvitationsHandler = class {
6123
6123
  }
6124
6124
  }
6125
6125
  };
6126
+ var checkInvitation = (protocol, invitation) => {
6127
+ const expiresOn = getExpirationTime(invitation);
6128
+ if (expiresOn && expiresOn.getTime() < Date.now()) {
6129
+ return new InvalidInvitationError("Invitation already expired.");
6130
+ }
6131
+ return protocol.checkInvitation(invitation);
6132
+ };
6126
6133
  var createAdmissionKeypair = () => {
6127
6134
  const keypair = createKeyPair();
6128
6135
  return {
@@ -6132,7 +6139,7 @@ var createAdmissionKeypair = () => {
6132
6139
  };
6133
6140
 
6134
6141
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
6135
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
6142
+ import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6136
6143
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6137
6144
  import { trace as trace8 } from "@dxos/tracing";
6138
6145
  var InvitationsServiceImpl = class {
@@ -6237,7 +6244,7 @@ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInv
6237
6244
  import { writeMessages as writeMessages4 } from "@dxos/feed-store";
6238
6245
  import { invariant as invariant16 } from "@dxos/invariant";
6239
6246
  import { log as log19 } from "@dxos/log";
6240
- import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6247
+ import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6241
6248
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6242
6249
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6243
6250
  var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
@@ -6257,7 +6264,7 @@ var SpaceInvitationProtocol = class {
6257
6264
  }
6258
6265
  checkCanInviteNewMembers() {
6259
6266
  if (this._spaceKey == null) {
6260
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6267
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6261
6268
  }
6262
6269
  const space = this._spaceManager.spaces.get(this._spaceKey);
6263
6270
  if (space == null) {
@@ -6271,7 +6278,7 @@ var SpaceInvitationProtocol = class {
6271
6278
  getInvitationContext() {
6272
6279
  invariant16(this._spaceKey, void 0, {
6273
6280
  F: __dxlog_file23,
6274
- L: 64,
6281
+ L: 65,
6275
6282
  S: this,
6276
6283
  A: [
6277
6284
  "this._spaceKey",
@@ -6281,7 +6288,7 @@ var SpaceInvitationProtocol = class {
6281
6288
  const space = this._spaceManager.spaces.get(this._spaceKey);
6282
6289
  invariant16(space, void 0, {
6283
6290
  F: __dxlog_file23,
6284
- L: 66,
6291
+ L: 67,
6285
6292
  S: this,
6286
6293
  A: [
6287
6294
  "space",
@@ -6297,7 +6304,7 @@ var SpaceInvitationProtocol = class {
6297
6304
  async admit(invitation, request, guestProfile) {
6298
6305
  invariant16(this._spaceKey && request.space, void 0, {
6299
6306
  F: __dxlog_file23,
6300
- L: 79,
6307
+ L: 80,
6301
6308
  S: this,
6302
6309
  A: [
6303
6310
  "this._spaceKey && request.space",
@@ -6309,7 +6316,7 @@ var SpaceInvitationProtocol = class {
6309
6316
  guest: request.space.deviceKey
6310
6317
  }, {
6311
6318
  F: __dxlog_file23,
6312
- L: 80,
6319
+ L: 81,
6313
6320
  S: this,
6314
6321
  C: (f, a) => f(...a)
6315
6322
  });
@@ -6331,7 +6338,7 @@ var SpaceInvitationProtocol = class {
6331
6338
  async delegate(invitation) {
6332
6339
  invariant16(this._spaceKey, void 0, {
6333
6340
  F: __dxlog_file23,
6334
- L: 100,
6341
+ L: 101,
6335
6342
  S: this,
6336
6343
  A: [
6337
6344
  "this._spaceKey",
@@ -6341,7 +6348,7 @@ var SpaceInvitationProtocol = class {
6341
6348
  const space = this._spaceManager.spaces.get(this._spaceKey);
6342
6349
  invariant16(space, void 0, {
6343
6350
  F: __dxlog_file23,
6344
- L: 102,
6351
+ L: 103,
6345
6352
  S: this,
6346
6353
  A: [
6347
6354
  "space",
@@ -6351,7 +6358,7 @@ var SpaceInvitationProtocol = class {
6351
6358
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6352
6359
  invariant16(invitation.guestKeypair?.publicKey, void 0, {
6353
6360
  F: __dxlog_file23,
6354
- L: 104,
6361
+ L: 105,
6355
6362
  S: this,
6356
6363
  A: [
6357
6364
  "invitation.guestKeypair?.publicKey",
@@ -6364,7 +6371,7 @@ var SpaceInvitationProtocol = class {
6364
6371
  id: invitation.invitationId
6365
6372
  }, {
6366
6373
  F: __dxlog_file23,
6367
- L: 107,
6374
+ L: 108,
6368
6375
  S: this,
6369
6376
  C: (f, a) => f(...a)
6370
6377
  });
@@ -6373,13 +6380,13 @@ var SpaceInvitationProtocol = class {
6373
6380
  authMethod: invitation.authMethod,
6374
6381
  swarmKey: invitation.swarmKey,
6375
6382
  role: invitation.role ?? SpaceMember6.Role.ADMIN,
6376
- expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
6383
+ expiresOn: computeExpirationTime(invitation),
6377
6384
  multiUse: invitation.multiUse ?? false,
6378
6385
  guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6379
6386
  });
6380
6387
  invariant16(credential.credential, void 0, {
6381
6388
  F: __dxlog_file23,
6382
- L: 127,
6389
+ L: 126,
6383
6390
  S: this,
6384
6391
  A: [
6385
6392
  "credential.credential",
@@ -6394,7 +6401,7 @@ var SpaceInvitationProtocol = class {
6394
6401
  async cancelDelegation(invitation) {
6395
6402
  invariant16(this._spaceKey, void 0, {
6396
6403
  F: __dxlog_file23,
6397
- L: 133,
6404
+ L: 132,
6398
6405
  S: this,
6399
6406
  A: [
6400
6407
  "this._spaceKey",
@@ -6403,7 +6410,7 @@ var SpaceInvitationProtocol = class {
6403
6410
  });
6404
6411
  invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6405
6412
  F: __dxlog_file23,
6406
- L: 134,
6413
+ L: 133,
6407
6414
  S: this,
6408
6415
  A: [
6409
6416
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6413,7 +6420,7 @@ var SpaceInvitationProtocol = class {
6413
6420
  const space = this._spaceManager.spaces.get(this._spaceKey);
6414
6421
  invariant16(space, void 0, {
6415
6422
  F: __dxlog_file23,
6416
- L: 136,
6423
+ L: 135,
6417
6424
  S: this,
6418
6425
  A: [
6419
6426
  "space",
@@ -6425,14 +6432,14 @@ var SpaceInvitationProtocol = class {
6425
6432
  id: invitation.invitationId
6426
6433
  }, {
6427
6434
  F: __dxlog_file23,
6428
- L: 138,
6435
+ L: 137,
6429
6436
  S: this,
6430
6437
  C: (f, a) => f(...a)
6431
6438
  });
6432
6439
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6433
6440
  invariant16(credential.credential, void 0, {
6434
6441
  F: __dxlog_file23,
6435
- L: 145,
6442
+ L: 144,
6436
6443
  S: this,
6437
6444
  A: [
6438
6445
  "credential.credential",
@@ -6445,7 +6452,7 @@ var SpaceInvitationProtocol = class {
6445
6452
  }
6446
6453
  checkInvitation(invitation) {
6447
6454
  if (invitation.spaceKey == null) {
6448
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6455
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6449
6456
  }
6450
6457
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6451
6458
  return new AlreadyJoinedError3("Already joined space.");
@@ -6471,7 +6478,7 @@ var SpaceInvitationProtocol = class {
6471
6478
  async accept(response) {
6472
6479
  invariant16(response.space, void 0, {
6473
6480
  F: __dxlog_file23,
6474
- L: 180,
6481
+ L: 179,
6475
6482
  S: this,
6476
6483
  A: [
6477
6484
  "response.space",
@@ -6482,7 +6489,7 @@ var SpaceInvitationProtocol = class {
6482
6489
  const assertion = getCredentialAssertion5(credential);
6483
6490
  invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6484
6491
  F: __dxlog_file23,
6485
- L: 183,
6492
+ L: 182,
6486
6493
  S: this,
6487
6494
  A: [
6488
6495
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -6491,7 +6498,7 @@ var SpaceInvitationProtocol = class {
6491
6498
  });
6492
6499
  invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6493
6500
  F: __dxlog_file23,
6494
- L: 184,
6501
+ L: 183,
6495
6502
  S: this,
6496
6503
  A: [
6497
6504
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6727,7 +6734,7 @@ var InvitationsManager = class {
6727
6734
  }
6728
6735
  }
6729
6736
  _createInvitation(protocol, _options) {
6730
- const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false, ...options } = _options ?? {};
6737
+ const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
6731
6738
  const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
6732
6739
  return {
6733
6740
  invitationId,
@@ -7314,7 +7321,7 @@ _ts_decorate9([
7314
7321
  ], EdgeAgentManager.prototype, "createAgent", null);
7315
7322
 
7316
7323
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7317
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
7324
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7318
7325
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7319
7326
  import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7320
7327
  var EdgeAgentServiceImpl = class {
@@ -7393,7 +7400,7 @@ import { trace as Trace3 } from "@dxos/tracing";
7393
7400
  import { safeInstanceof } from "@dxos/util";
7394
7401
 
7395
7402
  // packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts
7396
- import { generateSeedPhrase as generateSeedPhrase2, keyPairFromSeedPhrase as keyPairFromSeedPhrase2 } from "@dxos/credentials";
7403
+ import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
7397
7404
  import { sign as sign3 } from "@dxos/crypto";
7398
7405
  import { invariant as invariant19 } from "@dxos/invariant";
7399
7406
  import { PublicKey as PublicKey14 } from "@dxos/keys";
@@ -7409,27 +7416,41 @@ var EdgeIdentityRecoveryManager = class {
7409
7416
  this._identityProvider = _identityProvider;
7410
7417
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7411
7418
  }
7412
- async createRecoveryPhrase() {
7419
+ async createRecoveryCredential({ recoveryKey, algorithm }) {
7413
7420
  const identity = this._identityProvider();
7414
7421
  invariant19(identity, void 0, {
7415
7422
  F: __dxlog_file27,
7416
- L: 29,
7423
+ L: 37,
7417
7424
  S: this,
7418
7425
  A: [
7419
7426
  "identity",
7420
7427
  ""
7421
7428
  ]
7422
7429
  });
7423
- const seedphrase = generateSeedPhrase2();
7424
- const keypair = keyPairFromSeedPhrase2(seedphrase);
7425
- const recoveryKey = PublicKey14.from(keypair.publicKey);
7430
+ let recoveryCode;
7431
+ if (!recoveryKey) {
7432
+ recoveryCode = generateSeedPhrase();
7433
+ const keypair = keyPairFromSeedPhrase(recoveryCode);
7434
+ recoveryKey = PublicKey14.from(keypair.publicKey);
7435
+ algorithm = -8;
7436
+ }
7437
+ invariant19(algorithm, "Algorithm is required.", {
7438
+ F: __dxlog_file27,
7439
+ L: 47,
7440
+ S: this,
7441
+ A: [
7442
+ "algorithm",
7443
+ "'Algorithm is required.'"
7444
+ ]
7445
+ });
7426
7446
  const identityKey = identity.identityKey;
7427
7447
  const credential = await identity.getIdentityCredentialSigner().createCredential({
7428
7448
  subject: identityKey,
7429
7449
  assertion: {
7430
7450
  "@type": "dxos.halo.credentials.IdentityRecovery",
7431
7451
  recoveryKey,
7432
- identityKey
7452
+ identityKey,
7453
+ algorithm
7433
7454
  }
7434
7455
  });
7435
7456
  const receipt = await identity.controlPipeline.writer.write({
@@ -7444,20 +7465,81 @@ var EdgeIdentityRecoveryManager = class {
7444
7465
  ]
7445
7466
  ]));
7446
7467
  return {
7447
- seedphrase
7468
+ recoveryCode
7448
7469
  };
7449
7470
  }
7450
- async recoverIdentity(args) {
7471
+ async requestRecoveryChallenge() {
7451
7472
  invariant19(this._edgeClient, "Not connected to EDGE.", {
7452
7473
  F: __dxlog_file27,
7453
- L: 51,
7474
+ L: 66,
7454
7475
  S: this,
7455
7476
  A: [
7456
7477
  "this._edgeClient",
7457
7478
  "'Not connected to EDGE.'"
7458
7479
  ]
7459
7480
  });
7460
- const recoveryKeypair = keyPairFromSeedPhrase2(args.seedphrase);
7481
+ const deviceKey = await this._keyring.createKey();
7482
+ const controlFeedKey = await this._keyring.createKey();
7483
+ const request = {
7484
+ deviceKey: deviceKey.toHex(),
7485
+ controlFeedKey: controlFeedKey.toHex()
7486
+ };
7487
+ try {
7488
+ await this._edgeClient.recoverIdentity(request);
7489
+ throw new Error("No challenge received.");
7490
+ } catch (error) {
7491
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7492
+ throw error;
7493
+ }
7494
+ return {
7495
+ deviceKey,
7496
+ controlFeedKey,
7497
+ challenge: error.challenge
7498
+ };
7499
+ }
7500
+ }
7501
+ async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7502
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7503
+ F: __dxlog_file27,
7504
+ L: 98,
7505
+ S: this,
7506
+ A: [
7507
+ "this._edgeClient",
7508
+ "'Not connected to EDGE.'"
7509
+ ]
7510
+ });
7511
+ const request = {
7512
+ identityDid,
7513
+ deviceKey: deviceKey.toHex(),
7514
+ controlFeedKey: controlFeedKey.toHex(),
7515
+ signature: clientDataJson && authenticatorData ? {
7516
+ signature: Buffer.from(signature).toString("base64"),
7517
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7518
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7519
+ } : Buffer.from(signature).toString("base64")
7520
+ };
7521
+ const response = await this._edgeClient.recoverIdentity(request);
7522
+ await this._acceptRecoveredIdentity({
7523
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7524
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7525
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7526
+ identityKey: PublicKey14.fromHex(response.identityKey),
7527
+ deviceKey,
7528
+ controlFeedKey,
7529
+ dataFeedKey: await this._keyring.createKey()
7530
+ });
7531
+ }
7532
+ async recoverIdentity({ recoveryCode }) {
7533
+ invariant19(this._edgeClient, "Not connected to EDGE.", {
7534
+ F: __dxlog_file27,
7535
+ L: 128,
7536
+ S: this,
7537
+ A: [
7538
+ "this._edgeClient",
7539
+ "'Not connected to EDGE.'"
7540
+ ]
7541
+ });
7542
+ const recoveryKeypair = keyPairFromSeedPhrase(recoveryCode);
7461
7543
  const recoveryKey = PublicKey14.from(recoveryKeypair.publicKey);
7462
7544
  const deviceKey = await this._keyring.createKey();
7463
7545
  const controlFeedKey = await this._keyring.createKey();
@@ -7481,7 +7563,7 @@ var EdgeIdentityRecoveryManager = class {
7481
7563
  }
7482
7564
  log23.info("recovering identity", response, {
7483
7565
  F: __dxlog_file27,
7484
- L: 77,
7566
+ L: 154,
7485
7567
  S: this,
7486
7568
  C: (f, a) => f(...a)
7487
7569
  });
@@ -7622,7 +7704,8 @@ var ServiceContext = class extends Resource7 {
7622
7704
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7623
7705
  this.echoHost = new EchoHost({
7624
7706
  kv: this.level,
7625
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7707
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7708
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7626
7709
  });
7627
7710
  this._meshReplicator = new MeshEchoReplicator();
7628
7711
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7641,7 +7724,7 @@ var ServiceContext = class extends Resource7 {
7641
7724
  await this._checkStorageVersion();
7642
7725
  log24("opening...", void 0, {
7643
7726
  F: __dxlog_file28,
7644
- L: 198,
7727
+ L: 199,
7645
7728
  S: this,
7646
7729
  C: (f, a) => f(...a)
7647
7730
  });
@@ -7649,7 +7732,7 @@ var ServiceContext = class extends Resource7 {
7649
7732
  id: this._instanceId
7650
7733
  }), {
7651
7734
  F: __dxlog_file28,
7652
- L: 199,
7735
+ L: 200,
7653
7736
  S: this,
7654
7737
  C: (f, a) => f(...a)
7655
7738
  });
@@ -7676,7 +7759,7 @@ var ServiceContext = class extends Resource7 {
7676
7759
  count: loadedInvitations.invitations?.length
7677
7760
  }, {
7678
7761
  F: __dxlog_file28,
7679
- L: 227,
7762
+ L: 228,
7680
7763
  S: this,
7681
7764
  C: (f, a) => f(...a)
7682
7765
  });
@@ -7684,13 +7767,13 @@ var ServiceContext = class extends Resource7 {
7684
7767
  id: this._instanceId
7685
7768
  }), {
7686
7769
  F: __dxlog_file28,
7687
- L: 229,
7770
+ L: 230,
7688
7771
  S: this,
7689
7772
  C: (f, a) => f(...a)
7690
7773
  });
7691
7774
  log24("opened", void 0, {
7692
7775
  F: __dxlog_file28,
7693
- L: 230,
7776
+ L: 231,
7694
7777
  S: this,
7695
7778
  C: (f, a) => f(...a)
7696
7779
  });
@@ -7698,7 +7781,7 @@ var ServiceContext = class extends Resource7 {
7698
7781
  async _close(ctx) {
7699
7782
  log24("closing...", void 0, {
7700
7783
  F: __dxlog_file28,
7701
- L: 234,
7784
+ L: 235,
7702
7785
  S: this,
7703
7786
  C: (f, a) => f(...a)
7704
7787
  });
@@ -7717,7 +7800,7 @@ var ServiceContext = class extends Resource7 {
7717
7800
  await this._edgeConnection?.close();
7718
7801
  log24("closed", void 0, {
7719
7802
  F: __dxlog_file28,
7720
- L: 250,
7803
+ L: 251,
7721
7804
  S: this,
7722
7805
  C: (f, a) => f(...a)
7723
7806
  });
@@ -7728,7 +7811,7 @@ var ServiceContext = class extends Resource7 {
7728
7811
  await identity.joinNetwork();
7729
7812
  await this._initialize(new Context9(void 0, {
7730
7813
  F: __dxlog_file28,
7731
- L: 257
7814
+ L: 258
7732
7815
  }));
7733
7816
  return identity;
7734
7817
  }
@@ -7739,7 +7822,7 @@ var ServiceContext = class extends Resource7 {
7739
7822
  const factory = this._handlerFactories.get(invitation.kind);
7740
7823
  invariant20(factory, `Unknown invitation kind: ${invitation.kind}`, {
7741
7824
  F: __dxlog_file28,
7742
- L: 266,
7825
+ L: 267,
7743
7826
  S: this,
7744
7827
  A: [
7745
7828
  "factory",
@@ -7765,7 +7848,7 @@ var ServiceContext = class extends Resource7 {
7765
7848
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7766
7849
  await this._initialize(new Context9(void 0, {
7767
7850
  F: __dxlog_file28,
7768
- L: 285
7851
+ L: 286
7769
7852
  }));
7770
7853
  return identity;
7771
7854
  }
@@ -7779,7 +7862,7 @@ var ServiceContext = class extends Resource7 {
7779
7862
  async _initialize(ctx) {
7780
7863
  log24("initializing spaces...", void 0, {
7781
7864
  F: __dxlog_file28,
7782
- L: 300,
7865
+ L: 301,
7783
7866
  S: this,
7784
7867
  C: (f, a) => f(...a)
7785
7868
  });
@@ -7818,7 +7901,7 @@ var ServiceContext = class extends Resource7 {
7818
7901
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7819
7902
  invariant20(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7820
7903
  F: __dxlog_file28,
7821
- L: 338,
7904
+ L: 339,
7822
7905
  S: this,
7823
7906
  A: [
7824
7907
  "this.dataSpaceManager",
@@ -7842,7 +7925,7 @@ var ServiceContext = class extends Resource7 {
7842
7925
  details: assertion
7843
7926
  }, {
7844
7927
  F: __dxlog_file28,
7845
- L: 354,
7928
+ L: 355,
7846
7929
  S: this,
7847
7930
  C: (f, a) => f(...a)
7848
7931
  });
@@ -7853,7 +7936,7 @@ var ServiceContext = class extends Resource7 {
7853
7936
  details: assertion
7854
7937
  }, {
7855
7938
  F: __dxlog_file28,
7856
- L: 358,
7939
+ L: 359,
7857
7940
  S: this,
7858
7941
  C: (f, a) => f(...a)
7859
7942
  });
@@ -7864,7 +7947,7 @@ var ServiceContext = class extends Resource7 {
7864
7947
  details: assertion
7865
7948
  }, {
7866
7949
  F: __dxlog_file28,
7867
- L: 363,
7950
+ L: 364,
7868
7951
  S: this,
7869
7952
  C: (f, a) => f(...a)
7870
7953
  });
@@ -7875,7 +7958,7 @@ var ServiceContext = class extends Resource7 {
7875
7958
  } catch (err) {
7876
7959
  log24.catch(err, void 0, {
7877
7960
  F: __dxlog_file28,
7878
- L: 369,
7961
+ L: 370,
7879
7962
  S: this,
7880
7963
  C: (f, a) => f(...a)
7881
7964
  });
@@ -7891,12 +7974,12 @@ var ServiceContext = class extends Resource7 {
7891
7974
  let edgeIdentity;
7892
7975
  const identity = this.identityManager.identity;
7893
7976
  if (identity) {
7894
- log24.info("Setting identity on edge connection", {
7977
+ log24("setting identity on edge connection", {
7895
7978
  identity: identity.identityKey.toHex(),
7896
7979
  swarms: this.networkManager.topics
7897
7980
  }, {
7898
7981
  F: __dxlog_file28,
7899
- L: 383,
7982
+ L: 384,
7900
7983
  S: this,
7901
7984
  C: (f, a) => f(...a)
7902
7985
  });
@@ -7910,7 +7993,7 @@ var ServiceContext = class extends Resource7 {
7910
7993
  });
7911
7994
  invariant20(identity.deviceCredentialChain, void 0, {
7912
7995
  F: __dxlog_file28,
7913
- L: 401,
7996
+ L: 403,
7914
7997
  S: this,
7915
7998
  A: [
7916
7999
  "identity.deviceCredentialChain",
@@ -8220,7 +8303,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8220
8303
 
8221
8304
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
8222
8305
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
8223
- import { Stream as Stream12 } from "@dxos/codec-protobuf";
8306
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8224
8307
  import { invariant as invariant22 } from "@dxos/invariant";
8225
8308
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8226
8309
  var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
@@ -8310,7 +8393,7 @@ var DevicesServiceImpl = class {
8310
8393
 
8311
8394
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
8312
8395
  import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
8313
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
8396
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8314
8397
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8315
8398
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
8316
8399
  var ContactsServiceImpl = class {
@@ -8393,7 +8476,7 @@ var ContactsServiceImpl = class {
8393
8476
 
8394
8477
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
8395
8478
  import { Event as Event10 } from "@dxos/async";
8396
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
8479
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8397
8480
  import { PublicKey as PublicKey18 } from "@dxos/keys";
8398
8481
  import { getContextFromEntry, log as log26 } from "@dxos/log";
8399
8482
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
@@ -8516,7 +8599,7 @@ var shouldLog = (entry2, request) => {
8516
8599
  var LOG_PROCESSING = 0;
8517
8600
 
8518
8601
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8519
- import { Stream as Stream15 } from "@dxos/codec-protobuf";
8602
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8520
8603
  var NetworkServiceImpl = class {
8521
8604
  constructor(networkManager, signalManager) {
8522
8605
  this.networkManager = networkManager;
@@ -8546,10 +8629,39 @@ var NetworkServiceImpl = class {
8546
8629
  async updateConfig(request) {
8547
8630
  await this.networkManager.setConnectionState(request.swarm);
8548
8631
  }
8632
+ async joinSwarm(request) {
8633
+ return this.signalManager.join(request);
8634
+ }
8635
+ async leaveSwarm(request) {
8636
+ return this.signalManager.leave(request);
8637
+ }
8638
+ subscribeSwarmState(request) {
8639
+ return new Stream15(({ next }) => {
8640
+ const unsubscribe = this.signalManager.swarmState?.on((state) => {
8641
+ if (request.topic.equals(state.swarmKey)) {
8642
+ next(state);
8643
+ }
8644
+ });
8645
+ return unsubscribe;
8646
+ });
8647
+ }
8648
+ async sendMessage(message) {
8649
+ return this.signalManager.sendMessage(message);
8650
+ }
8651
+ subscribeMessages(peer) {
8652
+ return new Stream15(({ next }) => {
8653
+ const unsubscribe = this.signalManager.onMessage.on((message) => {
8654
+ if (message.recipient.peerKey === peer.peerKey) {
8655
+ next(message);
8656
+ }
8657
+ });
8658
+ return unsubscribe;
8659
+ });
8660
+ }
8549
8661
  };
8550
8662
 
8551
8663
  // packages/sdk/client-services/src/packlets/system/system-service.ts
8552
- import { Stream as Stream16 } from "@dxos/codec-protobuf";
8664
+ import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
8553
8665
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
8554
8666
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
8555
8667
  var SystemServiceImpl = class {
@@ -9053,4 +9165,4 @@ export {
9053
9165
  importProfileData,
9054
9166
  ClientServicesHost
9055
9167
  };
9056
- //# sourceMappingURL=chunk-423GRVVV.mjs.map
9168
+ //# sourceMappingURL=chunk-SKOL3Q2R.mjs.map