@dxos/client-services 0.1.36-next.ef27157 → 0.1.37-next.41339e7

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 (32) hide show
  1. package/dist/lib/browser/{chunk-OINEQJWM.mjs → chunk-6PNXHM7C.mjs} +232 -90
  2. package/dist/lib/browser/chunk-6PNXHM7C.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 +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
  7. package/dist/lib/node/index.cjs +230 -88
  8. package/dist/lib/node/index.cjs.map +3 -3
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +230 -88
  11. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  12. package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -0
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  14. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/service-context.d.ts +0 -1
  16. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  18. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
  20. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  21. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -3
  22. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  23. package/package.json +30 -30
  24. package/src/packlets/identity/identity-manager.ts +2 -1
  25. package/src/packlets/invitations/invitations-handler.ts +50 -5
  26. package/src/packlets/services/service-context.ts +7 -9
  27. package/src/packlets/services/service-host.ts +8 -2
  28. package/src/packlets/spaces/data-space-manager.ts +5 -0
  29. package/src/packlets/storage/storage.ts +2 -0
  30. package/src/packlets/testing/test-builder.ts +3 -3
  31. package/src/packlets/tests/spaces.test.ts +24 -0
  32. package/dist/lib/browser/chunk-OINEQJWM.mjs.map +0 -7
@@ -82,7 +82,7 @@ var import_async18 = require("@dxos/async");
82
82
  var import_client8 = require("@dxos/client");
83
83
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
84
84
  var import_log16 = require("@dxos/log");
85
- var import_protocols6 = require("@dxos/protocols");
85
+ var import_protocols7 = require("@dxos/protocols");
86
86
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
87
87
 
88
88
  // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
@@ -698,10 +698,11 @@ var IdentityManager = class {
698
698
  async open() {
699
699
  var _a;
700
700
  import_log3.log.trace("dxos.halo.identity-manager", import_protocols2.trace.begin({
701
- id: this._instanceId
701
+ id: this._instanceId,
702
+ parentId: this._traceParent
702
703
  }), {
703
704
  file: "identity-manager.ts",
704
- line: 71,
705
+ line: 72,
705
706
  scope: this,
706
707
  callSite: (f, a) => f(...a)
707
708
  });
@@ -711,7 +712,7 @@ var IdentityManager = class {
711
712
  identityRecord
712
713
  }, {
713
714
  file: "identity-manager.ts",
714
- line: 75,
715
+ line: 76,
715
716
  scope: this,
716
717
  callSite: (f, a) => f(...a)
717
718
  });
@@ -724,7 +725,7 @@ var IdentityManager = class {
724
725
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
725
726
  }, {
726
727
  file: "identity-manager.ts",
727
- line: 80,
728
+ line: 81,
728
729
  scope: this,
729
730
  callSite: (f, a) => f(...a)
730
731
  });
@@ -738,7 +739,7 @@ var IdentityManager = class {
738
739
  id: this._instanceId
739
740
  }), {
740
741
  file: "identity-manager.ts",
741
- line: 90,
742
+ line: 91,
742
743
  scope: this,
743
744
  callSite: (f, a) => f(...a)
744
745
  });
@@ -748,7 +749,7 @@ var IdentityManager = class {
748
749
  (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
749
750
  (0, import_log3.log)("creating identity...", {}, {
750
751
  file: "identity-manager.ts",
751
- line: 95,
752
+ line: 96,
752
753
  scope: this,
753
754
  callSite: (f, a) => f(...a)
754
755
  });
@@ -797,7 +798,7 @@ var IdentityManager = class {
797
798
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
798
799
  }, {
799
800
  file: "identity-manager.ts",
800
- line: 150,
801
+ line: 151,
801
802
  scope: this,
802
803
  callSite: (f, a) => f(...a)
803
804
  });
@@ -807,7 +808,7 @@ var IdentityManager = class {
807
808
  deviceKey: identity.deviceKey
808
809
  }, {
809
810
  file: "identity-manager.ts",
810
- line: 156,
811
+ line: 157,
811
812
  scope: this,
812
813
  callSite: (f, a) => f(...a)
813
814
  });
@@ -822,7 +823,7 @@ var IdentityManager = class {
822
823
  params
823
824
  }, {
824
825
  file: "identity-manager.ts",
825
- line: 164,
826
+ line: 165,
826
827
  scope: this,
827
828
  callSite: (f, a) => f(...a)
828
829
  });
