@dxos/client-services 0.4.10-main.c42bfdb → 0.4.10-main.cb83c78

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 (40) hide show
  1. package/dist/lib/browser/{chunk-W7UANCHR.mjs → chunk-MR3A4F5A.mjs} +216 -149
  2. package/dist/lib/browser/chunk-MR3A4F5A.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +3 -3
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +9 -4
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-JSVLZGJM.cjs → chunk-SICZTC25.cjs} +230 -163
  8. package/dist/lib/node/chunk-SICZTC25.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 +14 -9
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/indexing/util.d.ts +2 -1
  14. package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
  15. package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
  16. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts +3 -1
  22. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  23. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
  24. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +34 -34
  27. package/src/packlets/indexing/util.ts +2 -2
  28. package/src/packlets/invitations/invitation-extension.ts +28 -1
  29. package/src/packlets/invitations/invitations-handler.ts +73 -32
  30. package/src/packlets/invitations/invitations-service.ts +5 -5
  31. package/src/packlets/services/automerge-host.test.ts +9 -3
  32. package/src/packlets/services/service-context.test.ts +4 -1
  33. package/src/packlets/services/service-context.ts +5 -3
  34. package/src/packlets/services/service-host.ts +14 -3
  35. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  36. package/src/packlets/storage/level.ts +1 -1
  37. package/src/packlets/testing/test-builder.ts +20 -4
  38. package/src/version.ts +1 -1
  39. package/dist/lib/browser/chunk-W7UANCHR.mjs.map +0 -7
  40. package/dist/lib/node/chunk-JSVLZGJM.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_JSVLZGJM_exports = {};
30
- __export(chunk_JSVLZGJM_exports, {
29
+ var chunk_SICZTC25_exports = {};
30
+ __export(chunk_SICZTC25_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -48,6 +48,7 @@ __export(chunk_JSVLZGJM_exports, {
48
48
  SpaceInvitationProtocol: () => SpaceInvitationProtocol,
49
49
  SpacesServiceImpl: () => SpacesServiceImpl,
50
50
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
51
+ createAdmissionKeypair: () => createAdmissionKeypair,
51
52
  createAuthProvider: () => createAuthProvider,
52
53
  createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
53
54
  createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
@@ -55,7 +56,6 @@ __export(chunk_JSVLZGJM_exports, {
55
56
  createLevel: () => createLevel,
56
57
  createStorageObjects: () => createStorageObjects,
57
58
  getNetworkPeers: () => getNetworkPeers,
58
- invitationExpired: () => invitationExpired,
59
59
  isLocked: () => isLocked,
60
60
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
61
61
  subscribeToFeeds: () => subscribeToFeeds,
@@ -65,7 +65,7 @@ __export(chunk_JSVLZGJM_exports, {
65
65
  subscribeToSpaces: () => subscribeToSpaces,
66
66
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
67
67
  });
68
- module.exports = __toCommonJS(chunk_JSVLZGJM_exports);
68
+ module.exports = __toCommonJS(chunk_SICZTC25_exports);
69
69
  var import_async = require("@dxos/async");
70
70
  var import_codec_protobuf = require("@dxos/codec-protobuf");
71
71
  var import_feed_store = require("@dxos/feed-store");
@@ -120,6 +120,7 @@ var import_async7 = require("@dxos/async");
120
120
  var import_client_protocol2 = require("@dxos/client-protocol");
121
121
  var import_context4 = require("@dxos/context");
122
122
  var import_credentials7 = require("@dxos/credentials");
123
+ var import_crypto = require("@dxos/crypto");
123
124
  var import_invariant5 = require("@dxos/invariant");
124
125
  var import_keys5 = require("@dxos/keys");
125
126
  var import_log4 = require("@dxos/log");
@@ -129,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
129
130
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
130
131
  var import_async8 = require("@dxos/async");
131
132
  var import_context5 = require("@dxos/context");
133
+ var import_crypto2 = require("@dxos/crypto");
132
134
  var import_invariant6 = require("@dxos/invariant");
133
135
  var import_keys6 = require("@dxos/keys");
134
136
  var import_log5 = require("@dxos/log");
@@ -139,6 +141,7 @@ var import_teleport = require("@dxos/teleport");
139
141
  var import_async9 = require("@dxos/async");
140
142
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
141
143
  var import_context6 = require("@dxos/context");
144
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
142
145
  var import_invariant7 = require("@dxos/invariant");
143
146
  var import_log6 = require("@dxos/log");
144
147
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
@@ -157,8 +160,8 @@ var import_client_protocol3 = require("@dxos/client-protocol");
157
160
  var import_context7 = require("@dxos/context");
158
161
  var import_debug3 = require("@dxos/debug");
159
162
  var import_echo_db = require("@dxos/echo-db");
160
- var import_echo_pipeline = require("@dxos/echo-pipeline");
161
163
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
164
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
162
165
  var import_invariant9 = require("@dxos/invariant");
163
166
  var import_keys7 = require("@dxos/keys");
164
167
  var import_log8 = require("@dxos/log");
@@ -203,7 +206,7 @@ var import_async15 = require("@dxos/async");
203
206
  var import_context10 = require("@dxos/context");
204
207
  var import_credentials14 = require("@dxos/credentials");
205
208
  var import_debug6 = require("@dxos/debug");
206
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
209
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
207
210
  var import_feed_store4 = require("@dxos/feed-store");
208
211
  var import_indexing = require("@dxos/indexing");
209
212
  var import_invariant13 = require("@dxos/invariant");
@@ -232,8 +235,8 @@ var import_util8 = require("@dxos/util");
232
235
  var import_async16 = require("@dxos/async");
233
236
  var import_client_protocol4 = require("@dxos/client-protocol");
234
237
  var import_context11 = require("@dxos/context");
235
- var import_echo_pipeline4 = require("@dxos/echo-pipeline");
236
- var E = __toESM(require("@dxos/echo-schema"));
238
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
239
+ var import_echo_schema = require("@dxos/echo-schema");
237
240
  var import_indexing2 = require("@dxos/indexing");
238
241
  var import_invariant15 = require("@dxos/invariant");
239
242
  var import_keys11 = require("@dxos/keys");
@@ -1485,6 +1488,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1485
1488
  this._callbacks = _callbacks;
1486
1489
  this._ctx = new import_context5.Context();
1487
1490
  this._remoteOptionsTrigger = new import_async8.Trigger();
1491
+ this._challenge = void 0;
1488
1492
  this.invitation = void 0;
1489
1493
  this.guestProfile = void 0;
1490
1494
  this.authenticationPassed = false;
@@ -1499,7 +1503,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1499
1503
  options: async (options) => {
1500
1504
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1501
1505
  F: __dxlog_file6,
1502
- L: 87,
1506
+ L: 90,
1503
1507
  S: this,
1504
1508
  A: [
1505
1509
  "!this._remoteOptions",
@@ -1516,7 +1520,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1516
1520
  id: traceId
1517
1521
  }), {
1518
1522
  F: __dxlog_file6,
1519
- L: 96,
1523
+ L: 99,
1520
1524
  S: this,
1521
1525
  C: (f, a) => f(...a)
1522
1526
  });
@@ -1526,7 +1530,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1526
1530
  invitationId
1527
1531
  }, {
1528
1532
  F: __dxlog_file6,
1529
- L: 100,
1533
+ L: 103,
1530
1534
  S: this,
1531
1535
  C: (f, a) => f(...a)
1532
1536
  });
@@ -1540,7 +1544,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1540
1544
  guestProfile: profile
1541
1545
  }, {
1542
1546
  F: __dxlog_file6,
1543
- L: 109,
1547
+ L: 112,
1544
1548
  S: this,
1545
1549
  C: (f, a) => f(...a)
1546
1550
  });
@@ -1549,25 +1553,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1549
1553
  ...this.invitation,
1550
1554
  state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1551
1555
  });
