@dxos/client-services 0.4.10-main.3c620fb → 0.4.10-main.3e35a2f

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.
@@ -1639,11 +1639,11 @@ var InvitationsHandler = class {
1639
1639
  this._networkManager = _networkManager;
1640
1640
  }
1641
1641
  createInvitation(protocol, options) {
1642
- const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
1642
+ const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400, multiUse = false } = options ?? {};
1643
1643
  const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
1644
1644
  invariant6(protocol, void 0, {
1645
1645
  F: __dxlog_file7,
1646
- L: 84,
1646
+ L: 85,
1647
1647
  S: this,
1648
1648
  A: [
1649
1649
  "protocol",
@@ -1658,9 +1658,10 @@ var InvitationsHandler = class {
1658
1658
  swarmKey,
1659
1659
  authCode,
1660
1660
  timeout,
1661
- persistent,
1661
+ persistent: persistent && type !== Invitation3.Type.OFFLINE,
1662
1662
  created,
1663
1663
  lifetime,
1664
+ multiUse,
1664
1665
  ...protocol.getInvitationContext()
1665
1666
  };
1666
1667
  const stream = new PushStream();
@@ -1675,7 +1676,7 @@ var InvitationsHandler = class {
1675
1676
  ...protocol.toJSON()
1676
1677
  }, {
1677
1678
  F: __dxlog_file7,
1678
- L: 109,
1679
+ L: 111,
1679
1680
  S: this,
1680
1681
  C: (f, a) => f(...a)
1681
1682
  });
@@ -1700,7 +1701,7 @@ var InvitationsHandler = class {
1700
1701
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1701
1702
  invariant6(deviceKey, void 0, {
1702
1703
  F: __dxlog_file7,
1703
- L: 130,
1704
+ L: 132,
1704
1705
  S: this,
1705
1706
  A: [
1706
1707
  "deviceKey",
@@ -1723,7 +1724,7 @@ var InvitationsHandler = class {
1723
1724
  id: traceId
1724
1725
  }), {
1725
1726
  F: __dxlog_file7,
1726
- L: 148,
1727
+ L: 150,
1727
1728
  S: this,
1728
1729
  C: (f, a) => f(...a)
1729
1730
  });
@@ -1731,7 +1732,7 @@ var InvitationsHandler = class {
1731
1732
  ...protocol.toJSON()
1732
1733
  }, {
1733
1734
  F: __dxlog_file7,
1734
- L: 149,
1735
+ L: 151,
1735
1736
  S: this,
1736
1737
  C: (f, a) => f(...a)
1737
1738
  });
@@ -1747,7 +1748,7 @@ var InvitationsHandler = class {
1747
1748
  ...protocol.toJSON()
1748
1749
  }, {
1749
1750
  F: __dxlog_file7,
1750
- L: 152,
1751
+ L: 154,
1751
1752
  S: this,
1752
1753
  C: (f, a) => f(...a)
1753
1754
  });
@@ -1759,7 +1760,7 @@ var InvitationsHandler = class {
1759
1760
  id: traceId
1760
1761
  }), {
1761
1762
  F: __dxlog_file7,
1762
- L: 154,
1763
+ L: 156,
1763
1764
  S: this,
1764
1765
  C: (f, a) => f(...a)
1765
1766
  });
@@ -1769,7 +1770,7 @@ var InvitationsHandler = class {
1769
1770
  ...protocol.toJSON()
1770
1771
  }, {
1771
1772
  F: __dxlog_file7,
1772
- L: 157,
1773
+ L: 159,
1773
1774
  S: this,
1774
1775
  C: (f, a) => f(...a)
1775
1776
  });
@@ -1780,7 +1781,7 @@ var InvitationsHandler = class {
1780
1781
  } else {
1781
1782
  log5.error("failed", err, {
1782
1783
  F: __dxlog_file7,
1783
- L: 160,
1784
+ L: 162,
1784
1785
  S: this,
1785
1786
  C: (f, a) => f(...a)
1786
1787
  });
@@ -1791,12 +1792,12 @@ var InvitationsHandler = class {
1791
1792
  error: err
1792
1793
  }), {
1793
1794
  F: __dxlog_file7,
1794
- L: 163,
1795
+ L: 165,
1795
1796
  S: this,
1796
1797
  C: (f, a) => f(...a)
1797
1798
  });