@@ -848,7 +849,7 @@ var IdentityManager = class {
848
849
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
849
850
  }, {
850
851
  file: "identity-manager.ts",
851
- line: 184,
852
+ line: 185,
852
853
  scope: this,
853
854
  callSite: (f, a) => f(...a)
854
855
  });
@@ -858,7 +859,7 @@ var IdentityManager = class {
858
859
  deviceKey: identity.deviceKey
859
860
  }, {
860
861
  file: "identity-manager.ts",
861
- line: 190,
862
+ line: 191,
862
863
  scope: this,
863
864
  callSite: (f, a) => f(...a)
864
865
  });
@@ -870,7 +871,7 @@ var IdentityManager = class {
870
871
  identityRecord
871
872
  }, {
872
873
  file: "identity-manager.ts",
873
- line: 196,
874
+ line: 197,
874
875
  scope: this,
875
876
  callSite: (f, a) => f(...a)
876
877
  });
@@ -903,7 +904,7 @@ var IdentityManager = class {
903
904
  identityKey: identityRecord.identityKey
904
905
  }, {
905
906
  file: "identity-manager.ts",
906
- line: 224,
907
+ line: 225,
907
908
  scope: this,
908
909
  callSite: (f, a) => f(...a)
909
910
  });
@@ -1083,7 +1084,7 @@ var InvitationsHandler = class {
1083
1084
  ...protocol.toJSON()
1084
1085
  }, {
1085
1086
  file: "invitations-handler.ts",
1086
- line: 102,
1087
+ line: 106,
1087
1088
  scope: this,
1088
1089
  callSite: (f, a) => f(...a)
1089
1090
  });
@@ -1101,7 +1102,7 @@ var InvitationsHandler = class {
1101
1102
  ...protocol.toJSON()
1102
1103
  }, {
1103
1104
  file: "invitations-handler.ts",
1104
- line: 115,
1105
+ line: 119,
1105
1106
  scope: this,
1106
1107
  callSite: (f, a) => f(...a)
1107
1108
  });
@@ -1120,7 +1121,7 @@ var InvitationsHandler = class {
1120
1121
  authCode: code
1121
1122
  }, {
1122
1123
  file: "invitations-handler.ts",
1123
- line: 134,
1124
+ line: 138,
1124
1125
  scope: this,
1125
1126
  callSite: (f, a) => f(...a)
1126
1127
  });
@@ -1129,7 +1130,7 @@ var InvitationsHandler = class {
1129
1130
  case import_services3.Invitation.AuthMethod.NONE: {
1130
1131
  (0, import_log4.log)("authentication not required", {}, {
1131
1132
  file: "invitations-handler.ts",
1132
- line: 139,
1133
+ line: 143,
1133
1134
  scope: this,
1134
1135
  callSite: (f, a) => f(...a)
1135
1136
  });
@@ -1154,7 +1155,7 @@ var InvitationsHandler = class {
1154
1155
  authMethod: invitation.authMethod
1155
1156
  }, {
1156
1157
  file: "invitations-handler.ts",
1157
- line: 157,
1158
+ line: 161,
1158
1159
  scope: this,
1159
1160
  callSite: (f, a) => f(...a)
1160
1161
  });
@@ -1184,12 +1185,22 @@ var InvitationsHandler = class {
1184
1185
  },
1185
1186
  onOpen: () => {
1186
1187
  (0, import_async7.scheduleTask)(ctx, async () => {
1188
+ const traceId = import_keys6.PublicKey.random().toHex();
1187
1189
  try {
1190
+ import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols3.trace.begin({
1191
+ id: traceId,
1192
+ parentId: this._traceParent
1193
+ }), {
1194
+ file: "invitations-handler.ts",
1195
+ line: 196,
1196
+ scope: this,
1197
+ callSite: (f, a) => f(...a)
1198
+ });
1188
1199
  (0, import_log4.log)("connected", {
1189
1200
  ...protocol.toJSON()
1190
1201
  }, {
1191
1202
  file: "invitations-handler.ts",
1192
- line: 191,
1203
+ line: 200,
1193
1204
  scope: this,
1194
1205
  callSite: (f, a) => f(...a)
1195
1206
  });
@@ -1205,7 +1216,7 @@ var InvitationsHandler = class {
1205
1216
  ...protocol.toJSON()
1206
1217
  }, {
1207
1218
  file: "invitations-handler.ts",
1208
- line: 194,
1219
+ line: 203,
1209
1220
  scope: this,
1210
1221
  callSite: (f, a) => f(...a)
1211
1222
  });
@@ -1213,13 +1224,21 @@ var InvitationsHandler = class {
1213
1224
  ...invitation,
1214
1225
  state: import_services3.Invitation.State.SUCCESS
1215
1226
  });
1227
+ import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols3.trace.end({
1228
+ id: traceId
1229
+ }), {
1230
+ file: "invitations-handler.ts",
1231
+ line: 205,
1232
+ scope: this,
1233
+ callSite: (f, a) => f(...a)
1234
+ });
1216
1235
  } catch (err) {
1217
1236
  if (err instanceof import_async7.TimeoutError) {
1218
1237
  (0, import_log4.log)("timeout", {
1219
1238
  ...protocol.toJSON()
1220
1239
  }, {
1221
1240
  file: "invitations-handler.ts",
1222
- line: 198,
1241
+ line: 208,
1223
1242
  scope: this,
1224
1243
  callSite: (f, a) => f(...a)
1225
1244
  });
@@ -1230,12 +1249,21 @@ var InvitationsHandler = class {
1230
1249
  } else {
1231
1250
  import_log4.log.error("failed", err, {
1232
1251
  file: "invitations-handler.ts",
1233
- line: 201,
1252
+ line: 211,
1234
1253
  scope: this,
1235
1254
  callSite: (f, a) => f(...a)
1236
1255
  });
1237
1256
  stream.error(err);
1238
1257
  }
1258
+ import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols3.trace.error({
1259
+ id: traceId,
1260
+ error: err
1261
+ }), {
1262
+ file: "invitations-handler.ts",
1263
+ line: 214,
1264
+ scope: this,
1265
+ callSite: (f, a) => f(...a)
1266
+ });
1239
1267
  } finally {
1240
1268
  if (type !== import_services3.Invitation.Type.MULTIUSE) {
1241
1269
  await (0, import_async7.sleep)(import_client.ON_CLOSE_DELAY);
@@ -1245,6 +1273,7 @@ var InvitationsHandler = class {
1245
1273
  });
1246
1274
  }