1556
+ this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
1552
1557
  import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
1553
1558
  id: traceId
1554
1559
  }), {
1555
1560
  F: __dxlog_file6,
1556
- L: 116,
1561
+ L: 122,
1557
1562
  S: this,
1558
1563
  C: (f, a) => f(...a)
1559
1564
  });
1560
1565
  return {
1561
- authMethod: this.invitation.authMethod
1566
+ authMethod: this.invitation.authMethod,
1567
+ challenge: this._challenge
1562
1568
  };
1563
1569
  },
1564
- authenticate: async ({ authCode: code }) => {
1570
+ authenticate: async ({ authCode: code, signedChallenge }) => {
1565
1571
  const traceId = import_keys6.PublicKey.random().toHex();
1566
1572
  import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
1567
1573
  id: traceId
1568
1574
  }), {
1569
1575
  F: __dxlog_file6,
1570
- L: 124,
1576
+ L: 131,
1571
1577
  S: this,
1572
1578
  C: (f, a) => f(...a)
1573
1579
  });
@@ -1575,14 +1581,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1575
1581
  authCode: code
1576
1582
  }, {
1577
1583
  F: __dxlog_file6,
1578
- L: 125,
1584
+ L: 132,
1579
1585
  S: this,
1580
1586
  C: (f, a) => f(...a)
1581
1587
  });
1582
1588
  let status = import_invitations2.AuthenticationResponse.Status.OK;
1583
1589
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1584
1590
  F: __dxlog_file6,
1585
- L: 128,
1591
+ L: 135,
1586
1592
  S: this,
1587
1593
  A: [
1588
1594
  "this.invitation",
@@ -1593,7 +1599,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1593
1599
  case import_services4.Invitation.AuthMethod.NONE: {
1594
1600
  (0, import_log5.log)("authentication not required", void 0, {
1595
1601
  F: __dxlog_file6,
1596
- L: 131,
1602
+ L: 138,
1597
1603
  S: this,
1598
1604
  C: (f, a) => f(...a)
1599
1605
  });
@@ -1613,12 +1619,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1613
1619
  }
1614
1620
  break;
1615
1621
  }
1622
+ case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
1623
+ if (!this.invitation.guestKeypair) {
1624
+ status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
1625
+ break;
1626
+ }
1627
+ const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
1628
+ if (isSignatureValid) {
1629
+ this.authenticationPassed = true;
1630
+ } else {
1631
+ status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
1632
+ }
1633
+ break;
1634
+ }
1616
1635
  default: {
1617
1636
  import_log5.log.error("invalid authentication method", {
1618
1637
  authMethod: this.invitation.authMethod
1619
1638
  }, {
1620
1639
  F: __dxlog_file6,
1621
- L: 149,
1640
+ L: 176,
1622
1641
  S: this,
1623
1642
  C: (f, a) => f(...a)
1624
1643
  });
@@ -1633,7 +1652,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1633
1652
  }
1634
1653
  }), {
1635
1654
  F: __dxlog_file6,
1636
- L: 155,
1655
+ L: 182,
1637
1656
  S: this,
1638
1657
  C: (f, a) => f(...a)
1639
1658
  });
@@ -1647,14 +1666,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1647
1666
  id: traceId
1648
1667
  }), {
1649
1668
  F: __dxlog_file6,
1650
- L: 161,
1669
+ L: 188,
1651
1670
  S: this,
1652
1671
  C: (f, a) => f(...a)
1653
1672
  });
1654
1673
  try {
1655
1674
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1656
1675
  F: __dxlog_file6,
1657
- L: 164,
1676
+ L: 191,
1658
1677
  S: this,
1659
1678
  A: [
1660
1679
  "this.invitation",
@@ -1669,7 +1688,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1669
1688
  id: traceId
1670
1689
  }), {
1671
1690
  F: __dxlog_file6,
1672
- L: 172,
1691
+ L: 199,
1673
1692
  S: this,
1674
1693
  C: (f, a) => f(...a)
1675
1694
  });
@@ -1726,7 +1745,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1726
1745
  options: async (options) => {
1727
1746
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1728
1747
  F: __dxlog_file6,
1729
- L: 239,
1748
+ L: 266,
1730
1749
  S: this,
1731
1750
  A: [
1732
1751
  "!this._remoteOptions",
@@ -1753,7 +1772,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1753
1772
  try {
1754
1773
  (0, import_log5.log)("begin options", void 0, {
1755
1774
  F: __dxlog_file6,
1756
- L: 260,
1775
+ L: 287,
1757
1776
  S: this,
1758
1777
  C: (f, a) => f(...a)
1759
1778
  });
@@ -1765,7 +1784,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1765
1784
  }));
1766
1785
  (0, import_log5.log)("end options", void 0, {
1767
1786
  F: __dxlog_file6,
1768
- L: 263,
1787
+ L: 290,
1769
1788
  S: this,
1770
1789
  C: (f, a) => f(...a)
1771
1790
  });
