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

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 (37) hide show
  1. package/dist/lib/browser/{chunk-W7UANCHR.mjs → chunk-LGZBUJLB.mjs} +208 -144
  2. package/dist/lib/browser/chunk-LGZBUJLB.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 +8 -4
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-JSVLZGJM.cjs → chunk-HM374IDE.cjs} +224 -160
  8. package/dist/lib/node/chunk-HM374IDE.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 +13 -9
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
  14. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  15. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
  16. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +3 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/testing/test-builder.d.ts +4 -1
  22. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/package.json +34 -34
  25. package/src/packlets/invitations/invitation-extension.ts +28 -1
  26. package/src/packlets/invitations/invitations-handler.ts +73 -32
  27. package/src/packlets/invitations/invitations-service.ts +5 -5
  28. package/src/packlets/services/automerge-host.test.ts +9 -3
  29. package/src/packlets/services/service-context.test.ts +4 -1
  30. package/src/packlets/services/service-context.ts +2 -0
  31. package/src/packlets/services/service-host.ts +12 -1
  32. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  33. package/src/packlets/storage/level.ts +1 -1
  34. package/src/packlets/testing/test-builder.ts +20 -4
  35. package/src/version.ts +1 -1
  36. package/dist/lib/browser/chunk-W7UANCHR.mjs.map +0 -7
  37. 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_HM374IDE_exports = {};
30
+ __export(chunk_HM374IDE_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_HM374IDE_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,7 +235,7 @@ 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");
238
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
236
239
  var E = __toESM(require("@dxos/echo-schema"));
237
240
  var import_indexing2 = require("@dxos/indexing");
238
241
  var import_invariant15 = require("@dxos/invariant");
@@ -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,8 +4491,9 @@ 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"),
4496
+ db: level.sublevel("automerge"),
4437
4497
  metadata: this.indexMetadata
4438
4498
  });
4439
4499
  this.indexer = new import_indexing.Indexer({
@@ -4451,7 +4511,7 @@ var ServiceContext = class extends import_context10.Resource {
4451
4511
  await this._checkStorageVersion();
4452
4512
  (0, import_log12.log)("opening...", void 0, {
4453
4513
  F: __dxlog_file14,
4454
- L: 156,
4514
+ L: 157,
4455
4515
  S: this,
4456
4516
  C: (f, a) => f(...a)
4457
4517
  });
@@ -4459,12 +4519,13 @@ var ServiceContext = class extends import_context10.Resource {
4459
4519
  id: this._instanceId
4460
4520
  }), {
4461
4521
  F: __dxlog_file14,
4462
- L: 157,
4522
+ L: 158,
4463
4523
  S: this,
4464
4524
  C: (f, a) => f(...a)
4465
4525
  });
4466
4526
  await this.signalManager.open();
4467
4527
  await this.networkManager.open();
4528
+ await this.automergeHost.open();
4468
4529
  await this.metadataStore.load();
4469
4530
  await this.spaceManager.open();
4470
4531
  await this.identityManager.open(ctx);
@@ -4475,13 +4536,13 @@ var ServiceContext = class extends import_context10.Resource {
4475
4536
  id: this._instanceId
4476
4537
  }), {
4477
4538
  F: __dxlog_file14,
4478
- L: 167,
4539
+ L: 169,
4479
4540
  S: this,
4480
4541
  C: (f, a) => f(...a)
4481
4542
  });
4482
4543
  (0, import_log12.log)("opened", void 0, {
4483
4544
  F: __dxlog_file14,
4484
- L: 168,
4545
+ L: 170,
4485
4546
  S: this,
4486
4547
  C: (f, a) => f(...a)
4487
4548
  });