1247
1275
  });
1276
+ extension._traceParent = this._traceParent;
1248
1277
  return extension;
1249
1278
  };
1250
1279
  (0, import_async7.scheduleTask)(ctx, async () => {
@@ -1288,7 +1317,7 @@ var InvitationsHandler = class {
1288
1317
  ...protocol.toJSON()
1289
1318
  }, {
1290
1319
  file: "invitations-handler.ts",
1291
- line: 255,
1320
+ line: 267,
1292
1321
  scope: this,
1293
1322
  callSite: (f, a) => f(...a)
1294
1323
  });
@@ -1299,7 +1328,7 @@ var InvitationsHandler = class {
1299
1328
  } else {
1300
1329
  import_log4.log.warn("auth failed", err, {
1301
1330
  file: "invitations-handler.ts",
1302
- line: 258,
1331
+ line: 270,
1303
1332
  scope: this,
1304
1333
  callSite: (f, a) => f(...a)
1305
1334
  });
@@ -1313,7 +1342,7 @@ var InvitationsHandler = class {
1313
1342
  ...protocol.toJSON()
1314
1343
  }, {
1315
1344
  file: "invitations-handler.ts",
1316
- line: 266,
1345
+ line: 278,
1317
1346
  scope: this,
1318
1347
  callSite: (f, a) => f(...a)
1319
1348
  });
@@ -1324,7 +1353,17 @@ var InvitationsHandler = class {
1324
1353
  const extension = new InvitationGuestExtension({
1325
1354
  onOpen: () => {
1326
1355
  (0, import_async7.scheduleTask)(ctx, async () => {
1356
+ const traceId = import_keys6.PublicKey.random().toHex();
1327
1357
  try {
1358
+ import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols3.trace.begin({
1359
+ id: traceId,
1360
+ parentId: this._traceParent
1361
+ }), {
1362
+ file: "invitations-handler.ts",
1363
+ line: 290,
1364
+ scope: this,
1365
+ callSite: (f, a) => f(...a)
1366
+ });
1328
1367
  if (++connectionCount > 1) {
1329
1368
  throw new Error(`multiple connections detected: ${connectionCount}`);
1330
1369
  }
@@ -1333,7 +1372,7 @@ var InvitationsHandler = class {
1333
1372
  ...protocol.toJSON()
1334
1373
  }, {
1335
1374
  file: "invitations-handler.ts",
1336
- line: 284,
1375
+ line: 301,
1337
1376
  scope: this,
1338
1377
  callSite: (f, a) => f(...a)
1339
1378
  });
@@ -1345,7 +1384,7 @@ var InvitationsHandler = class {
1345
1384
  ...protocol.toJSON()
1346
1385
  }, {
1347
1386
  file: "invitations-handler.ts",
1348
- line: 288,
1387
+ line: 305,
1349
1388
  scope: this,
1350
1389
  callSite: (f, a) => f(...a)
1351
1390
  });
@@ -1355,7 +1394,7 @@ var InvitationsHandler = class {
1355
1394
  response: introductionResponse
1356
1395
  }, {
1357
1396
  file: "invitations-handler.ts",
1358
- line: 292,
1397
+ line: 309,
1359
1398
  scope: this,
1360
1399
  callSite: (f, a) => f(...a)
1361
1400
  });
@@ -1367,7 +1406,7 @@ var InvitationsHandler = class {
1367
1406
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1368
1407
  (0, import_log4.log)("guest waiting for authentication code...", {}, {
1369
1408
  file: "invitations-handler.ts",
1370
- line: 301,
1409
+ line: 318,
1371
1410
  scope: this,
1372
1411
  callSite: (f, a) => f(...a)
1373
1412
  });
@@ -1380,7 +1419,7 @@ var InvitationsHandler = class {
1380
1419
  });
1381
1420
  (0, import_log4.log)("sending authentication request", {}, {
1382
1421
  file: "invitations-handler.ts",
1383
- line: 305,
1422
+ line: 322,
1384
1423
  scope: this,
1385
1424
  callSite: (f, a) => f(...a)
1386
1425
  });
@@ -1402,7 +1441,7 @@ var InvitationsHandler = class {
1402
1441
  attempt
1403
1442
  }, {
1404
1443
  file: "invitations-handler.ts",
1405
- line: 316,
1444
+ line: 333,
1406
1445
  scope: this,
1407
1446
  callSite: (f, a) => f(...a)
1408
1447
  });
@@ -1420,7 +1459,7 @@ var InvitationsHandler = class {
1420
1459
  ...protocol.toJSON()
1421
1460
  }, {
1422
1461
  file: "invitations-handler.ts",
1423
- line: 327,
1462
+ line: 344,
1424
1463
  scope: this,
1425
1464
  callSite: (f, a) => f(...a)
1426
1465
  });
@@ -1431,7 +1470,7 @@ var InvitationsHandler = class {
1431
1470
  ...protocol.toJSON()
1432
1471
  }, {
1433
1472
  file: "invitations-handler.ts",
1434
- line: 335,
1473
+ line: 352,
1435
1474
  scope: this,
1436
1475
  callSite: (f, a) => f(...a)
1437
1476
  });
@@ -1440,13 +1479,21 @@ var InvitationsHandler = class {
1440
1479
  ...result,
1441
1480
  state: import_services3.Invitation.State.SUCCESS
1442
1481
  });