@@ -1779,7 +1798,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1779
1798
  } catch (err) {
1780
1799
  (0, import_log5.log)("openError", err, {
1781
1800
  F: __dxlog_file6,
1782
- L: 273,
1801
+ L: 300,
1783
1802
  S: this,
1784
1803
  C: (f, a) => f(...a)
1785
1804
  });
@@ -1789,7 +1808,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1789
1808
  async onClose() {
1790
1809
  (0, import_log5.log)("onClose", void 0, {
1791
1810
  F: __dxlog_file6,
1792
- L: 279,
1811
+ L: 306,
1793
1812
  S: this,
1794
1813
  C: (f, a) => f(...a)
1795
1814
  });
@@ -1806,11 +1825,11 @@ var InvitationsHandler = class {
1806
1825
  this._networkManager = _networkManager;
1807
1826
  }
1808
1827
  createInvitation(protocol, options) {
1809
- 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 = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
1828
+ 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 ?? {};
1810
1829
  const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1811
1830
  (0, import_invariant5.invariant)(protocol, void 0, {
1812
1831
  F: __dxlog_file7,
1813
- L: 84,
1832
+ L: 87,
1814
1833
  S: this,
1815
1834
  A: [
1816
1835
  "protocol",
@@ -1825,9 +1844,11 @@ var InvitationsHandler = class {
1825
1844
  swarmKey,
1826
1845
  authCode,
1827
1846
  timeout,
1828
- persistent,
1847
+ persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
1848
+ guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
1829
1849
  created,
1830
1850
  lifetime,
1851
+ multiUse,
1831
1852
  ...protocol.getInvitationContext()
1832
1853
  };
1833
1854
  const stream = new import_async7.PushStream();
@@ -1842,7 +1863,7 @@ var InvitationsHandler = class {
1842
1863
  ...protocol.toJSON()
1843
1864
  }, {
1844
1865
  F: __dxlog_file7,
1845
- L: 109,
1866
+ L: 115,
1846
1867
  S: this,
1847
1868
  C: (f, a) => f(...a)
1848
1869
  });
@@ -1867,7 +1888,7 @@ var InvitationsHandler = class {
1867
1888
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1868
1889
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1869
1890
  F: __dxlog_file7,
1870
- L: 130,
1891
+ L: 136,
1871
1892
  S: this,
1872
1893
  A: [
1873
1894
  "deviceKey",
@@ -1890,7 +1911,7 @@ var InvitationsHandler = class {
1890
1911
  id: traceId
1891
1912
  }), {
1892
1913
  F: __dxlog_file7,
1893
- L: 148,
1914
+ L: 154,
1894
1915
  S: this,
1895
1916
  C: (f, a) => f(...a)
1896
1917
  });
@@ -1898,7 +1919,7 @@ var InvitationsHandler = class {
1898
1919
  ...protocol.toJSON()
1899
1920
  }, {
1900
1921
  F: __dxlog_file7,
1901
- L: 149,
1922
+ L: 155,
1902
1923
  S: this,
1903
1924
  C: (f, a) => f(...a)
1904
1925
  });
@@ -1914,7 +1935,7 @@ var InvitationsHandler = class {
1914
1935
  ...protocol.toJSON()
1915
1936
  }, {
1916
1937
  F: __dxlog_file7,
1917
- L: 152,
1938
+ L: 158,
1918
1939
  S: this,
1919
1940
  C: (f, a) => f(...a)
1920
1941
  });
@@ -1926,7 +1947,7 @@ var InvitationsHandler = class {
1926
1947
  id: traceId
1927
1948
  }), {
1928
1949
  F: __dxlog_file7,
1929
- L: 154,
1950
+ L: 160,
1930
1951
  S: this,
1931
1952
  C: (f, a) => f(...a)
1932
1953
  });
@@ -1936,7 +1957,7 @@ var InvitationsHandler = class {
1936
1957
  ...protocol.toJSON()
1937
1958
  }, {
1938
1959
  F: __dxlog_file7,
1939
- L: 157,
1960
+ L: 163,
1940
1961
  S: this,
1941
1962
  C: (f, a) => f(...a)
1942
1963
  });
@@ -1947,7 +1968,7 @@ var InvitationsHandler = class {
1947
1968
  } else {
1948
1969
  import_log4.log.error("failed", err, {
1949
1970
  F: __dxlog_file7,
1950
- L: 160,
1971
+ L: 166,
1951
1972
  S: this,
1952
1973
  C: (f, a) => f(...a)
1953
1974
  });
@@ -1958,12 +1979,12 @@ var InvitationsHandler = class {
1958
1979
  error: err
1959
1980
  }), {
1960
1981
  F: __dxlog_file7,
1961
- L: 163,
1982
+ L: 169,
1962
1983
  S: this,
1963
1984
  C: (f, a) => f(...a)
1964
1985
  });
1965
1986
  } finally {
1966
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1987
+ if (!multiUse) {
1967
1988
  await swarmConnection.close();
1968
1989
  await ctx.dispose();
1969
1990
  }
@@ -1979,7 +2000,7 @@ var InvitationsHandler = class {
1979
2000
  ...protocol.toJSON()
1980
2001
  }, {
1981
2002
  F: __dxlog_file7,
1982
- L: 178,
2003
+ L: 184,
1983
2004
  S: this,
1984
2005
  C: (f, a) => f(...a)
1985
2006
  });