1798
1799
  } finally {
1799
- if (type !== Invitation3.Type.MULTIUSE) {
1800
+ if (!multiUse) {
1800
1801
  await swarmConnection.close();
1801
1802
  await ctx.dispose();
1802
1803
  }
@@ -1812,7 +1813,7 @@ var InvitationsHandler = class {
1812
1813
  ...protocol.toJSON()
1813
1814
  }, {
1814
1815
  F: __dxlog_file7,
1815
- L: 178,
1816
+ L: 180,
1816
1817
  S: this,
1817
1818
  C: (f, a) => f(...a)
1818
1819
  });
@@ -1823,7 +1824,7 @@ var InvitationsHandler = class {
1823
1824
  } else {
1824
1825
  log5.error("failed", err, {
1825
1826
  F: __dxlog_file7,
1826
- L: 181,
1827
+ L: 183,
1827
1828
  S: this,
1828
1829
  C: (f, a) => f(...a)
1829
1830
  });
@@ -1837,7 +1838,7 @@ var InvitationsHandler = class {
1837
1838
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1838
1839
  log5.warn("invitation has already expired", void 0, {
1839
1840
  F: __dxlog_file7,
1840
- L: 192,
1841
+ L: 194,
1841
1842
  S: this,
1842
1843
  C: (f, a) => f(...a)
1843
1844
  });
@@ -1888,7 +1889,7 @@ var InvitationsHandler = class {
1888
1889
  const { timeout = INVITATION_TIMEOUT } = invitation;
1889
1890
  invariant6(protocol, void 0, {
1890
1891
  F: __dxlog_file7,
1891
- L: 246,
1892
+ L: 248,
1892
1893
  S: this,
1893
1894
  A: [
1894
1895
  "protocol",
@@ -1898,7 +1899,7 @@ var InvitationsHandler = class {
1898
1899
  if (deviceProfile) {
1899
1900
  invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
1900
1901
  F: __dxlog_file7,
1901
- L: 250,
1902
+ L: 252,
1902
1903
  S: this,
1903
1904
  A: [
1904
1905
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -1913,7 +1914,7 @@ var InvitationsHandler = class {
1913
1914
  const setState = (newData) => {
1914
1915
  invariant6(newData.state !== void 0, void 0, {
1915
1916
  F: __dxlog_file7,
1916
- L: 261,
1917
+ L: 263,
1917
1918
  S: this,
1918
1919
  A: [
1919
1920
  "newData.state !== undefined",
@@ -1933,7 +1934,7 @@ var InvitationsHandler = class {
1933
1934
  ...protocol.toJSON()
1934
1935
  }, {
1935
1936
  F: __dxlog_file7,
1936
- L: 269,
1937
+ L: 271,
1937
1938
  S: this,
1938
1939
  C: (f, a) => f(...a)
1939
1940
  });
@@ -1943,7 +1944,7 @@ var InvitationsHandler = class {
1943
1944
  } else {
1944
1945
  log5.warn("auth failed", err, {
1945
1946
  F: __dxlog_file7,
1946
- L: 272,
1947
+ L: 274,
1947
1948
  S: this,
1948
1949
  C: (f, a) => f(...a)
1949
1950
  });
@@ -1957,7 +1958,7 @@ var InvitationsHandler = class {
1957
1958
  ...protocol.toJSON()
1958
1959
  }, {
1959
1960
  F: __dxlog_file7,
1960
- L: 280,
1961
+ L: 282,
1961
1962
  S: this,
1962
1963
  C: (f, a) => f(...a)
1963
1964
  });
@@ -1972,7 +1973,7 @@ var InvitationsHandler = class {
1972
1973
  currentState
1973
1974
  }, {
1974
1975
  F: __dxlog_file7,
1975
- L: 290,
1976
+ L: 292,
1976
1977
  S: this,
1977
1978
  C: (f, a) => f(...a)
1978
1979
  });
@@ -1987,7 +1988,7 @@ var InvitationsHandler = class {
1987
1988
  id: traceId
1988
1989
  }), {
1989
1990
  F: __dxlog_file7,
1990
- L: 299,
1991
+ L: 301,
1991
1992
  S: this,
1992
1993
  C: (f, a) => f(...a)
1993
1994
  });
@@ -1999,7 +2000,7 @@ var InvitationsHandler = class {
1999
2000
  ...protocol.toJSON()
2000
2001
  }, {
2001
2002
  F: __dxlog_file7,
2002
- L: 307,
2003
+ L: 309,
2003
2004
  S: this,
2004
2005
  C: (f, a) => f(...a)
2005
2006
  });
@@ -2010,7 +2011,7 @@ var InvitationsHandler = class {
2010
2011
  ...protocol.toJSON()
2011
2012
  }, {
2012
2013
  F: __dxlog_file7,
2013
- L: 311,
2014
+ L: 313,
2014
2015
  S: this,
2015
2016
  C: (f, a) => f(...a)
2016
2017
  });
@@ -2020,7 +2021,7 @@ var InvitationsHandler = class {
2020
2021
  response: introductionResponse
2021
2022
  }, {
2022
2023
  F: __dxlog_file7,
2023
- L: 315,
2024
+ L: 317,
2024
2025
  S: this,
2025
2026
  C: (f, a) => f(...a)
2026
2027
  });
@@ -2029,7 +2030,7 @@ var InvitationsHandler = class {
2029
2030
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2030
2031
  log5("guest waiting for authentication code...", void 0, {
2031
2032
  F: __dxlog_file7,
2032
- L: 321,
2033
+ L: 323,
2033
2034
  S: this,
2034
2035
  C: (f, a) => f(...a)
2035
2036
  });
@@ -2041,7 +2042,7 @@ var InvitationsHandler = class {
2041
2042
  });
2042
2043
  log5("sending authentication request", void 0, {
2043
2044
  F: __dxlog_file7,
2044
- L: 325,
2045
+ L: 327,
2045
2046
  S: this,
2046
2047
  C: (f, a) => f(...a)
2047
2048
  });
@@ -2062,7 +2063,7 @@ var InvitationsHandler = class {
2062
2063
  attempt
2063
2064
  }, {
2064
2065
  F: __dxlog_file7,
2065
- L: 336,
2066
+ L: 338,
2066
2067
  S: this,
2067
2068
  C: (f, a) => f(...a)
2068
2069
  });
@@ -2075,7 +2076,7 @@ var InvitationsHandler = class {
2075
2076
  ...protocol.toJSON()
2076
2077
  }, {
2077
2078
  F: __dxlog_file7,
2078
- L: 344,
2079
+ L: 346,
2079
2080
  S: this,
2080
2081
  C: (f, a) => f(...a)
2081
2082
  });
@@ -2087,7 +2088,7 @@ var InvitationsHandler = class {
2087
2088
  ...protocol.toJSON()
2088
2089
  }, {
2089
2090
  F: __dxlog_file7,
2090
- L: 355,
2091
+ L: 357,
2091
2092
  S: this,
2092
2093
  C: (f, a) => f(...a)
2093
2094
  });
@@ -2100,7 +2101,7 @@ var InvitationsHandler = class {
2100
2101
  id: traceId
2101
2102
  }), {
2102
2103
  F: __dxlog_file7,
2103
- L: 357,
2104
+ L: 359,
2104
2105
  S: this,
2105
2106
  C: (f, a) => f(...a)
2106
2107
  });
@@ -2110,7 +2111,7 @@ var InvitationsHandler = class {
2110
2111
  ...protocol.toJSON()
2111
2112
  }, {
2112
2113
  F: __dxlog_file7,
2113
- L: 360,
2114
+ L: 362,
2114
2115
  S: this,
2115
2116
  C: (f, a) => f(...a)
2116
2117
  });
@@ -2120,7 +2121,7 @@ var InvitationsHandler = class {
2120
2121
  } else {
2121
2122
  log5("auth failed", err, {
2122
2123
  F: __dxlog_file7,
2123
- L: 363,
2124
+ L: 365,
2124
2125
  S: this,
2125
2126
  C: (f, a) => f(...a)
2126
2127
  });
@@ -2131,7 +2132,7 @@ var InvitationsHandler = class {
2131
2132
  error: err
2132
2133
  }), {
2133
2134
  F: __dxlog_file7,
2134
- L: 366,
2135
+ L: 368,
2135
2136
  S: this,
2136
2137
  C: (f, a) => f(...a)
2137
2138
  });
@@ -2149,7 +2150,7 @@ var InvitationsHandler = class {
2149
2150
  ...protocol.toJSON()
2150
2151
  }, {
2151
2152
  F: __dxlog_file7,
2152
- L: 377,
2153
+ L: 379,
2153
2154
  S: this,
2154
2155
  C: (f, a) => f(...a)
2155
2156
  });