1482
+ import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols3.trace.end({
1483
+ id: traceId
1484
+ }), {
1485
+ file: "invitations-handler.ts",
1486
+ line: 354,
1487
+ scope: this,
1488
+ callSite: (f, a) => f(...a)
1489
+ });
1443
1490
  } catch (err) {
1444
1491
  if (err instanceof import_async7.TimeoutError) {
1445
1492
  (0, import_log4.log)("timeout", {
1446
1493
  ...protocol.toJSON()
1447
1494
  }, {
1448
1495
  file: "invitations-handler.ts",
1449
- line: 339,
1496
+ line: 357,
1450
1497
  scope: this,
1451
1498
  callSite: (f, a) => f(...a)
1452
1499
  });
@@ -1455,14 +1502,23 @@ var InvitationsHandler = class {
1455
1502
  state: import_services3.Invitation.State.TIMEOUT
1456
1503
  });
1457
1504
  } else {
1458
- import_log4.log.warn("auth failed", err, {
1505
+ (0, import_log4.log)("auth failed", err, {
1459
1506
  file: "invitations-handler.ts",
1460
- line: 342,
1507
+ line: 360,
1461
1508
  scope: this,
1462
1509
  callSite: (f, a) => f(...a)
1463
1510
  });
1464
1511
  stream.error(err);
1465
1512
  }
1513
+ import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols3.trace.error({
1514
+ id: traceId,
1515
+ error: err
1516
+ }), {
1517
+ file: "invitations-handler.ts",
1518
+ line: 363,
1519
+ scope: this,
1520
+ callSite: (f, a) => f(...a)
1521
+ });
1466
1522
  } finally {
1467
1523
  await ctx.dispose();
1468
1524
  }
@@ -1521,13 +1577,73 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1521
1577
  // Perhaps in the future we will have more complex logic here.
