@dxos/echo-pipeline 0.5.9-main.eacfffa → 0.5.9-main.f099efe

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.
@@ -1676,6 +1676,73 @@ var createIdFromSpaceKey = async (spaceKey) => {
1676
1676
  return spaceId;
1677
1677
  };
1678
1678
 
1679
+ // packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts
1680
+ import { scheduleTask as scheduleTask2 } from "@dxos/async";
1681
+ import { Context as Context5 } from "@dxos/context";
1682
+ import { ProtocolError, schema as schema6 } from "@dxos/protocols";
1683
+ import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1684
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
1685
+ var CredentialRetrieverExtension = class extends RpcExtension2 {
1686
+ constructor(_request, _onResult) {
1687
+ super({
1688
+ requested: {
1689
+ AdmissionDiscoveryService: schema6.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
1690
+ }
1691
+ });
1692
+ this._request = _request;
1693
+ this._onResult = _onResult;
1694
+ this._ctx = new Context5(void 0, {
1695
+ F: __dxlog_file9,
1696
+ L: 25
1697
+ });
1698
+ }
1699
+ async getHandlers() {
1700
+ return {};
1701
+ }
1702
+ async onOpen(context) {
1703
+ await super.onOpen(context);
1704
+ scheduleTask2(this._ctx, async () => {
1705
+ try {
1706
+ const result = await this.rpc.AdmissionDiscoveryService.getAdmissionCredential(this._request);
1707
+ this._onResult.wake(result.admissionCredential);
1708
+ } catch (err) {
1709
+ context.close(err);
1710
+ }
1711
+ });
1712
+ }
1713
+ async onClose() {
1714
+ await this._ctx.dispose();
1715
+ }
1716
+ async onAbort() {
1717
+ await this._ctx.dispose();
1718
+ }
1719
+ };
1720
+ var CredentialServerExtension = class extends RpcExtension2 {
1721
+ constructor(_space) {
1722
+ super({
1723
+ exposed: {
1724
+ AdmissionDiscoveryService: schema6.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
1725
+ }
1726
+ });
1727
+ this._space = _space;
1728
+ }
1729
+ async getHandlers() {
1730
+ return {
1731
+ AdmissionDiscoveryService: {
1732
+ getAdmissionCredential: async (request) => {
1733
+ const memberInfo = this._space.spaceState.members.get(request.memberKey);
1734
+ if (!memberInfo?.credential) {
1735
+ throw new ProtocolError("Space member not found.", request);
1736
+ }
1737
+ return {
1738
+ admissionCredential: memberInfo.credential
1739
+ };
1740
+ }
1741
+ }
1742
+ };
1743
+ }
1744
+ };
1745
+
1679
1746
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1680
1747
  import { discoveryKey, subtleCrypto as subtleCrypto3 } from "@dxos/crypto";
1681
1748
  import { PublicKey as PublicKey6 } from "@dxos/keys";
@@ -1696,7 +1763,7 @@ function _ts_decorate6(decorators, target, key, desc) {
1696
1763
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1697
1764
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1698
1765
  }