@@ -1990,7 +2011,7 @@ var InvitationsHandler = class {
1990
2011
  } else {
1991
2012
  import_log4.log.error("failed", err, {
1992
2013
  F: __dxlog_file7,
1993
- L: 181,
2014
+ L: 187,
1994
2015
  S: this,
1995
2016
  C: (f, a) => f(...a)
1996
2017
  });
@@ -2004,7 +2025,7 @@ var InvitationsHandler = class {
2004
2025
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2005
2026
  import_log4.log.warn("invitation has already expired", void 0, {
2006
2027
  F: __dxlog_file7,
2007
- L: 192,
2028
+ L: 198,
2008
2029
  S: this,
2009
2030
  C: (f, a) => f(...a)
2010
2031
  });
@@ -2055,7 +2076,7 @@ var InvitationsHandler = class {
2055
2076
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2056
2077
  (0, import_invariant5.invariant)(protocol, void 0, {
2057
2078
  F: __dxlog_file7,
2058
- L: 246,
2079
+ L: 252,
2059
2080
  S: this,
2060
2081
  A: [
2061
2082
  "protocol",
@@ -2065,7 +2086,7 @@ var InvitationsHandler = class {
2065
2086
  if (deviceProfile) {
2066
2087
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2067
2088
  F: __dxlog_file7,
2068
- L: 250,
2089
+ L: 256,
2069
2090
  S: this,
2070
2091
  A: [
2071
2092
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2080,7 +2101,7 @@ var InvitationsHandler = class {
2080
2101
  const setState = (newData) => {
2081
2102
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2082
2103
  F: __dxlog_file7,
2083
- L: 261,
2104
+ L: 267,
2084
2105
  S: this,
2085
2106
  A: [
2086
2107
  "newData.state !== undefined",
@@ -2100,7 +2121,7 @@ var InvitationsHandler = class {
2100
2121
  ...protocol.toJSON()
2101
2122
  }, {
2102
2123
  F: __dxlog_file7,
2103
- L: 269,
2124
+ L: 275,
2104
2125
  S: this,
2105
2126
  C: (f, a) => f(...a)
2106
2127
  });
@@ -2110,7 +2131,7 @@ var InvitationsHandler = class {
2110
2131
  } else {
2111
2132
  import_log4.log.warn("auth failed", err, {
2112
2133
  F: __dxlog_file7,
2113
- L: 272,
2134
+ L: 278,
2114
2135
  S: this,
2115
2136
  C: (f, a) => f(...a)
2116
2137
  });
@@ -2124,7 +2145,7 @@ var InvitationsHandler = class {
2124
2145
  ...protocol.toJSON()
2125
2146
  }, {
2126
2147
  F: __dxlog_file7,
2127
- L: 280,
2148
+ L: 286,
2128
2149
  S: this,
2129
2150
  C: (f, a) => f(...a)
2130
2151
  });
@@ -2139,7 +2160,7 @@ var InvitationsHandler = class {
2139
2160
  currentState
2140
2161
  }, {
2141
2162
  F: __dxlog_file7,
2142
- L: 290,
2163
+ L: 296,
2143
2164
  S: this,
2144
2165
  C: (f, a) => f(...a)
2145
2166
  });
@@ -2154,7 +2175,7 @@ var InvitationsHandler = class {
2154
2175
  id: traceId
2155
2176
  }), {
2156
2177
  F: __dxlog_file7,
2157
- L: 299,
2178
+ L: 305,
2158
2179
  S: this,
2159
2180
  C: (f, a) => f(...a)
2160
2181
  });
@@ -2166,7 +2187,7 @@ var InvitationsHandler = class {
2166
2187
  ...protocol.toJSON()
2167
2188
  }, {
2168
2189
  F: __dxlog_file7,
2169
- L: 307,
2190
+ L: 313,
2170
2191
  S: this,
2171
2192
  C: (f, a) => f(...a)
2172
2193
  });
@@ -2177,7 +2198,7 @@ var InvitationsHandler = class {
2177
2198
  ...protocol.toJSON()
2178
2199
  }, {
2179
2200
  F: __dxlog_file7,
2180
- L: 311,
2201
+ L: 317,
2181
2202
  S: this,
2182
2203
  C: (f, a) => f(...a)
2183
2204
  });
@@ -2187,62 +2208,28 @@ var InvitationsHandler = class {
2187
2208
  response: introductionResponse
2188
2209
  }, {
2189
2210
  F: __dxlog_file7,
2190
- L: 315,
2211
+ L: 321,
2191
2212
  S: this,
2192
2213
  C: (f, a) => f(...a)
2193
2214
  });
2194
2215
  invitation.authMethod = introductionResponse.authMethod;
2195
2216
  if (isAuthenticationRequired(invitation)) {
2196
- for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2197
- (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2198
- F: __dxlog_file7,
2199
- L: 321,
2200
- S: this,
2201
- C: (f, a) => f(...a)
2202
- });
2203
- setState({
2204
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2205
- });
2206
- const authCode = await authenticated.wait({
2207
- timeout
2208
- });
2209
- (0, import_log4.log)("sending authentication request", void 0, {
2210
- F: __dxlog_file7,
2211
- L: 325,
2212
- S: this,
2213
- C: (f, a) => f(...a)
2214
- });
2215
- setState({
2216
- state: import_services3.Invitation.State.AUTHENTICATING
2217
- });
2218
- const response = await extension.rpc.InvitationHostService.authenticate({
2219
- authCode
2220
- });
2221
- if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2217
+ switch (invitation.authMethod) {
2218
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET:
2219
+ await this._handleGuestOtpAuth(extension, setState, authenticated, {
2220
+ timeout
2221
+ });
2222
+ break;
2223
+ case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
2224
+ await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
2222
2225
  break;
2223
- }
2224
- if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2225
- if (attempt === MAX_OTP_ATTEMPTS) {
2226
- throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2227
- } else {
2228
- (0, import_log4.log)("retrying invalid code", {
2229
- attempt
2230
- }, {
2231
- F: __dxlog_file7,
2232
- L: 336,
2233
- S: this,
2234
- C: (f, a) => f(...a)
2235
- });
2236
- authenticated.reset();
2237
- }
2238
- }
2239
2226
  }
2240
2227
  }
2241
2228
  (0, import_log4.log)("request admission", {
2242
2229
  ...protocol.toJSON()
2243
2230
  }, {
2244
2231
  F: __dxlog_file7,
2245
- L: 344,
2232
+ L: 337,
2246
2233
  S: this,
2247
2234
  C: (f, a) => f(...a)
2248
2235
  });
@@ -2254,7 +2241,7 @@ var InvitationsHandler = class {
2254
2241
  ...protocol.toJSON()
2255
2242
  }, {
2256
2243
  F: __dxlog_file7,
2257
- L: 355,
2244
+ L: 348,
2258
2245
  S: this,
2259
2246
  C: (f, a) => f(...a)
2260
2247
  });
@@ -2267,7 +2254,7 @@ var InvitationsHandler = class {
2267
2254
  id: traceId
2268
2255
  }), {
2269
2256
  F: __dxlog_file7,
2270
- L: 357,
2257
+ L: 350,
2271
2258
  S: this,
2272
2259
  C: (f, a) => f(...a)
2273
2260
  });
@@ -2277,7 +2264,7 @@ var InvitationsHandler = class {
2277
2264
  ...protocol.toJSON()
2278
2265
  }, {
2279
2266
  F: __dxlog_file7,
2280
- L: 360,
2267
+ L: 353,
2281
2268
  S: this,
2282
2269
  C: (f, a) => f(...a)
2283
2270
  });