1522
1578
  InvitationHostService: {
1523
1579
  introduce: async (request) => {
1524
- return this._callbacks.introduce(request);
1580
+ const traceId = import_keys6.PublicKey.random().toHex();
1581
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1582
+ id: traceId,
1583
+ parentId: this._traceParent
1584
+ }), {
1585
+ file: "invitations-handler.ts",
1586
+ line: 442,
1587
+ scope: this,
1588
+ callSite: (f, a) => f(...a)
1589
+ });
1590
+ const response = await this._callbacks.introduce(request);
1591
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1592
+ id: traceId
1593
+ }), {
1594
+ file: "invitations-handler.ts",
1595
+ line: 447,
1596
+ scope: this,
1597
+ callSite: (f, a) => f(...a)
1598
+ });
1599
+ return response;
1525
1600
  },
1526
1601
  authenticate: async (request) => {
1527
- return this._callbacks.authenticate(request);
1602
+ const traceId = import_keys6.PublicKey.random().toHex();
1603
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1604
+ id: traceId,
1605
+ parentId: this._traceParent
1606
+ }), {
1607
+ file: "invitations-handler.ts",
1608
+ line: 453,
1609
+ scope: this,
1610
+ callSite: (f, a) => f(...a)
1611
+ });
1612
+ const response = await this._callbacks.authenticate(request);
1613
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.end({
1614
+ id: traceId,
1615
+ data: {
1616
+ ...response
1617
+ }
1618
+ }), {
1619
+ file: "invitations-handler.ts",
1620
+ line: 458,
1621
+ scope: this,
1622
+ callSite: (f, a) => f(...a)
1623
+ });
1624
+ return response;
1528
1625
  },
1529
1626
  admit: async (request) => {
1530
- return this._callbacks.admit(request);
1627
+ const traceId = import_keys6.PublicKey.random().toHex();
1628
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
1629
+ id: traceId,
1630
+ parentId: this._traceParent
1631
+ }), {
1632
+ file: "invitations-handler.ts",
1633
+ line: 464,
1634
+ scope: this,
1635
+ callSite: (f, a) => f(...a)
1636
+ });
1637
+ const response = await this._callbacks.admit(request);
1638
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1639
+ id: traceId
1640
+ }), {
1641
+ file: "invitations-handler.ts",
1642
+ line: 469,
1643
+ scope: this,
1644
+ callSite: (f, a) => f(...a)
1645
+ });
1646
+ return response;
1531
1647
  }
1532
1648
  }
1533
1649
  };
@@ -1916,6 +2032,7 @@ var import_credentials11 = require("@dxos/credentials");
1916
2032
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
1917
2033
  var import_keys9 = require("@dxos/keys");
1918
2034
  var import_log9 = require("@dxos/log");
2035
+ var import_protocols5 = require("@dxos/protocols");
1919
2036
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
1920
2037
  var import_util5 = require("@dxos/util");
1921
2038
 
@@ -2412,6 +2529,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2412
2529
  this.updated = new import_async10.Event();
2413
2530
  this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
2414
2531
  this._isOpen = false;
2532
+ this._instanceId = import_keys9.PublicKey.random().toHex();
2415
2533
  }
2416
2534
  // TODO(burdon): Remove.
2417
2535
  get spaces() {
@@ -2420,7 +2538,16 @@ var DataSpaceManager = class DataSpaceManager2 {
2420
2538
  async open() {
2421
2539
  (0, import_log9.log)("open", {}, {
2422
2540
  file: "data-space-manager.ts",
2423
- line: 80,
2541
+ line: 83,
2542
+ scope: this,
2543
+ callSite: (f, a) => f(...a)
2544
+ });
2545
+ import_log9.log.trace("dxos.echo.data-space-manager", import_protocols5.trace.begin({
2546
+ id: this._instanceId,
2547
+ parentId: this._traceParent
2548
+ }), {
2549
+ file: "data-space-manager.ts",
2550
+ line: 84,
2424
2551
  scope: this,
2425
2552
  callSite: (f, a) => f(...a)
2426
2553
  });
@@ -2429,7 +2556,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2429
2556
  spaces: this._metadataStore.spaces.length
2430
2557
  }, {
2431
2558
  file: "data-space-manager.ts",
2432
- line: 82,
2559
+ line: 86,
2433
2560
  scope: this,
2434
2561
  callSite: (f, a) => f(...a)
2435
2562
  });
@@ -2438,7 +2565,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2438
2565
  spaceMetadata
2439
2566
  }, {
2440
2567
  file: "data-space-manager.ts",
2441
- line: 85,
2568
+ line: 89,
2442
2569
  scope: this,
2443
2570
  callSite: (f, a) => f(...a)
2444
2571
  });