1699
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1766
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1700
1767
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1701
1768
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1702
1769
  var SpaceProtocol = class {
@@ -1733,7 +1800,7 @@ var SpaceProtocol = class {
1733
1800
  log8("addFeed", {
1734
1801
  key: feed.key
1735
1802
  }, {
1736
- F: __dxlog_file9,
1803
+ F: __dxlog_file10,
1737
1804
  L: 109,
1738
1805
  S: this,
1739
1806
  C: (f, a) => f(...a)
@@ -1751,7 +1818,7 @@ var SpaceProtocol = class {
1751
1818
  const credentials = await this._swarmIdentity.credentialProvider(Buffer.from(""));
1752
1819
  await this.blobSync.open();
1753
1820
  log8("starting...", void 0, {
1754
- F: __dxlog_file9,
1821
+ F: __dxlog_file10,
1755
1822
  L: 128,
1756
1823
  S: this,
1757
1824
  C: (f, a) => f(...a)
@@ -1765,7 +1832,7 @@ var SpaceProtocol = class {
1765
1832
  label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
1766
1833
  });
1767
1834
  log8("started", void 0, {
1768
- F: __dxlog_file9,
1835
+ F: __dxlog_file10,
1769
1836
  L: 138,
1770
1837
  S: this,
1771
1838
  C: (f, a) => f(...a)
@@ -1778,14 +1845,14 @@ var SpaceProtocol = class {
1778
1845
  await this.blobSync.close();
1779
1846
  if (this._connection) {
1780
1847
  log8("stopping...", void 0, {
1781
- F: __dxlog_file9,
1848
+ F: __dxlog_file10,
1782
1849
  L: 149,
1783
1850
  S: this,
1784
1851
  C: (f, a) => f(...a)
1785
1852
  });
1786
1853
  await this._connection.close();
1787
1854
  log8("stopped", void 0, {
1788
- F: __dxlog_file9,
1855
+ F: __dxlog_file10,
1789
1856
  L: 151,
1790
1857
  S: this,
1791
1858
  C: (f, a) => f(...a)
@@ -1859,7 +1926,7 @@ var SpaceProtocolSession = class {
1859
1926
  verifier: this._swarmIdentity.credentialAuthenticator,
1860
1927
  onAuthSuccess: () => {
1861
1928
  log8("Peer authenticated", void 0, {
1862
- F: __dxlog_file9,
1929
+ F: __dxlog_file10,
1863
1930
  L: 248,
1864
1931
  S: this,
1865
1932
  C: (f, a) => f(...a)
@@ -1877,7 +1944,7 @@ var SpaceProtocolSession = class {
1877
1944
  }
1878
1945
  async close() {
1879
1946
  log8("close", void 0, {
1880
- F: __dxlog_file9,
1947
+ F: __dxlog_file10,
1881
1948
  L: 264,
1882
1949
  S: this,
1883
1950
  C: (f, a) => f(...a)
@@ -1896,7 +1963,7 @@ _ts_decorate6([
1896
1963
  ], SpaceProtocolSession.prototype, "authStatus", null);
1897
1964
 
1898
1965
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
1899
- import { synchronized as synchronized4, trackLeaks as trackLeaks3 } from "@dxos/async";
1966
+ import { synchronized as synchronized4, trackLeaks as trackLeaks3, Trigger as Trigger2 } from "@dxos/async";
1900
1967
  import { failUndefined as failUndefined2 } from "@dxos/debug";
1901
1968
  import { PublicKey as PublicKey7 } from "@dxos/keys";
1902
1969
  import { log as log9 } from "@dxos/log";
@@ -1912,7 +1979,7 @@ function _ts_decorate7(decorators, target, key, desc) {
1912
1979
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1913
1980
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1914
1981
  }
1915
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1982
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1916
1983
  var SpaceManager = class {
1917
1984
  constructor({ feedStore, networkManager, metadataStore, snapshotStore, blobStore }) {
1918
1985
  this._spaces = new ComplexMap5(PublicKey7.hash);
@@ -1938,16 +2005,16 @@ var SpaceManager = class {
1938
2005
  log9.trace("dxos.echo.space-manager.construct-space", trace4.begin({
1939
2006
  id: this._instanceId
1940
2007
  }), {
1941
- F: __dxlog_file10,
1942
- L: 94,
2008
+ F: __dxlog_file11,
2009
+ L: 103,
1943
2010
  S: this,
1944
2011
  C: (f, a) => f(...a)
1945
2012
  });
1946
2013
  log9("constructing space...", {
1947
2014
  spaceKey: metadata.genesisFeedKey
1948
2015
  }, {
1949
- F: __dxlog_file10,
1950
- L: 95,
2016
+ F: __dxlog_file11,
2017
+ L: 104,
1951
2018
  S: this,
1952
2019
  C: (f, a) => f(...a)
1953
2020
  });
@@ -1979,13 +2046,74 @@ var SpaceManager = class {
1979
2046
  log9.trace("dxos.echo.space-manager.construct-space", trace4.end({
1980
2047
  id: this._instanceId
1981
2048
  }), {
1982
- F: __dxlog_file10,
1983
- L: 126,
2049
+ F: __dxlog_file11,
2050
+ L: 135,
1984
2051
  S: this,
1985
2052
  C: (f, a) => f(...a)
1986
2053
  });
1987
2054
  return space;
1988
2055
  }
2056
+ async requestSpaceAdmissionCredential(params) {
2057
+ const traceKey = "dxos.echo.space-manager.request-space-admission";
2058
+ log9.trace(traceKey, trace4.begin({
2059
+ id: this._instanceId
2060
+ }), {
2061
+ F: __dxlog_file11,
2062
+ L: 141,
2063
+ S: this,
2064
+ C: (f, a) => f(...a)
2065
+ });
2066
+ log9("requesting space admission credential...", {
2067
+ spaceKey: params.spaceKey
2068
+ }, {
2069
+ F: __dxlog_file11,
2070
+ L: 142,
2071
+ S: this,
2072
+ C: (f, a) => f(...a)
2073
+ });
2074
+ const onCredentialResolved = new Trigger2();
2075
+ const protocol = new SpaceProtocol({
2076
+ topic: params.spaceKey,
2077
+ swarmIdentity: params.swarmIdentity,
2078
+ networkManager: this._networkManager,
2079
+ onSessionAuth: (session) => {
2080
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialRetrieverExtension({
2081
+ spaceKey: params.spaceKey,
2082
+ memberKey: params.identityKey
2083
+ }, onCredentialResolved));
2084
+ },
2085
+ onAuthFailure: (session) => session.close(),
2086
+ blobStore: this._blobStore
2087
+ });
2088
+ try {
2089
+ await protocol.start();
2090
+ const credential = await onCredentialResolved.wait({
2091
+ timeout: params.timeout
2092
+ });
2093
+ log9.trace(traceKey, trace4.end({
2094
+ id: this._instanceId
2095
+ }), {
2096
+ F: __dxlog_file11,
2097
+ L: 165,
2098
+ S: this,
2099
+ C: (f, a) => f(...a)
2100
+ });
2101
+ return credential;
2102
+ } catch (err) {
2103
+ log9.trace(traceKey, trace4.error({
2104
+ id: this._instanceId,
2105
+ error: err
2106
+ }), {
2107
+ F: __dxlog_file11,
2108
+ L: 168,
2109
+ S: this,
2110
+ C: (f, a) => f(...a)
2111
+ });
2112
+ throw err;
2113
+ } finally {
2114
+ await protocol.stop();
2115
+ }
2116
+ }
1989
2117
  };
1990
2118
  _ts_decorate7([
1991
2119
  synchronized4
@@ -2015,6 +2143,8 @@ export {
2015
2143
  AuthExtension,
2016
2144
  Space,
2017
2145
  createIdFromSpaceKey,
2146
+ CredentialRetrieverExtension,
2147
+ CredentialServerExtension,
2018
2148
  MOCK_AUTH_PROVIDER,
2019
2149
  MOCK_AUTH_VERIFIER,
2020
2150
  SpaceProtocol,
@@ -2022,4 +2152,4 @@ export {
2022
2152
  SpaceProtocolSession,
2023
2153
  SpaceManager
2024
2154
  };
2025
- //# sourceMappingURL=chunk-ZCEMVITI.mjs.map
2155
+ //# sourceMappingURL=chunk-HS77A4I4.mjs.map