@dxos/client-services 0.4.10-main.fd8ea31 → 0.4.10-next.71cec10

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 (50) hide show
  1. package/dist/lib/browser/{chunk-WLE7E36I.mjs → chunk-5U7G5S73.mjs} +287 -355
  2. package/dist/lib/browser/chunk-5U7G5S73.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/packlets/testing/index.mjs +112 -125
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-YXZQQAQN.cjs → chunk-Y3ADPF24.cjs} +377 -445
  8. package/dist/lib/node/chunk-Y3ADPF24.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +43 -43
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +115 -125
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  14. package/dist/types/src/packlets/indexing/util.d.ts +5 -0
  15. package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
  16. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +1 -3
  17. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +1 -6
  19. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +2 -4
  21. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/invitations-manager.d.ts +7 -9
  23. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -2
  26. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  27. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  28. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -5
  29. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  30. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  31. package/dist/types/src/packlets/testing/test-builder.d.ts +0 -3
  32. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  33. package/dist/types/src/version.d.ts +1 -1
  34. package/package.json +34 -34
  35. package/src/packlets/identity/identity-manager.ts +0 -1
  36. package/src/packlets/identity/identity.test.ts +0 -3
  37. package/src/packlets/indexing/util.ts +65 -1
  38. package/src/packlets/invitations/device-invitation-protocol.ts +1 -6
  39. package/src/packlets/invitations/invitation-protocol.ts +1 -7
  40. package/src/packlets/invitations/invitations-handler.ts +71 -10
  41. package/src/packlets/invitations/invitations-manager.ts +40 -114
  42. package/src/packlets/invitations/invitations-service.ts +2 -4
  43. package/src/packlets/invitations/space-invitation-protocol.ts +3 -45
  44. package/src/packlets/services/service-context.ts +2 -3
  45. package/src/packlets/spaces/data-space-manager.ts +2 -48
  46. package/src/packlets/testing/invitation-utils.ts +97 -100
  47. package/src/packlets/testing/test-builder.ts +1 -19
  48. package/src/version.ts +1 -1
  49. package/dist/lib/browser/chunk-WLE7E36I.mjs.map +0 -7
  50. package/dist/lib/node/chunk-YXZQQAQN.cjs.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_YXZQQAQN_exports = {};
30
- __export(chunk_YXZQQAQN_exports, {
29
+ var chunk_Y3ADPF24_exports = {};
30
+ __export(chunk_Y3ADPF24_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -66,7 +66,7 @@ __export(chunk_YXZQQAQN_exports, {
66
66
  subscribeToSpaces: () => subscribeToSpaces,
67
67
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
68
68
  });
69
- module.exports = __toCommonJS(chunk_YXZQQAQN_exports);
69
+ module.exports = __toCommonJS(chunk_Y3ADPF24_exports);
70
70
  var import_async = require("@dxos/async");
71
71
  var import_codec_protobuf = require("@dxos/codec-protobuf");
72
72
  var import_feed_store = require("@dxos/feed-store");
@@ -120,6 +120,7 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
120
120
  var import_async7 = require("@dxos/async");
121
121
  var import_client_protocol2 = require("@dxos/client-protocol");
122
122
  var import_context4 = require("@dxos/context");
123
+ var import_credentials7 = require("@dxos/credentials");
123
124
  var import_crypto = require("@dxos/crypto");
124
125
  var import_invariant5 = require("@dxos/invariant");
125
126
  var import_keys5 = require("@dxos/keys");
@@ -140,65 +141,59 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
140
141
  var import_teleport = require("@dxos/teleport");
141
142
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
142
143
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
143
- var import_credentials7 = require("@dxos/credentials");
144
+ var import_credentials8 = require("@dxos/credentials");
144
145
  var import_feed_store3 = require("@dxos/feed-store");
145
146
  var import_invariant7 = require("@dxos/invariant");
146
147
  var import_log6 = require("@dxos/log");
147
148
  var import_protocols6 = require("@dxos/protocols");
148
149
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
149
- var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
150
150
  var import_async9 = require("@dxos/async");
151
- var import_client_protocol3 = require("@dxos/client-protocol");
152
- var import_context6 = require("@dxos/context");
153
- var import_credentials9 = require("@dxos/credentials");
154
151
  var import_echo_pipeline = require("@dxos/echo-pipeline");
155
152
  var import_invariant8 = require("@dxos/invariant");
156
- var import_keys7 = require("@dxos/keys");
157
153
  var import_log7 = require("@dxos/log");
158
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
159
154
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
160
155
  var import_debug2 = require("@dxos/debug");
161
156
  var import_rpc = require("@dxos/rpc");
162
157
  var import_tracing3 = require("@dxos/tracing");
163
158
  var import_async10 = require("@dxos/async");
164
- var import_client_protocol4 = require("@dxos/client-protocol");
165
- var import_context7 = require("@dxos/context");
159
+ var import_client_protocol3 = require("@dxos/client-protocol");
160
+ var import_context6 = require("@dxos/context");
166
161
  var import_debug3 = require("@dxos/debug");
167
162
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
168
163
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
169
164
  var import_echo_schema = require("@dxos/echo-schema");
170
165
  var import_invariant9 = require("@dxos/invariant");
171
- var import_keys8 = require("@dxos/keys");
166
+ var import_keys7 = require("@dxos/keys");
172
167
  var import_log8 = require("@dxos/log");
173
168
  var import_protocols7 = require("@dxos/protocols");
174
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
175
- var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
169
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
170
+ var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
176
171
  var import_timeframe2 = require("@dxos/timeframe");
177
172
  var import_tracing4 = require("@dxos/tracing");
178
173
  var import_util4 = require("@dxos/util");
179
174
  var import_async11 = require("@dxos/async");
180
- var import_credentials11 = require("@dxos/credentials");
175
+ var import_credentials10 = require("@dxos/credentials");
181
176
  var import_async12 = require("@dxos/async");
182
- var import_context8 = require("@dxos/context");
177
+ var import_context7 = require("@dxos/context");
183
178
  var import_invariant10 = require("@dxos/invariant");
184
- var import_keys9 = require("@dxos/keys");
179
+ var import_keys8 = require("@dxos/keys");
185
180
  var import_log9 = require("@dxos/log");
186
181
  var import_protocols8 = require("@dxos/protocols");
187
182
  var import_teleport2 = require("@dxos/teleport");
188
183
  var import_util5 = require("@dxos/util");
189
184
  var import_async13 = require("@dxos/async");
190
- var import_context9 = require("@dxos/context");
191
- var import_credentials12 = require("@dxos/credentials");
185
+ var import_context8 = require("@dxos/context");
186
+ var import_credentials11 = require("@dxos/credentials");
192
187
  var import_invariant11 = require("@dxos/invariant");
193
- var import_keys10 = require("@dxos/keys");
188
+ var import_keys9 = require("@dxos/keys");
194
189
  var import_log10 = require("@dxos/log");
195
190
  var import_protocols9 = require("@dxos/protocols");
196
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
191
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
197
192
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
198
193
  var import_util6 = require("@dxos/util");
199
- var import_credentials13 = require("@dxos/credentials");
194
+ var import_credentials12 = require("@dxos/credentials");
200
195
  var import_debug4 = require("@dxos/debug");
201
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
196
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
202
197
  var import_timeframe3 = require("@dxos/timeframe");
203
198
  var import_async14 = require("@dxos/async");
204
199
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
@@ -206,79 +201,79 @@ var import_debug5 = require("@dxos/debug");
206
201
  var import_invariant12 = require("@dxos/invariant");
207
202
  var import_log11 = require("@dxos/log");
208
203
  var import_protocols10 = require("@dxos/protocols");
209
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
204
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
210
205
  var import_async15 = require("@dxos/async");
211
- var import_context10 = require("@dxos/context");
212
- var import_credentials15 = require("@dxos/credentials");
206
+ var import_context9 = require("@dxos/context");
207
+ var import_credentials14 = require("@dxos/credentials");
213
208
  var import_debug6 = require("@dxos/debug");
214
209
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
215
210
  var import_feed_store4 = require("@dxos/feed-store");
216
211
  var import_indexing = require("@dxos/indexing");
217
212
  var import_invariant13 = require("@dxos/invariant");
218
213
  var import_keyring = require("@dxos/keyring");
219
- var import_keys11 = require("@dxos/keys");
214
+ var import_keys10 = require("@dxos/keys");
220
215
  var import_log12 = require("@dxos/log");
221
216
  var import_protocols11 = require("@dxos/protocols");
222
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
217
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
223
218
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
224
219
  var import_tracing5 = require("@dxos/tracing");
225
220
  var import_util7 = require("@dxos/util");
226
221
  var import_automerge = require("@dxos/automerge/automerge");
227
222
  var import_protocols12 = require("@dxos/protocols");
228
223
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
229
- var import_credentials16 = require("@dxos/credentials");
224
+ var import_credentials15 = require("@dxos/credentials");
230
225
  var import_invariant14 = require("@dxos/invariant");
231
226
  var import_protocols13 = require("@dxos/protocols");
232
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
227
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
233
228
  var import_tracing6 = require("@dxos/tracing");
234
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
229
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
235
230
  var import_config = require("@dxos/config");
236
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
231
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
237
232
  var import_tracing7 = require("@dxos/tracing");
238
233
  var import_util8 = require("@dxos/util");
239
234
  var import_async16 = require("@dxos/async");
240
- var import_client_protocol5 = require("@dxos/client-protocol");
241
- var import_context11 = require("@dxos/context");
235
+ var import_client_protocol4 = require("@dxos/client-protocol");
236
+ var import_context10 = require("@dxos/context");
242
237
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
243
238
  var import_echo_schema2 = require("@dxos/echo-schema");
244
239
  var import_indexing2 = require("@dxos/indexing");
245
240
  var import_invariant15 = require("@dxos/invariant");
246
- var import_keys12 = require("@dxos/keys");
241
+ var import_keys11 = require("@dxos/keys");
247
242
  var import_log13 = require("@dxos/log");
248
243
  var import_messaging = require("@dxos/messaging");
249
244
  var import_network_manager2 = require("@dxos/network-manager");
250
245
  var import_protocols14 = require("@dxos/protocols");
251
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
246
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
252
247
  var import_tracing8 = require("@dxos/tracing");
253
248
  var import_util9 = require("@dxos/util");
254
249
  var import_websocket_rpc = require("@dxos/websocket-rpc");
255
250
  var import_async17 = require("@dxos/async");
256
251
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
257
252
  var import_invariant16 = require("@dxos/invariant");
258
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
253
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
259
254
  var import_invariant17 = require("@dxos/invariant");
260
255
  var import_lock_file = require("@dxos/lock-file");
261
256
  var import_log14 = require("@dxos/log");
262
257
  var import_async18 = require("@dxos/async");
263
258
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
264
- var import_keys13 = require("@dxos/keys");
259
+ var import_keys12 = require("@dxos/keys");
265
260
  var import_log15 = require("@dxos/log");
266
- var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
261
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
267
262
  var import_util10 = require("@dxos/util");
268
263
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
269
264
  var import_protocols15 = require("@dxos/protocols");
270
265
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
271
266
  var import_random_access_storage = require("@dxos/random-access-storage");
272
- var import_client_protocol6 = require("@dxos/client-protocol");
267
+ var import_client_protocol5 = require("@dxos/client-protocol");
273
268
  var import_config3 = require("@dxos/protocols/proto/dxos/config");
274
269
  var import_util11 = require("@dxos/util");
275
270
  var import_level = require("level");
276
271
  var import_node_path = __toESM(require("node:path"));
277
- var import_keys14 = require("@dxos/keys");
272
+ var import_keys13 = require("@dxos/keys");
278
273
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
279
- var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
274
+ var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
280
275
  var import_util12 = require("@dxos/util");
281
- var import_keys15 = require("@dxos/keys");
276
+ var import_keys14 = require("@dxos/keys");
282
277
  var import_util13 = require("@dxos/util");
283
278
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
284
279
  return new import_codec_protobuf.Stream(({ next }) => {
@@ -1297,9 +1292,7 @@ var IdentityManager = class {
1297
1292
  C: (f, a) => f(...a)
1298
1293
  });
1299
1294
  },
1300
- memberKey: identityKey,
1301
- onDelegatedInvitationStatusChange: async () => {
1302
- }
1295
+ memberKey: identityKey
1303
1296
  });
1304
1297
  }