@@ -2451,7 +2578,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2451
2578
  async close() {
2452
2579
  (0, import_log9.log)("close", {}, {
2453
2580
  file: "data-space-manager.ts",
2454
- line: 96,
2581
+ line: 100,
2455
2582
  scope: this,
2456
2583
  callSite: (f, a) => f(...a)
2457
2584
  });
@@ -2460,6 +2587,14 @@ var DataSpaceManager = class DataSpaceManager2 {
2460
2587
  for (const space of this._spaces.values()) {
2461
2588
  await space.close();
2462
2589
  }
2590
+ import_log9.log.trace("dxos.echo.data-space-manager", import_protocols5.trace.end({
2591
+ id: this._instanceId
2592
+ }), {
2593
+ file: "data-space-manager.ts",
2594
+ line: 106,
2595
+ scope: this,
2596
+ callSite: (f, a) => f(...a)
2597
+ });
2463
2598
  }
2464
2599
  /**
2465
2600
  * Creates a new space writing the genesis credentials to the control feed.
@@ -2479,7 +2614,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2479
2614
  spaceKey
2480
2615
  }, {
2481
2616
  file: "data-space-manager.ts",
2482
- line: 120,
2617
+ line: 125,
2483
2618
  scope: this,
2484
2619
  callSite: (f, a) => f(...a)
2485
2620
  });
@@ -2499,7 +2634,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2499
2634
  opts
2500
2635
  }, {
2501
2636
  file: "data-space-manager.ts",
2502
- line: 139,
2637
+ line: 144,
2503
2638
  scope: this,
2504
2639
  callSite: (f, a) => f(...a)
2505
2640
  });
@@ -2533,7 +2668,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2533
2668
  metadata
2534
2669
  }, {
2535
2670
  file: "data-space-manager.ts",
2536
- line: 175,
2671
+ line: 180,
2537
2672
  scope: this,
2538
2673
  callSite: (f, a) => f(...a)
2539
2674
  });
@@ -2588,7 +2723,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2588
2723
  space: space.key
2589
2724
  }, {
2590
2725
  file: "data-space-manager.ts",
2591
- line: 224,
2726
+ line: 229,
2592
2727
  scope: this,
2593
2728
  callSite: (f, a) => f(...a)
2594
2729
  });
@@ -2600,7 +2735,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2600
2735
  open: this._isOpen
2601
2736
  }, {
2602
2737
  file: "data-space-manager.ts",
2603
- line: 231,
2738
+ line: 236,
2604
2739
  scope: this,
2605
2740
  callSite: (f, a) => f(...a)
2606
2741
  });
@@ -2825,6 +2960,8 @@ var toStorageType = (type) => {
2825
2960
  return import_random_access_storage.StorageType.IDB;
2826
2961
  case StorageDriver.NODE:
2827
2962
  return import_random_access_storage.StorageType.NODE;
2963
+ case StorageDriver.WEBFS:
2964
+ return import_random_access_storage.StorageType.WEBFS;
2828
2965
  default:
2829
2966
  throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
2830
2967
  }
@@ -3421,7 +3558,7 @@ var import_feed_store4 = require("@dxos/feed-store");
3421
3558
  var import_keyring = require("@dxos/keyring");
3422
3559
  var import_keys10 = require("@dxos/keys");
3423
3560
  var import_log15 = require("@dxos/log");
3424
- var import_protocols5 = require("@dxos/protocols");
3561
+ var import_protocols6 = require("@dxos/protocols");
3425
3562
  var ServiceContext = class {
3426
3563
  // prettier-ignore
3427
3564
  constructor(storage, networkManager, modelFactory) {
@@ -3432,6 +3569,7 @@ var ServiceContext = class {
3432
3569
  this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
3433
3570
  this._handlerFactories = /* @__PURE__ */ new Map();
3434
3571
  this._instanceId = import_keys10.PublicKey.random().toHex();
3572
+ networkManager._traceParent = this._instanceId;
3435
3573
  this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
3436
3574
  this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
3437
3575
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
@@ -3448,25 +3586,28 @@ var ServiceContext = class {
3448
3586
  feedStore: this.feedStore,
3449
3587
  networkManager: this.networkManager
3450
3588
  });
3589
+ this.spaceManager._traceParent = this._instanceId;
3451
3590
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3591
+ this.identityManager._traceParent = this._instanceId;
3452
3592
  this.invitations = new InvitationsHandler(this.networkManager);