@@ -2287,7 +2274,7 @@ var InvitationsHandler = class {
2287
2274
  } else {
2288
2275
  (0, import_log4.log)("auth failed", err, {
2289
2276
  F: __dxlog_file7,
2290
- L: 363,
2277
+ L: 356,
2291
2278
  S: this,
2292
2279
  C: (f, a) => f(...a)
2293
2280
  });
@@ -2298,7 +2285,7 @@ var InvitationsHandler = class {
2298
2285
  error: err
2299
2286
  }), {
2300
2287
  F: __dxlog_file7,
2301
- L: 366,
2288
+ L: 359,
2302
2289
  S: this,
2303
2290
  C: (f, a) => f(...a)
2304
2291
  });
@@ -2316,7 +2303,7 @@ var InvitationsHandler = class {
2316
2303
  ...protocol.toJSON()
2317
2304
  }, {
2318
2305
  F: __dxlog_file7,
2319
- L: 377,
2306
+ L: 370,
2320
2307
  S: this,
2321
2308
  C: (f, a) => f(...a)
2322
2309
  });
@@ -2326,7 +2313,7 @@ var InvitationsHandler = class {
2326
2313
  } else {
2327
2314
  (0, import_log4.log)("auth failed", err, {
2328
2315
  F: __dxlog_file7,
2329
- L: 380,
2316
+ L: 373,
2330
2317
  S: this,
2331
2318
  C: (f, a) => f(...a)
2332
2319
  });
@@ -2343,7 +2330,7 @@ var InvitationsHandler = class {
2343
2330
  } else {
2344
2331
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2345
2332
  F: __dxlog_file7,
2346
- L: 394,
2333
+ L: 387,
2347
2334
  S: this,
2348
2335
  A: [
2349
2336
  "invitation.swarmKey",
@@ -2381,9 +2368,81 @@ var InvitationsHandler = class {
2381
2368
  });
2382
2369
  return observable;
2383
2370
  }
2371
+ async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2372
+ for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2373
+ (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2374
+ F: __dxlog_file7,
2375
+ L: 427,
2376
+ S: this,
2377
+ C: (f, a) => f(...a)
2378
+ });
2379
+ setState({
2380
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2381
+ });
2382
+ const authCode = await authenticated.wait(options);
2383
+ (0, import_log4.log)("sending authentication request", void 0, {
2384
+ F: __dxlog_file7,
2385
+ L: 431,
2386
+ S: this,
2387
+ C: (f, a) => f(...a)
2388
+ });
2389
+ setState({
2390
+ state: import_services3.Invitation.State.AUTHENTICATING
2391
+ });
2392
+ const response = await extension.rpc.InvitationHostService.authenticate({
2393
+ authCode
2394
+ });
2395
+ if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2396
+ break;
2397
+ }
2398
+ if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2399
+ if (attempt === MAX_OTP_ATTEMPTS) {
2400
+ throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2401
+ } else {
2402
+ (0, import_log4.log)("retrying invalid code", {
2403
+ attempt
2404
+ }, {
2405
+ F: __dxlog_file7,
2406
+ L: 442,
2407
+ S: this,
2408
+ C: (f, a) => f(...a)
2409
+ });
2410
+ authenticated.reset();
2411
+ }
2412
+ }
2413
+ }
2414
+ }
2415
+ async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
2416
+ if (invitation.guestKeypair?.privateKey == null) {
2417
+ throw new Error("keypair missing in the invitation");
2418
+ }
2419
+ if (introductionResponse.challenge == null) {
2420
+ throw new Error("challenge missing in the introduction");
2421
+ }
2422
+ (0, import_log4.log)("sending authentication request", void 0, {
2423
+ F: __dxlog_file7,
2424
+ L: 461,
2425
+ S: this,
2426
+ C: (f, a) => f(...a)
2427
+ });
2428
+ setState({
2429
+ state: import_services3.Invitation.State.AUTHENTICATING
2430
+ });
2431
+ const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
2432
+ const response = await extension.rpc.InvitationHostService.authenticate({
2433
+ signedChallenge: signature
2434
+ });
2435
+ if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
2436
+ throw new Error(`Authentication failed with code: ${response.status}`);
2437
+ }
2438
+ }
2384
2439
  };
2385
- var invitationExpired = (invitation) => {
2386
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2440
+ var createAdmissionKeypair = () => {
2441
+ const keypair = (0, import_crypto.createKeyPair)();
2442
+ return {
2443
+ publicKey: import_keys5.PublicKey.from(keypair.publicKey),
2444
+ privateKey: keypair.secretKey
2445
+ };
2387
2446
  };
2388
2447
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2389
2448
  var InvitationsServiceImpl = class {
@@ -2440,7 +2499,7 @@ var InvitationsServiceImpl = class {
2440
2499
  await this._metadataStore.removeInvitation(invitation.get().invitationId);
2441
2500
  }
2442
2501
  this._createInvitations.delete(invitation.get().invitationId);
2443
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2502
+ if (!invitation.get().multiUse) {
2444
2503
  this._removedCreated.emit(invitation.get());
2445
2504
  }
2446
2505
  });
@@ -2448,7 +2507,7 @@ var InvitationsServiceImpl = class {
2448
2507
  }
2449
2508
  async loadPersistentInvitations() {
2450
2509
  const persistentInvitations = this._metadataStore.getInvitations();
2451
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2510
+ const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2452
2511
  const cInvitations = freshInvitations.map((persistentInvitation) => {
2453
2512
  (0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2454
2513
  F: __dxlog_file8,
@@ -2501,7 +2560,7 @@ var InvitationsServiceImpl = class {
2501
2560
  }, () => {
2502
2561
  close();
2503
2562
  this._acceptInvitations.delete(invitation.get().invitationId);
2504
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2563
+ if (!invitation.get().multiUse) {
2505
2564
  this._removedAccepted.emit(invitation.get());
2506
2565
  }
2507
2566
  });
@@ -3387,7 +3446,7 @@ var DataSpace = class {
3387
3446
  });
3388
3447
  this.stateUpdate.emit();
3389
3448
  if (!this.notarizationPlugin.hasWriter) {
3390
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
3449
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
3391
3450
  credential: {
3392
3451
  credential
3393
3452
  }
@@ -3585,7 +3644,7 @@ var DataSpace = class {
3585
3644
  ""
3586
3645
  ]
3587
3646
  });
3588
- const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3647
+ const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3589
3648
  await docLoader.loadSpaceRootDocHandle(this._ctx, {
3590
3649
  rootUrl: newRoot.url
3591
3650
  });
@@ -4407,8 +4466,8 @@ var ServiceContext = class extends import_context10.Resource {
4407
4466
  this.initialized = new import_async15.Trigger();
4408
4467
  this._handlerFactories = /* @__PURE__ */ new Map();
4409
4468
  this._instanceId = import_keys10.PublicKey.random().toHex();
4410
- this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
4411
- this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
4469
+ this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
4470
+ this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
4412
4471
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4413
4472
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4414
4473
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4416,12 +4475,12 @@ var ServiceContext = class extends import_context10.Resource {
4416
4475
  root: storage.createDirectory("feeds"),
4417
4476
  signer: this.keyring,
4418
4477
  hypercore: {
4419
- valueEncoding: import_echo_pipeline3.valueEncoding,
4478
+ valueEncoding: import_echo_pipeline4.valueEncoding,
4420
4479
  stats: true
4421
4480
  }
4422
4481
  })
4423
4482
  });
