@dxos/client-services 0.4.10-main.c75170d → 0.4.10-main.c8e5c39
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.
- package/dist/lib/browser/{chunk-JP7F2IH3.mjs → chunk-7OKNHCYB.mjs} +425 -410
- package/dist/lib/browser/chunk-7OKNHCYB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -4
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +131 -116
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-34EZSH65.cjs → chunk-5JA576YH.cjs} +527 -508
- package/dist/lib/node/chunk-5JA576YH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +48 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +130 -118
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +9 -7
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -3
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +10 -71
- package/src/packlets/invitations/invitations-manager.ts +114 -40
- package/src/packlets/invitations/invitations-service.ts +4 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/automerge-host.test.ts +4 -4
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +12 -25
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +5 -16
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +56 -13
- package/src/packlets/spaces/data-space.ts +14 -19
- package/src/packlets/storage/level.ts +1 -0
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +27 -14
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-JP7F2IH3.mjs.map +0 -7
- package/dist/lib/node/chunk-34EZSH65.cjs.map +0 -7
- package/dist/types/src/packlets/indexing/index.d.ts +0 -2
- package/dist/types/src/packlets/indexing/index.d.ts.map +0 -1
- package/dist/types/src/packlets/indexing/util.d.ts +0 -16
- package/dist/types/src/packlets/indexing/util.d.ts.map +0 -1
- package/src/packlets/indexing/index.ts +0 -5
- package/src/packlets/indexing/util.ts +0 -89
|
@@ -1086,7 +1086,9 @@ var IdentityManager = class {
|
|
|
1086
1086
|
C: (f, a) => f(...a)
|
|
1087
1087
|
});
|
|
1088
1088
|
},
|
|
1089
|
-
memberKey: identityKey
|
|
1089
|
+
memberKey: identityKey,
|
|
1090
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1091
|
+
}
|
|
1090
1092
|
});
|
|
1091
1093
|
}
|
|
1092
1094
|
};
|
|
@@ -1194,10 +1196,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1194
1196
|
kind: Invitation.Kind.DEVICE
|
|
1195
1197
|
};
|
|
1196
1198
|
}
|
|
1197
|
-
async
|
|
1199
|
+
async delegate(invitation) {
|
|
1200
|
+
throw new Error("delegation not supported");
|
|
1201
|
+
}
|
|
1202
|
+
async admit(_, request) {
|
|
1198
1203
|
invariant4(request.device, void 0, {
|
|
1199
1204
|
F: __dxlog_file5,
|
|
1200
|
-
L:
|
|
1205
|
+
L: 42,
|
|
1201
1206
|
S: this,
|
|
1202
1207
|
A: [
|
|
1203
1208
|
"request.device",
|
|
@@ -1243,7 +1248,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1243
1248
|
async accept(response, request) {
|
|
1244
1249
|
invariant4(response.device, void 0, {
|
|
1245
1250
|
F: __dxlog_file5,
|
|
1246
|
-
L:
|
|
1251
|
+
L: 87,
|
|
1247
1252
|
S: this,
|
|
1248
1253
|
A: [
|
|
1249
1254
|
"response.device",
|
|
@@ -1253,7 +1258,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1253
1258
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1254
1259
|
invariant4(request.device, void 0, {
|
|
1255
1260
|
F: __dxlog_file5,
|
|
1256
|
-
L:
|
|
1261
|
+
L: 90,
|
|
1257
1262
|
S: this,
|
|
1258
1263
|
A: [
|
|
1259
1264
|
"request.device",
|
|
@@ -1279,9 +1284,8 @@ var DeviceInvitationProtocol = class {
|
|
|
1279
1284
|
|
|
1280
1285
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1281
1286
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
1282
|
-
import { AuthenticatingInvitation,
|
|
1287
|
+
import { AuthenticatingInvitation, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
1283
1288
|
import { Context as Context5 } from "@dxos/context";
|
|
1284
|
-
import { generatePasscode } from "@dxos/credentials";
|
|
1285
1289
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1286
1290
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1287
1291
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -1656,51 +1660,7 @@ var InvitationsHandler = class {
|
|
|
1656
1660
|
constructor(_networkManager) {
|
|
1657
1661
|
this._networkManager = _networkManager;
|
|
1658
1662
|
}
|
|
1659
|
-
|
|
1660
|
-
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 = options?.authMethod !== Invitation3.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
1661
|
-
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1662
|
-
invariant6(protocol, void 0, {
|
|
1663
|
-
F: __dxlog_file7,
|
|
1664
|
-
L: 87,
|
|
1665
|
-
S: this,
|
|
1666
|
-
A: [
|
|
1667
|
-
"protocol",
|
|
1668
|
-
""
|
|
1669
|
-
]
|
|
1670
|
-
});
|
|
1671
|
-
const invitation = {
|
|
1672
|
-
invitationId,
|
|
1673
|
-
type,
|
|
1674
|
-
authMethod,
|
|
1675
|
-
state,
|
|
1676
|
-
swarmKey,
|
|
1677
|
-
authCode,
|
|
1678
|
-
timeout,
|
|
1679
|
-
persistent: persistent && type !== Invitation3.Type.DELEGATED,
|
|
1680
|
-
guestKeypair: guestKeypair ?? (authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1681
|
-
created,
|
|
1682
|
-
lifetime,
|
|
1683
|
-
multiUse,
|
|
1684
|
-
...protocol.getInvitationContext()
|
|
1685
|
-
};
|
|
1686
|
-
const stream = new PushStream();
|
|
1687
|
-
const ctx = new Context5({
|
|
1688
|
-
onError: (err) => {
|
|
1689
|
-
stream.error(err);
|
|
1690
|
-
void ctx.dispose();
|
|
1691
|
-
}
|
|
1692
|
-
});
|
|
1693
|
-
ctx.onDispose(() => {
|
|
1694
|
-
log5("complete", {
|
|
1695
|
-
...protocol.toJSON()
|
|
1696
|
-
}, {
|
|
1697
|
-
F: __dxlog_file7,
|
|
1698
|
-
L: 115,
|
|
1699
|
-
S: this,
|
|
1700
|
-
C: (f, a) => f(...a)
|
|
1701
|
-
});
|
|
1702
|
-
stream.complete();
|
|
1703
|
-
});
|
|
1663
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1704
1664
|
const createExtension = () => {
|
|
1705
1665
|
const extension = new InvitationHostExtension({
|
|
1706
1666
|
onStateUpdate: (invitation2) => {
|
|
@@ -1709,8 +1669,8 @@ var InvitationsHandler = class {
|
|
|
1709
1669
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
1710
1670
|
});
|
|
1711
1671
|
},
|
|
1712
|
-
resolveInvitation: async ({ invitationId
|
|
1713
|
-
if (
|
|
1672
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1673
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1714
1674
|
return void 0;
|
|
1715
1675
|
}
|
|
1716
1676
|
return invitation;
|
|
@@ -1720,14 +1680,14 @@ var InvitationsHandler = class {
|
|
|
1720
1680
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1721
1681
|
invariant6(deviceKey, void 0, {
|
|
1722
1682
|
F: __dxlog_file7,
|
|
1723
|
-
L:
|
|
1683
|
+
L: 87,
|
|
1724
1684
|
S: this,
|
|
1725
1685
|
A: [
|
|
1726
1686
|
"deviceKey",
|
|
1727
1687
|
""
|
|
1728
1688
|
]
|
|
1729
1689
|
});
|
|
1730
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1690
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1731
1691
|
extension.completedTrigger.wake(deviceKey);
|
|
1732
1692
|
return admissionResponse;
|
|
1733
1693
|
} catch (err) {
|
|
@@ -1743,7 +1703,7 @@ var InvitationsHandler = class {
|
|
|
1743
1703
|
id: traceId
|
|
1744
1704
|
}), {
|
|
1745
1705
|
F: __dxlog_file7,
|
|
1746
|
-
L:
|
|
1706
|
+
L: 105,
|
|
1747
1707
|
S: this,
|
|
1748
1708
|
C: (f, a) => f(...a)
|
|
1749
1709
|
});
|
|
@@ -1751,7 +1711,7 @@ var InvitationsHandler = class {
|
|
|
1751
1711
|
...protocol.toJSON()
|
|
1752
1712
|
}, {
|
|
1753
1713
|
F: __dxlog_file7,
|
|
1754
|
-
L:
|
|
1714
|
+
L: 106,
|
|
1755
1715
|
S: this,
|
|
1756
1716
|
C: (f, a) => f(...a)
|
|
1757
1717
|
});
|
|
@@ -1760,14 +1720,14 @@ var InvitationsHandler = class {
|
|
|
1760
1720
|
state: Invitation3.State.CONNECTED
|
|
1761
1721
|
});
|
|
1762
1722
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1763
|
-
timeout
|
|
1723
|
+
timeout: invitation.timeout
|
|
1764
1724
|
});
|
|
1765
1725
|
log5("admitted guest", {
|
|
1766
1726
|
guest: deviceKey,
|
|
1767
1727
|
...protocol.toJSON()
|
|
1768
1728
|
}, {
|
|
1769
1729
|
F: __dxlog_file7,
|
|
1770
|
-
L:
|
|
1730
|
+
L: 109,
|
|
1771
1731
|
S: this,
|
|
1772
1732
|
C: (f, a) => f(...a)
|
|
1773
1733
|
});
|
|
@@ -1779,7 +1739,7 @@ var InvitationsHandler = class {
|
|
|
1779
1739
|
id: traceId
|
|
1780
1740
|
}), {
|
|
1781
1741
|
F: __dxlog_file7,
|
|
1782
|
-
L:
|
|
1742
|
+
L: 111,
|
|
1783
1743
|
S: this,
|
|
1784
1744
|
C: (f, a) => f(...a)
|
|
1785
1745
|
});
|
|
@@ -1789,7 +1749,7 @@ var InvitationsHandler = class {
|
|
|
1789
1749
|
...protocol.toJSON()
|
|
1790
1750
|
}, {
|
|
1791
1751
|
F: __dxlog_file7,
|
|
1792
|
-
L:
|
|
1752
|
+
L: 114,
|
|
1793
1753
|
S: this,
|
|
1794
1754
|
C: (f, a) => f(...a)
|
|
1795
1755
|
});
|
|
@@ -1800,7 +1760,7 @@ var InvitationsHandler = class {
|
|
|
1800
1760
|
} else {
|
|
1801
1761
|
log5.error("failed", err, {
|
|
1802
1762
|
F: __dxlog_file7,
|
|
1803
|
-
L:
|
|
1763
|
+
L: 117,
|
|
1804
1764
|
S: this,
|
|
1805
1765
|
C: (f, a) => f(...a)
|
|
1806
1766
|
});
|
|
@@ -1811,12 +1771,12 @@ var InvitationsHandler = class {
|
|
|
1811
1771
|
error: err
|
|
1812
1772
|
}), {
|
|
1813
1773
|
F: __dxlog_file7,
|
|
1814
|
-
L:
|
|
1774
|
+
L: 120,
|
|
1815
1775
|
S: this,
|
|
1816
1776
|
C: (f, a) => f(...a)
|
|
1817
1777
|
});
|
|
1818
1778
|
} finally {
|
|
1819
|
-
if (!multiUse) {
|
|
1779
|
+
if (!invitation.multiUse) {
|
|
1820
1780
|
await swarmConnection.close();
|
|
1821
1781
|
await ctx.dispose();
|
|
1822
1782
|
}
|
|
@@ -1832,7 +1792,7 @@ var InvitationsHandler = class {
|
|
|
1832
1792
|
...protocol.toJSON()
|
|
1833
1793
|
}, {
|
|
1834
1794
|
F: __dxlog_file7,
|
|
1835
|
-
L:
|
|
1795
|
+
L: 135,
|
|
1836
1796
|
S: this,
|
|
1837
1797
|
C: (f, a) => f(...a)
|
|
1838
1798
|
});
|
|
@@ -1843,7 +1803,7 @@ var InvitationsHandler = class {
|
|
|
1843
1803
|
} else {
|
|
1844
1804
|
log5.error("failed", err, {
|
|
1845
1805
|
F: __dxlog_file7,
|
|
1846
|
-
L:
|
|
1806
|
+
L: 138,
|
|
1847
1807
|
S: this,
|
|
1848
1808
|
C: (f, a) => f(...a)
|
|
1849
1809
|
});
|
|
@@ -1857,7 +1817,7 @@ var InvitationsHandler = class {
|
|
|
1857
1817
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1858
1818
|
log5.warn("invitation has already expired", void 0, {
|
|
1859
1819
|
F: __dxlog_file7,
|
|
1860
|
-
L:
|
|
1820
|
+
L: 149,
|
|
1861
1821
|
S: this,
|
|
1862
1822
|
C: (f, a) => f(...a)
|
|
1863
1823
|
});
|
|
@@ -1891,24 +1851,12 @@ var InvitationsHandler = class {
|
|
|
1891
1851
|
state: Invitation3.State.CONNECTING
|
|
1892
1852
|
});
|
|
1893
1853
|
});
|
|
1894
|
-
const observable = new CancellableInvitation({
|
|
1895
|
-
initialInvitation: invitation,
|
|
1896
|
-
subscriber: stream.observable,
|
|
1897
|
-
onCancel: async () => {
|
|
1898
|
-
stream.next({
|
|
1899
|
-
...invitation,
|
|
1900
|
-
state: Invitation3.State.CANCELLED
|
|
1901
|
-
});
|
|
1902
|
-
await ctx.dispose();
|
|
1903
|
-
}
|
|
1904
|
-
});
|
|
1905
|
-
return observable;
|
|
1906
1854
|
}
|
|
1907
1855
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
1908
1856
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1909
1857
|
invariant6(protocol, void 0, {
|
|
1910
1858
|
F: __dxlog_file7,
|
|
1911
|
-
L:
|
|
1859
|
+
L: 191,
|
|
1912
1860
|
S: this,
|
|
1913
1861
|
A: [
|
|
1914
1862
|
"protocol",
|
|
@@ -1918,7 +1866,7 @@ var InvitationsHandler = class {
|
|
|
1918
1866
|
if (deviceProfile) {
|
|
1919
1867
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1920
1868
|
F: __dxlog_file7,
|
|
1921
|
-
L:
|
|
1869
|
+
L: 194,
|
|
1922
1870
|
S: this,
|
|
1923
1871
|
A: [
|
|
1924
1872
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1933,7 +1881,7 @@ var InvitationsHandler = class {
|
|
|
1933
1881
|
const setState = (newData) => {
|
|
1934
1882
|
invariant6(newData.state !== void 0, void 0, {
|
|
1935
1883
|
F: __dxlog_file7,
|
|
1936
|
-
L:
|
|
1884
|
+
L: 205,
|
|
1937
1885
|
S: this,
|
|
1938
1886
|
A: [
|
|
1939
1887
|
"newData.state !== undefined",
|
|
@@ -1953,7 +1901,7 @@ var InvitationsHandler = class {
|
|
|
1953
1901
|
...protocol.toJSON()
|
|
1954
1902
|
}, {
|
|
1955
1903
|
F: __dxlog_file7,
|
|
1956
|
-
L:
|
|
1904
|
+
L: 213,
|
|
1957
1905
|
S: this,
|
|
1958
1906
|
C: (f, a) => f(...a)
|
|
1959
1907
|
});
|
|
@@ -1963,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1963
1911
|
} else {
|
|
1964
1912
|
log5.warn("auth failed", err, {
|
|
1965
1913
|
F: __dxlog_file7,
|
|
1966
|
-
L:
|
|
1914
|
+
L: 216,
|
|
1967
1915
|
S: this,
|
|
1968
1916
|
C: (f, a) => f(...a)
|
|
1969
1917
|
});
|
|
@@ -1977,7 +1925,7 @@ var InvitationsHandler = class {
|
|
|
1977
1925
|
...protocol.toJSON()
|
|
1978
1926
|
}, {
|
|
1979
1927
|
F: __dxlog_file7,
|
|
1980
|
-
L:
|
|
1928
|
+
L: 224,
|
|
1981
1929
|
S: this,
|
|
1982
1930
|
C: (f, a) => f(...a)
|
|
1983
1931
|
});
|
|
@@ -1992,7 +1940,7 @@ var InvitationsHandler = class {
|
|
|
1992
1940
|
currentState
|
|
1993
1941
|
}, {
|
|
1994
1942
|
F: __dxlog_file7,
|
|
1995
|
-
L:
|
|
1943
|
+
L: 234,
|
|
1996
1944
|
S: this,
|
|
1997
1945
|
C: (f, a) => f(...a)
|
|
1998
1946
|
});
|
|
@@ -2007,7 +1955,7 @@ var InvitationsHandler = class {
|
|
|
2007
1955
|
id: traceId
|
|
2008
1956
|
}), {
|
|
2009
1957
|
F: __dxlog_file7,
|
|
2010
|
-
L:
|
|
1958
|
+
L: 243,
|
|
2011
1959
|
S: this,
|
|
2012
1960
|
C: (f, a) => f(...a)
|
|
2013
1961
|
});
|
|
@@ -2019,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
2019
1967
|
...protocol.toJSON()
|
|
2020
1968
|
}, {
|
|
2021
1969
|
F: __dxlog_file7,
|
|
2022
|
-
L:
|
|
1970
|
+
L: 251,
|
|
2023
1971
|
S: this,
|
|
2024
1972
|
C: (f, a) => f(...a)
|
|
2025
1973
|
});
|
|
@@ -2030,7 +1978,7 @@ var InvitationsHandler = class {
|
|
|
2030
1978
|
...protocol.toJSON()
|
|
2031
1979
|
}, {
|
|
2032
1980
|
F: __dxlog_file7,
|
|
2033
|
-
L:
|
|
1981
|
+
L: 255,
|
|
2034
1982
|
S: this,
|
|
2035
1983
|
C: (f, a) => f(...a)
|
|
2036
1984
|
});
|
|
@@ -2040,7 +1988,7 @@ var InvitationsHandler = class {
|
|
|
2040
1988
|
response: introductionResponse
|
|
2041
1989
|
}, {
|
|
2042
1990
|
F: __dxlog_file7,
|
|
2043
|
-
L:
|
|
1991
|
+
L: 259,
|
|
2044
1992
|
S: this,
|
|
2045
1993
|
C: (f, a) => f(...a)
|
|
2046
1994
|
});
|
|
@@ -2061,7 +2009,7 @@ var InvitationsHandler = class {
|
|
|
2061
2009
|
...protocol.toJSON()
|
|
2062
2010
|
}, {
|
|
2063
2011
|
F: __dxlog_file7,
|
|
2064
|
-
L:
|
|
2012
|
+
L: 275,
|
|
2065
2013
|
S: this,
|
|
2066
2014
|
C: (f, a) => f(...a)
|
|
2067
2015
|
});
|
|
@@ -2073,7 +2021,7 @@ var InvitationsHandler = class {
|
|
|
2073
2021
|
...protocol.toJSON()
|
|
2074
2022
|
}, {
|
|
2075
2023
|
F: __dxlog_file7,
|
|
2076
|
-
L:
|
|
2024
|
+
L: 286,
|
|
2077
2025
|
S: this,
|
|
2078
2026
|
C: (f, a) => f(...a)
|
|
2079
2027
|
});
|
|
@@ -2086,7 +2034,7 @@ var InvitationsHandler = class {
|
|
|
2086
2034
|
id: traceId
|
|
2087
2035
|
}), {
|
|
2088
2036
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2037
|
+
L: 288,
|
|
2090
2038
|
S: this,
|
|
2091
2039
|
C: (f, a) => f(...a)
|
|
2092
2040
|
});
|
|
@@ -2096,7 +2044,7 @@ var InvitationsHandler = class {
|
|
|
2096
2044
|
...protocol.toJSON()
|
|
2097
2045
|
}, {
|
|
2098
2046
|
F: __dxlog_file7,
|
|
2099
|
-
L:
|
|
2047
|
+
L: 291,
|
|
2100
2048
|
S: this,
|
|
2101
2049
|
C: (f, a) => f(...a)
|
|
2102
2050
|
});
|
|
@@ -2106,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2106
2054
|
} else {
|
|
2107
2055
|
log5("auth failed", err, {
|
|
2108
2056
|
F: __dxlog_file7,
|
|
2109
|
-
L:
|
|
2057
|
+
L: 294,
|
|
2110
2058
|
S: this,
|
|
2111
2059
|
C: (f, a) => f(...a)
|
|
2112
2060
|
});
|
|
@@ -2117,7 +2065,7 @@ var InvitationsHandler = class {
|
|
|
2117
2065
|
error: err
|
|
2118
2066
|
}), {
|
|
2119
2067
|
F: __dxlog_file7,
|
|
2120
|
-
L:
|
|
2068
|
+
L: 297,
|
|
2121
2069
|
S: this,
|
|
2122
2070
|
C: (f, a) => f(...a)
|
|
2123
2071
|
});
|
|
@@ -2135,7 +2083,7 @@ var InvitationsHandler = class {
|
|
|
2135
2083
|
...protocol.toJSON()
|
|
2136
2084
|
}, {
|
|
2137
2085
|
F: __dxlog_file7,
|
|
2138
|
-
L:
|
|
2086
|
+
L: 308,
|
|
2139
2087
|
S: this,
|
|
2140
2088
|
C: (f, a) => f(...a)
|
|
2141
2089
|
});
|
|
@@ -2145,7 +2093,7 @@ var InvitationsHandler = class {
|
|
|
2145
2093
|
} else {
|
|
2146
2094
|
log5("auth failed", err, {
|
|
2147
2095
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2096
|
+
L: 311,
|
|
2149
2097
|
S: this,
|
|
2150
2098
|
C: (f, a) => f(...a)
|
|
2151
2099
|
});
|
|
@@ -2162,7 +2110,7 @@ var InvitationsHandler = class {
|
|
|
2162
2110
|
} else {
|
|
2163
2111
|
invariant6(invitation.swarmKey, void 0, {
|
|
2164
2112
|
F: __dxlog_file7,
|
|
2165
|
-
L:
|
|
2113
|
+
L: 325,
|
|
2166
2114
|
S: this,
|
|
2167
2115
|
A: [
|
|
2168
2116
|
"invitation.swarmKey",
|
|
@@ -2204,7 +2152,7 @@ var InvitationsHandler = class {
|
|
|
2204
2152
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2205
2153
|
log5("guest waiting for authentication code...", void 0, {
|
|
2206
2154
|
F: __dxlog_file7,
|
|
2207
|
-
L:
|
|
2155
|
+
L: 365,
|
|
2208
2156
|
S: this,
|
|
2209
2157
|
C: (f, a) => f(...a)
|
|
2210
2158
|
});
|
|
@@ -2214,7 +2162,7 @@ var InvitationsHandler = class {
|
|
|
2214
2162
|
const authCode = await authenticated.wait(options);
|
|
2215
2163
|
log5("sending authentication request", void 0, {
|
|
2216
2164
|
F: __dxlog_file7,
|
|
2217
|
-
L:
|
|
2165
|
+
L: 369,
|
|
2218
2166
|
S: this,
|
|
2219
2167
|
C: (f, a) => f(...a)
|
|
2220
2168
|
});
|
|
@@ -2235,7 +2183,7 @@ var InvitationsHandler = class {
|
|
|
2235
2183
|
attempt
|
|
2236
2184
|
}, {
|
|
2237
2185
|
F: __dxlog_file7,
|
|
2238
|
-
L:
|
|
2186
|
+
L: 380,
|
|
2239
2187
|
S: this,
|
|
2240
2188
|
C: (f, a) => f(...a)
|
|
2241
2189
|
});
|
|
@@ -2253,7 +2201,7 @@ var InvitationsHandler = class {
|
|
|
2253
2201
|
}
|
|
2254
2202
|
log5("sending authentication request", void 0, {
|
|
2255
2203
|
F: __dxlog_file7,
|
|
2256
|
-
L:
|
|
2204
|
+
L: 399,
|
|
2257
2205
|
S: this,
|
|
2258
2206
|
C: (f, a) => f(...a)
|
|
2259
2207
|
});
|
|
@@ -2289,9 +2237,8 @@ var InvitationsServiceImpl = class {
|
|
|
2289
2237
|
return {};
|
|
2290
2238
|
}
|
|
2291
2239
|
createInvitation(options) {
|
|
2292
|
-
const invitation = this._invitationsManager.createInvitation(options);
|
|
2293
2240
|
return new Stream8(({ next, close }) => {
|
|
2294
|
-
invitation.subscribe(next, close, close);
|
|
2241
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2295
2242
|
});
|
|
2296
2243
|
}
|
|
2297
2244
|
acceptInvitation(request) {
|
|
@@ -2376,12 +2323,13 @@ var InvitationsServiceImpl = class {
|
|
|
2376
2323
|
};
|
|
2377
2324
|
|
|
2378
2325
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2379
|
-
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2326
|
+
import { createAdmissionCredentials, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
|
|
2380
2327
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2381
2328
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2382
2329
|
import { log as log6 } from "@dxos/log";
|
|
2383
2330
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2384
2331
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2332
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2385
2333
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2386
2334
|
var SpaceInvitationProtocol = class {
|
|
2387
2335
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
@@ -2402,10 +2350,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2402
2350
|
spaceKey: this._spaceKey
|
|
2403
2351
|
};
|
|
2404
2352
|
}
|
|
2405
|
-
async admit(request, guestProfile) {
|
|
2353
|
+
async admit(invitation, request, guestProfile) {
|
|
2406
2354
|
invariant7(this._spaceKey, void 0, {
|
|
2407
2355
|
F: __dxlog_file8,
|
|
2408
|
-
L:
|
|
2356
|
+
L: 55,
|
|
2409
2357
|
S: this,
|
|
2410
2358
|
A: [
|
|
2411
2359
|
"this._spaceKey",
|
|
@@ -2415,7 +2363,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2415
2363
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2416
2364
|
invariant7(space, void 0, {
|
|
2417
2365
|
F: __dxlog_file8,
|
|
2418
|
-
L:
|
|
2366
|
+
L: 57,
|
|
2419
2367
|
S: this,
|
|
2420
2368
|
A: [
|
|
2421
2369
|
"space",
|
|
@@ -2424,7 +2372,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2424
2372
|
});
|
|
2425
2373
|
invariant7(request.space, void 0, {
|
|
2426
2374
|
F: __dxlog_file8,
|
|
2427
|
-
L:
|
|
2375
|
+
L: 59,
|
|
2428
2376
|
S: this,
|
|
2429
2377
|
A: [
|
|
2430
2378
|
"request.space",
|
|
@@ -2437,14 +2385,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2437
2385
|
guest: deviceKey
|
|
2438
2386
|
}, {
|
|
2439
2387
|
F: __dxlog_file8,
|
|
2440
|
-
L:
|
|
2388
|
+
L: 62,
|
|
2441
2389
|
S: this,
|
|
2442
2390
|
C: (f, a) => f(...a)
|
|
2443
2391
|
});
|
|
2444
|
-
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2392
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2445
2393
|
invariant7(credentials[0].credential, void 0, {
|
|
2446
2394
|
F: __dxlog_file8,
|
|
2447
|
-
L:
|
|
2395
|
+
L: 74,
|
|
2448
2396
|
S: this,
|
|
2449
2397
|
A: [
|
|
2450
2398
|
"credentials[0].credential",
|
|
@@ -2454,7 +2402,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2454
2402
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2455
2403
|
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2456
2404
|
F: __dxlog_file8,
|
|
2457
|
-
L:
|
|
2405
|
+
L: 76,
|
|
2458
2406
|
S: this,
|
|
2459
2407
|
A: [
|
|
2460
2408
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2469,6 +2417,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2469
2417
|
}
|
|
2470
2418
|
};
|
|
2471
2419
|
}
|
|
2420
|
+
async delegate(invitation) {
|
|
2421
|
+
invariant7(this._spaceKey, void 0, {
|
|
2422
|
+
F: __dxlog_file8,
|
|
2423
|
+
L: 89,
|
|
2424
|
+
S: this,
|
|
2425
|
+
A: [
|
|
2426
|
+
"this._spaceKey",
|
|
2427
|
+
""
|
|
2428
|
+
]
|
|
2429
|
+
});
|
|
2430
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2431
|
+
invariant7(space, void 0, {
|
|
2432
|
+
F: __dxlog_file8,
|
|
2433
|
+
L: 91,
|
|
2434
|
+
S: this,
|
|
2435
|
+
A: [
|
|
2436
|
+
"space",
|
|
2437
|
+
""
|
|
2438
|
+
]
|
|
2439
|
+
});
|
|
2440
|
+
if (invitation.authMethod === Invitation4.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2441
|
+
invariant7(invitation.guestKeypair?.publicKey, void 0, {
|
|
2442
|
+
F: __dxlog_file8,
|
|
2443
|
+
L: 93,
|
|
2444
|
+
S: this,
|
|
2445
|
+
A: [
|
|
2446
|
+
"invitation.guestKeypair?.publicKey",
|
|
2447
|
+
""
|
|
2448
|
+
]
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
log6("writing delegate space invitation", {
|
|
2452
|
+
host: this._signingContext.deviceKey,
|
|
2453
|
+
id: invitation.invitationId
|
|
2454
|
+
}, {
|
|
2455
|
+
F: __dxlog_file8,
|
|
2456
|
+
L: 96,
|
|
2457
|
+
S: this,
|
|
2458
|
+
C: (f, a) => f(...a)
|
|
2459
|
+
});
|
|
2460
|
+
const credential = await createDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, {
|
|
2461
|
+
invitationId: invitation.invitationId,
|
|
2462
|
+
authMethod: invitation.authMethod,
|
|
2463
|
+
swarmKey: invitation.swarmKey,
|
|
2464
|
+
role: SpaceMember.Role.ADMIN,
|
|
2465
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2466
|
+
multiUse: invitation.multiUse ?? false,
|
|
2467
|
+
guestKey: invitation.authMethod === Invitation4.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2468
|
+
});
|
|
2469
|
+
invariant7(credential.credential, void 0, {
|
|
2470
|
+
F: __dxlog_file8,
|
|
2471
|
+
L: 116,
|
|
2472
|
+
S: this,
|
|
2473
|
+
A: [
|
|
2474
|
+
"credential.credential",
|
|
2475
|
+
""
|
|
2476
|
+
]
|
|
2477
|
+
});
|
|
2478
|
+
await writeMessages2(space.inner.controlPipeline.writer, [
|
|
2479
|
+
credential
|
|
2480
|
+
]);
|
|
2481
|
+
return credential.credential.credential.id;
|
|
2482
|
+
}
|
|
2472
2483
|
checkInvitation(invitation) {
|
|
2473
2484
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2474
2485
|
return new AlreadyJoinedError2("Already joined space.");
|
|
@@ -2494,7 +2505,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2494
2505
|
async accept(response) {
|
|
2495
2506
|
invariant7(response.space, void 0, {
|
|
2496
2507
|
F: __dxlog_file8,
|
|
2497
|
-
L:
|
|
2508
|
+
L: 149,
|
|
2498
2509
|
S: this,
|
|
2499
2510
|
A: [
|
|
2500
2511
|
"response.space",
|
|
@@ -2505,7 +2516,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2505
2516
|
const assertion = getCredentialAssertion(credential);
|
|
2506
2517
|
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2507
2518
|
F: __dxlog_file8,
|
|
2508
|
-
L:
|
|
2519
|
+
L: 152,
|
|
2509
2520
|
S: this,
|
|
2510
2521
|
A: [
|
|
2511
2522
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2514,7 +2525,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2514
2525
|
});
|
|
2515
2526
|
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2516
2527
|
F: __dxlog_file8,
|
|
2517
|
-
L:
|
|
2528
|
+
L: 153,
|
|
2518
2529
|
S: this,
|
|
2519
2530
|
A: [
|
|
2520
2531
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2538,10 +2549,15 @@ var SpaceInvitationProtocol = class {
|
|
|
2538
2549
|
};
|
|
2539
2550
|
|
|
2540
2551
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
2541
|
-
import { Event as Event3 } from "@dxos/async";
|
|
2552
|
+
import { Event as Event3, PushStream as PushStream2 } from "@dxos/async";
|
|
2553
|
+
import { AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2554
|
+
import { Context as Context6 } from "@dxos/context";
|
|
2555
|
+
import { generatePasscode } from "@dxos/credentials";
|
|
2542
2556
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2543
2557
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2558
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2544
2559
|
import { log as log7 } from "@dxos/log";
|
|
2560
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2545
2561
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2546
2562
|
var InvitationsManager = class {
|
|
2547
2563
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
@@ -2558,25 +2574,39 @@ var InvitationsManager = class {
|
|
|
2558
2574
|
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2559
2575
|
this._persistentInvitationsLoaded = false;
|
|
2560
2576
|
}
|
|
2561
|
-
createInvitation(options) {
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2577
|
+
async createInvitation(options) {
|
|
2578
|
+
if (options.invitationId) {
|
|
2579
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2580
|
+
if (existingInvitation) {
|
|
2581
|
+
return existingInvitation;
|
|
2582
|
+
}
|
|
2565
2583
|
}
|
|
2566
2584
|
const handler = this._getHandler(options);
|
|
2567
|
-
const invitation = this.
|
|
2568
|
-
this.
|
|
2569
|
-
this.
|
|
2570
|
-
|
|
2571
|
-
this._onInvitationComplete(
|
|
2572
|
-
this._createInvitations.delete(
|
|
2573
|
-
this.removedCreated.emit(
|
|
2574
|
-
if (
|
|
2575
|
-
await
|
|
2576
|
-
await this._safeDeleteInvitation(invitation.get());
|
|
2585
|
+
const invitation = this._createInvitation(handler, options);
|
|
2586
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2587
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2588
|
+
this.invitationCreated.emit(invitation);
|
|
2589
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2590
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2591
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2592
|
+
if (observableInvitation.get().persistent) {
|
|
2593
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2577
2594
|
}
|
|
2578
2595
|
});
|
|
2579
|
-
|
|
2596
|
+
try {
|
|
2597
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2598
|
+
} catch (err) {
|
|
2599
|
+
log7.catch(err, void 0, {
|
|
2600
|
+
F: __dxlog_file9,
|
|
2601
|
+
L: 76,
|
|
2602
|
+
S: this,
|
|
2603
|
+
C: (f, a) => f(...a)
|
|
2604
|
+
});
|
|
2605
|
+
await observableInvitation.cancel();
|
|
2606
|
+
return observableInvitation;
|
|
2607
|
+
}
|
|
2608
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2609
|
+
return observableInvitation;
|
|
2580
2610
|
}
|
|
2581
2611
|
async loadPersistentInvitations() {
|
|
2582
2612
|
if (this._persistentInvitationsLoaded) {
|
|
@@ -2588,10 +2618,10 @@ var InvitationsManager = class {
|
|
|
2588
2618
|
try {
|
|
2589
2619
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2590
2620
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
2591
|
-
const
|
|
2621
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2592
2622
|
invariant8(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2593
2623
|
F: __dxlog_file9,
|
|
2594
|
-
L:
|
|
2624
|
+
L: 97,
|
|
2595
2625
|
S: this,
|
|
2596
2626
|
A: [
|
|
2597
2627
|
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
@@ -2601,15 +2631,16 @@ var InvitationsManager = class {
|
|
|
2601
2631
|
return this.createInvitation({
|
|
2602
2632
|
...persistentInvitation,
|
|
2603
2633
|
persistent: false
|
|
2604
|
-
})
|
|
2634
|
+
});
|
|
2605
2635
|
});
|
|
2636
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2606
2637
|
return {
|
|
2607
|
-
invitations: cInvitations
|
|
2638
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2608
2639
|
};
|
|
2609
2640
|
} catch (err) {
|
|
2610
2641
|
log7.catch(err, void 0, {
|
|
2611
2642
|
F: __dxlog_file9,
|
|
2612
|
-
L:
|
|
2643
|
+
L: 104,
|
|
2613
2644
|
S: this,
|
|
2614
2645
|
C: (f, a) => f(...a)
|
|
2615
2646
|
});
|
|
@@ -2640,13 +2671,13 @@ var InvitationsManager = class {
|
|
|
2640
2671
|
async authenticate({ invitationId, authCode }) {
|
|
2641
2672
|
log7("authenticating...", void 0, {
|
|
2642
2673
|
F: __dxlog_file9,
|
|
2643
|
-
L:
|
|
2674
|
+
L: 133,
|
|
2644
2675
|
S: this,
|
|
2645
2676
|
C: (f, a) => f(...a)
|
|
2646
2677
|
});
|
|
2647
2678
|
invariant8(invitationId, void 0, {
|
|
2648
2679
|
F: __dxlog_file9,
|
|
2649
|
-
L:
|
|
2680
|
+
L: 134,
|
|
2650
2681
|
S: this,
|
|
2651
2682
|
A: [
|
|
2652
2683
|
"invitationId",
|
|
@@ -2659,7 +2690,7 @@ var InvitationsManager = class {
|
|
|
2659
2690
|
invitationId
|
|
2660
2691
|
}, {
|
|
2661
2692
|
F: __dxlog_file9,
|
|
2662
|
-
L:
|
|
2693
|
+
L: 137,
|
|
2663
2694
|
S: this,
|
|
2664
2695
|
C: (f, a) => f(...a)
|
|
2665
2696
|
});
|
|
@@ -2672,13 +2703,13 @@ var InvitationsManager = class {
|
|
|
2672
2703
|
invitationId
|
|
2673
2704
|
}, {
|
|
2674
2705
|
F: __dxlog_file9,
|
|
2675
|
-
L:
|
|
2706
|
+
L: 144,
|
|
2676
2707
|
S: this,
|
|
2677
2708
|
C: (f, a) => f(...a)
|
|
2678
2709
|
});
|
|
2679
2710
|
invariant8(invitationId, void 0, {
|
|
2680
2711
|
F: __dxlog_file9,
|
|
2681
|
-
L:
|
|
2712
|
+
L: 145,
|
|
2682
2713
|
S: this,
|
|
2683
2714
|
A: [
|
|
2684
2715
|
"invitationId",
|
|
@@ -2719,25 +2750,73 @@ var InvitationsManager = class {
|
|
|
2719
2750
|
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2720
2751
|
}
|
|
2721
2752
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2753
|
+
_createInvitation(protocol, options) {
|
|
2754
|
+
const { invitationId = PublicKey7.random().toHex(), type = Invitation5.Type.INTERACTIVE, authMethod = Invitation5.AuthMethod.SHARED_SECRET, state = Invitation5.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey7.random(), persistent = options?.authMethod !== Invitation5.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2755
|
+
const authCode = options?.authCode ?? (authMethod === Invitation5.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2756
|
+
return {
|
|
2757
|
+
invitationId,
|
|
2758
|
+
type,
|
|
2759
|
+
authMethod,
|
|
2760
|
+
state,
|
|
2761
|
+
swarmKey,
|
|
2762
|
+
authCode,
|
|
2763
|
+
timeout,
|
|
2764
|
+
persistent: persistent && type !== Invitation5.Type.DELEGATED,
|
|
2765
|
+
guestKeypair: guestKeypair ?? (authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2766
|
+
created,
|
|
2767
|
+
lifetime,
|
|
2768
|
+
multiUse,
|
|
2769
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2770
|
+
...protocol.getInvitationContext()
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
_createObservableInvitation(handler, invitation) {
|
|
2774
|
+
const stream = new PushStream2();
|
|
2775
|
+
const ctx = new Context6({
|
|
2776
|
+
onError: (err) => {
|
|
2777
|
+
stream.error(err);
|
|
2778
|
+
void ctx.dispose();
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
ctx.onDispose(() => {
|
|
2782
|
+
log7("complete", {
|
|
2783
|
+
...handler.toJSON()
|
|
2784
|
+
}, {
|
|
2785
|
+
F: __dxlog_file9,
|
|
2786
|
+
L: 228,
|
|
2787
|
+
S: this,
|
|
2788
|
+
C: (f, a) => f(...a)
|
|
2739
2789
|
});
|
|
2790
|
+
stream.complete();
|
|
2791
|
+
});
|
|
2792
|
+
const observableInvitation = new CancellableInvitation({
|
|
2793
|
+
initialInvitation: invitation,
|
|
2794
|
+
subscriber: stream.observable,
|
|
2795
|
+
onCancel: async () => {
|
|
2796
|
+
stream.next({
|
|
2797
|
+
...invitation,
|
|
2798
|
+
state: Invitation5.State.CANCELLED
|
|
2799
|
+
});
|
|
2800
|
+
await ctx.dispose();
|
|
2801
|
+
}
|
|
2740
2802
|
});
|
|
2803
|
+
return {
|
|
2804
|
+
ctx,
|
|
2805
|
+
stream,
|
|
2806
|
+
observableInvitation
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2810
|
+
if (invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2811
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2812
|
+
changeStream.next({
|
|
2813
|
+
...invitation,
|
|
2814
|
+
delegationCredentialId
|
|
2815
|
+
});
|
|
2816
|
+
} else if (invitation.persistent) {
|
|
2817
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2818
|
+
this.saved.emit(invitation);
|
|
2819
|
+
}
|
|
2741
2820
|
}
|
|
2742
2821
|
async _safeDeleteInvitation(invitation) {
|
|
2743
2822
|
try {
|
|
@@ -2745,7 +2824,7 @@ var InvitationsManager = class {
|
|
|
2745
2824
|
} catch (err) {
|
|
2746
2825
|
log7.catch(err, void 0, {
|
|
2747
2826
|
F: __dxlog_file9,
|
|
2748
|
-
L:
|
|
2827
|
+
L: 260,
|
|
2749
2828
|
S: this,
|
|
2750
2829
|
C: (f, a) => f(...a)
|
|
2751
2830
|
});
|
|
@@ -2842,13 +2921,13 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2842
2921
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2843
2922
|
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2844
2923
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2845
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2924
|
+
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2846
2925
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2847
|
-
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2848
2926
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2849
2927
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2928
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
2850
2929
|
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2851
|
-
import { PublicKey as
|
|
2930
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2852
2931
|
import { log as log9 } from "@dxos/log";
|
|
2853
2932
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2854
2933
|
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2897,9 +2976,9 @@ var AutomergeSpaceState = class {
|
|
|
2897
2976
|
|
|
2898
2977
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2899
2978
|
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2900
|
-
import { Context as
|
|
2979
|
+
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2901
2980
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2902
|
-
import { PublicKey as
|
|
2981
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2903
2982
|
import { log as log8 } from "@dxos/log";
|
|
2904
2983
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2905
2984
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
@@ -2911,11 +2990,11 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2911
2990
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2912
2991
|
var NotarizationPlugin = class {
|
|
2913
2992
|
constructor() {
|
|
2914
|
-
this._ctx = new
|
|
2993
|
+
this._ctx = new Context7();
|
|
2915
2994
|
this._extensionOpened = new Event5();
|
|
2916
2995
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2917
|
-
this._processedCredentials = new ComplexSet2(
|
|
2918
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2996
|
+
this._processedCredentials = new ComplexSet2(PublicKey8.hash);
|
|
2997
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey8.hash);
|
|
2919
2998
|
}
|
|
2920
2999
|
get hasWriter() {
|
|
2921
3000
|
return !!this._writer;
|
|
@@ -3177,7 +3256,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3177
3256
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3178
3257
|
var DataSpace = class {
|
|
3179
3258
|
constructor(params) {
|
|
3180
|
-
this._ctx = new
|
|
3259
|
+
this._ctx = new Context8();
|
|
3181
3260
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3182
3261
|
this._cache = void 0;
|
|
3183
3262
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -3198,9 +3277,9 @@ var DataSpace = class {
|
|
|
3198
3277
|
this._metadataStore = params.metadataStore;
|
|
3199
3278
|
this._signingContext = params.signingContext;
|
|
3200
3279
|
this._callbacks = params.callbacks ?? {};
|
|
3201
|
-
this.
|
|
3280
|
+
this._echoHost = params.echoHost;
|
|
3202
3281
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3203
|
-
trustedKeysProvider: () => new ComplexSet3(
|
|
3282
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey9.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3204
3283
|
update: this._inner.stateUpdate,
|
|
3205
3284
|
authTimeout: AUTH_TIMEOUT2
|
|
3206
3285
|
});
|
|
@@ -3210,7 +3289,7 @@ var DataSpace = class {
|
|
|
3210
3289
|
state: SpaceState[this._state]
|
|
3211
3290
|
}, {
|
|
3212
3291
|
F: __dxlog_file11,
|
|
3213
|
-
L:
|
|
3292
|
+
L: 135,
|
|
3214
3293
|
S: this,
|
|
3215
3294
|
C: (f, a) => f(...a)
|
|
3216
3295
|
});
|
|
@@ -3254,13 +3333,13 @@ var DataSpace = class {
|
|
|
3254
3333
|
await this._notarizationPlugin.open();
|
|
3255
3334
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3256
3335
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3257
|
-
await this._inner.open(new
|
|
3336
|
+
await this._inner.open(new Context8());
|
|
3258
3337
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3259
3338
|
log9("new state", {
|
|
3260
3339
|
state: SpaceState[this._state]
|
|
3261
3340
|
}, {
|
|
3262
3341
|
F: __dxlog_file11,
|
|
3263
|
-
L:
|
|
3342
|
+
L: 193,
|
|
3264
3343
|
S: this,
|
|
3265
3344
|
C: (f, a) => f(...a)
|
|
3266
3345
|
});
|
|
@@ -3278,12 +3357,12 @@ var DataSpace = class {
|
|
|
3278
3357
|
state: SpaceState[this._state]
|
|
3279
3358
|
}, {
|
|
3280
3359
|
F: __dxlog_file11,
|
|
3281
|
-
L:
|
|
3360
|
+
L: 207,
|
|
3282
3361
|
S: this,
|
|
3283
3362
|
C: (f, a) => f(...a)
|
|
3284
3363
|
});
|
|
3285
3364
|
await this._ctx.dispose();
|
|
3286
|
-
this._ctx = new
|
|
3365
|
+
this._ctx = new Context8();
|
|
3287
3366
|
await this.authVerifier.close();
|
|
3288
3367
|
await this._inner.close();
|
|
3289
3368
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3310,7 +3389,7 @@ var DataSpace = class {
|
|
|
3310
3389
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3311
3390
|
log9("data pipeline initialization cancelled", err, {
|
|
3312
3391
|
F: __dxlog_file11,
|
|
3313
|
-
L:
|
|
3392
|
+
L: 240,
|
|
3314
3393
|
S: this,
|
|
3315
3394
|
C: (f, a) => f(...a)
|
|
3316
3395
|
});
|
|
@@ -3318,7 +3397,7 @@ var DataSpace = class {
|
|
|
3318
3397
|
}
|
|
3319
3398
|
log9.error("Error initializing data pipeline", err, {
|
|
3320
3399
|
F: __dxlog_file11,
|
|
3321
|
-
L:
|
|
3400
|
+
L: 244,
|
|
3322
3401
|
S: this,
|
|
3323
3402
|
C: (f, a) => f(...a)
|
|
3324
3403
|
});
|
|
@@ -3327,7 +3406,7 @@ var DataSpace = class {
|
|
|
3327
3406
|
state: SpaceState[this._state]
|
|
3328
3407
|
}, {
|
|
3329
3408
|
F: __dxlog_file11,
|
|
3330
|
-
L:
|
|
3409
|
+
L: 246,
|
|
3331
3410
|
S: this,
|
|
3332
3411
|
C: (f, a) => f(...a)
|
|
3333
3412
|
});
|
|
@@ -3347,7 +3426,7 @@ var DataSpace = class {
|
|
|
3347
3426
|
state: SpaceState[this._state]
|
|
3348
3427
|
}, {
|
|
3349
3428
|
F: __dxlog_file11,
|
|
3350
|
-
L:
|
|
3429
|
+
L: 262,
|
|
3351
3430
|
S: this,
|
|
3352
3431
|
C: (f, a) => f(...a)
|
|
3353
3432
|
});
|
|
@@ -3357,7 +3436,7 @@ var DataSpace = class {
|
|
|
3357
3436
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3358
3437
|
log9("data pipeline ready", void 0, {
|
|
3359
3438
|
F: __dxlog_file11,
|
|
3360
|
-
L:
|
|
3439
|
+
L: 274,
|
|
3361
3440
|
S: this,
|
|
3362
3441
|
C: (f, a) => f(...a)
|
|
3363
3442
|
});
|
|
@@ -3367,7 +3446,7 @@ var DataSpace = class {
|
|
|
3367
3446
|
state: SpaceState[this._state]
|
|
3368
3447
|
}, {
|
|
3369
3448
|
F: __dxlog_file11,
|
|
3370
|
-
L:
|
|
3449
|
+
L: 278,
|
|
3371
3450
|
S: this,
|
|
3372
3451
|
C: (f, a) => f(...a)
|
|
3373
3452
|
});
|
|
@@ -3383,7 +3462,7 @@ var DataSpace = class {
|
|
|
3383
3462
|
await this._createWritableFeeds();
|
|
3384
3463
|
log9("writable feeds created", void 0, {
|
|
3385
3464
|
F: __dxlog_file11,
|
|
3386
|
-
L:
|
|
3465
|
+
L: 294,
|
|
3387
3466
|
S: this,
|
|
3388
3467
|
C: (f, a) => f(...a)
|
|
3389
3468
|
});
|
|
@@ -3446,12 +3525,12 @@ var DataSpace = class {
|
|
|
3446
3525
|
rootUrl
|
|
3447
3526
|
}, {
|
|
3448
3527
|
F: __dxlog_file11,
|
|
3449
|
-
L:
|
|
3528
|
+
L: 360,
|
|
3450
3529
|
S: this,
|
|
3451
3530
|
C: (f, a) => f(...a)
|
|
3452
3531
|
});
|
|
3453
|
-
this.
|
|
3454
|
-
const handle = this.
|
|
3532
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3533
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3455
3534
|
queueMicrotask(async () => {
|
|
3456
3535
|
try {
|
|
3457
3536
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3478,7 +3557,7 @@ var DataSpace = class {
|
|
|
3478
3557
|
err
|
|
3479
3558
|
}, {
|
|
3480
3559
|
F: __dxlog_file11,
|
|
3481
|
-
L:
|
|
3560
|
+
L: 383,
|
|
3482
3561
|
S: this,
|
|
3483
3562
|
C: (f, a) => f(...a)
|
|
3484
3563
|
});
|
|
@@ -3516,7 +3595,7 @@ var DataSpace = class {
|
|
|
3516
3595
|
break;
|
|
3517
3596
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3518
3597
|
{
|
|
3519
|
-
const document = this.
|
|
3598
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3520
3599
|
epoch = {
|
|
3521
3600
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3522
3601
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3528,12 +3607,12 @@ var DataSpace = class {
|
|
|
3528
3607
|
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3529
3608
|
{
|
|
3530
3609
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3531
|
-
const rootHandle = this.
|
|
3610
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3532
3611
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3533
|
-
const newRoot = this.
|
|
3612
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3534
3613
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3535
3614
|
F: __dxlog_file11,
|
|
3536
|
-
L:
|
|
3615
|
+
L: 433,
|
|
3537
3616
|
S: this,
|
|
3538
3617
|
A: [
|
|
3539
3618
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3552,19 +3631,19 @@ var DataSpace = class {
|
|
|
3552
3631
|
{
|
|
3553
3632
|
log9.info("Fragmenting", void 0, {
|
|
3554
3633
|
F: __dxlog_file11,
|
|
3555
|
-
L:
|
|
3634
|
+
L: 445,
|
|
3556
3635
|
S: this,
|
|
3557
3636
|
C: (f, a) => f(...a)
|
|
3558
3637
|
});
|
|
3559
3638
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3560
|
-
const rootHandle = this.
|
|
3639
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3561
3640
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3562
3641
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3563
3642
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3564
3643
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3565
3644
|
invariant10(properties, "Properties not found", {
|
|
3566
3645
|
F: __dxlog_file11,
|
|
3567
|
-
L:
|
|
3646
|
+
L: 455,
|
|
3568
3647
|
S: this,
|
|
3569
3648
|
A: [
|
|
3570
3649
|
"properties",
|
|
@@ -3577,17 +3656,17 @@ var DataSpace = class {
|
|
|
3577
3656
|
properties
|
|
3578
3657
|
])
|
|
3579
3658
|
};
|
|
3580
|
-
const newRoot = this.
|
|
3659
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3581
3660
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3582
3661
|
F: __dxlog_file11,
|
|
3583
|
-
L:
|
|
3662
|
+
L: 460,
|
|
3584
3663
|
S: this,
|
|
3585
3664
|
A: [
|
|
3586
3665
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3587
3666
|
""
|
|
3588
3667
|
]
|
|
3589
3668
|
});
|
|
3590
|
-
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this.
|
|
3669
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3591
3670
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3592
3671
|
rootUrl: newRoot.url
|
|
3593
3672
|
});
|
|
@@ -3649,7 +3728,7 @@ var DataSpace = class {
|
|
|
3649
3728
|
state: SpaceState[this._state]
|
|
3650
3729
|
}, {
|
|
3651
3730
|
F: __dxlog_file11,
|
|
3652
|
-
L:
|
|
3731
|
+
L: 526,
|
|
3653
3732
|
S: this,
|
|
3654
3733
|
C: (f, a) => f(...a)
|
|
3655
3734
|
});
|
|
@@ -3704,20 +3783,20 @@ DataSpace = _ts_decorate4([
|
|
|
3704
3783
|
|
|
3705
3784
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3706
3785
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3707
|
-
import { Context as
|
|
3786
|
+
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3708
3787
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3709
3788
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3710
|
-
import { PublicKey as
|
|
3789
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3711
3790
|
import { log as log10 } from "@dxos/log";
|
|
3712
3791
|
import { trace as trace7 } from "@dxos/protocols";
|
|
3713
|
-
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3792
|
+
import { Invitation as Invitation6, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3714
3793
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
3715
3794
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
3716
3795
|
|
|
3717
3796
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3718
3797
|
import { createCredential } from "@dxos/credentials";
|
|
3719
3798
|
import { failUndefined } from "@dxos/debug";
|
|
3720
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3799
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3721
3800
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3722
3801
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3723
3802
|
const credentials = [
|
|
@@ -3737,7 +3816,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3737
3816
|
assertion: {
|
|
3738
3817
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3739
3818
|
spaceKey: space.key,
|
|
3740
|
-
role:
|
|
3819
|
+
role: SpaceMember2.Role.ADMIN,
|
|
3741
3820
|
profile: signingContext.getProfile(),
|
|
3742
3821
|
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
3743
3822
|
}
|
|
@@ -3799,18 +3878,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3799
3878
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3800
3879
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3801
3880
|
var DataSpaceManager = class {
|
|
3802
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3881
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3803
3882
|
this._spaceManager = _spaceManager;
|
|
3804
3883
|
this._metadataStore = _metadataStore;
|
|
3805
3884
|
this._keyring = _keyring;
|
|
3806
3885
|
this._signingContext = _signingContext;
|
|
3807
3886
|
this._feedStore = _feedStore;
|
|
3808
|
-
this.
|
|
3809
|
-
this.
|
|
3887
|
+
this._echoHost = _echoHost;
|
|
3888
|
+
this._invitationsManager = _invitationsManager;
|
|
3889
|
+
this._ctx = new Context9();
|
|
3810
3890
|
this.updated = new Event7();
|
|
3811
|
-
this._spaces = new ComplexMap3(
|
|
3891
|
+
this._spaces = new ComplexMap3(PublicKey10.hash);
|
|
3812
3892
|
this._isOpen = false;
|
|
3813
|
-
this._instanceId =
|
|
3893
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3814
3894
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3815
3895
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3816
3896
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3822,7 +3902,7 @@ var DataSpaceManager = class {
|
|
|
3822
3902
|
async open() {
|
|
3823
3903
|
log10("open", void 0, {
|
|
3824
3904
|
F: __dxlog_file12,
|
|
3825
|
-
L:
|
|
3905
|
+
L: 102,
|
|
3826
3906
|
S: this,
|
|
3827
3907
|
C: (f, a) => f(...a)
|
|
3828
3908
|
});
|
|
@@ -3830,7 +3910,7 @@ var DataSpaceManager = class {
|
|
|
3830
3910
|
id: this._instanceId
|
|
3831
3911
|
}), {
|
|
3832
3912
|
F: __dxlog_file12,
|
|
3833
|
-
L:
|
|
3913
|
+
L: 103,
|
|
3834
3914
|
S: this,
|
|
3835
3915
|
C: (f, a) => f(...a)
|
|
3836
3916
|
});
|
|
@@ -3838,7 +3918,7 @@ var DataSpaceManager = class {
|
|
|
3838
3918
|
spaces: this._metadataStore.spaces.length
|
|
3839
3919
|
}, {
|
|
3840
3920
|
F: __dxlog_file12,
|
|
3841
|
-
L:
|
|
3921
|
+
L: 104,
|
|
3842
3922
|
S: this,
|
|
3843
3923
|
C: (f, a) => f(...a)
|
|
3844
3924
|
});
|
|
@@ -3848,7 +3928,7 @@ var DataSpaceManager = class {
|
|
|
3848
3928
|
spaceMetadata
|
|
3849
3929
|
}, {
|
|
3850
3930
|
F: __dxlog_file12,
|
|
3851
|
-
L:
|
|
3931
|
+
L: 108,
|
|
3852
3932
|
S: this,
|
|
3853
3933
|
C: (f, a) => f(...a)
|
|
3854
3934
|
});
|
|
@@ -3859,7 +3939,7 @@ var DataSpaceManager = class {
|
|
|
3859
3939
|
err
|
|
3860
3940
|
}, {
|
|
3861
3941
|
F: __dxlog_file12,
|
|
3862
|
-
L:
|
|
3942
|
+
L: 111,
|
|
3863
3943
|
S: this,
|
|
3864
3944
|
C: (f, a) => f(...a)
|
|
3865
3945
|
});
|
|
@@ -3876,7 +3956,7 @@ var DataSpaceManager = class {
|
|
|
3876
3956
|
id: this._instanceId
|
|
3877
3957
|
}), {
|
|
3878
3958
|
F: __dxlog_file12,
|
|
3879
|
-
L:
|
|
3959
|
+
L: 124,
|
|
3880
3960
|
S: this,
|
|
3881
3961
|
C: (f, a) => f(...a)
|
|
3882
3962
|
});
|
|
@@ -3884,7 +3964,7 @@ var DataSpaceManager = class {
|
|
|
3884
3964
|
async close() {
|
|
3885
3965
|
log10("close", void 0, {
|
|
3886
3966
|
F: __dxlog_file12,
|
|
3887
|
-
L:
|
|
3967
|
+
L: 129,
|
|
3888
3968
|
S: this,
|
|
3889
3969
|
C: (f, a) => f(...a)
|
|
3890
3970
|
});
|
|
@@ -3900,7 +3980,7 @@ var DataSpaceManager = class {
|
|
|
3900
3980
|
async createSpace() {
|
|
3901
3981
|
invariant11(this._isOpen, "Not open.", {
|
|
3902
3982
|
F: __dxlog_file12,
|
|
3903
|
-
L:
|
|
3983
|
+
L: 142,
|
|
3904
3984
|
S: this,
|
|
3905
3985
|
A: [
|
|
3906
3986
|
"this._isOpen",
|
|
@@ -3921,18 +4001,13 @@ var DataSpaceManager = class {
|
|
|
3921
4001
|
spaceKey
|
|
3922
4002
|
}, {
|
|
3923
4003
|
F: __dxlog_file12,
|
|
3924
|
-
L:
|
|
4004
|
+
L: 154,
|
|
3925
4005
|
S: this,
|
|
3926
4006
|
C: (f, a) => f(...a)
|
|
3927
4007
|
});
|
|
3928
|
-
const
|
|
3929
|
-
automergeRoot.change((doc) => {
|
|
3930
|
-
doc.access = {
|
|
3931
|
-
spaceKey: spaceKey.toHex()
|
|
3932
|
-
};
|
|
3933
|
-
});
|
|
4008
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
3934
4009
|
const space = await this._constructSpace(metadata);
|
|
3935
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4010
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
3936
4011
|
await this._metadataStore.addSpace(metadata);
|
|
3937
4012
|
const memberCredential = credentials[1];
|
|
3938
4013
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
@@ -4037,8 +4112,8 @@ var DataSpaceManager = class {
|
|
|
4037
4112
|
remotePeerId: session.remotePeerId
|
|
4038
4113
|
}));
|
|
4039
4114
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
4040
|
-
this.
|
|
4041
|
-
session.addExtension("dxos.mesh.teleport.automerge", this.
|
|
4115
|
+
this._echoHost.authorizeDevice(space.key, session.remotePeerId);
|
|
4116
|
+
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4042
4117
|
},
|
|
4043
4118
|
onAuthFailure: () => {
|
|
4044
4119
|
log10.warn("auth failure", void 0, {
|
|
@@ -4048,7 +4123,10 @@ var DataSpaceManager = class {
|
|
|
4048
4123
|
C: (f, a) => f(...a)
|
|
4049
4124
|
});
|
|
4050
4125
|
},
|
|
4051
|
-
memberKey: this._signingContext.identityKey
|
|
4126
|
+
memberKey: this._signingContext.identityKey,
|
|
4127
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4128
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4129
|
+
}
|
|
4052
4130
|
});
|
|
4053
4131
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4054
4132
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
@@ -4060,6 +4138,7 @@ var DataSpaceManager = class {
|
|
|
4060
4138
|
presence,
|
|
4061
4139
|
keyring: this._keyring,
|
|
4062
4140
|
feedStore: this._feedStore,
|
|
4141
|
+
echoHost: this._echoHost,
|
|
4063
4142
|
signingContext: this._signingContext,
|
|
4064
4143
|
callbacks: {
|
|
4065
4144
|
beforeReady: async () => {
|
|
@@ -4067,7 +4146,7 @@ var DataSpaceManager = class {
|
|
|
4067
4146
|
space: space.key
|
|
4068
4147
|
}, {
|
|
4069
4148
|
F: __dxlog_file12,
|
|
4070
|
-
L:
|
|
4149
|
+
L: 269,
|
|
4071
4150
|
S: this,
|
|
4072
4151
|
C: (f, a) => f(...a)
|
|
4073
4152
|
});
|
|
@@ -4078,11 +4157,14 @@ var DataSpaceManager = class {
|
|
|
4078
4157
|
open: this._isOpen
|
|
4079
4158
|
}, {
|
|
4080
4159
|
F: __dxlog_file12,
|
|
4081
|
-
L:
|
|
4160
|
+
L: 272,
|
|
4082
4161
|
S: this,
|
|
4083
4162
|
C: (f, a) => f(...a)
|
|
4084
4163
|
});
|
|
4085
4164
|
if (this._isOpen) {
|
|
4165
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4166
|
+
...space.spaceState.invitations.entries()
|
|
4167
|
+
]);
|
|
4086
4168
|
this.updated.emit();
|
|
4087
4169
|
}
|
|
4088
4170
|
},
|
|
@@ -4091,14 +4173,13 @@ var DataSpaceManager = class {
|
|
|
4091
4173
|
space: space.key
|
|
4092
4174
|
}, {
|
|
4093
4175
|
F: __dxlog_file12,
|
|
4094
|
-
L:
|
|
4176
|
+
L: 279,
|
|
4095
4177
|
S: this,
|
|
4096
4178
|
C: (f, a) => f(...a)
|
|
4097
4179
|
});
|
|
4098
4180
|
}
|
|
4099
4181
|
},
|
|
4100
|
-
cache: metadata.cache
|
|
4101
|
-
automergeHost: this._automergeHost
|
|
4182
|
+
cache: metadata.cache
|
|
4102
4183
|
});
|
|
4103
4184
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4104
4185
|
await dataSpace.open();
|
|
@@ -4109,6 +4190,41 @@ var DataSpaceManager = class {
|
|
|
4109
4190
|
this._spaces.set(metadata.key, dataSpace);
|
|
4110
4191
|
return dataSpace;
|
|
4111
4192
|
}
|
|
4193
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4194
|
+
if (dataSpace?.state !== SpaceState2.READY) {
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
4197
|
+
if (isActive) {
|
|
4198
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4199
|
+
[
|
|
4200
|
+
delegatedInvitation.credentialId,
|
|
4201
|
+
delegatedInvitation.invitation
|
|
4202
|
+
]
|
|
4203
|
+
]);
|
|
4204
|
+
} else {
|
|
4205
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4209
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4210
|
+
return this._invitationsManager.createInvitation({
|
|
4211
|
+
type: Invitation6.Type.DELEGATED,
|
|
4212
|
+
kind: Invitation6.Kind.SPACE,
|
|
4213
|
+
spaceKey: space.key,
|
|
4214
|
+
authMethod: invitation.authMethod,
|
|
4215
|
+
invitationId: invitation.invitationId,
|
|
4216
|
+
swarmKey: invitation.swarmKey,
|
|
4217
|
+
guestKeypair: invitation.guestKey ? {
|
|
4218
|
+
publicKey: invitation.guestKey
|
|
4219
|
+
} : void 0,
|
|
4220
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4221
|
+
multiUse: invitation.multiUse,
|
|
4222
|
+
delegationCredentialId: credentialId,
|
|
4223
|
+
persistent: false
|
|
4224
|
+
});
|
|
4225
|
+
});
|
|
4226
|
+
await Promise.all(tasks);
|
|
4227
|
+
}
|
|
4112
4228
|
};
|
|
4113
4229
|
_ts_decorate5([
|
|
4114
4230
|
synchronized2
|
|
@@ -4133,7 +4249,7 @@ import { raise as raise2 } from "@dxos/debug";
|
|
|
4133
4249
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4134
4250
|
import { log as log11 } from "@dxos/log";
|
|
4135
4251
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4136
|
-
import { SpaceMember as
|
|
4252
|
+
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4137
4253
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4138
4254
|
var SpacesServiceImpl = class {
|
|
4139
4255
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
@@ -4331,7 +4447,7 @@ var SpacesServiceImpl = class {
|
|
|
4331
4447
|
identityKey: member.key,
|
|
4332
4448
|
profile: member.profile ?? {}
|
|
4333
4449
|
},
|
|
4334
|
-
presence: member.removed ?
|
|
4450
|
+
presence: member.removed ? SpaceMember3.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
4335
4451
|
peerStates: peers
|
|
4336
4452
|
};
|
|
4337
4453
|
}),
|
|
@@ -4345,102 +4461,21 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4345
4461
|
|
|
4346
4462
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4347
4463
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4348
|
-
import { Context as
|
|
4464
|
+
import { Context as Context10, Resource } from "@dxos/context";
|
|
4349
4465
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4350
4466
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4351
|
-
import {
|
|
4467
|
+
import { EchoHost } from "@dxos/echo-db";
|
|
4468
|
+
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4352
4469
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4353
|
-
import { IndexMetadataStore, IndexStore, Indexer, createStorageCallbacks } from "@dxos/indexing";
|
|
4354
4470
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4355
4471
|
import { Keyring } from "@dxos/keyring";
|
|
4356
|
-
import { PublicKey as
|
|
4472
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4357
4473
|
import { log as log12 } from "@dxos/log";
|
|
4358
4474
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4359
|
-
import { Invitation as
|
|
4475
|
+
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4360
4476
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4361
4477
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4362
4478
|
import { safeInstanceof } from "@dxos/util";
|
|
4363
|
-
|
|
4364
|
-
// packages/sdk/client-services/src/packlets/indexing/util.ts
|
|
4365
|
-
import { getHeads } from "@dxos/automerge/automerge";
|
|
4366
|
-
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4367
|
-
import { idCodec } from "@dxos/protocols";
|
|
4368
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4369
|
-
/**
|
|
4370
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4371
|
-
* @param ids
|
|
4372
|
-
*/
|
|
4373
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4374
|
-
async function* loadDocuments(ids) {
|
|
4375
|
-
for (const id of ids) {
|
|
4376
|
-
const { documentId, objectId } = idCodec.decode(id);
|
|
4377
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4378
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4379
|
-
const doc = handle.docSync();
|
|
4380
|
-
const hash = getHeads(doc).join("");
|
|
4381
|
-
yield doc.objects?.[objectId] ? [
|
|
4382
|
-
{
|
|
4383
|
-
id,
|
|
4384
|
-
object: doc.objects[objectId],
|
|
4385
|
-
currentHash: hash
|
|
4386
|
-
}
|
|
4387
|
-
] : [];
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
);
|
|
4391
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4392
|
-
/**
|
|
4393
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4394
|
-
* @param ids
|
|
4395
|
-
*/
|
|
4396
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4397
|
-
async function* getAllDocuments() {
|
|
4398
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4399
|
-
async function* getObjectsFromHandle(handle) {
|
|
4400
|
-
if (visited.has(handle.documentId)) {
|
|
4401
|
-
return;
|
|
4402
|
-
}
|
|
4403
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4404
|
-
const doc = handle.docSync();
|
|
4405
|
-
const heads = getHeads(doc);
|
|
4406
|
-
if (doc.objects) {
|
|
4407
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4408
|
-
return {
|
|
4409
|
-
id: idCodec.encode({
|
|
4410
|
-
documentId: handle.documentId,
|
|
4411
|
-
objectId
|
|
4412
|
-
}),
|
|
4413
|
-
object,
|
|
4414
|
-
currentHash: heads.join("")
|
|
4415
|
-
};
|
|
4416
|
-
});
|
|
4417
|
-
}
|
|
4418
|
-
if (doc.links) {
|
|
4419
|
-
for (const id of Object.values(doc.links)) {
|
|
4420
|
-
if (visited.has(id)) {
|
|
4421
|
-
continue;
|
|
4422
|
-
}
|
|
4423
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4424
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4425
|
-
yield result;
|
|
4426
|
-
}
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
visited.add(handle.documentId);
|
|
4430
|
-
}
|
|
4431
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4432
|
-
if (visited.has(handle.documentId)) {
|
|
4433
|
-
continue;
|
|
4434
|
-
}
|
|
4435
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4436
|
-
yield result;
|
|
4437
|
-
}
|
|
4438
|
-
visited.add(handle.documentId);
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
);
|
|
4442
|
-
|
|
4443
|
-
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4444
4479
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4445
4480
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4446
4481
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4462,7 +4497,7 @@ var ServiceContext = class extends Resource {
|
|
|
4462
4497
|
this._runtimeParams = _runtimeParams;
|
|
4463
4498
|
this.initialized = new Trigger5();
|
|
4464
4499
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4465
|
-
this._instanceId =
|
|
4500
|
+
this._instanceId = PublicKey11.random().toHex();
|
|
4466
4501
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4467
4502
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4468
4503
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4485,34 +4520,19 @@ var ServiceContext = class extends Resource {
|
|
|
4485
4520
|
snapshotStore: this.snapshotStore
|
|
4486
4521
|
});
|
|
4487
4522
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4488
|
-
this.
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
this.automergeHost = new AutomergeHost({
|
|
4492
|
-
directory: storage.createDirectory("automerge"),
|
|
4493
|
-
db: level.sublevel("automerge"),
|
|
4494
|
-
storageCallbacks: createStorageCallbacks({
|
|
4495
|
-
host: () => this.automergeHost,
|
|
4496
|
-
metadata: this.indexMetadata
|
|
4497
|
-
})
|
|
4498
|
-
});
|
|
4499
|
-
this.indexer = new Indexer({
|
|
4500
|
-
indexStore: new IndexStore({
|
|
4501
|
-
db: level.sublevel("index-storage")
|
|
4502
|
-
}),
|
|
4503
|
-
metadataStore: this.indexMetadata,
|
|
4504
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4505
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4523
|
+
this.echoHost = new EchoHost({
|
|
4524
|
+
kv: this.level,
|
|
4525
|
+
storage: this.storage
|
|
4506
4526
|
});
|
|
4507
4527
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4508
4528
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4509
|
-
this._handlerFactories.set(
|
|
4529
|
+
this._handlerFactories.set(Invitation7.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4510
4530
|
}
|
|
4511
4531
|
async _open(ctx) {
|
|
4512
4532
|
await this._checkStorageVersion();
|
|
4513
4533
|
log12("opening...", void 0, {
|
|
4514
4534
|
F: __dxlog_file14,
|
|
4515
|
-
L:
|
|
4535
|
+
L: 151,
|
|
4516
4536
|
S: this,
|
|
4517
4537
|
C: (f, a) => f(...a)
|
|
4518
4538
|
});
|
|
@@ -4520,13 +4540,13 @@ var ServiceContext = class extends Resource {
|
|
|
4520
4540
|
id: this._instanceId
|
|
4521
4541
|
}), {
|
|
4522
4542
|
F: __dxlog_file14,
|
|
4523
|
-
L:
|
|
4543
|
+
L: 152,
|
|
4524
4544
|
S: this,
|
|
4525
4545
|
C: (f, a) => f(...a)
|
|
4526
4546
|
});
|
|
4527
4547
|
await this.signalManager.open();
|
|
4528
4548
|
await this.networkManager.open();
|
|
4529
|
-
await this.
|
|
4549
|
+
await this.echoHost.open(ctx);
|
|
4530
4550
|
await this.metadataStore.load();
|
|
4531
4551
|
await this.spaceManager.open();
|
|
4532
4552
|
await this.identityManager.open(ctx);
|
|
@@ -4538,7 +4558,7 @@ var ServiceContext = class extends Resource {
|
|
|
4538
4558
|
count: loadedInvitations.invitations?.length
|
|
4539
4559
|
}, {
|
|
4540
4560
|
F: __dxlog_file14,
|
|
4541
|
-
L:
|
|
4561
|
+
L: 165,
|
|
4542
4562
|
S: this,
|
|
4543
4563
|
C: (f, a) => f(...a)
|
|
4544
4564
|
});
|
|
@@ -4546,53 +4566,52 @@ var ServiceContext = class extends Resource {
|
|
|
4546
4566
|
id: this._instanceId
|
|
4547
4567
|
}), {
|
|
4548
4568
|
F: __dxlog_file14,
|
|
4549
|
-
L:
|
|
4569
|
+
L: 167,
|
|
4550
4570
|
S: this,
|
|
4551
4571
|
C: (f, a) => f(...a)
|
|
4552
4572
|
});
|
|
4553
4573
|
log12("opened", void 0, {
|
|
4554
4574
|
F: __dxlog_file14,
|
|
4555
|
-
L:
|
|
4575
|
+
L: 168,
|
|
4556
4576
|
S: this,
|
|
4557
4577
|
C: (f, a) => f(...a)
|
|
4558
4578
|
});
|
|
4559
4579
|
}
|
|
4560
|
-
async _close() {
|
|
4580
|
+
async _close(ctx) {
|
|
4561
4581
|
log12("closing...", void 0, {
|
|
4562
4582
|
F: __dxlog_file14,
|
|
4563
|
-
L:
|
|
4583
|
+
L: 172,
|
|
4564
4584
|
S: this,
|
|
4565
4585
|
C: (f, a) => f(...a)
|
|
4566
4586
|
});
|
|
4567
4587
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4568
4588
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4569
4589
|
}
|
|
4570
|
-
await this.automergeHost.close();
|
|
4571
4590
|
await this.dataSpaceManager?.close();
|
|
4572
4591
|
await this.identityManager.close();
|
|
4573
4592
|
await this.spaceManager.close();
|
|
4574
4593
|
await this.feedStore.close();
|
|
4594
|
+
await this.metadataStore.close();
|
|
4595
|
+
await this.echoHost.close(ctx);
|
|
4575
4596
|
await this.networkManager.close();
|
|
4576
4597
|
await this.signalManager.close();
|
|
4577
|
-
await this.metadataStore.close();
|
|
4578
|
-
await this.indexer.destroy();
|
|
4579
4598
|
log12("closed", void 0, {
|
|
4580
4599
|
F: __dxlog_file14,
|
|
4581
|
-
L:
|
|
4600
|
+
L: 184,
|
|
4582
4601
|
S: this,
|
|
4583
4602
|
C: (f, a) => f(...a)
|
|
4584
4603
|
});
|
|
4585
4604
|
}
|
|
4586
4605
|
async createIdentity(params = {}) {
|
|
4587
4606
|
const identity = await this.identityManager.createIdentity(params);
|
|
4588
|
-
await this._initialize(new
|
|
4607
|
+
await this._initialize(new Context10());
|
|
4589
4608
|
return identity;
|
|
4590
4609
|
}
|
|
4591
4610
|
getInvitationHandler(invitation) {
|
|
4592
4611
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4593
4612
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4594
4613
|
F: __dxlog_file14,
|
|
4595
|
-
L:
|
|
4614
|
+
L: 195,
|
|
4596
4615
|
S: this,
|
|
4597
4616
|
A: [
|
|
4598
4617
|
"factory",
|
|
@@ -4611,7 +4630,7 @@ var ServiceContext = class extends Resource {
|
|
|
4611
4630
|
}
|
|
4612
4631
|
async _acceptIdentity(params) {
|
|
4613
4632
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4614
|
-
await this._initialize(new
|
|
4633
|
+
await this._initialize(new Context10());
|
|
4615
4634
|
return identity;
|
|
4616
4635
|
}
|
|
4617
4636
|
async _checkStorageVersion() {
|
|
@@ -4624,7 +4643,7 @@ var ServiceContext = class extends Resource {
|
|
|
4624
4643
|
async _initialize(ctx) {
|
|
4625
4644
|
log12("initializing spaces...", void 0, {
|
|
4626
4645
|
F: __dxlog_file14,
|
|
4627
|
-
L:
|
|
4646
|
+
L: 226,
|
|
4628
4647
|
S: this,
|
|
4629
4648
|
C: (f, a) => f(...a)
|
|
4630
4649
|
});
|
|
@@ -4642,12 +4661,12 @@ var ServiceContext = class extends Resource {
|
|
|
4642
4661
|
});
|
|
4643
4662
|
}
|
|
4644
4663
|
};
|
|
4645
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.
|
|
4664
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
4646
4665
|
await this.dataSpaceManager.open();
|
|
4647
|
-
this._handlerFactories.set(
|
|
4666
|
+
this._handlerFactories.set(Invitation7.Kind.SPACE, (invitation) => {
|
|
4648
4667
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4649
4668
|
F: __dxlog_file14,
|
|
4650
|
-
L:
|
|
4669
|
+
L: 251,
|
|
4651
4670
|
S: this,
|
|
4652
4671
|
A: [
|
|
4653
4672
|
"this.dataSpaceManager",
|
|
@@ -4671,7 +4690,7 @@ var ServiceContext = class extends Resource {
|
|
|
4671
4690
|
details: assertion
|
|
4672
4691
|
}, {
|
|
4673
4692
|
F: __dxlog_file14,
|
|
4674
|
-
L:
|
|
4693
|
+
L: 267,
|
|
4675
4694
|
S: this,
|
|
4676
4695
|
C: (f, a) => f(...a)
|
|
4677
4696
|
});
|
|
@@ -4682,7 +4701,7 @@ var ServiceContext = class extends Resource {
|
|
|
4682
4701
|
details: assertion
|
|
4683
4702
|
}, {
|
|
4684
4703
|
F: __dxlog_file14,
|
|
4685
|
-
L:
|
|
4704
|
+
L: 271,
|
|
4686
4705
|
S: this,
|
|
4687
4706
|
C: (f, a) => f(...a)
|
|
4688
4707
|
});
|
|
@@ -4693,7 +4712,7 @@ var ServiceContext = class extends Resource {
|
|
|
4693
4712
|
details: assertion
|
|
4694
4713
|
}, {
|
|
4695
4714
|
F: __dxlog_file14,
|
|
4696
|
-
L:
|
|
4715
|
+
L: 276,
|
|
4697
4716
|
S: this,
|
|
4698
4717
|
C: (f, a) => f(...a)
|
|
4699
4718
|
});
|
|
@@ -4704,7 +4723,7 @@ var ServiceContext = class extends Resource {
|
|
|
4704
4723
|
} catch (err) {
|
|
4705
4724
|
log12.catch(err, void 0, {
|
|
4706
4725
|
F: __dxlog_file14,
|
|
4707
|
-
L:
|
|
4726
|
+
L: 282,
|
|
4708
4727
|
S: this,
|
|
4709
4728
|
C: (f, a) => f(...a)
|
|
4710
4729
|
});
|
|
@@ -4754,11 +4773,11 @@ import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
|
4754
4773
|
import { credentialTypeFilter } from "@dxos/credentials";
|
|
4755
4774
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4756
4775
|
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
4757
|
-
import { SpaceMember as
|
|
4776
|
+
import { SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4758
4777
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4759
4778
|
|
|
4760
4779
|
// packages/sdk/client-services/src/version.ts
|
|
4761
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4780
|
+
var DXOS_VERSION = "0.4.10-main.c8e5c39";
|
|
4762
4781
|
|
|
4763
4782
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4764
4783
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4880,7 +4899,7 @@ var getSpaceStats = async (space) => {
|
|
|
4880
4899
|
displayName: member.assertion.profile?.displayName
|
|
4881
4900
|
}
|
|
4882
4901
|
},
|
|
4883
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4902
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE
|
|
4884
4903
|
})),
|
|
4885
4904
|
pipeline: {
|
|
4886
4905
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -5001,12 +5020,11 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
5001
5020
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
5002
5021
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
5003
5022
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
5004
|
-
import { Context as
|
|
5005
|
-
import {
|
|
5023
|
+
import { Context as Context11 } from "@dxos/context";
|
|
5024
|
+
import { encodeReference } from "@dxos/echo-pipeline";
|
|
5006
5025
|
import { getTypeReference } from "@dxos/echo-schema";
|
|
5007
|
-
import { IndexServiceImpl } from "@dxos/indexing";
|
|
5008
5026
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5009
|
-
import { PublicKey as
|
|
5027
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
5010
5028
|
import { log as log16 } from "@dxos/log";
|
|
5011
5029
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5012
5030
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
@@ -5225,7 +5243,7 @@ var isLocked = (lockPath) => {
|
|
|
5225
5243
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5226
5244
|
import { Event as Event8 } from "@dxos/async";
|
|
5227
5245
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5228
|
-
import { PublicKey as
|
|
5246
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5229
5247
|
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
5230
5248
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5231
5249
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
@@ -5233,7 +5251,7 @@ var LoggingServiceImpl = class {
|
|
|
5233
5251
|
constructor() {
|
|
5234
5252
|
this._logs = new Event8();
|
|
5235
5253
|
this._started = Date.now();
|
|
5236
|
-
this._sessionId =
|
|
5254
|
+
this._sessionId = PublicKey12.random().toHex();
|
|
5237
5255
|
this._logProcessor = (_config, entry2) => {
|
|
5238
5256
|
this._logs.emit(entry2);
|
|
5239
5257
|
};
|
|
@@ -5444,10 +5462,10 @@ var toStorageType = (type) => {
|
|
|
5444
5462
|
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
5445
5463
|
import { Level } from "level";
|
|
5446
5464
|
import path from "@dxos/node-std/path";
|
|
5447
|
-
import { PublicKey as
|
|
5465
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
5448
5466
|
var createLevel = async (config) => {
|
|
5449
5467
|
const persistent = isPersistent(config);
|
|
5450
|
-
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5468
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey13.random().toHex()}`;
|
|
5451
5469
|
const level = new Level(storagePath);
|
|
5452
5470
|
await level.open();
|
|
5453
5471
|
return level;
|
|
@@ -5554,7 +5572,7 @@ var ClientServicesHost = class {
|
|
|
5554
5572
|
lockKey,
|
|
5555
5573
|
onAcquire: () => {
|
|
5556
5574
|
if (!this._opening) {
|
|
5557
|
-
void this.open(new
|
|
5575
|
+
void this.open(new Context11());
|
|
5558
5576
|
}
|
|
5559
5577
|
},
|
|
5560
5578
|
onRelease: () => this.close()
|
|
@@ -5611,7 +5629,7 @@ var ClientServicesHost = class {
|
|
|
5611
5629
|
initialize({ config, ...options }) {
|
|
5612
5630
|
invariant16(!this._open, "service host is open", {
|
|
5613
5631
|
F: __dxlog_file19,
|
|
5614
|
-
L:
|
|
5632
|
+
L: 190,
|
|
5615
5633
|
S: this,
|
|
5616
5634
|
A: [
|
|
5617
5635
|
"!this._open",
|
|
@@ -5620,14 +5638,14 @@ var ClientServicesHost = class {
|
|
|
5620
5638
|
});
|
|
5621
5639
|
log16("initializing...", void 0, {
|
|
5622
5640
|
F: __dxlog_file19,
|
|
5623
|
-
L:
|
|
5641
|
+
L: 191,
|
|
5624
5642
|
S: this,
|
|
5625
5643
|
C: (f, a) => f(...a)
|
|
5626
5644
|
});
|
|
5627
5645
|
if (config) {
|
|
5628
5646
|
invariant16(!this._config, "config already set", {
|
|
5629
5647
|
F: __dxlog_file19,
|
|
5630
|
-
L:
|
|
5648
|
+
L: 194,
|
|
5631
5649
|
S: this,
|
|
5632
5650
|
A: [
|
|
5633
5651
|
"!this._config",
|
|
@@ -5642,7 +5660,7 @@ var ClientServicesHost = class {
|
|
|
5642
5660
|
if (!options.signalManager) {
|
|
5643
5661
|
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5644
5662
|
F: __dxlog_file19,
|
|
5645
|
-
L:
|
|
5663
|
+
L: 202,
|
|
5646
5664
|
S: this,
|
|
5647
5665
|
C: (f, a) => f(...a)
|
|
5648
5666
|
});
|
|
@@ -5653,7 +5671,7 @@ var ClientServicesHost = class {
|
|
|
5653
5671
|
this._signalManager = signalManager;
|
|
5654
5672
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5655
5673
|
F: __dxlog_file19,
|
|
5656
|
-
L:
|
|
5674
|
+
L: 213,
|
|
5657
5675
|
S: this,
|
|
5658
5676
|
A: [
|
|
5659
5677
|
"!this._networkManager",
|
|
@@ -5667,7 +5685,7 @@ var ClientServicesHost = class {
|
|
|
5667
5685
|
});
|
|
5668
5686
|
log16("initialized", void 0, {
|
|
5669
5687
|
F: __dxlog_file19,
|
|
5670
|
-
L:
|
|
5688
|
+
L: 220,
|
|
5671
5689
|
S: this,
|
|
5672
5690
|
C: (f, a) => f(...a)
|
|
5673
5691
|
});
|
|
@@ -5676,18 +5694,18 @@ var ClientServicesHost = class {
|
|
|
5676
5694
|
if (this._open) {
|
|
5677
5695
|
return;
|
|
5678
5696
|
}
|
|
5679
|
-
const traceId =
|
|
5697
|
+
const traceId = PublicKey14.random().toHex();
|
|
5680
5698
|
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5681
5699
|
id: traceId
|
|
5682
5700
|
}), {
|
|
5683
5701
|
F: __dxlog_file19,
|
|
5684
|
-
L:
|
|
5702
|
+
L: 231,
|
|
5685
5703
|
S: this,
|
|
5686
5704
|
C: (f, a) => f(...a)
|
|
5687
5705
|
});
|
|
5688
5706
|
invariant16(this._config, "config not set", {
|
|
5689
5707
|
F: __dxlog_file19,
|
|
5690
|
-
L:
|
|
5708
|
+
L: 233,
|
|
5691
5709
|
S: this,
|
|
5692
5710
|
A: [
|
|
5693
5711
|
"this._config",
|
|
@@ -5696,7 +5714,7 @@ var ClientServicesHost = class {
|
|
|
5696
5714
|
});
|
|
5697
5715
|
invariant16(this._storage, "storage not set", {
|
|
5698
5716
|
F: __dxlog_file19,
|
|
5699
|
-
L:
|
|
5717
|
+
L: 234,
|
|
5700
5718
|
S: this,
|
|
5701
5719
|
A: [
|
|
5702
5720
|
"this._storage",
|
|
@@ -5705,7 +5723,7 @@ var ClientServicesHost = class {
|
|
|
5705
5723
|
});
|
|
5706
5724
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5707
5725
|
F: __dxlog_file19,
|
|
5708
|
-
L:
|
|
5726
|
+
L: 235,
|
|
5709
5727
|
S: this,
|
|
5710
5728
|
A: [
|
|
5711
5729
|
"this._signalManager",
|
|
@@ -5714,7 +5732,7 @@ var ClientServicesHost = class {
|
|
|
5714
5732
|
});
|
|
5715
5733
|
invariant16(this._networkManager, "network manager not set", {
|
|
5716
5734
|
F: __dxlog_file19,
|
|
5717
|
-
L:
|
|
5735
|
+
L: 236,
|
|
5718
5736
|
S: this,
|
|
5719
5737
|
A: [
|
|
5720
5738
|
"this._networkManager",
|
|
@@ -5726,7 +5744,7 @@ var ClientServicesHost = class {
|
|
|
5726
5744
|
lockKey: this._resourceLock?.lockKey
|
|
5727
5745
|
}, {
|
|
5728
5746
|
F: __dxlog_file19,
|
|
5729
|
-
L:
|
|
5747
|
+
L: 239,
|
|
5730
5748
|
S: this,
|
|
5731
5749
|
C: (f, a) => f(...a)
|
|
5732
5750
|
});
|
|
@@ -5746,11 +5764,8 @@ var ClientServicesHost = class {
|
|
|
5746
5764
|
await this._serviceContext.initialized.wait();
|
|
5747
5765
|
return this._serviceContext.dataSpaceManager;
|
|
5748
5766
|
}),
|
|
5749
|
-
DataService:
|
|
5750
|
-
|
|
5751
|
-
indexer: this._serviceContext.indexer,
|
|
5752
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5753
|
-
}),
|
|
5767
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5768
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5754
5769
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5755
5770
|
LoggingService: this._loggingService,
|
|
5756
5771
|
TracingService: this._tracingService,
|
|
@@ -5781,7 +5796,7 @@ var ClientServicesHost = class {
|
|
|
5781
5796
|
deviceKey
|
|
5782
5797
|
}, {
|
|
5783
5798
|
F: __dxlog_file19,
|
|
5784
|
-
L:
|
|
5799
|
+
L: 315,
|
|
5785
5800
|
S: this,
|
|
5786
5801
|
C: (f, a) => f(...a)
|
|
5787
5802
|
});
|
|
@@ -5789,7 +5804,7 @@ var ClientServicesHost = class {
|
|
|
5789
5804
|
id: traceId
|
|
5790
5805
|
}), {
|
|
5791
5806
|
F: __dxlog_file19,
|
|
5792
|
-
L:
|
|
5807
|
+
L: 316,
|
|
5793
5808
|
S: this,
|
|
5794
5809
|
C: (f, a) => f(...a)
|
|
5795
5810
|
});
|
|
@@ -5803,7 +5818,7 @@ var ClientServicesHost = class {
|
|
|
5803
5818
|
deviceKey
|
|
5804
5819
|
}, {
|
|
5805
5820
|
F: __dxlog_file19,
|
|
5806
|
-
L:
|
|
5821
|
+
L: 327,
|
|
5807
5822
|
S: this,
|
|
5808
5823
|
C: (f, a) => f(...a)
|
|
5809
5824
|
});
|
|
@@ -5821,24 +5836,24 @@ var ClientServicesHost = class {
|
|
|
5821
5836
|
deviceKey
|
|
5822
5837
|
}, {
|
|
5823
5838
|
F: __dxlog_file19,
|
|
5824
|
-
L:
|
|
5839
|
+
L: 336,
|
|
5825
5840
|
S: this,
|
|
5826
5841
|
C: (f, a) => f(...a)
|
|
5827
5842
|
});
|
|
5828
5843
|
}
|
|
5829
5844
|
async reset() {
|
|
5830
|
-
const traceId =
|
|
5845
|
+
const traceId = PublicKey14.random().toHex();
|
|
5831
5846
|
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5832
5847
|
id: traceId
|
|
5833
5848
|
}), {
|
|
5834
5849
|
F: __dxlog_file19,
|
|
5835
|
-
L:
|
|
5850
|
+
L: 341,
|
|
5836
5851
|
S: this,
|
|
5837
5852
|
C: (f, a) => f(...a)
|
|
5838
5853
|
});
|
|
5839
5854
|
log16("resetting...", void 0, {
|
|
5840
5855
|
F: __dxlog_file19,
|
|
5841
|
-
L:
|
|
5856
|
+
L: 343,
|
|
5842
5857
|
S: this,
|
|
5843
5858
|
C: (f, a) => f(...a)
|
|
5844
5859
|
});
|
|
@@ -5846,7 +5861,7 @@ var ClientServicesHost = class {
|
|
|
5846
5861
|
await this._storage.reset();
|
|
5847
5862
|
log16("reset", void 0, {
|
|
5848
5863
|
F: __dxlog_file19,
|
|
5849
|
-
L:
|
|
5864
|
+
L: 346,
|
|
5850
5865
|
S: this,
|
|
5851
5866
|
C: (f, a) => f(...a)
|
|
5852
5867
|
});
|
|
@@ -5854,7 +5869,7 @@ var ClientServicesHost = class {
|
|
|
5854
5869
|
id: traceId
|
|
5855
5870
|
}), {
|
|
5856
5871
|
F: __dxlog_file19,
|
|
5857
|
-
L:
|
|
5872
|
+
L: 347,
|
|
5858
5873
|
S: this,
|
|
5859
5874
|
C: (f, a) => f(...a)
|
|
5860
5875
|
});
|
|
@@ -5867,14 +5882,14 @@ var ClientServicesHost = class {
|
|
|
5867
5882
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5868
5883
|
invariant16(automergeIndex, void 0, {
|
|
5869
5884
|
F: __dxlog_file19,
|
|
5870
|
-
L:
|
|
5885
|
+
L: 359,
|
|
5871
5886
|
S: this,
|
|
5872
5887
|
A: [
|
|
5873
5888
|
"automergeIndex",
|
|
5874
5889
|
""
|
|
5875
5890
|
]
|
|
5876
5891
|
});
|
|
5877
|
-
const document = await this._serviceContext.
|
|
5892
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5878
5893
|
await document.whenReady();
|
|
5879
5894
|
const properties = {
|
|
5880
5895
|
system: {
|
|
@@ -5887,14 +5902,14 @@ var ClientServicesHost = class {
|
|
|
5887
5902
|
keys: []
|
|
5888
5903
|
}
|
|
5889
5904
|
};
|
|
5890
|
-
const propertiesId =
|
|
5905
|
+
const propertiesId = PublicKey14.random().toHex();
|
|
5891
5906
|
document.change((doc) => {
|
|
5892
5907
|
assignDeep2(doc, [
|
|
5893
5908
|
"objects",
|
|
5894
5909
|
propertiesId
|
|
5895
5910
|
], properties);
|
|
5896
5911
|
});
|
|
5897
|
-
await this._serviceContext.
|
|
5912
|
+
await this._serviceContext.echoHost.flush();
|
|
5898
5913
|
return identity;
|
|
5899
5914
|
}
|
|
5900
5915
|
};
|
|
@@ -5917,7 +5932,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5917
5932
|
], ClientServicesHost);
|
|
5918
5933
|
|
|
5919
5934
|
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
5920
|
-
import { PublicKey as
|
|
5935
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5921
5936
|
import { humanize } from "@dxos/util";
|
|
5922
5937
|
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5923
5938
|
|
|
@@ -5994,4 +6009,4 @@ export {
|
|
|
5994
6009
|
ClientServicesHost,
|
|
5995
6010
|
ClientServicesProviderResource
|
|
5996
6011
|
};
|
|
5997
|
-
//# sourceMappingURL=chunk-
|
|
6012
|
+
//# sourceMappingURL=chunk-7OKNHCYB.mjs.map
|