3593
+ this.invitations._traceParent = this._instanceId;
3453
3594
  this._handlerFactories.set(import_client7.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3454
3595
  var _a;
3455
3596
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3456
3597
  }, this._acceptIdentity.bind(this)));
3457
3598
  }
3458
3599
  async open() {
3459
- import_log15.log.trace("dxos.sdk.client-services", import_protocols5.trace.begin({
3600
+ import_log15.log.trace("dxos.sdk.service-context", import_protocols6.trace.begin({
3460
3601
  id: this._instanceId
3461
3602
  }), {
3462
3603
  file: "service-context.ts",
3463
- line: 111,
3604
+ line: 115,
3464
3605
  scope: this,
3465
3606
  callSite: (f, a) => f(...a)
3466
3607
  });
3467
3608
  (0, import_log15.log)("opening...", {}, {
3468
3609
  file: "service-context.ts",
3469
- line: 113,
3610
+ line: 117,
3470
3611
  scope: this,
3471
3612
  callSite: (f, a) => f(...a)
3472
3613
  });
@@ -3478,7 +3619,7 @@ var ServiceContext = class {
3478
3619
  }
3479
3620
  (0, import_log15.log)("opened", {}, {
3480
3621
  file: "service-context.ts",
3481
- line: 120,
3622
+ line: 124,
3482
3623
  scope: this,
3483
3624
  callSite: (f, a) => f(...a)
3484
3625
  });
@@ -3487,7 +3628,7 @@ var ServiceContext = class {
3487
3628
  var _a, _b;
3488
3629
  (0, import_log15.log)("closing...", {}, {
3489
3630
  file: "service-context.ts",
3490
- line: 124,
3631
+ line: 128,
3491
3632
  scope: this,
3492
3633
  callSite: (f, a) => f(...a)
3493
3634
  });
@@ -3500,34 +3641,18 @@ var ServiceContext = class {
3500
3641
  this.dataServiceSubscriptions.clear();
3501
3642
  (0, import_log15.log)("closed", {}, {
3502
3643
  file: "service-context.ts",
3503
- line: 132,
3644
+ line: 136,
3504
3645
  scope: this,
3505
3646
  callSite: (f, a) => f(...a)
3506
3647
  });
3507
- import_log15.log.trace("dxos.sdk.client-services", import_protocols5.trace.end({
3648
+ import_log15.log.trace("dxos.sdk.service-context", import_protocols6.trace.end({
3508
3649
  id: this._instanceId
3509
3650
  }), {
3510
- file: "service-context.ts",
3511
- line: 134,
3512
- scope: this,
3513
- callSite: (f, a) => f(...a)
3514
- });
3515
- }
3516
- async reset() {
3517
- (0, import_log15.log)("resetting...", {}, {
3518
3651
  file: "service-context.ts",
3519
3652
  line: 138,
3520
3653
  scope: this,
3521
3654
  callSite: (f, a) => f(...a)
3522
3655
  });
3523
- await this.close();
3524
- await this.storage.reset();
3525
- (0, import_log15.log)("reset", {}, {
3526
- file: "service-context.ts",
3527
- line: 141,
3528
- scope: this,
3529
- callSite: (f, a) => f(...a)
3530
- });
3531
3656
  }
3532
3657
  async createIdentity(params = {}) {
3533
3658
  const identity = await this.identityManager.createIdentity(params);
@@ -3549,7 +3674,7 @@ var ServiceContext = class {
3549
3674
  var _a;
3550
3675
  (0, import_log15.log)("initializing spaces...", {}, {
3551
3676
  file: "service-context.ts",
3552
- line: 166,
3677
+ line: 163,
3553
3678
  scope: this,
3554
3679
  callSite: (f, a) => f(...a)
3555
3680
  });
@@ -3568,6 +3693,7 @@ var ServiceContext = class {
3568
3693
  }
3569
3694
  };
3570
3695
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
3696
+ this.dataSpaceManager._traceParent = this._instanceId;
3571
3697
  await this.dataSpaceManager.open();
3572
3698
  this._handlerFactories.set(import_client7.Invitation.Kind.SPACE, (invitation) => {
3573
3699
  (0, import_node_assert12.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
@@ -3588,7 +3714,7 @@ var ServiceContext = class {
3588
3714
  details: assertion
3589
3715
  }, {
3590
3716
  file: "service-context.ts",
3591
- line: 207,
3717
+ line: 205,
3592
3718
  scope: this,
3593
3719
  callSite: (f, a) => f(...a)
3594
3720
  });
@@ -3599,7 +3725,7 @@ var ServiceContext = class {
3599
3725
  details: assertion
3600
3726
  }, {
3601
3727
  file: "service-context.ts",
3602
- line: 211,
3728
+ line: 209,
3603
3729
  scope: this,
3604
3730
  callSite: (f, a) => f(...a)
3605
3731
  });
@@ -3610,7 +3736,7 @@ var ServiceContext = class {
3610
3736
  details: assertion
3611
3737
  }, {
3612
3738
  file: "service-context.ts",
3613
- line: 216,
3739
+ line: 214,
3614
3740
  scope: this,
3615
3741
  callSite: (f, a) => f(...a)
3616
3742
  });
@@ -3621,7 +3747,7 @@ var ServiceContext = class {
3621
3747
  } catch (err) {
3622
3748
  import_log15.log.catch(err, {}, {
3623
3749
  file: "service-context.ts",
3624
- line: 222,
3750
+ line: 220,
3625
3751
  scope: this,
3626
3752
  callSite: (f, a) => f(...a)
3627
3753
  });
@@ -3699,8 +3825,7 @@ var ClientServicesHost = class {
3699
3825
  }
3700
3826
  },
3701
3827
  onReset: async () => {
3702
- (0, import_node_assert13.default)(this._serviceContext, "service host is closed");
3703
- await this._serviceContext.reset();
3828
+ await this.reset();
3704
3829
  }
3705
3830
  });
3706
3831
  this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
@@ -3743,11 +3868,11 @@ var ClientServicesHost = class {
3743
3868
  if (this._open) {
3744
3869
  return;
3745
3870
  }
3746
- import_log16.log.trace("dxos.sdk.client-services-host", import_protocols6.trace.begin({
3871
+ import_log16.log.trace("dxos.sdk.client-services-host", import_protocols7.trace.begin({
3747
3872
  id: this._instanceId
3748
3873
  }), {
3749
3874
  file: "service-host.ts",
3750
- line: 167,
3875
+ line: 166,
3751
3876
  scope: this,
3752
3877
  callSite: (f, a) => f(...a)
3753
3878
  });
@@ -3759,7 +3884,7 @@ var ClientServicesHost = class {
3759
3884
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3760
3885
  }, {
3761
3886
  file: "service-host.ts",
3762
- line: 174,
3887
+ line: 173,
3763
3888
  scope: this,
3764
3889
  callSite: (f, a) => f(...a)
3765
3890
  });
@@ -3793,7 +3918,7 @@ var ClientServicesHost = class {
3793
3918
  deviceKey
3794
3919
  }, {
3795
3920
  file: "service-host.ts",
3796
- line: 221,
3921
+ line: 220,
3797
3922
  scope: this,
3798
3923
  callSite: (f, a) => f(...a)
3799
3924
  });
@@ -3808,7 +3933,7 @@ var ClientServicesHost = class {
3808
3933
  deviceKey
3809
3934
  }, {
3810
3935
  file: "service-host.ts",
3811
- line: 230,
3936
+ line: 229,
3812
3937
  scope: this,
3813
3938
  callSite: (f, a) => f(...a)
3814
3939
  });
@@ -3822,15 +3947,32 @@ var ClientServicesHost = class {
3822
3947
  deviceKey
3823
3948
  }, {
3824
3949
  file: "service-host.ts",
3825
- line: 235,
3950
+ line: 234,
3826
3951
  scope: this,
3827
3952
  callSite: (f, a) => f(...a)
3828
3953
  });
3829
- import_log16.log.trace("dxos.sdk.client-services-host", import_protocols6.trace.end({
3954
+ import_log16.log.trace("dxos.sdk.client-services-host", import_protocols7.trace.end({
3830
3955
  id: this._instanceId
3831
3956
  }), {
3832
3957
  file: "service-host.ts",
3833
- line: 237,
3958
+ line: 236,
3959
+ scope: this,
3960
+ callSite: (f, a) => f(...a)
3961
+ });
3962
+ }
3963
+ async reset() {
3964
+ var _a;
3965
+ (0, import_log16.log)("resetting...", {}, {
3966
+ file: "service-host.ts",
3967
+ line: 240,
3968
+ scope: this,
3969
+ callSite: (f, a) => f(...a)
3970
+ });
3971
+ await ((_a = this._serviceContext) == null ? void 0 : _a.close());
3972
+ await this._storage.reset();
3973
+ (0, import_log16.log)("reset", {}, {
3974
+ file: "service-host.ts",
3975
+ line: 243,
3834
3976
  scope: this,
3835
3977
  callSite: (f, a) => f(...a)
3836
3978
  });