1305
1298
  };
@@ -1396,13 +1389,10 @@ var DeviceInvitationProtocol = class {
1396
1389
  kind: import_services2.Invitation.Kind.DEVICE
1397
1390
  };
1398
1391
  }
1399
- async delegate(invitation) {
1400
- throw new Error("delegation not supported");
1401
- }
1402
- async admit(_, request) {
1392
+ async admit(request) {
1403
1393
  (0, import_invariant4.invariant)(request.device, void 0, {
1404
1394
  F: __dxlog_file5,
1405
- L: 42,
1395
+ L: 37,
1406
1396
  S: this,
1407
1397
  A: [
1408
1398
  "request.device",
@@ -1448,7 +1438,7 @@ var DeviceInvitationProtocol = class {
1448
1438
  async accept(response, request) {
1449
1439
  (0, import_invariant4.invariant)(response.device, void 0, {
1450
1440
  F: __dxlog_file5,
1451
- L: 87,
1441
+ L: 82,
1452
1442
  S: this,
1453
1443
  A: [
1454
1444
  "response.device",
@@ -1458,7 +1448,7 @@ var DeviceInvitationProtocol = class {
1458
1448
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1459
1449
  (0, import_invariant4.invariant)(request.device, void 0, {
1460
1450
  F: __dxlog_file5,
1461
- L: 90,
1451
+ L: 85,
1462
1452
  S: this,
1463
1453
  A: [
1464
1454
  "request.device",
@@ -1833,7 +1823,51 @@ var InvitationsHandler = class {
1833
1823
  constructor(_networkManager) {
1834
1824
  this._networkManager = _networkManager;
1835
1825
  }
1836
- handleInvitationFlow(ctx, stream, protocol, invitation) {
1826
+ createInvitation(protocol, options) {
1827
+ const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = options?.authMethod !== import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
1828
+ const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1829
+ (0, import_invariant5.invariant)(protocol, void 0, {
1830
+ F: __dxlog_file7,
1831
+ L: 87,
1832
+ S: this,
1833
+ A: [
1834
+ "protocol",
1835
+ ""
1836
+ ]
1837
+ });
1838
+ const invitation = {
1839
+ invitationId,
1840
+ type,
1841
+ authMethod,
1842
+ state,
1843
+ swarmKey,
1844
+ authCode,
1845
+ timeout,
1846
+ persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
1847
+ guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
1848
+ created,
1849
+ lifetime,
1850
+ multiUse,
1851
+ ...protocol.getInvitationContext()
1852
+ };
1853
+ const stream = new import_async7.PushStream();
1854
+ const ctx = new import_context4.Context({
1855
+ onError: (err) => {
1856
+ stream.error(err);
1857
+ void ctx.dispose();
1858
+ }
1859
+ });
1860
+ ctx.onDispose(() => {
1861
+ (0, import_log4.log)("complete", {
1862
+ ...protocol.toJSON()
1863
+ }, {
1864
+ F: __dxlog_file7,
1865
+ L: 115,
1866
+ S: this,
1867
+ C: (f, a) => f(...a)
1868
+ });
1869
+ stream.complete();
1870
+ });
1837
1871
  const createExtension = () => {
1838
1872
  const extension = new InvitationHostExtension({
1839
1873
  onStateUpdate: (invitation2) => {
@@ -1842,8 +1876,8 @@ var InvitationsHandler = class {
1842
1876
  state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1843
1877
  });
1844
1878
  },
1845
- resolveInvitation: async ({ invitationId }) => {
1846
- if (invitationId && invitationId !== invitation.invitationId) {
1879
+ resolveInvitation: async ({ invitationId: invitationId2 }) => {
1880
+ if (invitationId2 && invitationId2 !== invitation.invitationId) {
1847
1881
  return void 0;
1848
1882
  }
1849
1883
  return invitation;
@@ -1853,14 +1887,14 @@ var InvitationsHandler = class {
1853
1887
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1854
1888
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1855
1889
  F: __dxlog_file7,
1856
- L: 87,
1890
+ L: 136,
1857
1891
  S: this,
1858
1892
  A: [
1859
1893
  "deviceKey",
1860
1894
  ""
1861
1895
  ]
1862
1896
  });
1863
- const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
1897
+ const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1864
1898
  extension.completedTrigger.wake(deviceKey);
1865
1899
  return admissionResponse;
1866
1900
  } catch (err) {
@@ -1876,7 +1910,7 @@ var InvitationsHandler = class {
1876
1910
  id: traceId
1877
1911
  }), {
1878
1912
  F: __dxlog_file7,
1879
- L: 105,
1913
+ L: 154,
1880
1914
  S: this,
1881
1915
  C: (f, a) => f(...a)
1882
1916
  });
@@ -1884,7 +1918,7 @@ var InvitationsHandler = class {
1884
1918
  ...protocol.toJSON()
1885
1919
  }, {
1886
1920
  F: __dxlog_file7,
1887
- L: 106,
1921
+ L: 155,
1888
1922
  S: this,
1889
1923
  C: (f, a) => f(...a)
1890
1924
  });
@@ -1893,14 +1927,14 @@ var InvitationsHandler = class {
1893
1927
  state: import_services3.Invitation.State.CONNECTED
1894
1928
  });
1895
1929
  const deviceKey = await extension.completedTrigger.wait({
1896
- timeout: invitation.timeout
1930
+ timeout
1897
1931
  });
1898
1932
  (0, import_log4.log)("admitted guest", {
1899
1933
  guest: deviceKey,
1900
1934
  ...protocol.toJSON()
1901
1935
  }, {
1902
1936
  F: __dxlog_file7,
1903
- L: 109,
1937
+ L: 158,
1904
1938
  S: this,
1905
1939
  C: (f, a) => f(...a)
1906
1940
  });
@@ -1912,7 +1946,7 @@ var InvitationsHandler = class {
1912
1946
  id: traceId
1913
1947
  }), {
1914
1948
  F: __dxlog_file7,
1915
- L: 111,
1949
+ L: 160,
1916
1950
  S: this,
1917
1951
  C: (f, a) => f(...a)
1918
1952
  });
@@ -1922,7 +1956,7 @@ var InvitationsHandler = class {
1922
1956
  ...protocol.toJSON()
1923
1957
  }, {
1924
1958
  F: __dxlog_file7,
1925
- L: 114,
1959
+ L: 163,
1926
1960
  S: this,
1927
1961
  C: (f, a) => f(...a)
1928
1962
  });
@@ -1933,7 +1967,7 @@ var InvitationsHandler = class {
1933
1967
  } else {
1934
1968
  import_log4.log.error("failed", err, {
1935
1969
  F: __dxlog_file7,
1936
- L: 117,
1970
+ L: 166,
1937
1971
  S: this,
1938
1972
  C: (f, a) => f(...a)
1939
1973
  });
@@ -1944,12 +1978,12 @@ var InvitationsHandler = class {
1944
1978
  error: err
1945
1979
  }), {
1946
1980
  F: __dxlog_file7,
1947
- L: 120,
1981
+ L: 169,
1948
1982
  S: this,
1949
1983
  C: (f, a) => f(...a)
1950
1984
  });
1951
1985
  } finally {
1952
- if (!invitation.multiUse) {
1986
+ if (!multiUse) {
1953
1987
  await swarmConnection.close();
1954
1988
  await ctx.dispose();
1955
1989
  }
@@ -1965,7 +1999,7 @@ var InvitationsHandler = class {
1965
1999
  ...protocol.toJSON()
1966
2000
  }, {
1967
2001
  F: __dxlog_file7,
1968
- L: 135,
2002
+ L: 184,
1969
2003
  S: this,
1970
2004
  C: (f, a) => f(...a)
1971
2005
  });
@@ -1976,7 +2010,7 @@ var InvitationsHandler = class {
1976
2010
  } else {
1977
2011
  import_log4.log.error("failed", err, {
1978
2012
  F: __dxlog_file7,
1979
- L: 138,
2013
+ L: 187,
1980
2014
  S: this,
1981
2015
  C: (f, a) => f(...a)
1982
2016
  });
@@ -1990,7 +2024,7 @@ var InvitationsHandler = class {
1990
2024
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1991
2025
  import_log4.log.warn("invitation has already expired", void 0, {
1992
2026
  F: __dxlog_file7,
1993
- L: 149,
2027
+ L: 198,
1994
2028
  S: this,
1995
2029
  C: (f, a) => f(...a)
1996
2030
  });
@@ -2024,12 +2058,24 @@ var InvitationsHandler = class {
2024
2058
  state: import_services3.Invitation.State.CONNECTING
2025
2059
  });
2026
2060
  });
2061
+ const observable = new import_client_protocol2.CancellableInvitation({
2062
+ initialInvitation: invitation,
2063
+ subscriber: stream.observable,
2064
+ onCancel: async () => {
2065
+ stream.next({
2066
+ ...invitation,
2067
+ state: import_services3.Invitation.State.CANCELLED
2068
+ });
2069
+ await ctx.dispose();
2070
+ }
2071
+ });
2072
+ return observable;
2027
2073
  }
2028
2074
  acceptInvitation(protocol, invitation, deviceProfile) {
2029
2075
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2030
2076
  (0, import_invariant5.invariant)(protocol, void 0, {
2031
2077
  F: __dxlog_file7,
2032
- L: 191,
2078
+ L: 252,
2033
2079
  S: this,
2034
2080
  A: [
2035
2081
  "protocol",
@@ -2039,7 +2085,7 @@ var InvitationsHandler = class {
2039
2085
  if (deviceProfile) {
2040
2086
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2041
2087
  F: __dxlog_file7,
2042
- L: 194,
2088
+ L: 255,
2043
2089
  S: this,
2044
2090
  A: [
2045
2091
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2054,7 +2100,7 @@ var InvitationsHandler = class {
2054
2100
  const setState = (newData) => {
2055
2101
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2056
2102
  F: __dxlog_file7,
2057
- L: 205,
2103
+ L: 266,
2058
2104
  S: this,
2059
2105
  A: [
2060
2106
  "newData.state !== undefined",
@@ -2074,7 +2120,7 @@ var InvitationsHandler = class {
2074
2120
  ...protocol.toJSON()
2075
2121
  }, {
2076
2122
  F: __dxlog_file7,
2077
- L: 213,
2123
+ L: 274,
2078
2124
  S: this,
2079
2125
  C: (f, a) => f(...a)
2080
2126
  });
@@ -2084,7 +2130,7 @@ var InvitationsHandler = class {
2084
2130
  } else {
2085
2131
  import_log4.log.warn("auth failed", err, {
2086
2132
  F: __dxlog_file7,
2087
- L: 216,
2133
+ L: 277,
2088
2134
  S: this,
2089
2135
  C: (f, a) => f(...a)
2090
2136
  });
@@ -2098,7 +2144,7 @@ var InvitationsHandler = class {
2098
2144
  ...protocol.toJSON()
2099
2145
  }, {
2100
2146
  F: __dxlog_file7,
2101
- L: 224,
2147
+ L: 285,
2102
2148
  S: this,
2103
2149
  C: (f, a) => f(...a)
2104
2150
  });
@@ -2113,7 +2159,7 @@ var InvitationsHandler = class {
2113
2159
  currentState
2114
2160
  }, {
2115
2161
  F: __dxlog_file7,
2116
- L: 234,
2162
+ L: 295,
2117
2163
  S: this,
2118
2164
  C: (f, a) => f(...a)
2119
2165
  });
@@ -2128,7 +2174,7 @@ var InvitationsHandler = class {
2128
2174
  id: traceId
2129
2175
  }), {
2130
2176
  F: __dxlog_file7,
2131
- L: 243,
2177
+ L: 304,
2132
2178
  S: this,
2133
2179
  C: (f, a) => f(...a)
2134
2180
  });
@@ -2140,7 +2186,7 @@ var InvitationsHandler = class {
2140
2186
  ...protocol.toJSON()
2141
2187
  }, {
2142
2188
  F: __dxlog_file7,
2143
- L: 251,
2189
+ L: 312,
2144
2190
  S: this,
2145
2191
  C: (f, a) => f(...a)
2146
2192
  });
@@ -2151,7 +2197,7 @@ var InvitationsHandler = class {
2151
2197
  ...protocol.toJSON()
2152
2198
  }, {
2153
2199
  F: __dxlog_file7,
2154
- L: 255,
2200
+ L: 316,
2155
2201
  S: this,
2156
2202
  C: (f, a) => f(...a)
2157
2203
  });
@@ -2161,7 +2207,7 @@ var InvitationsHandler = class {
2161
2207
  response: introductionResponse
2162
2208
  }, {
2163
2209
  F: __dxlog_file7,
2164
- L: 259,
2210
+ L: 320,
2165
2211
  S: this,
2166
2212
  C: (f, a) => f(...a)
2167
2213
  });
@@ -2182,7 +2228,7 @@ var InvitationsHandler = class {
2182
2228
  ...protocol.toJSON()
2183
2229
  }, {
2184
2230
  F: __dxlog_file7,
2185
- L: 275,
2231
+ L: 336,
2186
2232
  S: this,
2187
2233
  C: (f, a) => f(...a)
2188
2234
  });
@@ -2194,7 +2240,7 @@ var InvitationsHandler = class {
2194
2240
  ...protocol.toJSON()
2195
2241
  }, {
2196
2242
  F: __dxlog_file7,
2197
- L: 286,
2243
+ L: 347,
2198
2244
  S: this,
2199
2245
  C: (f, a) => f(...a)
2200
2246
  });
@@ -2207,7 +2253,7 @@ var InvitationsHandler = class {
2207
2253
  id: traceId
2208
2254
  }), {
2209
2255
  F: __dxlog_file7,
2210
- L: 288,
2256
+ L: 349,
2211
2257
  S: this,
2212
2258
  C: (f, a) => f(...a)
2213
2259
  });
@@ -2217,7 +2263,7 @@ var InvitationsHandler = class {
2217
2263
  ...protocol.toJSON()
2218
2264
  }, {
2219
2265
  F: __dxlog_file7,
2220
- L: 291,
2266
+ L: 352,
2221
2267
  S: this,
2222
2268
  C: (f, a) => f(...a)
2223
2269
  });
@@ -2227,7 +2273,7 @@ var InvitationsHandler = class {
2227
2273
  } else {
2228
2274
  (0, import_log4.log)("auth failed", err, {
2229
2275
  F: __dxlog_file7,
2230
- L: 294,
2276
+ L: 355,
2231
2277
  S: this,
2232
2278
  C: (f, a) => f(...a)
2233
2279
  });
@@ -2238,7 +2284,7 @@ var InvitationsHandler = class {
2238
2284
  error: err
2239
2285
  }), {
2240
2286
  F: __dxlog_file7,
2241
- L: 297,
2287
+ L: 358,
2242
2288
  S: this,
2243
2289
  C: (f, a) => f(...a)
2244
2290
  });
@@ -2256,7 +2302,7 @@ var InvitationsHandler = class {
2256
2302
  ...protocol.toJSON()
2257
2303
  }, {
2258
2304
  F: __dxlog_file7,
2259
- L: 308,
2305
+ L: 369,
2260
2306
  S: this,
2261
2307
  C: (f, a) => f(...a)
2262
2308
  });
@@ -2266,7 +2312,7 @@ var InvitationsHandler = class {
2266
2312
  } else {
2267
2313
  (0, import_log4.log)("auth failed", err, {
2268
2314
  F: __dxlog_file7,
2269
- L: 311,
2315
+ L: 372,
2270
2316
  S: this,
2271
2317
  C: (f, a) => f(...a)
2272
2318
  });
@@ -2283,7 +2329,7 @@ var InvitationsHandler = class {
2283
2329
  } else {
2284
2330
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2285
2331
  F: __dxlog_file7,
2286
- L: 325,
2332
+ L: 386,
2287
2333
  S: this,
2288
2334
  A: [
2289
2335
  "invitation.swarmKey",
@@ -2325,7 +2371,7 @@ var InvitationsHandler = class {
2325
2371
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2326
2372
  (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2327
2373
  F: __dxlog_file7,
2328
- L: 365,
2374
+ L: 426,
2329
2375
  S: this,
2330
2376
  C: (f, a) => f(...a)
2331
2377
  });
@@ -2335,7 +2381,7 @@ var InvitationsHandler = class {
2335
2381
  const authCode = await authenticated.wait(options);
2336
2382
  (0, import_log4.log)("sending authentication request", void 0, {
2337
2383
  F: __dxlog_file7,
2338
- L: 369,
2384
+ L: 430,
2339
2385
  S: this,
2340
2386
  C: (f, a) => f(...a)
2341
2387
  });
@@ -2356,7 +2402,7 @@ var InvitationsHandler = class {
2356
2402
  attempt
2357
2403
  }, {
2358
2404
  F: __dxlog_file7,
2359
- L: 380,
2405
+ L: 441,
2360
2406
  S: this,
2361
2407
  C: (f, a) => f(...a)
2362
2408
  });
@@ -2374,7 +2420,7 @@ var InvitationsHandler = class {
2374
2420
  }
2375
2421
  (0, import_log4.log)("sending authentication request", void 0, {
2376
2422
  F: __dxlog_file7,
2377
- L: 399,
2423
+ L: 460,
2378
2424
  S: this,
2379
2425
  C: (f, a) => f(...a)
2380
2426
  });
@@ -2406,8 +2452,9 @@ var InvitationsServiceImpl = class {
2406
2452
  return {};
2407
2453
  }
2408
2454
  createInvitation(options) {
2455
+ const invitation = this._invitationsManager.createInvitation(options);
2409
2456
  return new import_codec_protobuf8.Stream(({ next, close }) => {
2410
- void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
2457
+ invitation.subscribe(next, close, close);
2411
2458
  });
2412
2459
  }
2413
2460
  acceptInvitation(request) {
@@ -2510,10 +2557,10 @@ var SpaceInvitationProtocol = class {
2510
2557
  spaceKey: this._spaceKey
2511
2558
  };
2512
2559
  }
2513
- async admit(invitation, request, guestProfile) {
2560
+ async admit(request, guestProfile) {
2514
2561
  (0, import_invariant7.invariant)(this._spaceKey, void 0, {
2515
2562
  F: __dxlog_file8,
2516
- L: 55,
2563
+ L: 47,
2517
2564
  S: this,
2518
2565
  A: [
2519
2566
  "this._spaceKey",
@@ -2523,7 +2570,7 @@ var SpaceInvitationProtocol = class {
2523
2570
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2524
2571
  (0, import_invariant7.invariant)(space, void 0, {
2525
2572
  F: __dxlog_file8,
2526
- L: 57,
2573
+ L: 49,
2527
2574
  S: this,
2528
2575
  A: [
2529
2576
  "space",
@@ -2532,7 +2579,7 @@ var SpaceInvitationProtocol = class {
2532
2579
  });
2533
2580
  (0, import_invariant7.invariant)(request.space, void 0, {
2534
2581
  F: __dxlog_file8,
2535
- L: 59,
2582
+ L: 51,
2536
2583
  S: this,
2537
2584
  A: [
2538
2585
  "request.space",
@@ -2545,14 +2592,14 @@ var SpaceInvitationProtocol = class {
2545
2592
  guest: deviceKey
2546
2593
  }, {
2547
2594
  F: __dxlog_file8,
2548
- L: 62,
2595
+ L: 54,
2549
2596
  S: this,
2550
2597
  C: (f, a) => f(...a)
2551
2598
  });
2552
- const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
2599
+ const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2553
2600
  (0, import_invariant7.invariant)(credentials[0].credential, void 0, {
2554
2601
  F: __dxlog_file8,
2555
- L: 74,
2602
+ L: 65,
2556
2603
  S: this,
2557
2604
  A: [
2558
2605
  "credentials[0].credential",
@@ -2560,9 +2607,9 @@ var SpaceInvitationProtocol = class {
2560
2607
  ]
2561
2608
  });
2562
2609
  const spaceMemberCredential = credentials[0].credential.credential;
2563
- (0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2610
+ (0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2564
2611
  F: __dxlog_file8,
2565
- L: 76,
2612
+ L: 67,
2566
2613
  S: this,
2567
2614
  A: [
2568
2615
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2577,69 +2624,6 @@ var SpaceInvitationProtocol = class {
2577
2624
  }
2578
2625
  };
2579
2626
  }
2580
- async delegate(invitation) {
2581
- (0, import_invariant7.invariant)(this._spaceKey, void 0, {
2582
- F: __dxlog_file8,
2583
- L: 89,
2584
- S: this,
2585
- A: [
2586
- "this._spaceKey",
2587
- ""
2588
- ]
2589
- });
2590
- const space = await this._spaceManager.spaces.get(this._spaceKey);
2591
- (0, import_invariant7.invariant)(space, void 0, {
2592
- F: __dxlog_file8,
2593
- L: 91,
2594
- S: this,
2595
- A: [
2596
- "space",
2597
- ""
2598
- ]
2599
- });
2600
- if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
2601
- (0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
2602
- F: __dxlog_file8,
2603
- L: 93,
2604
- S: this,
2605
- A: [
2606
- "invitation.guestKeypair?.publicKey",
2607
- ""
2608
- ]
2609
- });
2610
- }
2611
- (0, import_log6.log)("writing delegate space invitation", {
2612
- host: this._signingContext.deviceKey,
2613
- id: invitation.invitationId
2614
- }, {
2615
- F: __dxlog_file8,
2616
- L: 96,
2617
- S: this,
2618
- C: (f, a) => f(...a)
2619
- });
2620
- const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
2621
- invitationId: invitation.invitationId,
2622
- authMethod: invitation.authMethod,
2623
- swarmKey: invitation.swarmKey,
2624
- role: import_credentials8.SpaceMember.Role.ADMIN,
2625
- expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
2626
- multiUse: invitation.multiUse ?? false,
2627
- guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
2628
- });
2629
- (0, import_invariant7.invariant)(credential.credential, void 0, {
2630
- F: __dxlog_file8,
2631
- L: 116,
2632
- S: this,
2633
- A: [
2634
- "credential.credential",
2635
- ""
2636
- ]
2637
- });
2638
- await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
2639
- credential
2640
- ]);
2641
- return credential.credential.credential.id;
2642
- }
2643
2627
  checkInvitation(invitation) {
2644
2628
  if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
2645
2629
  return new import_protocols6.AlreadyJoinedError("Already joined space.");
@@ -2665,7 +2649,7 @@ var SpaceInvitationProtocol = class {
2665
2649
  async accept(response) {
2666
2650
  (0, import_invariant7.invariant)(response.space, void 0, {
2667
2651
  F: __dxlog_file8,
2668
- L: 149,
2652
+ L: 107,
2669
2653
  S: this,
2670
2654
  A: [
2671
2655
  "response.space",
@@ -2673,10 +2657,10 @@ var SpaceInvitationProtocol = class {
2673
2657
  ]
2674
2658
  });
2675
2659
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2676
- const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
2660
+ const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2677
2661
  (0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2678
2662
  F: __dxlog_file8,
2679
- L: 152,
2663
+ L: 110,
2680
2664
  S: this,
2681
2665
  A: [
2682
2666
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2685,7 +2669,7 @@ var SpaceInvitationProtocol = class {
2685
2669
  });
2686
2670
  (0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2687
2671
  F: __dxlog_file8,
2688
- L: 153,
2672
+ L: 111,
2689
2673
  S: this,
2690
2674
  A: [
2691
2675
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -2723,39 +2707,25 @@ var InvitationsManager = class {
2723
2707
  this._persistentInvitationsLoadedEvent = new import_async9.Event();
2724
2708
  this._persistentInvitationsLoaded = false;
2725
2709
  }
2726
- async createInvitation(options) {
2727
- if (options.invitationId) {
2728
- const existingInvitation = this._createInvitations.get(options.invitationId);
2729
- if (existingInvitation) {
2730
- return existingInvitation;
2731
- }
2710
+ createInvitation(options) {
2711
+ const existingInvitation = this._createInvitations.get(options.invitationId);
2712
+ if (existingInvitation) {
2713
+ return existingInvitation;
2732
2714
  }
2733
2715
  const handler = this._getHandler(options);
2734
- const invitation = this._createInvitation(handler, options);
2735
- const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
2736
- this._createInvitations.set(invitation.invitationId, observableInvitation);
2737
- this.invitationCreated.emit(invitation);
2738
- this._onInvitationComplete(observableInvitation, async () => {
2739
- this._createInvitations.delete(observableInvitation.get().invitationId);
2740
- this.removedCreated.emit(observableInvitation.get());
2741
- if (observableInvitation.get().persistent) {
2742
- await this._safeDeleteInvitation(observableInvitation.get());
2716
+ const invitation = this._invitationsHandler.createInvitation(handler, options);
2717
+ this._createInvitations.set(invitation.get().invitationId, invitation);
2718
+ this.invitationCreated.emit(invitation.get());
2719
+ const saveInvitationTask = invitation.get().persistent ? this._safePersistInBackground(invitation) : Promise.resolve();
2720
+ this._onInvitationComplete(invitation, async () => {
2721
+ this._createInvitations.delete(invitation.get().invitationId);
2722
+ this.removedCreated.emit(invitation.get());
2723
+ if (invitation.get().persistent) {
2724
+ await saveInvitationTask;
2725
+ await this._safeDeleteInvitation(invitation.get());
2743
2726
  }
2744
2727
  });
2745
- try {
2746
- await this._persistIfRequired(handler, stream, invitation);
2747
- } catch (err) {
2748
- import_log7.log.catch(err, void 0, {
2749
- F: __dxlog_file9,
2750
- L: 76,
2751
- S: this,
2752
- C: (f, a) => f(...a)
2753
- });
2754
- await observableInvitation.cancel();
2755
- return observableInvitation;
2756
- }
2757
- this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
2758
- return observableInvitation;
2728
+ return invitation;
2759
2729
  }
2760
2730
  async loadPersistentInvitations() {
2761
2731
  if (this._persistentInvitationsLoaded) {
@@ -2767,10 +2737,10 @@ var InvitationsManager = class {
2767
2737
  try {
2768
2738
  const persistentInvitations = this._metadataStore.getInvitations();
2769
2739
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2770
- const loadTasks = freshInvitations.map((persistentInvitation) => {
2740
+ const cInvitations = freshInvitations.map((persistentInvitation) => {
2771
2741
  (0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2772
2742
  F: __dxlog_file9,
2773
- L: 97,
2743
+ L: 82,
2774
2744
  S: this,
2775
2745
  A: [
2776
2746
  "!this._createInvitations.get(persistentInvitation.invitationId)",
@@ -2780,16 +2750,15 @@ var InvitationsManager = class {
2780
2750
  return this.createInvitation({
2781
2751
  ...persistentInvitation,
2782
2752
  persistent: false
2783
- });
2753
+ }).get();
2784
2754
  });
2785
- const cInvitations = await Promise.all(loadTasks);
2786
2755
  return {
2787
- invitations: cInvitations.map((invitation) => invitation.get())
2756
+ invitations: cInvitations
2788
2757
  };
2789
2758
  } catch (err) {
2790
2759
  import_log7.log.catch(err, void 0, {
2791
2760
  F: __dxlog_file9,
2792
- L: 104,
2761
+ L: 88,
2793
2762
  S: this,
2794
2763
  C: (f, a) => f(...a)
2795
2764
  });
@@ -2820,13 +2789,13 @@ var InvitationsManager = class {
2820
2789
  async authenticate({ invitationId, authCode }) {
2821
2790
  (0, import_log7.log)("authenticating...", void 0, {
2822
2791
  F: __dxlog_file9,
2823
- L: 133,
2792
+ L: 117,
2824
2793
  S: this,
2825
2794
  C: (f, a) => f(...a)
2826
2795
  });
2827
2796
  (0, import_invariant8.invariant)(invitationId, void 0, {
2828
2797
  F: __dxlog_file9,
2829
- L: 134,
2798
+ L: 118,
2830
2799
  S: this,
2831
2800
  A: [
2832
2801
  "invitationId",
@@ -2839,7 +2808,7 @@ var InvitationsManager = class {
2839
2808
  invitationId
2840
2809
  }, {
2841
2810
  F: __dxlog_file9,
2842
- L: 137,
2811
+ L: 121,
2843
2812
  S: this,
2844
2813
  C: (f, a) => f(...a)
2845
2814
  });
@@ -2852,13 +2821,13 @@ var InvitationsManager = class {
2852
2821
  invitationId
2853
2822
  }, {
2854
2823
  F: __dxlog_file9,
2855
- L: 144,
2824
+ L: 128,
2856
2825
  S: this,
2857
2826
  C: (f, a) => f(...a)
2858
2827
  });
2859
2828
  (0, import_invariant8.invariant)(invitationId, void 0, {
2860
2829
  F: __dxlog_file9,
2861
- L: 145,
2830
+ L: 129,
2862
2831
  S: this,
2863
2832
  A: [
2864
2833
  "invitationId",
@@ -2899,73 +2868,25 @@ var InvitationsManager = class {
2899
2868
  this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
2900
2869
  }
2901
2870
  }
2902
- _createInvitation(protocol, options) {
2903
- const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
2904
- const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
2905
- return {
2906
- invitationId,
2907
- type,
2908
- authMethod,
2909
- state,
2910
- swarmKey,
2911
- authCode,
2912
- timeout,
2913
- persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
2914
- guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
2915
- created,
2916
- lifetime,
2917
- multiUse,
2918
- delegationCredentialId: options?.delegationCredentialId,
2919
- ...protocol.getInvitationContext()
2920
- };
2921
- }
2922
- _createObservableInvitation(handler, invitation) {
2923
- const stream = new import_async9.PushStream();
2924
- const ctx = new import_context6.Context({
2925
- onError: (err) => {
2926
- stream.error(err);
2927
- void ctx.dispose();
2928
- }
2929
- });
2930
- ctx.onDispose(() => {
2931
- (0, import_log7.log)("complete", {
2932
- ...handler.toJSON()
2933
- }, {
2934
- F: __dxlog_file9,
2935
- L: 228,
2936
- S: this,
2937
- C: (f, a) => f(...a)
2871
+ _safePersistInBackground(invitation) {
2872
+ return new Promise((resolve) => {
2873
+ setTimeout(async () => {
2874
+ try {
2875
+ await this._metadataStore.addInvitation(invitation.get());
2876
+ this.saved.emit(invitation.get());
2877
+ } catch (err) {
2878
+ import_log7.log.catch(err, void 0, {
2879
+ F: __dxlog_file9,
2880
+ L: 173,
2881
+ S: this,
2882
+ C: (f, a) => f(...a)
2883
+ });
2884
+ await invitation.cancel();
2885
+ } finally {
2886
+ resolve();
2887
+ }
2938
2888
  });
2939
- stream.complete();
2940
- });
2941
- const observableInvitation = new import_client_protocol3.CancellableInvitation({
2942
- initialInvitation: invitation,
2943
- subscriber: stream.observable,
2944
- onCancel: async () => {
2945
- stream.next({
2946
- ...invitation,
2947
- state: import_services7.Invitation.State.CANCELLED
2948
- });
2949
- await ctx.dispose();
2950
- }
2951
2889
  });
2952
- return {
2953
- ctx,
2954
- stream,
2955
- observableInvitation
2956
- };
2957
- }
2958
- async _persistIfRequired(handler, changeStream, invitation) {
2959
- if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
2960
- const delegationCredentialId = await handler.delegate(invitation);
2961
- changeStream.next({
2962
- ...invitation,
2963
- delegationCredentialId
2964
- });
2965
- } else if (invitation.persistent) {
2966
- await this._metadataStore.addInvitation(invitation);
2967
- this.saved.emit(invitation);
2968
- }
2969
2890
  }
2970
2891
  async _safeDeleteInvitation(invitation) {
2971
2892
  try {
@@ -2973,7 +2894,7 @@ var InvitationsManager = class {
2973
2894
  } catch (err) {
2974
2895
  import_log7.log.catch(err, void 0, {
2975
2896
  F: __dxlog_file9,
2976
- L: 260,
2897
+ L: 186,
2977
2898
  S: this,
2978
2899
  C: (f, a) => f(...a)
2979
2900
  });
@@ -3069,7 +2990,7 @@ var AutomergeSpaceState = class {
3069
2990
  this._isProcessingRootDocs = false;
3070
2991
  }
3071
2992
  async processCredential(credential) {
3072
- if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2993
+ if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3073
2994
  return;
3074
2995
  }
3075
2996
  this.lastEpoch = credential;
@@ -3101,11 +3022,11 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3101
3022
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3102
3023
  var NotarizationPlugin = class {
3103
3024
  constructor() {
3104
- this._ctx = new import_context8.Context();
3025
+ this._ctx = new import_context7.Context();
3105
3026
  this._extensionOpened = new import_async12.Event();
3106
3027
  this._extensions = /* @__PURE__ */ new Set();
3107
- this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
3108
- this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
3028
+ this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
3029
+ this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
3109
3030
  }
3110
3031
  get hasWriter() {
3111
3032
  return !!this._writer;
@@ -3226,7 +3147,7 @@ var NotarizationPlugin = class {
3226
3147
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
3227
3148
  try {
3228
3149
  await Promise.race([
3229
- (0, import_context8.rejectOnDispose)(ctx),
3150
+ (0, import_context7.rejectOnDispose)(ctx),
3230
3151
  allNotarized,
3231
3152
  errors.wait()
3232
3153
  ]);
@@ -3365,11 +3286,11 @@ function _ts_decorate4(decorators, target, key, desc) {
3365
3286
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3366
3287
  var DataSpace = class {
3367
3288
  constructor(params) {
3368
- this._ctx = new import_context7.Context();
3289
+ this._ctx = new import_context6.Context();
3369
3290
  this._notarizationPlugin = new NotarizationPlugin();
3370
3291
  this._cache = void 0;
3371
3292
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3372
- this._state = import_services8.SpaceState.CLOSED;
3293
+ this._state = import_services7.SpaceState.CLOSED;
3373
3294
  this.error = void 0;
3374
3295
  this.stateUpdate = new import_async10.Event();
3375
3296
  this.metrics = {};
@@ -3384,14 +3305,14 @@ var DataSpace = class {
3384
3305
  this._callbacks = params.callbacks ?? {};
3385
3306
  this._automergeHost = params.automergeHost;
3386
3307
  this.authVerifier = new TrustedKeySetAuthVerifier({
3387
- trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
3308
+ trustedKeysProvider: () => new import_util4.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
3388
3309
  update: this._inner.stateUpdate,
3389
- authTimeout: import_client_protocol4.AUTH_TIMEOUT
3310
+ authTimeout: import_client_protocol3.AUTH_TIMEOUT
3390
3311
  });
3391
3312
  this._cache = params.cache;
3392
3313
  this._state = params.initialState;
3393
3314
  (0, import_log8.log)("new state", {
3394
- state: import_services8.SpaceState[this._state]
3315
+ state: import_services7.SpaceState[this._state]
3395
3316
  }, {
3396
3317
  F: __dxlog_file11,
3397
3318
  L: 140,
@@ -3438,10 +3359,10 @@ var DataSpace = class {
3438
3359
  await this._notarizationPlugin.open();
3439
3360
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3440
3361
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3441
- await this._inner.open(new import_context7.Context());
3442
- this._state = import_services8.SpaceState.CONTROL_ONLY;
3362
+ await this._inner.open(new import_context6.Context());
3363
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
3443
3364
  (0, import_log8.log)("new state", {
3444
- state: import_services8.SpaceState[this._state]
3365
+ state: import_services7.SpaceState[this._state]
3445
3366
  }, {
3446
3367
  F: __dxlog_file11,
3447
3368
  L: 198,
@@ -3457,9 +3378,9 @@ var DataSpace = class {
3457
3378
  }
3458
3379
  async _close() {
3459
3380
  await this._callbacks.beforeClose?.();
3460
- this._state = import_services8.SpaceState.CLOSED;
3381
+ this._state = import_services7.SpaceState.CLOSED;
3461
3382
  (0, import_log8.log)("new state", {
3462
- state: import_services8.SpaceState[this._state]
3383
+ state: import_services7.SpaceState[this._state]
3463
3384
  }, {
3464
3385
  F: __dxlog_file11,
3465
3386
  L: 212,
@@ -3467,7 +3388,7 @@ var DataSpace = class {
3467
3388
  C: (f, a) => f(...a)
3468
3389
  });
3469
3390
  await this._ctx.dispose();
3470
- this._ctx = new import_context7.Context();
3391
+ this._ctx = new import_context6.Context();
3471
3392
  await this.authVerifier.close();
3472
3393
  await this._inner.close();
3473
3394
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -3491,7 +3412,7 @@ var DataSpace = class {
3491
3412
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3492
3413
  await this.initializeDataPipeline();
3493
3414
  } catch (err) {
3494
- if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
3415
+ if (err instanceof import_protocols7.CancelledError || err instanceof import_context6.ContextDisposedError) {
3495
3416
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3496
3417
  F: __dxlog_file11,
3497
3418
  L: 245,
@@ -3506,9 +3427,9 @@ var DataSpace = class {
3506
3427
  S: this,
3507
3428
  C: (f, a) => f(...a)
3508
3429
  });
3509
- this._state = import_services8.SpaceState.ERROR;
3430
+ this._state = import_services7.SpaceState.ERROR;
3510
3431
  (0, import_log8.log)("new state", {
3511
- state: import_services8.SpaceState[this._state]
3432
+ state: import_services7.SpaceState[this._state]
3512
3433
  }, {
3513
3434
  F: __dxlog_file11,
3514
3435
  L: 251,
@@ -3523,12 +3444,12 @@ var DataSpace = class {
3523
3444
  });
3524
3445
  }
3525
3446
  async initializeDataPipeline() {
3526
- if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
3447
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3527
3448
  throw new import_protocols7.SystemError("Invalid operation");
3528
3449
  }
3529
- this._state = import_services8.SpaceState.INITIALIZING;
3450
+ this._state = import_services7.SpaceState.INITIALIZING;
3530
3451
  (0, import_log8.log)("new state", {
3531
- state: import_services8.SpaceState[this._state]
3452
+ state: import_services7.SpaceState[this._state]
3532
3453
  }, {
3533
3454
  F: __dxlog_file11,
3534
3455
  L: 267,
@@ -3538,7 +3459,7 @@ var DataSpace = class {
3538
3459
  await this._initializeAndReadControlPipeline();
3539
3460
  await (0, import_async10.sleep)(1);
3540
3461
  this._automergeSpaceState.startProcessingRootDocs();
3541
- await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3462
+ await (0, import_context6.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3542
3463
  (0, import_log8.log)("data pipeline ready", void 0, {
3543
3464
  F: __dxlog_file11,
3544
3465
  L: 279,
@@ -3546,9 +3467,9 @@ var DataSpace = class {
3546
3467
  C: (f, a) => f(...a)
3547
3468
  });
3548
3469
  await this._callbacks.beforeReady?.();
3549
- this._state = import_services8.SpaceState.READY;
3470
+ this._state = import_services7.SpaceState.READY;
3550
3471
  (0, import_log8.log)("new state", {
3551
- state: import_services8.SpaceState[this._state]
3472
+ state: import_services7.SpaceState[this._state]
3552
3473
  }, {
3553
3474
  F: __dxlog_file11,
3554
3475
  L: 283,
@@ -3594,7 +3515,7 @@ var DataSpace = class {
3594
3515
  spaceKey: this.key,
3595
3516
  deviceKey: this._signingContext.deviceKey,
3596
3517
  identityKey: this._signingContext.identityKey,
3597
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
3518
+ designation: import_credentials9.AdmittedFeed.Designation.CONTROL
3598
3519
  }
3599
3520
  }));
3600
3521
  }
@@ -3611,7 +3532,7 @@ var DataSpace = class {
3611
3532
  spaceKey: this.key,
3612
3533
  deviceKey: this._signingContext.deviceKey,
3613
3534
  identityKey: this._signingContext.identityKey,
3614
- designation: import_credentials10.AdmittedFeed.Designation.DATA
3535
+ designation: import_credentials9.AdmittedFeed.Designation.DATA
3615
3536
  }
3616
3537
  }));
3617
3538
  }
@@ -3639,7 +3560,7 @@ var DataSpace = class {
3639
3560
  queueMicrotask(async () => {
3640
3561
  try {
3641
3562
  await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
3642
- await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
3563
+ await (0, import_context6.cancelWithContext)(this._ctx, handle.whenReady());
3643
3564
  });
3644
3565
  if (this._ctx.disposed) {
3645
3566
  return;
@@ -3653,7 +3574,7 @@ var DataSpace = class {
3653
3574
  });
3654
3575
  }
3655
3576
  } catch (err) {
3656
- if (err instanceof import_context7.ContextDisposedError) {
3577
+ if (err instanceof import_context6.ContextDisposedError) {
3657
3578
  return;
3658
3579
  }
3659
3580
  import_log8.log.warn("error loading automerge root doc", {
@@ -3688,7 +3609,7 @@ var DataSpace = class {
3688
3609
  let epoch;
3689
3610
  switch (options?.migration) {
3690
3611
  case void 0:
3691
- case import_services8.CreateEpochRequest.Migration.NONE:
3612
+ case import_services7.CreateEpochRequest.Migration.NONE:
3692
3613
  {
3693
3614
  epoch = {
3694
3615
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3698,7 +3619,7 @@ var DataSpace = class {
3698
3619
  };
3699
3620
  }
3700
3621
  break;
3701
- case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3622
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3702
3623
  {
3703
3624
  const document = this._automergeHost.repo.create();
3704
3625
  epoch = {
@@ -3709,11 +3630,11 @@ var DataSpace = class {
3709
3630
  };
3710
3631
  }
3711
3632
  break;
3712
- case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3633
+ case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3713
3634
  {
3714
3635
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3715
3636
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3716
- await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3637
+ await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3717
3638
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3718
3639
  (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3719
3640
  F: __dxlog_file11,
@@ -3732,7 +3653,7 @@ var DataSpace = class {
3732
3653
  };
3733
3654
  }
3734
3655
  break;
3735
- case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3656
+ case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3736
3657
  {
3737
3658
  import_log8.log.info("Fragmenting", void 0, {
3738
3659
  F: __dxlog_file11,
@@ -3742,7 +3663,7 @@ var DataSpace = class {
3742
3663
  });
3743
3664
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3744
3665
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3745
- await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3666
+ await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3746
3667
  const objects = Object.entries(rootHandle.docSync().objects);
3747
3668
  const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
3748
3669
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
@@ -3815,22 +3736,22 @@ var DataSpace = class {
3815
3736
  ]));
3816
3737
  }
3817
3738
  async activate() {
3818
- if (this._state !== import_services8.SpaceState.INACTIVE) {
3739
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
3819
3740
  return;
3820
3741
  }
3821
- await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
3742
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3822
3743
  await this._open();
3823
3744
  this.initializeDataPipelineAsync();
3824
3745
  }
3825
3746
  async deactivate() {
3826
- if (this._state === import_services8.SpaceState.INACTIVE) {
3747
+ if (this._state === import_services7.SpaceState.INACTIVE) {
3827
3748
  return;
3828
3749
  }
3829
- await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
3750
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3830
3751
  await this._close();
3831
- this._state = import_services8.SpaceState.INACTIVE;
3752
+ this._state = import_services7.SpaceState.INACTIVE;
3832
3753
  (0, import_log8.log)("new state", {
3833
- state: import_services8.SpaceState[this._state]
3754
+ state: import_services7.SpaceState[this._state]
3834
3755
  }, {
3835
3756
  F: __dxlog_file11,
3836
3757
  L: 531,
@@ -3848,7 +3769,7 @@ _ts_decorate4([
3848
3769
  ], DataSpace.prototype, "key", null);
3849
3770
  _ts_decorate4([
3850
3771
  import_tracing4.trace.info({
3851
- enum: import_services8.SpaceState
3772
+ enum: import_services7.SpaceState
3852
3773
  })
3853
3774
  ], DataSpace.prototype, "state", null);
3854
3775
  _ts_decorate4([
@@ -3887,7 +3808,7 @@ DataSpace = _ts_decorate4([
3887
3808
  ], DataSpace);
3888
3809
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3889
3810
  const credentials = [
3890
- await (0, import_credentials13.createCredential)({
3811
+ await (0, import_credentials12.createCredential)({
3891
3812
  signer: keyring,
3892
3813
  issuer: space.key,
3893
3814
  subject: space.key,
@@ -3896,14 +3817,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3896
3817
  spaceKey: space.key
3897
3818
  }
3898
3819
  }),
3899
- await (0, import_credentials13.createCredential)({
3820
+ await (0, import_credentials12.createCredential)({
3900
3821
  signer: keyring,
3901
3822
  issuer: space.key,
3902
3823
  subject: signingContext.identityKey,
3903
3824
  assertion: {
3904
3825
  "@type": "dxos.halo.credentials.SpaceMember",
3905
3826
  spaceKey: space.key,
3906
- role: import_credentials14.SpaceMember.Role.ADMIN,
3827
+ role: import_credentials13.SpaceMember.Role.ADMIN,
3907
3828
  profile: signingContext.getProfile(),
3908
3829
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
3909
3830
  }
@@ -3915,7 +3836,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3915
3836
  spaceKey: space.key,
3916
3837
  identityKey: signingContext.identityKey,
3917
3838
  deviceKey: signingContext.deviceKey,
3918
- designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3839
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3919
3840
  }
3920
3841
  }),
3921
3842
  await signingContext.credentialSigner.createCredential({
@@ -3925,7 +3846,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3925
3846
  spaceKey: space.key,
3926
3847
  identityKey: signingContext.identityKey,
3927
3848
  deviceKey: signingContext.deviceKey,
3928
- designation: import_credentials14.AdmittedFeed.Designation.DATA
3849
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
3929
3850
  }
3930
3851
  }),
3931
3852
  await signingContext.credentialSigner.createCredential({
@@ -3963,19 +3884,18 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
3963
3884
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3964
3885
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3965
3886
  var DataSpaceManager = class {
3966
- constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, _invitationsManager, params) {
3887
+ constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
3967
3888
  this._spaceManager = _spaceManager;
3968
3889
  this._metadataStore = _metadataStore;
3969
3890
  this._keyring = _keyring;
3970
3891
  this._signingContext = _signingContext;
3971
3892
  this._feedStore = _feedStore;
3972
3893
  this._automergeHost = _automergeHost;
3973
- this._invitationsManager = _invitationsManager;
3974
- this._ctx = new import_context9.Context();
3894
+ this._ctx = new import_context8.Context();
3975
3895
  this.updated = new import_async13.Event();
3976
- this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
3896
+ this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
3977
3897
  this._isOpen = false;
3978
- this._instanceId = import_keys10.PublicKey.random().toHex();
3898
+ this._instanceId = import_keys9.PublicKey.random().toHex();
3979
3899
  const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
3980
3900
  this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
3981
3901
  this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
@@ -3987,7 +3907,7 @@ var DataSpaceManager = class {
3987
3907
  async open() {
3988
3908
  (0, import_log10.log)("open", void 0, {
3989
3909
  F: __dxlog_file12,
3990
- L: 101,
3910
+ L: 98,
3991
3911
  S: this,
3992
3912
  C: (f, a) => f(...a)
3993
3913
  });
@@ -3995,7 +3915,7 @@ var DataSpaceManager = class {
3995
3915
  id: this._instanceId
3996
3916
  }), {
3997
3917
  F: __dxlog_file12,
3998
- L: 102,
3918
+ L: 99,
3999
3919
  S: this,
4000
3920
  C: (f, a) => f(...a)
4001
3921
  });
@@ -4003,7 +3923,7 @@ var DataSpaceManager = class {
4003
3923
  spaces: this._metadataStore.spaces.length
4004
3924
  }, {
4005
3925
  F: __dxlog_file12,
4006
- L: 103,
3926
+ L: 100,
4007
3927
  S: this,
4008
3928
  C: (f, a) => f(...a)
4009
3929
  });
@@ -4013,7 +3933,7 @@ var DataSpaceManager = class {
4013
3933
  spaceMetadata
4014
3934
  }, {
4015
3935
  F: __dxlog_file12,
4016
- L: 107,
3936
+ L: 104,
4017
3937
  S: this,
4018
3938
  C: (f, a) => f(...a)
4019
3939
  });
@@ -4024,7 +3944,7 @@ var DataSpaceManager = class {
4024
3944
  err
4025
3945
  }, {
4026
3946
  F: __dxlog_file12,
4027
- L: 110,
3947
+ L: 107,
4028
3948
  S: this,
4029
3949
  C: (f, a) => f(...a)
4030
3950
  });
@@ -4033,7 +3953,7 @@ var DataSpaceManager = class {
4033
3953
  this._isOpen = true;
4034
3954
  this.updated.emit();
4035
3955
  for (const space of this._spaces.values()) {
4036
- if (space.state !== import_services9.SpaceState.INACTIVE) {
3956
+ if (space.state !== import_services8.SpaceState.INACTIVE) {
4037
3957
  space.initializeDataPipelineAsync();
4038
3958
  }
4039
3959
  }
@@ -4041,7 +3961,7 @@ var DataSpaceManager = class {
4041
3961
  id: this._instanceId
4042
3962
  }), {
4043
3963
  F: __dxlog_file12,
4044
- L: 123,
3964
+ L: 120,
4045
3965
  S: this,
4046
3966
  C: (f, a) => f(...a)
4047
3967
  });
@@ -4049,7 +3969,7 @@ var DataSpaceManager = class {
4049
3969
  async close() {
4050
3970
  (0, import_log10.log)("close", void 0, {
4051
3971
  F: __dxlog_file12,
4052
- L: 128,
3972
+ L: 125,
4053
3973
  S: this,
4054
3974
  C: (f, a) => f(...a)
4055
3975
  });
@@ -4065,7 +3985,7 @@ var DataSpaceManager = class {
4065
3985
  async createSpace() {
4066
3986
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
4067
3987
  F: __dxlog_file12,
4068
- L: 141,
3988
+ L: 138,
4069
3989
  S: this,
4070
3990
  A: [
4071
3991
  "this._isOpen",
@@ -4080,13 +4000,13 @@ var DataSpaceManager = class {
4080
4000
  genesisFeedKey: controlFeedKey,
4081
4001
  controlFeedKey,
4082
4002
  dataFeedKey,
4083
- state: import_services9.SpaceState.ACTIVE
4003
+ state: import_services8.SpaceState.ACTIVE
4084
4004
  };
4085
4005
  (0, import_log10.log)("creating space...", {
4086
4006
  spaceKey
4087
4007
  }, {
4088
4008
  F: __dxlog_file12,
4089
- L: 153,
4009
+ L: 150,
4090
4010
  S: this,
4091
4011
  C: (f, a) => f(...a)
4092
4012
  });
@@ -4100,9 +4020,9 @@ var DataSpaceManager = class {
4100
4020
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
4101
4021
  await this._metadataStore.addSpace(metadata);
4102
4022
  const memberCredential = credentials[1];
4103
- (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4023
+ (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4104
4024
  F: __dxlog_file12,
4105
- L: 166,
4025
+ L: 163,
4106
4026
  S: this,
4107
4027
  A: [
4108
4028
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4120,13 +4040,13 @@ var DataSpaceManager = class {
4120
4040
  opts
4121
4041
  }, {
4122
4042
  F: __dxlog_file12,
4123
- L: 178,
4043
+ L: 175,
4124
4044
  S: this,
4125
4045
  C: (f, a) => f(...a)
4126
4046
  });
4127
4047
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
4128
4048
  F: __dxlog_file12,
4129
- L: 179,
4049
+ L: 176,
4130
4050
  S: this,
4131
4051
  A: [
4132
4052
  "this._isOpen",
@@ -4135,7 +4055,7 @@ var DataSpaceManager = class {
4135
4055
  });
4136
4056
  (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4137
4057
  F: __dxlog_file12,
4138
- L: 180,
4058
+ L: 177,
4139
4059
  S: this,
4140
4060
  A: [
4141
4061
  "!this._spaces.has(opts.spaceKey)",
@@ -4160,9 +4080,9 @@ var DataSpaceManager = class {
4160
4080
  * TODO(dmaretskyi): Consider removing.
4161
4081
  */
4162
4082
  async waitUntilSpaceReady(spaceKey) {
4163
- await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4083
+ await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4164
4084
  const space = this._spaces.get(spaceKey);
4165
- return !!space && space.state === import_services9.SpaceState.READY;
4085
+ return !!space && space.state === import_services8.SpaceState.READY;
4166
4086
  }));
4167
4087
  }
4168
4088
  async _constructSpace(metadata) {
@@ -4170,7 +4090,7 @@ var DataSpaceManager = class {
4170
4090
  metadata
4171
4091
  }, {
4172
4092
  F: __dxlog_file12,
4173
- L: 213,
4093
+ L: 210,
4174
4094
  S: this,
4175
4095
  C: (f, a) => f(...a)
4176
4096
  });
@@ -4208,21 +4128,18 @@ var DataSpaceManager = class {
4208
4128
  onAuthFailure: () => {
4209
4129
  import_log10.log.warn("auth failure", void 0, {
4210
4130
  F: __dxlog_file12,
4211
- L: 250,
4131
+ L: 247,
4212
4132
  S: this,
4213
4133
  C: (f, a) => f(...a)
4214
4134
  });
4215
4135
  },
4216
- memberKey: this._signingContext.identityKey,
4217
- onDelegatedInvitationStatusChange: (invitation, isActive) => {
4218
- return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
4219
- }
4136
+ memberKey: this._signingContext.identityKey
4220
4137
  });
4221
4138
  controlFeed && await space.setControlFeed(controlFeed);
4222
4139
  dataFeed && await space.setDataFeed(dataFeed);
4223
4140
  const dataSpace = new DataSpace({
4224
4141
  inner: space,
4225
- initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
4142
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
4226
4143
  metadataStore: this._metadataStore,
4227
4144
  gossip,
4228
4145
  presence,
@@ -4235,7 +4152,7 @@ var DataSpaceManager = class {
4235
4152
  space: space.key
4236
4153
  }, {
4237
4154
  F: __dxlog_file12,
4238
- L: 271,
4155
+ L: 265,
4239
4156
  S: this,
4240
4157
  C: (f, a) => f(...a)
4241
4158
  });
@@ -4246,14 +4163,11 @@ var DataSpaceManager = class {
4246
4163
  open: this._isOpen
4247
4164
  }, {
4248
4165
  F: __dxlog_file12,
4249
- L: 274,
4166
+ L: 268,
4250
4167
  S: this,
4251
4168
  C: (f, a) => f(...a)
4252
4169
  });
4253
4170
  if (this._isOpen) {
4254
- await this._createDelegatedInvitations(dataSpace, [
4255
- ...space.spaceState.invitations.entries()
4256
- ]);
4257
4171
  this.updated.emit();
4258
4172
  }
4259
4173
  },
@@ -4262,7 +4176,7 @@ var DataSpaceManager = class {
4262
4176
  space: space.key
4263
4177
  }, {
4264
4178
  F: __dxlog_file12,
4265
- L: 281,
4179
+ L: 274,
4266
4180
  S: this,
4267
4181
  C: (f, a) => f(...a)
4268
4182
  });
@@ -4271,7 +4185,7 @@ var DataSpaceManager = class {
4271
4185
  cache: metadata.cache,
4272
4186
  automergeHost: this._automergeHost
4273
4187
  });
4274
- if (metadata.state !== import_services9.SpaceState.INACTIVE) {
4188
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
4275
4189
  await dataSpace.open();
4276
4190
  }
4277
4191
  if (metadata.controlTimeframe) {
@@ -4280,41 +4194,6 @@ var DataSpaceManager = class {
4280
4194
  this._spaces.set(metadata.key, dataSpace);
4281
4195
  return dataSpace;
4282
4196
  }
4283
- async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
4284
- if (dataSpace?.state !== import_services9.SpaceState.READY) {
4285
- return;
4286
- }
4287
- if (isActive) {
4288
- await this._createDelegatedInvitations(dataSpace, [
4289
- [
4290
- delegatedInvitation.credentialId,
4291
- delegatedInvitation.invitation
4292
- ]
4293
- ]);
4294
- } else {
4295
- await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
4296
- }
4297
- }
4298
- async _createDelegatedInvitations(space, invitations) {
4299
- const tasks = invitations.map(([credentialId, invitation]) => {
4300
- return this._invitationsManager.createInvitation({
4301
- type: import_services9.Invitation.Type.DELEGATED,
4302
- kind: import_services9.Invitation.Kind.SPACE,
4303
- spaceKey: space.key,
4304
- authMethod: invitation.authMethod,
4305
- invitationId: invitation.invitationId,
4306
- swarmKey: invitation.swarmKey,
4307
- guestKeypair: invitation.guestKey ? {
4308
- publicKey: invitation.guestKey
4309
- } : void 0,
4310
- lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
4311
- multiUse: invitation.multiUse,
4312
- delegationCredentialId: credentialId,
4313
- persistent: false
4314
- });
4315
- });
4316
- await Promise.all(tasks);
4317
- }
4318
4197
  };
4319
4198
  _ts_decorate5([
4320
4199
  import_async13.synchronized
@@ -4351,10 +4230,10 @@ var SpacesServiceImpl = class {
4351
4230
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4352
4231
  if (state) {
4353
4232
  switch (state) {
4354
- case import_services10.SpaceState.ACTIVE:
4233
+ case import_services9.SpaceState.ACTIVE:
4355
4234
  await space.activate();
4356
4235
  break;
4357
- case import_services10.SpaceState.INACTIVE:
4236
+ case import_services9.SpaceState.INACTIVE:
4358
4237
  await space.deactivate();
4359
4238
  break;
4360
4239
  default:
@@ -4528,7 +4407,7 @@ var SpacesServiceImpl = class {
4528
4407
  identityKey: member.key,
4529
4408
  profile: member.profile ?? {}
4530
4409
  },
4531
- presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
4410
+ presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
4532
4411
  peerStates: peers
4533
4412
  };
4534
4413
  }),
@@ -4564,6 +4443,59 @@ var createSelectedDocumentsIterator = (automergeHost) => (
4564
4443
  }
4565
4444
  }
4566
4445
  );
4446
+ var createDocumentsIterator = (automergeHost) => (
4447
+ /**
4448
+ * Recursively get all object data blobs from Automerge Repo.
4449
+ * @param ids
4450
+ */
4451
+ // TODO(mykola): Unload automerge handles after usage.
4452
+ async function* getAllDocuments() {
4453
+ const visited = /* @__PURE__ */ new Set();
4454
+ async function* getObjectsFromHandle(handle) {
4455
+ if (visited.has(handle.documentId)) {
4456
+ return;
4457
+ }
4458
+ if (!handle.isReady()) {
4459
+ await handle.whenReady();
4460
+ }
4461
+ const doc = handle.docSync();
4462
+ const heads = (0, import_automerge.getHeads)(doc);
4463
+ if (doc.objects) {
4464
+ yield Object.entries(doc.objects).map(([objectId, object]) => {
4465
+ return {
4466
+ id: import_protocols12.idCodec.encode({
4467
+ documentId: handle.documentId,
4468
+ objectId
4469
+ }),
4470
+ object,
4471
+ currentHash: heads.join("")
4472
+ };
4473
+ });
4474
+ }
4475
+ if (doc.links) {
4476
+ for (const id of Object.values(doc.links)) {
4477
+ if (visited.has(id)) {
4478
+ continue;
4479
+ }
4480
+ const linkHandle = automergeHost.repo.handles[id] ?? automergeHost.repo.find(id);
4481
+ for await (const result of getObjectsFromHandle(linkHandle)) {
4482
+ yield result;
4483
+ }
4484
+ }
4485
+ }
4486
+ visited.add(handle.documentId);
4487
+ }
4488
+ for (const handle of Object.values(automergeHost.repo.handles)) {
4489
+ if (visited.has(handle.documentId)) {
4490
+ continue;
4491
+ }
4492
+ for await (const result of getObjectsFromHandle(handle)) {
4493
+ yield result;
4494
+ }
4495
+ visited.add(handle.documentId);
4496
+ }
4497
+ }
4498
+ );
4567
4499
  function _ts_decorate6(decorators, target, key, desc) {
4568
4500
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4569
4501
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4575,7 +4507,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4575
4507
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4576
4508
  }
4577
4509
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4578
- var ServiceContext = class extends import_context10.Resource {
4510
+ var ServiceContext = class extends import_context9.Resource {
4579
4511
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4580
4512
  super();
4581
4513
  this.storage = storage;
@@ -4585,7 +4517,7 @@ var ServiceContext = class extends import_context10.Resource {
4585
4517
  this._runtimeParams = _runtimeParams;
4586
4518
  this.initialized = new import_async15.Trigger();
4587
4519
  this._handlerFactories = /* @__PURE__ */ new Map();
4588
- this._instanceId = import_keys11.PublicKey.random().toHex();
4520
+ this._instanceId = import_keys10.PublicKey.random().toHex();
4589
4521
  this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
4590
4522
  this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
4591
4523
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
@@ -4620,16 +4552,16 @@ var ServiceContext = class extends import_context10.Resource {
4620
4552
  })
4621
4553
  });
4622
4554
  this.indexer = new import_indexing.Indexer({
4623
- db: this.level,
4624
4555
  indexStore: new import_indexing.IndexStore({
4625
4556
  db: level.sublevel("index-storage")
4626
4557
  }),
4627
4558
  metadataStore: this.indexMetadata,
4628
- loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
4559
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
4560
+ getAllDocuments: createDocumentsIterator(this.automergeHost)
4629
4561
  });
4630
4562
  this.invitations = new InvitationsHandler(this.networkManager);
4631
4563
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
4632
- this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4564
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4633
4565
  }
4634
4566
  async _open(ctx) {
4635
4567
  await this._checkStorageVersion();
@@ -4708,7 +4640,7 @@ var ServiceContext = class extends import_context10.Resource {
4708
4640
  }
4709
4641
  async createIdentity(params = {}) {
4710
4642
  const identity = await this.identityManager.createIdentity(params);
4711
- await this._initialize(new import_context10.Context());
4643
+ await this._initialize(new import_context9.Context());
4712
4644
  return identity;
4713
4645
  }
4714
4646
  getInvitationHandler(invitation) {
@@ -4734,7 +4666,7 @@ var ServiceContext = class extends import_context10.Resource {
4734
4666
  }
4735
4667
  async _acceptIdentity(params) {
4736
4668
  const identity = await this.identityManager.acceptIdentity(params);
4737
- await this._initialize(new import_context10.Context());
4669
+ await this._initialize(new import_context9.Context());
4738
4670
  return identity;
4739
4671
  }
4740
4672
  async _checkStorageVersion() {
@@ -4765,12 +4697,12 @@ var ServiceContext = class extends import_context10.Resource {
4765
4697
  });
4766
4698
  }
4767
4699
  };
4768
- this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this.invitationsManager, this._runtimeParams);
4700
+ this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4769
4701
  await this.dataSpaceManager.open();
4770
- this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
4702
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4771
4703
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4772
4704
  F: __dxlog_file14,
4773
- L: 265,
4705
+ L: 264,
4774
4706
  S: this,
4775
4707
  A: [
4776
4708
  "this.dataSpaceManager",
@@ -4782,7 +4714,7 @@ var ServiceContext = class extends import_context10.Resource {
4782
4714
  this.initialized.wake();
4783
4715
  this._deviceSpaceSync = {
4784
4716
  processCredential: async (credential) => {
4785
- const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4717
+ const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4786
4718
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4787
4719
  return;
4788
4720
  }
@@ -4794,7 +4726,7 @@ var ServiceContext = class extends import_context10.Resource {
4794
4726
  details: assertion
4795
4727
  }, {
4796
4728
  F: __dxlog_file14,
4797
- L: 281,
4729
+ L: 280,
4798
4730
  S: this,
4799
4731
  C: (f, a) => f(...a)
4800
4732
  });
@@ -4805,7 +4737,7 @@ var ServiceContext = class extends import_context10.Resource {
4805
4737
  details: assertion
4806
4738
  }, {
4807
4739
  F: __dxlog_file14,
4808
- L: 285,
4740
+ L: 284,
4809
4741
  S: this,
4810
4742
  C: (f, a) => f(...a)
4811
4743
  });
@@ -4816,7 +4748,7 @@ var ServiceContext = class extends import_context10.Resource {
4816
4748
  details: assertion
4817
4749
  }, {
4818
4750
  F: __dxlog_file14,
4819
- L: 290,
4751
+ L: 289,
4820
4752
  S: this,
4821
4753
  C: (f, a) => f(...a)
4822
4754
  });
@@ -4827,7 +4759,7 @@ var ServiceContext = class extends import_context10.Resource {
4827
4759
  } catch (err) {
4828
4760
  import_log12.log.catch(err, void 0, {
4829
4761
  F: __dxlog_file14,
4830
- L: 296,
4762
+ L: 295,
4831
4763
  S: this,
4832
4764
  C: (f, a) => f(...a)
4833
4765
  });
@@ -4869,26 +4801,26 @@ var ServiceRegistry = class {
4869
4801
  delete this._handlers[name];
4870
4802
  }
4871
4803
  };
4872
- var DXOS_VERSION = "0.4.10-main.fd8ea31";
4804
+ var DXOS_VERSION = "0.4.10-next.71cec10";
4873
4805
  var getPlatform = () => {
4874
4806
  if (process.browser) {
4875
4807
  if (typeof window !== "undefined") {
4876
4808
  const { userAgent } = window.navigator;
4877
4809
  return {
4878
- type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
4810
+ type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
4879
4811
  userAgent,
4880
4812
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
4881
4813
  };
4882
4814
  } else {
4883
4815
  return {
4884
- type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
4816
+ type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
4885
4817
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
4886
4818
  };
4887
4819
  }
4888
4820
  } else {
4889
4821
  const { platform: platform2, version, arch } = process;
4890
4822
  return {
4891
- type: import_services13.Platform.PLATFORM_TYPE.NODE,
4823
+ type: import_services12.Platform.PLATFORM_TYPE.NODE,
4892
4824
  platform: platform2,
4893
4825
  arch,
4894
4826
  runtime: version,
@@ -4975,7 +4907,7 @@ var getSpaceStats = async (space) => {
4975
4907
  const stats = {
4976
4908
  key: space.key,
4977
4909
  metrics: space.metrics,
4978
- epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
4910
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
4979
4911
  ...credential.subject.assertion,
4980
4912
  id: credential.id
4981
4913
  })),
@@ -4986,7 +4918,7 @@ var getSpaceStats = async (space) => {
4986
4918
  displayName: member.assertion.profile?.displayName
4987
4919
  }
4988
4920
  },
4989
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
4921
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
4990
4922
  })),
4991
4923
  pipeline: {
4992
4924
  // TODO(burdon): Pick properties from credentials if needed.
@@ -5050,9 +4982,9 @@ var DevicesServiceImpl = class {
5050
4982
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
5051
4983
  return {
5052
4984
  deviceKey: key,
5053
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
4985
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
5054
4986
  profile,
5055
- presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
4987
+ presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
5056
4988
  };
5057
4989
  })
5058
4990
  });
@@ -5151,7 +5083,7 @@ var LoggingServiceImpl = class {
5151
5083
  constructor() {
5152
5084
  this._logs = new import_async18.Event();
5153
5085
  this._started = Date.now();
5154
- this._sessionId = import_keys13.PublicKey.random().toHex();
5086
+ this._sessionId = import_keys12.PublicKey.random().toHex();
5155
5087
  this._logProcessor = (_config, entry2) => {
5156
5088
  this._logs.emit(entry2);
5157
5089
  };
@@ -5248,16 +5180,16 @@ var LoggingServiceImpl = class {
5248
5180
  };
5249
5181
  var matchFilter = (filter, level, path2, options) => {
5250
5182
  switch (options) {
5251
- case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5183
+ case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5252
5184
  return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5253
- case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
5185
+ case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
5254
5186
  return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5255
5187
  }
5256
5188
  };
5257
5189
  var shouldLog = (entry2, request) => {
5258
- const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5190
+ const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5259
5191
  if (request.filters === void 0) {
5260
- return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5192
+ return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5261
5193
  } else {
5262
5194
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5263
5195
  }
@@ -5294,7 +5226,7 @@ var NetworkServiceImpl = class {
5294
5226
  }
5295
5227
  };
5296
5228
  var getRootPath = (config) => {
5297
- const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
5229
+ const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
5298
5230
  return `${dataRoot}/`;
5299
5231
  };
5300
5232
  var isPersistent = (config) => {
@@ -5345,7 +5277,7 @@ var toStorageType = (type) => {
5345
5277
  };
5346
5278
  var createLevel = async (config) => {
5347
5279
  const persistent = isPersistent(config);
5348
- const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
5280
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5349
5281
  const level = new import_level.Level(storagePath);
5350
5282
  await level.open();
5351
5283
  return level;
@@ -5370,8 +5302,8 @@ var SystemServiceImpl = class {
5370
5302
  return {
5371
5303
  timestamp: /* @__PURE__ */ new Date(),
5372
5304
  diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
5373
- truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5374
- humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5305
+ truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5306
+ humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5375
5307
  })))
5376
5308
  };
5377
5309
  }
@@ -5445,7 +5377,7 @@ var ClientServicesHost = class {
5445
5377
  lockKey,
5446
5378
  onAcquire: () => {
5447
5379
  if (!this._opening) {
5448
- void this.open(new import_context11.Context());
5380
+ void this.open(new import_context10.Context());
5449
5381
  }
5450
5382
  },
5451
5383
  onRelease: () => this.close()
@@ -5454,14 +5386,14 @@ var ClientServicesHost = class {
5454
5386
  this._systemService = new SystemServiceImpl({
5455
5387
  config: () => this._config,
5456
5388
  statusUpdate: this._statusUpdate,
5457
- getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
5389
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
5458
5390
  getDiagnostics: () => {
5459
5391
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
5460
5392
  },
5461
5393
  onUpdateStatus: async (status) => {
5462
- if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
5394
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
5463
5395
  await this._resourceLock?.acquire();
5464
- } else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
5396
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
5465
5397
  await this._resourceLock?.release();
5466
5398
  }
5467
5399
  },
@@ -5471,7 +5403,7 @@ var ClientServicesHost = class {
5471
5403
  });
5472
5404
  this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5473
5405
  this._loggingService = new LoggingServiceImpl();
5474
- this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
5406
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
5475
5407
  SystemService: this._systemService,
5476
5408
  TracingService: this._tracingService
5477
5409
  });
@@ -5567,7 +5499,7 @@ var ClientServicesHost = class {
5567
5499
  if (this._open) {
5568
5500
  return;
5569
5501
  }
5570
- const traceId = import_keys12.PublicKey.random().toHex();
5502
+ const traceId = import_keys11.PublicKey.random().toHex();
5571
5503
  import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
5572
5504
  id: traceId
5573
5505
  }), {
@@ -5660,7 +5592,7 @@ var ClientServicesHost = class {
5660
5592
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
5661
5593
  url: devtoolsProxy,
5662
5594
  requested: {},
5663
- exposed: import_client_protocol5.clientServiceBundle,
5595
+ exposed: import_client_protocol4.clientServiceBundle,
5664
5596
  handlers: this.services
5665
5597
  });
5666
5598
  void this._devtoolsProxy.open();
@@ -5721,7 +5653,7 @@ var ClientServicesHost = class {
5721
5653
  });
5722
5654
  }
5723
5655
  async reset() {
5724
- const traceId = import_keys12.PublicKey.random().toHex();
5656
+ const traceId = import_keys11.PublicKey.random().toHex();
5725
5657
  import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
5726
5658
  id: traceId
5727
5659
  }), {
@@ -5772,16 +5704,16 @@ var ClientServicesHost = class {
5772
5704
  await document.whenReady();
5773
5705
  const properties = {
5774
5706
  system: {
5775
- type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
5707
+ type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol4.Properties))
5776
5708
  },
5777
5709
  data: {
5778
- [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5710
+ [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
5779
5711
  },
5780
5712
  meta: {
5781
5713
  keys: []
5782
5714
  }
5783
5715
  };
5784
- const propertiesId = import_keys12.PublicKey.random().toHex();
5716
+ const propertiesId = import_keys11.PublicKey.random().toHex();
5785
5717
  document.change((doc) => {
5786
5718
  (0, import_util9.assignDeep)(doc, [
5787
5719
  "objects",
@@ -5816,7 +5748,7 @@ var DiagnosticsCollector = class {
5816
5748
  }
5817
5749
  static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5818
5750
  const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5819
- keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5751
+ keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5820
5752
  });
5821
5753
  const clientDiagnostics = {
5822
5754
  config,
@@ -5881,4 +5813,4 @@ var findConfigs = () => {
5881
5813
  subscribeToSpaces,
5882
5814
  subscribeToSwarmInfo
5883
5815
  });
5884
- //# sourceMappingURL=chunk-YXZQQAQN.cjs.map
5816
+ //# sourceMappingURL=chunk-Y3ADPF24.cjs.map