4424
- this.spaceManager = new import_echo_pipeline3.SpaceManager({
4483
+ this.spaceManager = new import_echo_pipeline4.SpaceManager({
4425
4484
  feedStore: this.feedStore,
4426
4485
  networkManager: this.networkManager,
4427
4486
  blobStore: this.blobStore,
@@ -4432,13 +4491,17 @@ var ServiceContext = class extends import_context10.Resource {
4432
4491
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4433
4492
  db: level.sublevel("index-metadata")
4434
4493
  });
4435
- this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4494
+ this.automergeHost = new import_echo_pipeline4.AutomergeHost({
4436
4495
  directory: storage.createDirectory("automerge"),
4437
- metadata: this.indexMetadata
4496
+ db: level.sublevel("automerge"),
4497
+ storageCallbacks: (0, import_indexing.createStorageCallbacks)({
4498
+ host: () => this.automergeHost,
4499
+ metadata: this.indexMetadata
4500
+ })
4438
4501
  });
4439
4502
  this.indexer = new import_indexing.Indexer({
4440
4503
  indexStore: new import_indexing.IndexStore({
4441
- directory: storage.createDirectory("index-store")
4504
+ db: level.sublevel("index-store")
4442
4505
  }),
4443
4506
  metadataStore: this.indexMetadata,
4444
4507
  loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
@@ -4451,7 +4514,7 @@ var ServiceContext = class extends import_context10.Resource {
4451
4514
  await this._checkStorageVersion();
4452
4515
  (0, import_log12.log)("opening...", void 0, {
4453
4516
  F: __dxlog_file14,
4454
- L: 156,
4517
+ L: 157,
4455
4518
  S: this,
4456
4519
  C: (f, a) => f(...a)
4457
4520
  });
@@ -4459,12 +4522,13 @@ var ServiceContext = class extends import_context10.Resource {
4459
4522
  id: this._instanceId
4460
4523
  }), {
4461
4524
  F: __dxlog_file14,
4462
- L: 157,
4525
+ L: 158,
4463
4526
  S: this,
4464
4527
  C: (f, a) => f(...a)
4465
4528
  });
4466
4529
  await this.signalManager.open();
4467
4530
  await this.networkManager.open();
4531
+ await this.automergeHost.open();
4468
4532
  await this.metadataStore.load();
4469
4533
  await this.spaceManager.open();
4470
4534
  await this.identityManager.open(ctx);
@@ -4475,13 +4539,13 @@ var ServiceContext = class extends import_context10.Resource {
4475
4539
  id: this._instanceId
4476
4540
  }), {
4477
4541
  F: __dxlog_file14,
4478
- L: 167,
4542
+ L: 169,
4479
4543
  S: this,
4480
4544
  C: (f, a) => f(...a)
4481
4545
  });
4482
4546
  (0, import_log12.log)("opened", void 0, {
4483
4547
  F: __dxlog_file14,
4484
- L: 168,
4548
+ L: 170,
4485
4549
  S: this,
4486
4550
  C: (f, a) => f(...a)
4487
4551
  });
@@ -4489,7 +4553,7 @@ var ServiceContext = class extends import_context10.Resource {
4489
4553
  async _close() {
4490
4554
  (0, import_log12.log)("closing...", void 0, {
4491
4555
  F: __dxlog_file14,
4492
- L: 172,
4556
+ L: 174,
4493
4557
  S: this,
4494
4558
  C: (f, a) => f(...a)
4495
4559
  });
@@ -4507,7 +4571,7 @@ var ServiceContext = class extends import_context10.Resource {
4507
4571
  await this.indexer.destroy();
4508
4572
  (0, import_log12.log)("closed", void 0, {
4509
4573
  F: __dxlog_file14,
4510
- L: 185,
4574
+ L: 187,
4511
4575
  S: this,
4512
4576
  C: (f, a) => f(...a)
4513
4577
  });
@@ -4521,7 +4585,7 @@ var ServiceContext = class extends import_context10.Resource {
4521
4585
  const factory = this._handlerFactories.get(invitation.kind);
4522
4586
  (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4523
4587
  F: __dxlog_file14,
4524
- L: 196,
4588
+ L: 198,
4525
4589
  S: this,
4526
4590
  A: [
4527
4591
  "factory",
@@ -4553,7 +4617,7 @@ var ServiceContext = class extends import_context10.Resource {
4553
4617
  async _initialize(ctx) {
4554
4618
  (0, import_log12.log)("initializing spaces...", void 0, {
4555
4619
  F: __dxlog_file14,
4556
- L: 227,
4620
+ L: 229,
4557
4621
  S: this,
4558
4622
  C: (f, a) => f(...a)
4559
4623
  });
@@ -4576,7 +4640,7 @@ var ServiceContext = class extends import_context10.Resource {
4576
4640
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4577
4641
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4578
4642
  F: __dxlog_file14,
4579
- L: 251,
4643
+ L: 253,
4580
4644
  S: this,
4581
4645
  A: [
4582
4646
  "this.dataSpaceManager",
@@ -4600,7 +4664,7 @@ var ServiceContext = class extends import_context10.Resource {
4600
4664
  details: assertion
4601
4665
  }, {
4602
4666
  F: __dxlog_file14,
4603
- L: 267,
4667
+ L: 269,
4604
4668
  S: this,
4605
4669
  C: (f, a) => f(...a)
4606
4670
  });
@@ -4611,7 +4675,7 @@ var ServiceContext = class extends import_context10.Resource {
4611
4675
  details: assertion
4612
4676
  }, {
4613
4677
  F: __dxlog_file14,
4614
- L: 271,
4678
+ L: 273,
4615
4679
  S: this,
4616
4680
  C: (f, a) => f(...a)
4617
4681
  });
@@ -4622,7 +4686,7 @@ var ServiceContext = class extends import_context10.Resource {
4622
4686
  details: assertion
4623
4687
  }, {
4624
4688
  F: __dxlog_file14,
4625
- L: 276,
4689
+ L: 278,
4626
4690
  S: this,
4627
4691
  C: (f, a) => f(...a)
4628
4692
  });
@@ -4633,7 +4697,7 @@ var ServiceContext = class extends import_context10.Resource {
4633
4697
  } catch (err) {
4634
4698
  import_log12.log.catch(err, void 0, {
4635
4699
  F: __dxlog_file14,
4636
- L: 282,
4700
+ L: 284,
4637
4701
  S: this,
4638
4702
  C: (f, a) => f(...a)
4639
4703
  });
@@ -4675,7 +4739,7 @@ var ServiceRegistry = class {
4675
4739
  delete this._handlers[name];
4676
4740
  }
4677
4741
  };
4678
- var DXOS_VERSION = "0.4.10-main.c42bfdb";
4742
+ var DXOS_VERSION = "0.4.10-main.cb83c78";
4679
4743
  var getPlatform = () => {
4680
4744
  if (process.browser) {
4681
4745
  if (typeof window !== "undefined") {
@@ -5151,7 +5215,7 @@ var toStorageType = (type) => {
5151
5215
  };
5152
5216
  var createLevel = async (config) => {
5153
5217
  const persistent = isPersistent(config);
5154
- const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys13.PublicKey.random().toHex());
5218
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5155
5219
  const level = new import_level.Level(storagePath);
5156
5220
  await level.open();
5157
5221
  return level;
@@ -5225,6 +5289,7 @@ var ClientServicesHost = class {
5225
5289
  transportFactory,
5226
5290
  signalManager,
5227
5291
  storage,
5292
+ level,
5228
5293
  // TODO(wittjosiah): Turn this on by default.
5229
5294
  lockKey,
5230
5295
  callbacks,
@@ -5235,6 +5300,7 @@ var ClientServicesHost = class {
5235
5300
  this._opening = false;
5236
5301
  this._open = false;
5237
5302
  this._storage = storage;
5303
+ this._level = level;
5238
5304
  this._callbacks = callbacks;
5239
5305
  this._runtimeParams = runtimeParams;
5240
5306
  if (config) {
@@ -5306,7 +5372,7 @@ var ClientServicesHost = class {
5306
5372
  initialize({ config, ...options }) {
5307
5373
  (0, import_invariant15.invariant)(!this._open, "service host is open", {
5308
5374
  F: __dxlog_file18,
5309
- L: 188,
5375
+ L: 197,
5310
5376
  S: this,
5311
5377
  A: [
5312
5378
  "!this._open",
@@ -5315,14 +5381,14 @@ var ClientServicesHost = class {
5315
5381
  });
5316
5382
  (0, import_log13.log)("initializing...", void 0, {
5317
5383
  F: __dxlog_file18,
5318
- L: 189,
5384
+ L: 198,
5319
5385
  S: this,
5320
5386
  C: (f, a) => f(...a)
5321
5387
  });
5322
5388
  if (config) {
5323
5389
  (0, import_invariant15.invariant)(!this._config, "config already set", {
5324
5390
  F: __dxlog_file18,
5325
- L: 192,
5391
+ L: 201,
5326
5392
  S: this,
5327
5393
  A: [
5328
5394
  "!this._config",
@@ -5337,7 +5403,7 @@ var ClientServicesHost = class {
5337
5403
  if (!options.signalManager) {
5338
5404
  import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5339
5405
  F: __dxlog_file18,
5340
- L: 200,
5406
+ L: 209,
5341
5407
  S: this,
5342
5408
  C: (f, a) => f(...a)
5343
5409
  });
@@ -5348,7 +5414,7 @@ var ClientServicesHost = class {
5348
5414
  this._signalManager = signalManager;
5349
5415
  (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5350
5416
  F: __dxlog_file18,
5351
- L: 211,
5417
+ L: 220,
5352
5418
  S: this,
5353
5419
  A: [
5354
5420
  "!this._networkManager",
@@ -5362,7 +5428,7 @@ var ClientServicesHost = class {
5362
5428
  });
5363
5429
  (0, import_log13.log)("initialized", void 0, {
5364
5430
  F: __dxlog_file18,
5365
- L: 218,
5431
+ L: 227,
5366
5432
  S: this,
5367
5433
  C: (f, a) => f(...a)
5368
5434
  });
@@ -5376,13 +5442,13 @@ var ClientServicesHost = class {
5376
5442
  id: traceId
5377
5443
  }), {
5378
5444
  F: __dxlog_file18,
5379
- L: 229,
5445
+ L: 238,
5380
5446
  S: this,
5381
5447
  C: (f, a) => f(...a)
5382
5448
  });
5383
5449
  (0, import_invariant15.invariant)(this._config, "config not set", {
5384
5450
  F: __dxlog_file18,
5385
- L: 231,
5451
+ L: 240,
5386
5452
  S: this,
5387
5453
  A: [
5388
5454
  "this._config",
@@ -5391,7 +5457,7 @@ var ClientServicesHost = class {
5391
5457
  });
5392
5458
  (0, import_invariant15.invariant)(this._storage, "storage not set", {
5393
5459
  F: __dxlog_file18,
5394
- L: 232,
5460
+ L: 241,
5395
5461
  S: this,
5396
5462
  A: [
5397
5463
  "this._storage",
@@ -5400,7 +5466,7 @@ var ClientServicesHost = class {
5400
5466
  });
5401
5467
  (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5402
5468
  F: __dxlog_file18,
5403
- L: 233,
5469
+ L: 242,
5404
5470
  S: this,
5405
5471
  A: [
5406
5472
  "this._signalManager",
@@ -5409,7 +5475,7 @@ var ClientServicesHost = class {
5409
5475
  });
5410
5476
  (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5411
5477
  F: __dxlog_file18,
5412
- L: 234,
5478
+ L: 243,
5413
5479
  S: this,
5414
5480
  A: [
5415
5481
  "this._networkManager",
@@ -5421,13 +5487,14 @@ var ClientServicesHost = class {
5421
5487
  lockKey: this._resourceLock?.lockKey
5422
5488
  }, {
5423
5489
  F: __dxlog_file18,
5424
- L: 237,
5490
+ L: 246,
5425
5491
  S: this,
5426
5492
  C: (f, a) => f(...a)
5427
5493
  });
5428
5494
  if (!this._level) {
5429
5495
  this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5430
5496
  }
5497
+ await this._level.open();
5431
5498
  await this._resourceLock?.acquire();
5432
5499
  await this._loggingService.open();
5433
5500
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
@@ -5440,7 +5507,7 @@ var ClientServicesHost = class {
5440
5507
  await this._serviceContext.initialized.wait();
5441
5508
  return this._serviceContext.dataSpaceManager;
5442
5509
  }),
5443
- DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5510
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5444
5511
  IndexService: new import_indexing2.IndexServiceImpl({
5445
5512
  indexer: this._serviceContext.indexer,
5446
5513
  automergeHost: this._serviceContext.automergeHost
@@ -5458,7 +5525,7 @@ var ClientServicesHost = class {
5458
5525
  await this._serviceContext.open(ctx);
5459
5526
  (0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5460
5527
  F: __dxlog_file18,
5461
- L: 303,
5528
+ L: 314,
5462
5529
  S: this,
5463
5530
  A: [
5464
5531
  "this.serviceRegistry.services.InvitationsService",
@@ -5470,7 +5537,7 @@ var ClientServicesHost = class {
5470
5537
  count: loadedInvitations.invitations?.length
5471
5538
  }, {
5472
5539
  F: __dxlog_file18,
5473
- L: 306,
5540
+ L: 317,
5474
5541
  S: this,
5475
5542
  C: (f, a) => f(...a)
5476
5543
  });
@@ -5493,7 +5560,7 @@ var ClientServicesHost = class {
5493
5560
  deviceKey
5494
5561
  }, {
5495
5562
  F: __dxlog_file18,
5496
- L: 324,
5563
+ L: 335,
5497
5564
  S: this,
5498
5565
  C: (f, a) => f(...a)
5499
5566
  });
@@ -5501,7 +5568,7 @@ var ClientServicesHost = class {
5501
5568
  id: traceId
5502
5569
  }), {
5503
5570
  F: __dxlog_file18,
5504
- L: 325,
5571
+ L: 336,
5505
5572
  S: this,
5506
5573
  C: (f, a) => f(...a)
5507
5574
  });
@@ -5515,7 +5582,7 @@ var ClientServicesHost = class {
5515
5582
  deviceKey
5516
5583
  }, {
5517
5584
  F: __dxlog_file18,
5518
- L: 336,
5585
+ L: 347,
5519
5586
  S: this,
5520
5587
  C: (f, a) => f(...a)
5521
5588
  });
@@ -5533,7 +5600,7 @@ var ClientServicesHost = class {
5533
5600
  deviceKey
5534
5601
  }, {
5535
5602
  F: __dxlog_file18,
5536
- L: 345,
5603
+ L: 356,
5537
5604
  S: this,
5538
5605
  C: (f, a) => f(...a)
5539
5606
  });
@@ -5544,13 +5611,13 @@ var ClientServicesHost = class {
5544
5611
  id: traceId
5545
5612
  }), {
5546
5613
  F: __dxlog_file18,
5547
- L: 350,
5614
+ L: 361,
5548
5615
  S: this,
5549
5616
  C: (f, a) => f(...a)
5550
5617
  });
5551
5618
  (0, import_log13.log)("resetting...", void 0, {
5552
5619
  F: __dxlog_file18,
5553
- L: 352,
5620
+ L: 363,
5554
5621
  S: this,
5555
5622
  C: (f, a) => f(...a)
5556
5623
  });
@@ -5558,7 +5625,7 @@ var ClientServicesHost = class {
5558
5625
  await this._storage.reset();
5559
5626
  (0, import_log13.log)("reset", void 0, {
5560
5627
  F: __dxlog_file18,
5561
- L: 355,
5628
+ L: 366,
5562
5629
  S: this,
5563
5630
  C: (f, a) => f(...a)
5564
5631
  });
@@ -5566,7 +5633,7 @@ var ClientServicesHost = class {
5566
5633
  id: traceId
5567
5634
  }), {
5568
5635
  F: __dxlog_file18,
5569
- L: 356,
5636
+ L: 367,
5570
5637
  S: this,
5571
5638
  C: (f, a) => f(...a)
5572
5639
  });
@@ -5579,7 +5646,7 @@ var ClientServicesHost = class {
5579
5646
  const automergeIndex = space.automergeSpaceState.rootUrl;
5580
5647
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5581
5648
  F: __dxlog_file18,
5582
- L: 368,
5649
+ L: 379,
5583
5650
  S: this,
5584
5651
  A: [
5585
5652
  "automergeIndex",
@@ -5590,7 +5657,7 @@ var ClientServicesHost = class {
5590
5657
  await document.whenReady();
5591
5658
  const properties = {
5592
5659
  system: {
5593
- type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
5660
+ type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema.getTypeReference)(import_client_protocol4.Properties))
5594
5661
  },
5595
5662
  data: {
5596
5663
  [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
@@ -5681,6 +5748,7 @@ var findConfigs = () => {
5681
5748
  SpaceInvitationProtocol,
5682
5749
  SpacesServiceImpl,
5683
5750
  TrustedKeySetAuthVerifier,
5751
+ createAdmissionKeypair,
5684
5752
  createAuthProvider,
5685
5753
  createCollectDiagnosticsBroadcastHandler,
5686
5754
  createCollectDiagnosticsBroadcastSender,
@@ -5688,7 +5756,6 @@ var findConfigs = () => {
5688
5756
  createLevel,
5689
5757
  createStorageObjects,
5690
5758
  getNetworkPeers,
5691
- invitationExpired,
5692
5759
  isLocked,
5693
5760
  subscribeToFeedBlocks,
5694
5761
  subscribeToFeeds,
@@ -5698,4 +5765,4 @@ var findConfigs = () => {
5698
5765
  subscribeToSpaces,
5699
5766
  subscribeToSwarmInfo
5700
5767
  });
5701
- //# sourceMappingURL=chunk-JSVLZGJM.cjs.map
5768
+ //# sourceMappingURL=chunk-SICZTC25.cjs.map