@@ -2159,7 +2160,7 @@ var InvitationsHandler = class {
2159
2160
  } else {
2160
2161
  log5("auth failed", err, {
2161
2162
  F: __dxlog_file7,
2162
- L: 380,
2163
+ L: 382,
2163
2164
  S: this,
2164
2165
  C: (f, a) => f(...a)
2165
2166
  });
@@ -2176,7 +2177,7 @@ var InvitationsHandler = class {
2176
2177
  } else {
2177
2178
  invariant6(invitation.swarmKey, void 0, {
2178
2179
  F: __dxlog_file7,
2179
- L: 394,
2180
+ L: 396,
2180
2181
  S: this,
2181
2182
  A: [
2182
2183
  "invitation.swarmKey",
@@ -2215,14 +2216,12 @@ var InvitationsHandler = class {
2215
2216
  return observable;
2216
2217
  }
2217
2218
  };
2218
- var invitationExpired = (invitation) => {
2219
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2220
- };
2221
2219
 
2222
2220
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
2223
2221
  import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
2224
2222
  import { Stream as Stream8 } from "@dxos/codec-protobuf";
2225
2223
  import { Context as Context6 } from "@dxos/context";
2224
+ import { hasInvitationExpired } from "@dxos/echo-pipeline";
2226
2225
  import { invariant as invariant7 } from "@dxos/invariant";
2227
2226
  import { log as log6 } from "@dxos/log";
2228
2227
  import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
@@ -2281,7 +2280,7 @@ var InvitationsServiceImpl = class {
2281
2280
  await this._metadataStore.removeInvitation(invitation.get().invitationId);
2282
2281
  }
2283
2282
  this._createInvitations.delete(invitation.get().invitationId);
2284
- if (invitation.get().type !== Invitation4.Type.MULTIUSE) {
2283
+ if (!invitation.get().multiUse) {
2285
2284
  this._removedCreated.emit(invitation.get());
2286
2285
  }
2287
2286
  });
@@ -2289,7 +2288,7 @@ var InvitationsServiceImpl = class {
2289
2288
  }
2290
2289
  async loadPersistentInvitations() {
2291
2290
  const persistentInvitations = this._metadataStore.getInvitations();
2292
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2291
+ const freshInvitations = persistentInvitations.filter(async (invitation) => !hasInvitationExpired(invitation));
2293
2292
  const cInvitations = freshInvitations.map((persistentInvitation) => {
2294
2293
  invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2295
2294
  F: __dxlog_file8,
@@ -2342,7 +2341,7 @@ var InvitationsServiceImpl = class {
2342
2341
  }, () => {
2343
2342
  close();
2344
2343
  this._acceptInvitations.delete(invitation.get().invitationId);
2345
- if (invitation.get().type !== Invitation4.Type.MULTIUSE) {
2344
+ if (!invitation.get().multiUse) {
2346
2345
  this._removedAccepted.emit(invitation.get());
2347
2346
  }
2348
2347
  });
@@ -4636,7 +4635,7 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/s
4636
4635
  import { TRACE_PROCESSOR } from "@dxos/tracing";
4637
4636
 
4638
4637
  // packages/sdk/client-services/src/version.ts
4639
- var DXOS_VERSION = "0.4.10-main.3c620fb";
4638
+ var DXOS_VERSION = "0.4.10-main.3e35a2f";
4640
4639
 
4641
4640
  // packages/sdk/client-services/src/packlets/services/platform.ts
4642
4641
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -5869,7 +5868,6 @@ export {
5869
5868
  IdentityServiceImpl,
5870
5869
  DeviceInvitationProtocol,
5871
5870
  InvitationsHandler,
5872
- invitationExpired,
5873
5871
  InvitationsServiceImpl,
5874
5872
  SpaceInvitationProtocol,
5875
5873
  ClientRpcServer,
@@ -5889,4 +5887,4 @@ export {
5889
5887
  ClientServicesHost,
5890
5888
  ClientServicesProviderResource
5891
5889
  };
5892
- //# sourceMappingURL=chunk-H2TNTLUE.mjs.map
5890
+ //# sourceMappingURL=chunk-S3G2RM7S.mjs.map