@@ -4489,7 +4550,7 @@ var ServiceContext = class extends import_context10.Resource {
4489
4550
  async _close() {
4490
4551
  (0, import_log12.log)("closing...", void 0, {
4491
4552
  F: __dxlog_file14,
4492
- L: 172,
4553
+ L: 174,
4493
4554
  S: this,
4494
4555
  C: (f, a) => f(...a)
4495
4556
  });
@@ -4507,7 +4568,7 @@ var ServiceContext = class extends import_context10.Resource {
4507
4568
  await this.indexer.destroy();
4508
4569
  (0, import_log12.log)("closed", void 0, {
4509
4570
  F: __dxlog_file14,
4510
- L: 185,
4571
+ L: 187,
4511
4572
  S: this,
4512
4573
  C: (f, a) => f(...a)
4513
4574
  });
@@ -4521,7 +4582,7 @@ var ServiceContext = class extends import_context10.Resource {
4521
4582
  const factory = this._handlerFactories.get(invitation.kind);
4522
4583
  (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4523
4584
  F: __dxlog_file14,
4524
- L: 196,
4585
+ L: 198,
4525
4586
  S: this,
4526
4587
  A: [
4527
4588
  "factory",
@@ -4553,7 +4614,7 @@ var ServiceContext = class extends import_context10.Resource {
4553
4614
  async _initialize(ctx) {
4554
4615
  (0, import_log12.log)("initializing spaces...", void 0, {
4555
4616
  F: __dxlog_file14,
4556
- L: 227,
4617
+ L: 229,
4557
4618
  S: this,
4558
4619
  C: (f, a) => f(...a)
4559
4620
  });
@@ -4576,7 +4637,7 @@ var ServiceContext = class extends import_context10.Resource {
4576
4637
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4577
4638
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4578
4639
  F: __dxlog_file14,
4579
- L: 251,
4640
+ L: 253,
4580
4641
  S: this,
4581
4642
  A: [
4582
4643
  "this.dataSpaceManager",
@@ -4600,7 +4661,7 @@ var ServiceContext = class extends import_context10.Resource {
4600
4661
  details: assertion
4601
4662
  }, {
4602
4663
  F: __dxlog_file14,
4603
- L: 267,
4664
+ L: 269,
4604
4665
  S: this,
4605
4666
  C: (f, a) => f(...a)
4606
4667
  });
@@ -4611,7 +4672,7 @@ var ServiceContext = class extends import_context10.Resource {
4611
4672
  details: assertion
4612
4673
  }, {
4613
4674
  F: __dxlog_file14,
4614
- L: 271,
4675
+ L: 273,
4615
4676
  S: this,
4616
4677
  C: (f, a) => f(...a)
4617
4678
  });
@@ -4622,7 +4683,7 @@ var ServiceContext = class extends import_context10.Resource {
4622
4683
  details: assertion
4623
4684
  }, {
4624
4685
  F: __dxlog_file14,
4625
- L: 276,
4686
+ L: 278,
4626
4687
  S: this,
4627
4688
  C: (f, a) => f(...a)
4628
4689
  });
@@ -4633,7 +4694,7 @@ var ServiceContext = class extends import_context10.Resource {
4633
4694
  } catch (err) {
4634
4695
  import_log12.log.catch(err, void 0, {
4635
4696
  F: __dxlog_file14,
4636
- L: 282,
4697
+ L: 284,
4637
4698
  S: this,
4638
4699
  C: (f, a) => f(...a)
4639
4700
  });
@@ -4675,7 +4736,7 @@ var ServiceRegistry = class {
4675
4736
  delete this._handlers[name];
4676
4737
  }
4677
4738
  };
4678
- var DXOS_VERSION = "0.4.10-main.c42bfdb";
4739
+ var DXOS_VERSION = "0.4.10-main.ccba876";
4679
4740
  var getPlatform = () => {
4680
4741
  if (process.browser) {
4681
4742
  if (typeof window !== "undefined") {
@@ -5151,7 +5212,7 @@ var toStorageType = (type) => {
5151
5212
  };
5152
5213
  var createLevel = async (config) => {
5153
5214
  const persistent = isPersistent(config);
5154
- const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys13.PublicKey.random().toHex());
5215
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5155
5216
  const level = new import_level.Level(storagePath);
5156
5217
  await level.open();
5157
5218
  return level;
@@ -5225,6 +5286,7 @@ var ClientServicesHost = class {
5225
5286
  transportFactory,
5226
5287
  signalManager,
5227
5288
  storage,
5289
+ level,
5228
5290
  // TODO(wittjosiah): Turn this on by default.
5229
5291
  lockKey,
5230
5292
  callbacks,
@@ -5235,6 +5297,7 @@ var ClientServicesHost = class {
5235
5297
  this._opening = false;
5236
5298
  this._open = false;
5237
5299
  this._storage = storage;
5300
+ this._level = level;
5238
5301
  this._callbacks = callbacks;
5239
5302
  this._runtimeParams = runtimeParams;
5240
5303
  if (config) {
@@ -5306,7 +5369,7 @@ var ClientServicesHost = class {
5306
5369
  initialize({ config, ...options }) {
5307
5370
  (0, import_invariant15.invariant)(!this._open, "service host is open", {
5308
5371
  F: __dxlog_file18,
5309
- L: 188,
5372
+ L: 197,
5310
5373
  S: this,
5311
5374
  A: [
5312
5375
  "!this._open",
@@ -5315,14 +5378,14 @@ var ClientServicesHost = class {
5315
5378
  });
5316
5379
  (0, import_log13.log)("initializing...", void 0, {
5317
5380
  F: __dxlog_file18,
5318
- L: 189,
5381
+ L: 198,
5319
5382
  S: this,
5320
5383
  C: (f, a) => f(...a)
5321
5384
  });
5322
5385
  if (config) {
5323
5386
  (0, import_invariant15.invariant)(!this._config, "config already set", {
5324
5387
  F: __dxlog_file18,
5325
- L: 192,
5388
+ L: 201,
5326
5389
  S: this,
5327
5390
  A: [
5328
5391
  "!this._config",
@@ -5337,7 +5400,7 @@ var ClientServicesHost = class {
5337
5400
  if (!options.signalManager) {
5338
5401
  import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5339
5402
  F: __dxlog_file18,
5340
- L: 200,
5403
+ L: 209,
5341
5404
  S: this,
5342
5405
  C: (f, a) => f(...a)
5343
5406
  });
@@ -5348,7 +5411,7 @@ var ClientServicesHost = class {
5348
5411
  this._signalManager = signalManager;
5349
5412
  (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5350
5413
  F: __dxlog_file18,
5351
- L: 211,
5414
+ L: 220,
5352
5415
  S: this,
5353
5416
  A: [
5354
5417
  "!this._networkManager",
@@ -5362,7 +5425,7 @@ var ClientServicesHost = class {
5362
5425
  });
5363
5426
  (0, import_log13.log)("initialized", void 0, {
5364
5427
  F: __dxlog_file18,
5365
- L: 218,
5428
+ L: 227,
5366
5429
  S: this,
5367
5430
  C: (f, a) => f(...a)
5368
5431
  });
@@ -5376,13 +5439,13 @@ var ClientServicesHost = class {
5376
5439
  id: traceId
5377
5440
  }), {
5378
5441
  F: __dxlog_file18,
5379
- L: 229,
5442
+ L: 238,
5380
5443
  S: this,
5381
5444
  C: (f, a) => f(...a)
5382
5445
  });
5383
5446
  (0, import_invariant15.invariant)(this._config, "config not set", {
5384
5447
  F: __dxlog_file18,
5385
- L: 231,
5448
+ L: 240,
5386
5449
  S: this,
5387
5450
  A: [
5388
5451
  "this._config",
@@ -5391,7 +5454,7 @@ var ClientServicesHost = class {
5391
5454
  });
5392
5455
  (0, import_invariant15.invariant)(this._storage, "storage not set", {
5393
5456
  F: __dxlog_file18,
5394
- L: 232,
5457
+ L: 241,
5395
5458
  S: this,
5396
5459
  A: [
5397
5460
  "this._storage",
@@ -5400,7 +5463,7 @@ var ClientServicesHost = class {
5400
5463
  });
5401
5464
  (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5402
5465
  F: __dxlog_file18,
5403
- L: 233,
5466
+ L: 242,
5404
5467
  S: this,
5405
5468
  A: [
5406
5469
  "this._signalManager",
@@ -5409,7 +5472,7 @@ var ClientServicesHost = class {
5409
5472
  });
5410
5473
  (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5411
5474
  F: __dxlog_file18,
5412
- L: 234,
5475
+ L: 243,
5413
5476
  S: this,
5414
5477
  A: [
5415
5478
  "this._networkManager",
@@ -5421,13 +5484,14 @@ var ClientServicesHost = class {
5421
5484
  lockKey: this._resourceLock?.lockKey
5422
5485
  }, {
5423
5486
  F: __dxlog_file18,
5424
- L: 237,
5487
+ L: 246,
5425
5488
  S: this,
5426
5489
  C: (f, a) => f(...a)
5427
5490
  });
5428
5491
  if (!this._level) {
5429
5492
  this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5430
5493
  }
5494
+ await this._level.open();
5431
5495
  await this._resourceLock?.acquire();
5432
5496
  await this._loggingService.open();
5433
5497
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
@@ -5440,7 +5504,7 @@ var ClientServicesHost = class {
5440
5504
  await this._serviceContext.initialized.wait();
5441
5505
  return this._serviceContext.dataSpaceManager;
5442
5506
  }),
5443
- DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5507
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5444
5508
  IndexService: new import_indexing2.IndexServiceImpl({
5445
5509
  indexer: this._serviceContext.indexer,
5446
5510
  automergeHost: this._serviceContext.automergeHost
@@ -5458,7 +5522,7 @@ var ClientServicesHost = class {
5458
5522
  await this._serviceContext.open(ctx);
5459
5523
  (0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5460
5524
  F: __dxlog_file18,
5461
- L: 303,
5525
+ L: 314,
5462
5526
  S: this,
5463
5527
  A: [
5464
5528
  "this.serviceRegistry.services.InvitationsService",
@@ -5470,7 +5534,7 @@ var ClientServicesHost = class {
5470
5534
  count: loadedInvitations.invitations?.length
5471
5535
  }, {
5472
5536
  F: __dxlog_file18,
5473
- L: 306,
5537
+ L: 317,
5474
5538
  S: this,
5475
5539
  C: (f, a) => f(...a)
5476
5540
  });
@@ -5493,7 +5557,7 @@ var ClientServicesHost = class {
5493
5557
  deviceKey
5494
5558
  }, {
5495
5559
  F: __dxlog_file18,
5496
- L: 324,
5560
+ L: 335,
5497
5561
  S: this,
5498
5562
  C: (f, a) => f(...a)
5499
5563
  });
@@ -5501,7 +5565,7 @@ var ClientServicesHost = class {
5501
5565
  id: traceId
5502
5566
  }), {
5503
5567
  F: __dxlog_file18,
5504
- L: 325,
5568
+ L: 336,
5505
5569
  S: this,
5506
5570
  C: (f, a) => f(...a)
5507
5571
  });
@@ -5515,7 +5579,7 @@ var ClientServicesHost = class {
5515
5579
  deviceKey
5516
5580
  }, {
5517
5581
  F: __dxlog_file18,
5518
- L: 336,
5582
+ L: 347,
5519
5583
  S: this,
5520
5584
  C: (f, a) => f(...a)
5521
5585
  });
@@ -5533,7 +5597,7 @@ var ClientServicesHost = class {
5533
5597
  deviceKey
5534
5598
  }, {
5535
5599
  F: __dxlog_file18,
5536
- L: 345,
5600
+ L: 356,
5537
5601
  S: this,
5538
5602
  C: (f, a) => f(...a)
5539
5603
  });
@@ -5544,13 +5608,13 @@ var ClientServicesHost = class {
5544
5608
  id: traceId
5545
5609
  }), {
5546
5610
  F: __dxlog_file18,
5547
- L: 350,
5611
+ L: 361,
5548
5612
  S: this,
5549
5613
  C: (f, a) => f(...a)
5550
5614
  });
5551
5615
  (0, import_log13.log)("resetting...", void 0, {
5552
5616
  F: __dxlog_file18,
5553
- L: 352,
5617
+ L: 363,
5554
5618
  S: this,
5555
5619
  C: (f, a) => f(...a)
5556
5620
  });
@@ -5558,7 +5622,7 @@ var ClientServicesHost = class {
5558
5622
  await this._storage.reset();
5559
5623
  (0, import_log13.log)("reset", void 0, {
5560
5624
  F: __dxlog_file18,
5561
- L: 355,
5625
+ L: 366,
5562
5626
  S: this,
5563
5627
  C: (f, a) => f(...a)
5564
5628
  });
@@ -5566,7 +5630,7 @@ var ClientServicesHost = class {
5566
5630
  id: traceId
5567
5631
  }), {
5568
5632
  F: __dxlog_file18,
5569
- L: 356,
5633
+ L: 367,
5570
5634
  S: this,
5571
5635
  C: (f, a) => f(...a)
5572
5636
  });
@@ -5579,7 +5643,7 @@ var ClientServicesHost = class {
5579
5643
  const automergeIndex = space.automergeSpaceState.rootUrl;
5580
5644
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5581
5645
  F: __dxlog_file18,
5582
- L: 368,
5646
+ L: 379,
5583
5647
  S: this,
5584
5648
  A: [
5585
5649
  "automergeIndex",
@@ -5590,7 +5654,7 @@ var ClientServicesHost = class {
5590
5654
  await document.whenReady();
5591
5655
  const properties = {
5592
5656
  system: {
5593
- type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
5657
+ type: (0, import_echo_pipeline5.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
5594
5658
  },
5595
5659
  data: {
5596
5660
  [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
@@ -5681,6 +5745,7 @@ var findConfigs = () => {
5681
5745
  SpaceInvitationProtocol,
5682
5746
  SpacesServiceImpl,
5683
5747
  TrustedKeySetAuthVerifier,
5748
+ createAdmissionKeypair,
5684
5749
  createAuthProvider,
5685
5750
  createCollectDiagnosticsBroadcastHandler,
5686
5751
  createCollectDiagnosticsBroadcastSender,
@@ -5688,7 +5753,6 @@ var findConfigs = () => {
5688
5753
  createLevel,
5689
5754
  createStorageObjects,
5690
5755
  getNetworkPeers,
5691
- invitationExpired,
5692
5756
  isLocked,
5693
5757
  subscribeToFeedBlocks,
5694
5758
  subscribeToFeeds,
@@ -5698,4 +5762,4 @@ var findConfigs = () => {
5698
5762
  subscribeToSpaces,
5699
5763
  subscribeToSwarmInfo
5700
5764
  });
5701
- //# sourceMappingURL=chunk-JSVLZGJM.cjs.map
5765
+ //# sourceMappingURL=chunk-HM374IDE.cjs.map