@dxos/client-services 0.4.10-main.c5e8686 → 0.4.10-main.c9da257
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-FUEOAPLA.mjs → chunk-NMSMHDG6.mjs} +652 -594
- package/dist/lib/browser/chunk-NMSMHDG6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -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-VRSCM2WE.cjs → chunk-7APQ34G5.cjs} +740 -679
- package/dist/lib/node/chunk-7APQ34G5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +49 -45
- 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/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.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 +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- 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 +6 -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/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/index.ts +1 -0
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +11 -73
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/automerge-host.test.ts +1 -1
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +23 -25
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +6 -26
- 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/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-FUEOAPLA.mjs.map +0 -7
- package/dist/lib/node/chunk-VRSCM2WE.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
|
});
|
|
@@ -1853,11 +1813,11 @@ var InvitationsHandler = class {
|
|
|
1853
1813
|
});
|
|
1854
1814
|
return extension;
|
|
1855
1815
|
};
|
|
1856
|
-
if (invitation.lifetime && invitation.created
|
|
1816
|
+
if (invitation.lifetime && invitation.created) {
|
|
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
|
});
|
|
@@ -2278,201 +2226,36 @@ var createAdmissionKeypair = () => {
|
|
|
2278
2226
|
};
|
|
2279
2227
|
|
|
2280
2228
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2281
|
-
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2282
2229
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2283
|
-
import {
|
|
2284
|
-
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2285
|
-
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2286
|
-
import { log as log6 } from "@dxos/log";
|
|
2287
|
-
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2288
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2230
|
+
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2289
2231
|
var InvitationsServiceImpl = class {
|
|
2290
|
-
constructor(
|
|
2291
|
-
this.
|
|
2292
|
-
this._getHandler = _getHandler;
|
|
2293
|
-
this._metadataStore = _metadataStore;
|
|
2294
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2295
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2296
|
-
this._invitationCreated = new Event3();
|
|
2297
|
-
this._invitationAccepted = new Event3();
|
|
2298
|
-
this._removedCreated = new Event3();
|
|
2299
|
-
this._removedAccepted = new Event3();
|
|
2300
|
-
this._saved = new Event3();
|
|
2301
|
-
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2302
|
-
this._persistentInvitationsLoaded = false;
|
|
2232
|
+
constructor(_invitationsManager) {
|
|
2233
|
+
this._invitationsManager = _invitationsManager;
|
|
2303
2234
|
}
|
|
2304
2235
|
// TODO(burdon): Guest/host label.
|
|
2305
2236
|
getLoggingContext() {
|
|
2306
2237
|
return {};
|
|
2307
2238
|
}
|
|
2308
2239
|
createInvitation(options) {
|
|
2309
|
-
let invitation;
|
|
2310
|
-
const savePersistentInvitationCtx = new Context6();
|
|
2311
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2312
|
-
if (existingInvitation) {
|
|
2313
|
-
invitation = existingInvitation;
|
|
2314
|
-
} else {
|
|
2315
|
-
const handler = this._getHandler(options);
|
|
2316
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2317
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2318
|
-
this._invitationCreated.emit(invitation.get());
|
|
2319
|
-
}
|
|
2320
2240
|
return new Stream8(({ next, close }) => {
|
|
2321
|
-
|
|
2322
|
-
scheduleTask3(savePersistentInvitationCtx, async () => {
|
|
2323
|
-
try {
|
|
2324
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2325
|
-
this._saved.emit(invitation.get());
|
|
2326
|
-
} catch (err) {
|
|
2327
|
-
close(err);
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
2330
|
-
}
|
|
2331
|
-
invitation.subscribe((invitation2) => {
|
|
2332
|
-
next(invitation2);
|
|
2333
|
-
}, async (err) => {
|
|
2334
|
-
await savePersistentInvitationCtx.dispose();
|
|
2335
|
-
close(err);
|
|
2336
|
-
}, async () => {
|
|
2337
|
-
close();
|
|
2338
|
-
if (invitation.get().persistent) {
|
|
2339
|
-
await savePersistentInvitationCtx.dispose();
|
|
2340
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2341
|
-
}
|
|
2342
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2343
|
-
if (!invitation.get().multiUse) {
|
|
2344
|
-
this._removedCreated.emit(invitation.get());
|
|
2345
|
-
}
|
|
2346
|
-
});
|
|
2241
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2347
2242
|
});
|
|
2348
2243
|
}
|
|
2349
|
-
|
|
2350
|
-
const
|
|
2351
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !hasInvitationExpired(invitation));
|
|
2352
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2353
|
-
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2354
|
-
F: __dxlog_file8,
|
|
2355
|
-
L: 109,
|
|
2356
|
-
S: this,
|
|
2357
|
-
A: [
|
|
2358
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2359
|
-
"'invitation already exists'"
|
|
2360
|
-
]
|
|
2361
|
-
});
|
|
2362
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2363
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2364
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2365
|
-
this._invitationCreated.emit(invitation.get());
|
|
2366
|
-
return persistentInvitation;
|
|
2367
|
-
});
|
|
2368
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2369
|
-
this._persistentInvitationsLoaded = true;
|
|
2370
|
-
return {
|
|
2371
|
-
invitations: cInvitations
|
|
2372
|
-
};
|
|
2373
|
-
}
|
|
2374
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2375
|
-
let invitation;
|
|
2376
|
-
if (deviceProfile) {
|
|
2377
|
-
invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2378
|
-
F: __dxlog_file8,
|
|
2379
|
-
L: 127,
|
|
2380
|
-
S: this,
|
|
2381
|
-
A: [
|
|
2382
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2383
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2384
|
-
]
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2388
|
-
if (existingInvitation) {
|
|
2389
|
-
invitation = existingInvitation;
|
|
2390
|
-
} else {
|
|
2391
|
-
const handler = this._getHandler(options);
|
|
2392
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2393
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2394
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2395
|
-
}
|
|
2244
|
+
acceptInvitation(request) {
|
|
2245
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2396
2246
|
return new Stream8(({ next, close }) => {
|
|
2397
|
-
invitation.subscribe(
|
|
2398
|
-
next(invitation2);
|
|
2399
|
-
}, (err) => {
|
|
2400
|
-
close(err);
|
|
2401
|
-
}, () => {
|
|
2402
|
-
close();
|
|
2403
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2404
|
-
if (!invitation.get().multiUse) {
|
|
2405
|
-
this._removedAccepted.emit(invitation.get());
|
|
2406
|
-
}
|
|
2407
|
-
});
|
|
2247
|
+
invitation.subscribe(next, close, close);
|
|
2408
2248
|
});
|
|
2409
2249
|
}
|
|
2410
|
-
async authenticate(
|
|
2411
|
-
|
|
2412
|
-
F: __dxlog_file8,
|
|
2413
|
-
L: 160,
|
|
2414
|
-
S: this,
|
|
2415
|
-
C: (f, a) => f(...a)
|
|
2416
|
-
});
|
|
2417
|
-
invariant7(invitationId, void 0, {
|
|
2418
|
-
F: __dxlog_file8,
|
|
2419
|
-
L: 161,
|
|
2420
|
-
S: this,
|
|
2421
|
-
A: [
|
|
2422
|
-
"invitationId",
|
|
2423
|
-
""
|
|
2424
|
-
]
|
|
2425
|
-
});
|
|
2426
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2427
|
-
if (!observable) {
|
|
2428
|
-
log6.warn("invalid invitation", {
|
|
2429
|
-
invitationId
|
|
2430
|
-
}, {
|
|
2431
|
-
F: __dxlog_file8,
|
|
2432
|
-
L: 164,
|
|
2433
|
-
S: this,
|
|
2434
|
-
C: (f, a) => f(...a)
|
|
2435
|
-
});
|
|
2436
|
-
} else {
|
|
2437
|
-
await observable.authenticate(authCode);
|
|
2438
|
-
}
|
|
2250
|
+
async authenticate(request) {
|
|
2251
|
+
return this._invitationsManager.authenticate(request);
|
|
2439
2252
|
}
|
|
2440
|
-
async cancelInvitation(
|
|
2441
|
-
|
|
2442
|
-
invitationId
|
|
2443
|
-
}, {
|
|
2444
|
-
F: __dxlog_file8,
|
|
2445
|
-
L: 171,
|
|
2446
|
-
S: this,
|
|
2447
|
-
C: (f, a) => f(...a)
|
|
2448
|
-
});
|
|
2449
|
-
invariant7(invitationId, void 0, {
|
|
2450
|
-
F: __dxlog_file8,
|
|
2451
|
-
L: 172,
|
|
2452
|
-
S: this,
|
|
2453
|
-
A: [
|
|
2454
|
-
"invitationId",
|
|
2455
|
-
""
|
|
2456
|
-
]
|
|
2457
|
-
});
|
|
2458
|
-
const created = this._createInvitations.get(invitationId);
|
|
2459
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2460
|
-
if (created) {
|
|
2461
|
-
await created.cancel();
|
|
2462
|
-
this._createInvitations.delete(invitationId);
|
|
2463
|
-
this._removedCreated.emit(created.get());
|
|
2464
|
-
if (created.get().persistent) {
|
|
2465
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2466
|
-
}
|
|
2467
|
-
} else if (accepted) {
|
|
2468
|
-
await accepted.cancel();
|
|
2469
|
-
this._acceptInvitations.delete(invitationId);
|
|
2470
|
-
this._removedAccepted.emit(accepted.get());
|
|
2471
|
-
}
|
|
2253
|
+
async cancelInvitation(request) {
|
|
2254
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2472
2255
|
}
|
|
2473
2256
|
queryInvitations() {
|
|
2474
2257
|
return new Stream8(({ next, ctx }) => {
|
|
2475
|
-
this.
|
|
2258
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2476
2259
|
next({
|
|
2477
2260
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2478
2261
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2481,7 +2264,7 @@ var InvitationsServiceImpl = class {
|
|
|
2481
2264
|
]
|
|
2482
2265
|
});
|
|
2483
2266
|
});
|
|
2484
|
-
this.
|
|
2267
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2485
2268
|
next({
|
|
2486
2269
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2487
2270
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2490,7 +2273,7 @@ var InvitationsServiceImpl = class {
|
|
|
2490
2273
|
]
|
|
2491
2274
|
});
|
|
2492
2275
|
});
|
|
2493
|
-
this.
|
|
2276
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2494
2277
|
next({
|
|
2495
2278
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2496
2279
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2499,7 +2282,7 @@ var InvitationsServiceImpl = class {
|
|
|
2499
2282
|
]
|
|
2500
2283
|
});
|
|
2501
2284
|
});
|
|
2502
|
-
this.
|
|
2285
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2503
2286
|
next({
|
|
2504
2287
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2505
2288
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2508,7 +2291,7 @@ var InvitationsServiceImpl = class {
|
|
|
2508
2291
|
]
|
|
2509
2292
|
});
|
|
2510
2293
|
});
|
|
2511
|
-
this.
|
|
2294
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2512
2295
|
next({
|
|
2513
2296
|
action: QueryInvitationsResponse.Action.SAVED,
|
|
2514
2297
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2520,40 +2303,34 @@ var InvitationsServiceImpl = class {
|
|
|
2520
2303
|
next({
|
|
2521
2304
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2522
2305
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2523
|
-
invitations:
|
|
2306
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2524
2307
|
existing: true
|
|
2525
2308
|
});
|
|
2526
2309
|
next({
|
|
2527
2310
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2528
2311
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2529
|
-
invitations:
|
|
2312
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2530
2313
|
existing: true
|
|
2531
2314
|
});
|
|
2532
|
-
|
|
2315
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2533
2316
|
next({
|
|
2534
2317
|
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2535
2318
|
type: QueryInvitationsResponse.Type.CREATED
|
|
2536
2319
|
});
|
|
2537
|
-
}
|
|
2538
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2539
|
-
next({
|
|
2540
|
-
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2541
|
-
type: QueryInvitationsResponse.Type.CREATED
|
|
2542
|
-
});
|
|
2543
|
-
});
|
|
2544
|
-
}
|
|
2320
|
+
});
|
|
2545
2321
|
});
|
|
2546
2322
|
}
|
|
2547
2323
|
};
|
|
2548
2324
|
|
|
2549
2325
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2550
|
-
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2326
|
+
import { createAdmissionCredentials, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
|
|
2551
2327
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2552
|
-
import { invariant as
|
|
2553
|
-
import { log as
|
|
2328
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2329
|
+
import { log as log6 } from "@dxos/log";
|
|
2554
2330
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2555
|
-
import { Invitation as
|
|
2556
|
-
|
|
2331
|
+
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2332
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2333
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2557
2334
|
var SpaceInvitationProtocol = class {
|
|
2558
2335
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2559
2336
|
this._spaceManager = _spaceManager;
|
|
@@ -2569,14 +2346,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2569
2346
|
}
|
|
2570
2347
|
getInvitationContext() {
|
|
2571
2348
|
return {
|
|
2572
|
-
kind:
|
|
2349
|
+
kind: Invitation4.Kind.SPACE,
|
|
2573
2350
|
spaceKey: this._spaceKey
|
|
2574
2351
|
};
|
|
2575
2352
|
}
|
|
2576
|
-
async admit(request, guestProfile) {
|
|
2577
|
-
|
|
2578
|
-
F:
|
|
2579
|
-
L:
|
|
2353
|
+
async admit(invitation, request, guestProfile) {
|
|
2354
|
+
invariant7(this._spaceKey, void 0, {
|
|
2355
|
+
F: __dxlog_file8,
|
|
2356
|
+
L: 55,
|
|
2580
2357
|
S: this,
|
|
2581
2358
|
A: [
|
|
2582
2359
|
"this._spaceKey",
|
|
@@ -2584,18 +2361,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2584
2361
|
]
|
|
2585
2362
|
});
|
|
2586
2363
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2587
|
-
|
|
2588
|
-
F:
|
|
2589
|
-
L:
|
|
2364
|
+
invariant7(space, void 0, {
|
|
2365
|
+
F: __dxlog_file8,
|
|
2366
|
+
L: 57,
|
|
2590
2367
|
S: this,
|
|
2591
2368
|
A: [
|
|
2592
2369
|
"space",
|
|
2593
2370
|
""
|
|
2594
2371
|
]
|
|
2595
2372
|
});
|
|
2596
|
-
|
|
2597
|
-
F:
|
|
2598
|
-
L:
|
|
2373
|
+
invariant7(request.space, void 0, {
|
|
2374
|
+
F: __dxlog_file8,
|
|
2375
|
+
L: 59,
|
|
2599
2376
|
S: this,
|
|
2600
2377
|
A: [
|
|
2601
2378
|
"request.space",
|
|
@@ -2603,19 +2380,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2603
2380
|
]
|
|
2604
2381
|
});
|
|
2605
2382
|
const { identityKey, deviceKey } = request.space;
|
|
2606
|
-
|
|
2383
|
+
log6("writing guest credentials", {
|
|
2607
2384
|
host: this._signingContext.deviceKey,
|
|
2608
2385
|
guest: deviceKey
|
|
2609
2386
|
}, {
|
|
2610
|
-
F:
|
|
2611
|
-
L:
|
|
2387
|
+
F: __dxlog_file8,
|
|
2388
|
+
L: 62,
|
|
2612
2389
|
S: this,
|
|
2613
2390
|
C: (f, a) => f(...a)
|
|
2614
2391
|
});
|
|
2615
|
-
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2616
|
-
|
|
2617
|
-
F:
|
|
2618
|
-
L:
|
|
2392
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2393
|
+
invariant7(credentials[0].credential, void 0, {
|
|
2394
|
+
F: __dxlog_file8,
|
|
2395
|
+
L: 74,
|
|
2619
2396
|
S: this,
|
|
2620
2397
|
A: [
|
|
2621
2398
|
"credentials[0].credential",
|
|
@@ -2623,9 +2400,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2623
2400
|
]
|
|
2624
2401
|
});
|
|
2625
2402
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2626
|
-
|
|
2627
|
-
F:
|
|
2628
|
-
L:
|
|
2403
|
+
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2404
|
+
F: __dxlog_file8,
|
|
2405
|
+
L: 76,
|
|
2629
2406
|
S: this,
|
|
2630
2407
|
A: [
|
|
2631
2408
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2640,6 +2417,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2640
2417
|
}
|
|
2641
2418
|
};
|
|
2642
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
|
+
}
|
|
2643
2483
|
checkInvitation(invitation) {
|
|
2644
2484
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2645
2485
|
return new AlreadyJoinedError2("Already joined space.");
|
|
@@ -2663,9 +2503,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2663
2503
|
};
|
|
2664
2504
|
}
|
|
2665
2505
|
async accept(response) {
|
|
2666
|
-
|
|
2667
|
-
F:
|
|
2668
|
-
L:
|
|
2506
|
+
invariant7(response.space, void 0, {
|
|
2507
|
+
F: __dxlog_file8,
|
|
2508
|
+
L: 149,
|
|
2669
2509
|
S: this,
|
|
2670
2510
|
A: [
|
|
2671
2511
|
"response.space",
|
|
@@ -2674,18 +2514,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2674
2514
|
});
|
|
2675
2515
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2676
2516
|
const assertion = getCredentialAssertion(credential);
|
|
2677
|
-
|
|
2678
|
-
F:
|
|
2679
|
-
L:
|
|
2517
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2518
|
+
F: __dxlog_file8,
|
|
2519
|
+
L: 152,
|
|
2680
2520
|
S: this,
|
|
2681
2521
|
A: [
|
|
2682
2522
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2683
2523
|
"'Invalid credential'"
|
|
2684
2524
|
]
|
|
2685
2525
|
});
|
|
2686
|
-
|
|
2687
|
-
F:
|
|
2688
|
-
L:
|
|
2526
|
+
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2527
|
+
F: __dxlog_file8,
|
|
2528
|
+
L: 153,
|
|
2689
2529
|
S: this,
|
|
2690
2530
|
A: [
|
|
2691
2531
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2708,6 +2548,295 @@ var SpaceInvitationProtocol = class {
|
|
|
2708
2548
|
}
|
|
2709
2549
|
};
|
|
2710
2550
|
|
|
2551
|
+
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
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";
|
|
2556
|
+
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2557
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2558
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2559
|
+
import { log as log7 } from "@dxos/log";
|
|
2560
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2561
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2562
|
+
var InvitationsManager = class {
|
|
2563
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2564
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2565
|
+
this._getHandler = _getHandler;
|
|
2566
|
+
this._metadataStore = _metadataStore;
|
|
2567
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2568
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2569
|
+
this.invitationCreated = new Event3();
|
|
2570
|
+
this.invitationAccepted = new Event3();
|
|
2571
|
+
this.removedCreated = new Event3();
|
|
2572
|
+
this.removedAccepted = new Event3();
|
|
2573
|
+
this.saved = new Event3();
|
|
2574
|
+
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2575
|
+
this._persistentInvitationsLoaded = false;
|
|
2576
|
+
}
|
|
2577
|
+
async createInvitation(options) {
|
|
2578
|
+
if (options.invitationId) {
|
|
2579
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2580
|
+
if (existingInvitation) {
|
|
2581
|
+
return existingInvitation;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
const handler = this._getHandler(options);
|
|
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());
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
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;
|
|
2610
|
+
}
|
|
2611
|
+
async loadPersistentInvitations() {
|
|
2612
|
+
if (this._persistentInvitationsLoaded) {
|
|
2613
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2614
|
+
return {
|
|
2615
|
+
invitations
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
try {
|
|
2619
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2620
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
2621
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2622
|
+
invariant8(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2623
|
+
F: __dxlog_file9,
|
|
2624
|
+
L: 97,
|
|
2625
|
+
S: this,
|
|
2626
|
+
A: [
|
|
2627
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2628
|
+
"'invitation already exists'"
|
|
2629
|
+
]
|
|
2630
|
+
});
|
|
2631
|
+
return this.createInvitation({
|
|
2632
|
+
...persistentInvitation,
|
|
2633
|
+
persistent: false
|
|
2634
|
+
});
|
|
2635
|
+
});
|
|
2636
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2637
|
+
return {
|
|
2638
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2639
|
+
};
|
|
2640
|
+
} catch (err) {
|
|
2641
|
+
log7.catch(err, void 0, {
|
|
2642
|
+
F: __dxlog_file9,
|
|
2643
|
+
L: 104,
|
|
2644
|
+
S: this,
|
|
2645
|
+
C: (f, a) => f(...a)
|
|
2646
|
+
});
|
|
2647
|
+
return {
|
|
2648
|
+
invitations: []
|
|
2649
|
+
};
|
|
2650
|
+
} finally {
|
|
2651
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2652
|
+
this._persistentInvitationsLoaded = true;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
acceptInvitation(request) {
|
|
2656
|
+
const options = request.invitation;
|
|
2657
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2658
|
+
if (existingInvitation) {
|
|
2659
|
+
return existingInvitation;
|
|
2660
|
+
}
|
|
2661
|
+
const handler = this._getHandler(options);
|
|
2662
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2663
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2664
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2665
|
+
this._onInvitationComplete(invitation, () => {
|
|
2666
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2667
|
+
this.removedAccepted.emit(invitation.get());
|
|
2668
|
+
});
|
|
2669
|
+
return invitation;
|
|
2670
|
+
}
|
|
2671
|
+
async authenticate({ invitationId, authCode }) {
|
|
2672
|
+
log7("authenticating...", void 0, {
|
|
2673
|
+
F: __dxlog_file9,
|
|
2674
|
+
L: 133,
|
|
2675
|
+
S: this,
|
|
2676
|
+
C: (f, a) => f(...a)
|
|
2677
|
+
});
|
|
2678
|
+
invariant8(invitationId, void 0, {
|
|
2679
|
+
F: __dxlog_file9,
|
|
2680
|
+
L: 134,
|
|
2681
|
+
S: this,
|
|
2682
|
+
A: [
|
|
2683
|
+
"invitationId",
|
|
2684
|
+
""
|
|
2685
|
+
]
|
|
2686
|
+
});
|
|
2687
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2688
|
+
if (!observable) {
|
|
2689
|
+
log7.warn("invalid invitation", {
|
|
2690
|
+
invitationId
|
|
2691
|
+
}, {
|
|
2692
|
+
F: __dxlog_file9,
|
|
2693
|
+
L: 137,
|
|
2694
|
+
S: this,
|
|
2695
|
+
C: (f, a) => f(...a)
|
|
2696
|
+
});
|
|
2697
|
+
} else {
|
|
2698
|
+
await observable.authenticate(authCode);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
async cancelInvitation({ invitationId }) {
|
|
2702
|
+
log7("cancelInvitation...", {
|
|
2703
|
+
invitationId
|
|
2704
|
+
}, {
|
|
2705
|
+
F: __dxlog_file9,
|
|
2706
|
+
L: 144,
|
|
2707
|
+
S: this,
|
|
2708
|
+
C: (f, a) => f(...a)
|
|
2709
|
+
});
|
|
2710
|
+
invariant8(invitationId, void 0, {
|
|
2711
|
+
F: __dxlog_file9,
|
|
2712
|
+
L: 145,
|
|
2713
|
+
S: this,
|
|
2714
|
+
A: [
|
|
2715
|
+
"invitationId",
|
|
2716
|
+
""
|
|
2717
|
+
]
|
|
2718
|
+
});
|
|
2719
|
+
const created = this._createInvitations.get(invitationId);
|
|
2720
|
+
if (created) {
|
|
2721
|
+
if (created.get().persistent) {
|
|
2722
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2723
|
+
}
|
|
2724
|
+
await created.cancel();
|
|
2725
|
+
this._createInvitations.delete(invitationId);
|
|
2726
|
+
this.removedCreated.emit(created.get());
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2730
|
+
if (accepted) {
|
|
2731
|
+
await accepted.cancel();
|
|
2732
|
+
this._acceptInvitations.delete(invitationId);
|
|
2733
|
+
this.removedAccepted.emit(accepted.get());
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
getCreatedInvitations() {
|
|
2737
|
+
return [
|
|
2738
|
+
...this._createInvitations.values()
|
|
2739
|
+
].map((i) => i.get());
|
|
2740
|
+
}
|
|
2741
|
+
getAcceptedInvitations() {
|
|
2742
|
+
return [
|
|
2743
|
+
...this._acceptInvitations.values()
|
|
2744
|
+
].map((i) => i.get());
|
|
2745
|
+
}
|
|
2746
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2747
|
+
if (this._persistentInvitationsLoaded) {
|
|
2748
|
+
callback();
|
|
2749
|
+
} else {
|
|
2750
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
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)
|
|
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
|
+
}
|
|
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
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
async _safeDeleteInvitation(invitation) {
|
|
2822
|
+
try {
|
|
2823
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2824
|
+
} catch (err) {
|
|
2825
|
+
log7.catch(err, void 0, {
|
|
2826
|
+
F: __dxlog_file9,
|
|
2827
|
+
L: 260,
|
|
2828
|
+
S: this,
|
|
2829
|
+
C: (f, a) => f(...a)
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
_onInvitationComplete(invitation, callback) {
|
|
2834
|
+
invitation.subscribe(() => {
|
|
2835
|
+
}, () => {
|
|
2836
|
+
}, callback);
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2711
2840
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2712
2841
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2713
2842
|
import { raise } from "@dxos/debug";
|
|
@@ -2790,15 +2919,15 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2790
2919
|
], ClientRpcServer);
|
|
2791
2920
|
|
|
2792
2921
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2793
|
-
import { Event as Event6, asyncTimeout, scheduleTask as
|
|
2922
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2794
2923
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2795
2924
|
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2796
2925
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2797
|
-
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2798
2926
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2799
2927
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2928
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
2800
2929
|
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2801
|
-
import { PublicKey as
|
|
2930
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2802
2931
|
import { log as log9 } from "@dxos/log";
|
|
2803
2932
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2804
2933
|
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2846,10 +2975,10 @@ var AutomergeSpaceState = class {
|
|
|
2846
2975
|
};
|
|
2847
2976
|
|
|
2848
2977
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2849
|
-
import { DeferredTask, Event as Event5, scheduleTask as
|
|
2978
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2850
2979
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2851
2980
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2852
|
-
import { PublicKey as
|
|
2981
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2853
2982
|
import { log as log8 } from "@dxos/log";
|
|
2854
2983
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2855
2984
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
@@ -2864,8 +2993,8 @@ var NotarizationPlugin = class {
|
|
|
2864
2993
|
this._ctx = new Context7();
|
|
2865
2994
|
this._extensionOpened = new Event5();
|
|
2866
2995
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2867
|
-
this._processedCredentials = new ComplexSet2(
|
|
2868
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2996
|
+
this._processedCredentials = new ComplexSet2(PublicKey8.hash);
|
|
2997
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey8.hash);
|
|
2869
2998
|
}
|
|
2870
2999
|
get hasWriter() {
|
|
2871
3000
|
return !!this._writer;
|
|
@@ -2913,7 +3042,7 @@ var NotarizationPlugin = class {
|
|
|
2913
3042
|
});
|
|
2914
3043
|
opCtx?.onDispose(() => ctx.dispose());
|
|
2915
3044
|
if (timeout !== 0) {
|
|
2916
|
-
|
|
3045
|
+
scheduleTask3(ctx, () => {
|
|
2917
3046
|
log8.warn("Notarization timeout", {
|
|
2918
3047
|
timeout,
|
|
2919
3048
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2947,7 +3076,7 @@ var NotarizationPlugin = class {
|
|
|
2947
3076
|
C: (f, a) => f(...a)
|
|
2948
3077
|
});
|
|
2949
3078
|
peersTried.clear();
|
|
2950
|
-
|
|
3079
|
+
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2951
3080
|
return;
|
|
2952
3081
|
}
|
|
2953
3082
|
peersTried.add(peer);
|
|
@@ -3148,9 +3277,9 @@ var DataSpace = class {
|
|
|
3148
3277
|
this._metadataStore = params.metadataStore;
|
|
3149
3278
|
this._signingContext = params.signingContext;
|
|
3150
3279
|
this._callbacks = params.callbacks ?? {};
|
|
3151
|
-
this.
|
|
3280
|
+
this._echoHost = params.echoHost;
|
|
3152
3281
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3153
|
-
trustedKeysProvider: () => new ComplexSet3(
|
|
3282
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey9.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3154
3283
|
update: this._inner.stateUpdate,
|
|
3155
3284
|
authTimeout: AUTH_TIMEOUT2
|
|
3156
3285
|
});
|
|
@@ -3160,7 +3289,7 @@ var DataSpace = class {
|
|
|
3160
3289
|
state: SpaceState[this._state]
|
|
3161
3290
|
}, {
|
|
3162
3291
|
F: __dxlog_file11,
|
|
3163
|
-
L:
|
|
3292
|
+
L: 135,
|
|
3164
3293
|
S: this,
|
|
3165
3294
|
C: (f, a) => f(...a)
|
|
3166
3295
|
});
|
|
@@ -3210,7 +3339,7 @@ var DataSpace = class {
|
|
|
3210
3339
|
state: SpaceState[this._state]
|
|
3211
3340
|
}, {
|
|
3212
3341
|
F: __dxlog_file11,
|
|
3213
|
-
L:
|
|
3342
|
+
L: 193,
|
|
3214
3343
|
S: this,
|
|
3215
3344
|
C: (f, a) => f(...a)
|
|
3216
3345
|
});
|
|
@@ -3228,7 +3357,7 @@ var DataSpace = class {
|
|
|
3228
3357
|
state: SpaceState[this._state]
|
|
3229
3358
|
}, {
|
|
3230
3359
|
F: __dxlog_file11,
|
|
3231
|
-
L:
|
|
3360
|
+
L: 207,
|
|
3232
3361
|
S: this,
|
|
3233
3362
|
C: (f, a) => f(...a)
|
|
3234
3363
|
});
|
|
@@ -3252,7 +3381,7 @@ var DataSpace = class {
|
|
|
3252
3381
|
* Initialize the data pipeline in a separate task.
|
|
3253
3382
|
*/
|
|
3254
3383
|
initializeDataPipelineAsync() {
|
|
3255
|
-
|
|
3384
|
+
scheduleTask4(this._ctx, async () => {
|
|
3256
3385
|
try {
|
|
3257
3386
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3258
3387
|
await this.initializeDataPipeline();
|
|
@@ -3260,7 +3389,7 @@ var DataSpace = class {
|
|
|
3260
3389
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3261
3390
|
log9("data pipeline initialization cancelled", err, {
|
|
3262
3391
|
F: __dxlog_file11,
|
|
3263
|
-
L:
|
|
3392
|
+
L: 240,
|
|
3264
3393
|
S: this,
|
|
3265
3394
|
C: (f, a) => f(...a)
|
|
3266
3395
|
});
|
|
@@ -3268,7 +3397,7 @@ var DataSpace = class {
|
|
|
3268
3397
|
}
|
|
3269
3398
|
log9.error("Error initializing data pipeline", err, {
|
|
3270
3399
|
F: __dxlog_file11,
|
|
3271
|
-
L:
|
|
3400
|
+
L: 244,
|
|
3272
3401
|
S: this,
|
|
3273
3402
|
C: (f, a) => f(...a)
|
|
3274
3403
|
});
|
|
@@ -3277,7 +3406,7 @@ var DataSpace = class {
|
|
|
3277
3406
|
state: SpaceState[this._state]
|
|
3278
3407
|
}, {
|
|
3279
3408
|
F: __dxlog_file11,
|
|
3280
|
-
L:
|
|
3409
|
+
L: 246,
|
|
3281
3410
|
S: this,
|
|
3282
3411
|
C: (f, a) => f(...a)
|
|
3283
3412
|
});
|
|
@@ -3297,7 +3426,7 @@ var DataSpace = class {
|
|
|
3297
3426
|
state: SpaceState[this._state]
|
|
3298
3427
|
}, {
|
|
3299
3428
|
F: __dxlog_file11,
|
|
3300
|
-
L:
|
|
3429
|
+
L: 262,
|
|
3301
3430
|
S: this,
|
|
3302
3431
|
C: (f, a) => f(...a)
|
|
3303
3432
|
});
|
|
@@ -3307,7 +3436,7 @@ var DataSpace = class {
|
|
|
3307
3436
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3308
3437
|
log9("data pipeline ready", void 0, {
|
|
3309
3438
|
F: __dxlog_file11,
|
|
3310
|
-
L:
|
|
3439
|
+
L: 274,
|
|
3311
3440
|
S: this,
|
|
3312
3441
|
C: (f, a) => f(...a)
|
|
3313
3442
|
});
|
|
@@ -3317,7 +3446,7 @@ var DataSpace = class {
|
|
|
3317
3446
|
state: SpaceState[this._state]
|
|
3318
3447
|
}, {
|
|
3319
3448
|
F: __dxlog_file11,
|
|
3320
|
-
L:
|
|
3449
|
+
L: 278,
|
|
3321
3450
|
S: this,
|
|
3322
3451
|
C: (f, a) => f(...a)
|
|
3323
3452
|
});
|
|
@@ -3333,7 +3462,7 @@ var DataSpace = class {
|
|
|
3333
3462
|
await this._createWritableFeeds();
|
|
3334
3463
|
log9("writable feeds created", void 0, {
|
|
3335
3464
|
F: __dxlog_file11,
|
|
3336
|
-
L:
|
|
3465
|
+
L: 294,
|
|
3337
3466
|
S: this,
|
|
3338
3467
|
C: (f, a) => f(...a)
|
|
3339
3468
|
});
|
|
@@ -3396,12 +3525,12 @@ var DataSpace = class {
|
|
|
3396
3525
|
rootUrl
|
|
3397
3526
|
}, {
|
|
3398
3527
|
F: __dxlog_file11,
|
|
3399
|
-
L:
|
|
3528
|
+
L: 360,
|
|
3400
3529
|
S: this,
|
|
3401
3530
|
C: (f, a) => f(...a)
|
|
3402
3531
|
});
|
|
3403
|
-
this.
|
|
3404
|
-
const handle = this.
|
|
3532
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3533
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3405
3534
|
queueMicrotask(async () => {
|
|
3406
3535
|
try {
|
|
3407
3536
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3428,7 +3557,7 @@ var DataSpace = class {
|
|
|
3428
3557
|
err
|
|
3429
3558
|
}, {
|
|
3430
3559
|
F: __dxlog_file11,
|
|
3431
|
-
L:
|
|
3560
|
+
L: 383,
|
|
3432
3561
|
S: this,
|
|
3433
3562
|
C: (f, a) => f(...a)
|
|
3434
3563
|
});
|
|
@@ -3466,7 +3595,7 @@ var DataSpace = class {
|
|
|
3466
3595
|
break;
|
|
3467
3596
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3468
3597
|
{
|
|
3469
|
-
const document = this.
|
|
3598
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3470
3599
|
epoch = {
|
|
3471
3600
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3472
3601
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3478,12 +3607,12 @@ var DataSpace = class {
|
|
|
3478
3607
|
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3479
3608
|
{
|
|
3480
3609
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3481
|
-
const rootHandle = this.
|
|
3610
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3482
3611
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3483
|
-
const newRoot = this.
|
|
3612
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3484
3613
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3485
3614
|
F: __dxlog_file11,
|
|
3486
|
-
L:
|
|
3615
|
+
L: 433,
|
|
3487
3616
|
S: this,
|
|
3488
3617
|
A: [
|
|
3489
3618
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3502,19 +3631,19 @@ var DataSpace = class {
|
|
|
3502
3631
|
{
|
|
3503
3632
|
log9.info("Fragmenting", void 0, {
|
|
3504
3633
|
F: __dxlog_file11,
|
|
3505
|
-
L:
|
|
3634
|
+
L: 445,
|
|
3506
3635
|
S: this,
|
|
3507
3636
|
C: (f, a) => f(...a)
|
|
3508
3637
|
});
|
|
3509
3638
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3510
|
-
const rootHandle = this.
|
|
3639
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3511
3640
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3512
3641
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3513
3642
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3514
3643
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3515
3644
|
invariant10(properties, "Properties not found", {
|
|
3516
3645
|
F: __dxlog_file11,
|
|
3517
|
-
L:
|
|
3646
|
+
L: 455,
|
|
3518
3647
|
S: this,
|
|
3519
3648
|
A: [
|
|
3520
3649
|
"properties",
|
|
@@ -3527,17 +3656,17 @@ var DataSpace = class {
|
|
|
3527
3656
|
properties
|
|
3528
3657
|
])
|
|
3529
3658
|
};
|
|
3530
|
-
const newRoot = this.
|
|
3659
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3531
3660
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3532
3661
|
F: __dxlog_file11,
|
|
3533
|
-
L:
|
|
3662
|
+
L: 460,
|
|
3534
3663
|
S: this,
|
|
3535
3664
|
A: [
|
|
3536
3665
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3537
3666
|
""
|
|
3538
3667
|
]
|
|
3539
3668
|
});
|
|
3540
|
-
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this.
|
|
3669
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3541
3670
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3542
3671
|
rootUrl: newRoot.url
|
|
3543
3672
|
});
|
|
@@ -3599,7 +3728,7 @@ var DataSpace = class {
|
|
|
3599
3728
|
state: SpaceState[this._state]
|
|
3600
3729
|
}, {
|
|
3601
3730
|
F: __dxlog_file11,
|
|
3602
|
-
L:
|
|
3731
|
+
L: 526,
|
|
3603
3732
|
S: this,
|
|
3604
3733
|
C: (f, a) => f(...a)
|
|
3605
3734
|
});
|
|
@@ -3657,17 +3786,17 @@ import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeak
|
|
|
3657
3786
|
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3658
3787
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3659
3788
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3660
|
-
import { PublicKey as
|
|
3789
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3661
3790
|
import { log as log10 } from "@dxos/log";
|
|
3662
3791
|
import { trace as trace7 } from "@dxos/protocols";
|
|
3663
|
-
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";
|
|
3664
3793
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
3665
3794
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
3666
3795
|
|
|
3667
3796
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3668
3797
|
import { createCredential } from "@dxos/credentials";
|
|
3669
3798
|
import { failUndefined } from "@dxos/debug";
|
|
3670
|
-
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";
|
|
3671
3800
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3672
3801
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3673
3802
|
const credentials = [
|
|
@@ -3687,7 +3816,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3687
3816
|
assertion: {
|
|
3688
3817
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3689
3818
|
spaceKey: space.key,
|
|
3690
|
-
role:
|
|
3819
|
+
role: SpaceMember2.Role.ADMIN,
|
|
3691
3820
|
profile: signingContext.getProfile(),
|
|
3692
3821
|
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
3693
3822
|
}
|
|
@@ -3749,18 +3878,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3749
3878
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3750
3879
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3751
3880
|
var DataSpaceManager = class {
|
|
3752
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3881
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3753
3882
|
this._spaceManager = _spaceManager;
|
|
3754
3883
|
this._metadataStore = _metadataStore;
|
|
3755
3884
|
this._keyring = _keyring;
|
|
3756
3885
|
this._signingContext = _signingContext;
|
|
3757
3886
|
this._feedStore = _feedStore;
|
|
3758
|
-
this.
|
|
3887
|
+
this._echoHost = _echoHost;
|
|
3888
|
+
this._invitationsManager = _invitationsManager;
|
|
3759
3889
|
this._ctx = new Context9();
|
|
3760
3890
|
this.updated = new Event7();
|
|
3761
|
-
this._spaces = new ComplexMap3(
|
|
3891
|
+
this._spaces = new ComplexMap3(PublicKey10.hash);
|
|
3762
3892
|
this._isOpen = false;
|
|
3763
|
-
this._instanceId =
|
|
3893
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3764
3894
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3765
3895
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3766
3896
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3772,7 +3902,7 @@ var DataSpaceManager = class {
|
|
|
3772
3902
|
async open() {
|
|
3773
3903
|
log10("open", void 0, {
|
|
3774
3904
|
F: __dxlog_file12,
|
|
3775
|
-
L:
|
|
3905
|
+
L: 102,
|
|
3776
3906
|
S: this,
|
|
3777
3907
|
C: (f, a) => f(...a)
|
|
3778
3908
|
});
|
|
@@ -3780,7 +3910,7 @@ var DataSpaceManager = class {
|
|
|
3780
3910
|
id: this._instanceId
|
|
3781
3911
|
}), {
|
|
3782
3912
|
F: __dxlog_file12,
|
|
3783
|
-
L:
|
|
3913
|
+
L: 103,
|
|
3784
3914
|
S: this,
|
|
3785
3915
|
C: (f, a) => f(...a)
|
|
3786
3916
|
});
|
|
@@ -3788,7 +3918,7 @@ var DataSpaceManager = class {
|
|
|
3788
3918
|
spaces: this._metadataStore.spaces.length
|
|
3789
3919
|
}, {
|
|
3790
3920
|
F: __dxlog_file12,
|
|
3791
|
-
L:
|
|
3921
|
+
L: 104,
|
|
3792
3922
|
S: this,
|
|
3793
3923
|
C: (f, a) => f(...a)
|
|
3794
3924
|
});
|
|
@@ -3798,7 +3928,7 @@ var DataSpaceManager = class {
|
|
|
3798
3928
|
spaceMetadata
|
|
3799
3929
|
}, {
|
|
3800
3930
|
F: __dxlog_file12,
|
|
3801
|
-
L:
|
|
3931
|
+
L: 108,
|
|
3802
3932
|
S: this,
|
|
3803
3933
|
C: (f, a) => f(...a)
|
|
3804
3934
|
});
|
|
@@ -3809,7 +3939,7 @@ var DataSpaceManager = class {
|
|
|
3809
3939
|
err
|
|
3810
3940
|
}, {
|
|
3811
3941
|
F: __dxlog_file12,
|
|
3812
|
-
L:
|
|
3942
|
+
L: 111,
|
|
3813
3943
|
S: this,
|
|
3814
3944
|
C: (f, a) => f(...a)
|
|
3815
3945
|
});
|
|
@@ -3826,7 +3956,7 @@ var DataSpaceManager = class {
|
|
|
3826
3956
|
id: this._instanceId
|
|
3827
3957
|
}), {
|
|
3828
3958
|
F: __dxlog_file12,
|
|
3829
|
-
L:
|
|
3959
|
+
L: 124,
|
|
3830
3960
|
S: this,
|
|
3831
3961
|
C: (f, a) => f(...a)
|
|
3832
3962
|
});
|
|
@@ -3834,7 +3964,7 @@ var DataSpaceManager = class {
|
|
|
3834
3964
|
async close() {
|
|
3835
3965
|
log10("close", void 0, {
|
|
3836
3966
|
F: __dxlog_file12,
|
|
3837
|
-
L:
|
|
3967
|
+
L: 129,
|
|
3838
3968
|
S: this,
|
|
3839
3969
|
C: (f, a) => f(...a)
|
|
3840
3970
|
});
|
|
@@ -3850,7 +3980,7 @@ var DataSpaceManager = class {
|
|
|
3850
3980
|
async createSpace() {
|
|
3851
3981
|
invariant11(this._isOpen, "Not open.", {
|
|
3852
3982
|
F: __dxlog_file12,
|
|
3853
|
-
L:
|
|
3983
|
+
L: 142,
|
|
3854
3984
|
S: this,
|
|
3855
3985
|
A: [
|
|
3856
3986
|
"this._isOpen",
|
|
@@ -3871,18 +4001,13 @@ var DataSpaceManager = class {
|
|
|
3871
4001
|
spaceKey
|
|
3872
4002
|
}, {
|
|
3873
4003
|
F: __dxlog_file12,
|
|
3874
|
-
L:
|
|
4004
|
+
L: 154,
|
|
3875
4005
|
S: this,
|
|
3876
4006
|
C: (f, a) => f(...a)
|
|
3877
4007
|
});
|
|
3878
|
-
const
|
|
3879
|
-
automergeRoot.change((doc) => {
|
|
3880
|
-
doc.access = {
|
|
3881
|
-
spaceKey: spaceKey.toHex()
|
|
3882
|
-
};
|
|
3883
|
-
});
|
|
4008
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
3884
4009
|
const space = await this._constructSpace(metadata);
|
|
3885
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4010
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
3886
4011
|
await this._metadataStore.addSpace(metadata);
|
|
3887
4012
|
const memberCredential = credentials[1];
|
|
3888
4013
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
@@ -3987,8 +4112,8 @@ var DataSpaceManager = class {
|
|
|
3987
4112
|
remotePeerId: session.remotePeerId
|
|
3988
4113
|
}));
|
|
3989
4114
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3990
|
-
this.
|
|
3991
|
-
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());
|
|
3992
4117
|
},
|
|
3993
4118
|
onAuthFailure: () => {
|
|
3994
4119
|
log10.warn("auth failure", void 0, {
|
|
@@ -3998,7 +4123,10 @@ var DataSpaceManager = class {
|
|
|
3998
4123
|
C: (f, a) => f(...a)
|
|
3999
4124
|
});
|
|
4000
4125
|
},
|
|
4001
|
-
memberKey: this._signingContext.identityKey
|
|
4126
|
+
memberKey: this._signingContext.identityKey,
|
|
4127
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4128
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4129
|
+
}
|
|
4002
4130
|
});
|
|
4003
4131
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4004
4132
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
@@ -4010,6 +4138,7 @@ var DataSpaceManager = class {
|
|
|
4010
4138
|
presence,
|
|
4011
4139
|
keyring: this._keyring,
|
|
4012
4140
|
feedStore: this._feedStore,
|
|
4141
|
+
echoHost: this._echoHost,
|
|
4013
4142
|
signingContext: this._signingContext,
|
|
4014
4143
|
callbacks: {
|
|
4015
4144
|
beforeReady: async () => {
|
|
@@ -4017,7 +4146,7 @@ var DataSpaceManager = class {
|
|
|
4017
4146
|
space: space.key
|
|
4018
4147
|
}, {
|
|
4019
4148
|
F: __dxlog_file12,
|
|
4020
|
-
L:
|
|
4149
|
+
L: 269,
|
|
4021
4150
|
S: this,
|
|
4022
4151
|
C: (f, a) => f(...a)
|
|
4023
4152
|
});
|
|
@@ -4028,11 +4157,14 @@ var DataSpaceManager = class {
|
|
|
4028
4157
|
open: this._isOpen
|
|
4029
4158
|
}, {
|
|
4030
4159
|
F: __dxlog_file12,
|
|
4031
|
-
L:
|
|
4160
|
+
L: 272,
|
|
4032
4161
|
S: this,
|
|
4033
4162
|
C: (f, a) => f(...a)
|
|
4034
4163
|
});
|
|
4035
4164
|
if (this._isOpen) {
|
|
4165
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4166
|
+
...space.spaceState.invitations.entries()
|
|
4167
|
+
]);
|
|
4036
4168
|
this.updated.emit();
|
|
4037
4169
|
}
|
|
4038
4170
|
},
|
|
@@ -4041,14 +4173,13 @@ var DataSpaceManager = class {
|
|
|
4041
4173
|
space: space.key
|
|
4042
4174
|
}, {
|
|
4043
4175
|
F: __dxlog_file12,
|
|
4044
|
-
L:
|
|
4176
|
+
L: 279,
|
|
4045
4177
|
S: this,
|
|
4046
4178
|
C: (f, a) => f(...a)
|
|
4047
4179
|
});
|
|
4048
4180
|
}
|
|
4049
4181
|
},
|
|
4050
|
-
cache: metadata.cache
|
|
4051
|
-
automergeHost: this._automergeHost
|
|
4182
|
+
cache: metadata.cache
|
|
4052
4183
|
});
|
|
4053
4184
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4054
4185
|
await dataSpace.open();
|
|
@@ -4059,6 +4190,41 @@ var DataSpaceManager = class {
|
|
|
4059
4190
|
this._spaces.set(metadata.key, dataSpace);
|
|
4060
4191
|
return dataSpace;
|
|
4061
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
|
+
}
|
|
4062
4228
|
};
|
|
4063
4229
|
_ts_decorate5([
|
|
4064
4230
|
synchronized2
|
|
@@ -4077,13 +4243,13 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4077
4243
|
], DataSpaceManager);
|
|
4078
4244
|
|
|
4079
4245
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4080
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4246
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4081
4247
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4082
4248
|
import { raise as raise2 } from "@dxos/debug";
|
|
4083
4249
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4084
4250
|
import { log as log11 } from "@dxos/log";
|
|
4085
4251
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4086
|
-
import { SpaceMember as
|
|
4252
|
+
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4087
4253
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4088
4254
|
var SpacesServiceImpl = class {
|
|
4089
4255
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
@@ -4134,7 +4300,7 @@ var SpacesServiceImpl = class {
|
|
|
4134
4300
|
}, {
|
|
4135
4301
|
maxFrequency: false ? void 0 : 2
|
|
4136
4302
|
});
|
|
4137
|
-
|
|
4303
|
+
scheduleTask5(ctx, async () => {
|
|
4138
4304
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4139
4305
|
const subscriptions = new EventSubscriptions2();
|
|
4140
4306
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4168,7 +4334,7 @@ var SpacesServiceImpl = class {
|
|
|
4168
4334
|
}
|
|
4169
4335
|
subscribeMessages({ spaceKey, channel }) {
|
|
4170
4336
|
return new Stream10(({ ctx, next }) => {
|
|
4171
|
-
|
|
4337
|
+
scheduleTask5(ctx, async () => {
|
|
4172
4338
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4173
4339
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4174
4340
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4187,7 +4353,7 @@ var SpacesServiceImpl = class {
|
|
|
4187
4353
|
}
|
|
4188
4354
|
};
|
|
4189
4355
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4190
|
-
|
|
4356
|
+
scheduleTask5(ctx, async () => {
|
|
4191
4357
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4192
4358
|
if (noTail) {
|
|
4193
4359
|
close();
|
|
@@ -4281,7 +4447,7 @@ var SpacesServiceImpl = class {
|
|
|
4281
4447
|
identityKey: member.key,
|
|
4282
4448
|
profile: member.profile ?? {}
|
|
4283
4449
|
},
|
|
4284
|
-
presence: member.removed ?
|
|
4450
|
+
presence: member.removed ? SpaceMember3.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
4285
4451
|
peerStates: peers
|
|
4286
4452
|
};
|
|
4287
4453
|
}),
|
|
@@ -4298,99 +4464,18 @@ import { Trigger as Trigger5 } from "@dxos/async";
|
|
|
4298
4464
|
import { Context as Context10, Resource } from "@dxos/context";
|
|
4299
4465
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4300
4466
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4301
|
-
import {
|
|
4467
|
+
import { EchoHost } from "@dxos/echo-db";
|
|
4468
|
+
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4302
4469
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4303
|
-
import { IndexMetadataStore, IndexStore, Indexer, createStorageCallbacks } from "@dxos/indexing";
|
|
4304
4470
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4305
4471
|
import { Keyring } from "@dxos/keyring";
|
|
4306
|
-
import { PublicKey as
|
|
4472
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4307
4473
|
import { log as log12 } from "@dxos/log";
|
|
4308
4474
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4309
|
-
import { Invitation as
|
|
4475
|
+
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4310
4476
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4311
4477
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4312
4478
|
import { safeInstanceof } from "@dxos/util";
|
|
4313
|
-
|
|
4314
|
-
// packages/sdk/client-services/src/packlets/indexing/util.ts
|
|
4315
|
-
import { getHeads } from "@dxos/automerge/automerge";
|
|
4316
|
-
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4317
|
-
import { idCodec } from "@dxos/protocols";
|
|
4318
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4319
|
-
/**
|
|
4320
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4321
|
-
* @param ids
|
|
4322
|
-
*/
|
|
4323
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4324
|
-
async function* loadDocuments(ids) {
|
|
4325
|
-
for (const id of ids) {
|
|
4326
|
-
const { documentId, objectId } = idCodec.decode(id);
|
|
4327
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4328
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4329
|
-
const doc = handle.docSync();
|
|
4330
|
-
const hash = getHeads(doc).join("");
|
|
4331
|
-
yield doc.objects?.[objectId] ? [
|
|
4332
|
-
{
|
|
4333
|
-
id,
|
|
4334
|
-
object: doc.objects[objectId],
|
|
4335
|
-
currentHash: hash
|
|
4336
|
-
}
|
|
4337
|
-
] : [];
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
|
-
);
|
|
4341
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4342
|
-
/**
|
|
4343
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4344
|
-
* @param ids
|
|
4345
|
-
*/
|
|
4346
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4347
|
-
async function* getAllDocuments() {
|
|
4348
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4349
|
-
async function* getObjectsFromHandle(handle) {
|
|
4350
|
-
if (visited.has(handle.documentId)) {
|
|
4351
|
-
return;
|
|
4352
|
-
}
|
|
4353
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4354
|
-
const doc = handle.docSync();
|
|
4355
|
-
const heads = getHeads(doc);
|
|
4356
|
-
if (doc.objects) {
|
|
4357
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4358
|
-
return {
|
|
4359
|
-
id: idCodec.encode({
|
|
4360
|
-
documentId: handle.documentId,
|
|
4361
|
-
objectId
|
|
4362
|
-
}),
|
|
4363
|
-
object,
|
|
4364
|
-
currentHash: heads.join("")
|
|
4365
|
-
};
|
|
4366
|
-
});
|
|
4367
|
-
}
|
|
4368
|
-
if (doc.links) {
|
|
4369
|
-
for (const id of Object.values(doc.links)) {
|
|
4370
|
-
if (visited.has(id)) {
|
|
4371
|
-
continue;
|
|
4372
|
-
}
|
|
4373
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4374
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4375
|
-
yield result;
|
|
4376
|
-
}
|
|
4377
|
-
}
|
|
4378
|
-
}
|
|
4379
|
-
visited.add(handle.documentId);
|
|
4380
|
-
}
|
|
4381
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4382
|
-
if (visited.has(handle.documentId)) {
|
|
4383
|
-
continue;
|
|
4384
|
-
}
|
|
4385
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4386
|
-
yield result;
|
|
4387
|
-
}
|
|
4388
|
-
visited.add(handle.documentId);
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
);
|
|
4392
|
-
|
|
4393
|
-
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4394
4479
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4395
4480
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4396
4481
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4412,7 +4497,7 @@ var ServiceContext = class extends Resource {
|
|
|
4412
4497
|
this._runtimeParams = _runtimeParams;
|
|
4413
4498
|
this.initialized = new Trigger5();
|
|
4414
4499
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4415
|
-
this._instanceId =
|
|
4500
|
+
this._instanceId = PublicKey11.random().toHex();
|
|
4416
4501
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4417
4502
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4418
4503
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4435,33 +4520,19 @@ var ServiceContext = class extends Resource {
|
|
|
4435
4520
|
snapshotStore: this.snapshotStore
|
|
4436
4521
|
});
|
|
4437
4522
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4438
|
-
this.
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
this.automergeHost = new AutomergeHost({
|
|
4442
|
-
directory: storage.createDirectory("automerge"),
|
|
4443
|
-
db: level.sublevel("automerge"),
|
|
4444
|
-
storageCallbacks: createStorageCallbacks({
|
|
4445
|
-
host: () => this.automergeHost,
|
|
4446
|
-
metadata: this.indexMetadata
|
|
4447
|
-
})
|
|
4448
|
-
});
|
|
4449
|
-
this.indexer = new Indexer({
|
|
4450
|
-
indexStore: new IndexStore({
|
|
4451
|
-
db: level.sublevel("index-storage")
|
|
4452
|
-
}),
|
|
4453
|
-
metadataStore: this.indexMetadata,
|
|
4454
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4455
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4523
|
+
this.echoHost = new EchoHost({
|
|
4524
|
+
kv: this.level,
|
|
4525
|
+
storage: this.storage
|
|
4456
4526
|
});
|
|
4457
4527
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4458
|
-
this.
|
|
4528
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4529
|
+
this._handlerFactories.set(Invitation7.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4459
4530
|
}
|
|
4460
4531
|
async _open(ctx) {
|
|
4461
4532
|
await this._checkStorageVersion();
|
|
4462
4533
|
log12("opening...", void 0, {
|
|
4463
4534
|
F: __dxlog_file14,
|
|
4464
|
-
L:
|
|
4535
|
+
L: 151,
|
|
4465
4536
|
S: this,
|
|
4466
4537
|
C: (f, a) => f(...a)
|
|
4467
4538
|
});
|
|
@@ -4469,56 +4540,64 @@ var ServiceContext = class extends Resource {
|
|
|
4469
4540
|
id: this._instanceId
|
|
4470
4541
|
}), {
|
|
4471
4542
|
F: __dxlog_file14,
|
|
4472
|
-
L:
|
|
4543
|
+
L: 152,
|
|
4473
4544
|
S: this,
|
|
4474
4545
|
C: (f, a) => f(...a)
|
|
4475
4546
|
});
|
|
4476
4547
|
await this.signalManager.open();
|
|
4477
4548
|
await this.networkManager.open();
|
|
4478
|
-
await this.
|
|
4549
|
+
await this.echoHost.open(ctx);
|
|
4479
4550
|
await this.metadataStore.load();
|
|
4480
4551
|
await this.spaceManager.open();
|
|
4481
4552
|
await this.identityManager.open(ctx);
|
|
4482
4553
|
if (this.identityManager.identity) {
|
|
4483
4554
|
await this._initialize(ctx);
|
|
4484
4555
|
}
|
|
4556
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4557
|
+
log12("loaded persistent invitations", {
|
|
4558
|
+
count: loadedInvitations.invitations?.length
|
|
4559
|
+
}, {
|
|
4560
|
+
F: __dxlog_file14,
|
|
4561
|
+
L: 165,
|
|
4562
|
+
S: this,
|
|
4563
|
+
C: (f, a) => f(...a)
|
|
4564
|
+
});
|
|
4485
4565
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4486
4566
|
id: this._instanceId
|
|
4487
4567
|
}), {
|
|
4488
4568
|
F: __dxlog_file14,
|
|
4489
|
-
L:
|
|
4569
|
+
L: 167,
|
|
4490
4570
|
S: this,
|
|
4491
4571
|
C: (f, a) => f(...a)
|
|
4492
4572
|
});
|
|
4493
4573
|
log12("opened", void 0, {
|
|
4494
4574
|
F: __dxlog_file14,
|
|
4495
|
-
L:
|
|
4575
|
+
L: 168,
|
|
4496
4576
|
S: this,
|
|
4497
4577
|
C: (f, a) => f(...a)
|
|
4498
4578
|
});
|
|
4499
4579
|
}
|
|
4500
|
-
async _close() {
|
|
4580
|
+
async _close(ctx) {
|
|
4501
4581
|
log12("closing...", void 0, {
|
|
4502
4582
|
F: __dxlog_file14,
|
|
4503
|
-
L:
|
|
4583
|
+
L: 172,
|
|
4504
4584
|
S: this,
|
|
4505
4585
|
C: (f, a) => f(...a)
|
|
4506
4586
|
});
|
|
4507
4587
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4508
4588
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4509
4589
|
}
|
|
4510
|
-
await this.automergeHost.close();
|
|
4511
4590
|
await this.dataSpaceManager?.close();
|
|
4512
4591
|
await this.identityManager.close();
|
|
4513
4592
|
await this.spaceManager.close();
|
|
4514
4593
|
await this.feedStore.close();
|
|
4594
|
+
await this.metadataStore.close();
|
|
4595
|
+
await this.echoHost.close(ctx);
|
|
4515
4596
|
await this.networkManager.close();
|
|
4516
4597
|
await this.signalManager.close();
|
|
4517
|
-
await this.metadataStore.close();
|
|
4518
|
-
await this.indexer.destroy();
|
|
4519
4598
|
log12("closed", void 0, {
|
|
4520
4599
|
F: __dxlog_file14,
|
|
4521
|
-
L:
|
|
4600
|
+
L: 184,
|
|
4522
4601
|
S: this,
|
|
4523
4602
|
C: (f, a) => f(...a)
|
|
4524
4603
|
});
|
|
@@ -4532,7 +4611,7 @@ var ServiceContext = class extends Resource {
|
|
|
4532
4611
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4533
4612
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4534
4613
|
F: __dxlog_file14,
|
|
4535
|
-
L:
|
|
4614
|
+
L: 195,
|
|
4536
4615
|
S: this,
|
|
4537
4616
|
A: [
|
|
4538
4617
|
"factory",
|
|
@@ -4564,7 +4643,7 @@ var ServiceContext = class extends Resource {
|
|
|
4564
4643
|
async _initialize(ctx) {
|
|
4565
4644
|
log12("initializing spaces...", void 0, {
|
|
4566
4645
|
F: __dxlog_file14,
|
|
4567
|
-
L:
|
|
4646
|
+
L: 226,
|
|
4568
4647
|
S: this,
|
|
4569
4648
|
C: (f, a) => f(...a)
|
|
4570
4649
|
});
|
|
@@ -4582,12 +4661,12 @@ var ServiceContext = class extends Resource {
|
|
|
4582
4661
|
});
|
|
4583
4662
|
}
|
|
4584
4663
|
};
|
|
4585
|
-
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);
|
|
4586
4665
|
await this.dataSpaceManager.open();
|
|
4587
|
-
this._handlerFactories.set(
|
|
4666
|
+
this._handlerFactories.set(Invitation7.Kind.SPACE, (invitation) => {
|
|
4588
4667
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4589
4668
|
F: __dxlog_file14,
|
|
4590
|
-
L:
|
|
4669
|
+
L: 251,
|
|
4591
4670
|
S: this,
|
|
4592
4671
|
A: [
|
|
4593
4672
|
"this.dataSpaceManager",
|
|
@@ -4611,7 +4690,7 @@ var ServiceContext = class extends Resource {
|
|
|
4611
4690
|
details: assertion
|
|
4612
4691
|
}, {
|
|
4613
4692
|
F: __dxlog_file14,
|
|
4614
|
-
L:
|
|
4693
|
+
L: 267,
|
|
4615
4694
|
S: this,
|
|
4616
4695
|
C: (f, a) => f(...a)
|
|
4617
4696
|
});
|
|
@@ -4622,7 +4701,7 @@ var ServiceContext = class extends Resource {
|
|
|
4622
4701
|
details: assertion
|
|
4623
4702
|
}, {
|
|
4624
4703
|
F: __dxlog_file14,
|
|
4625
|
-
L:
|
|
4704
|
+
L: 271,
|
|
4626
4705
|
S: this,
|
|
4627
4706
|
C: (f, a) => f(...a)
|
|
4628
4707
|
});
|
|
@@ -4633,7 +4712,7 @@ var ServiceContext = class extends Resource {
|
|
|
4633
4712
|
details: assertion
|
|
4634
4713
|
}, {
|
|
4635
4714
|
F: __dxlog_file14,
|
|
4636
|
-
L:
|
|
4715
|
+
L: 276,
|
|
4637
4716
|
S: this,
|
|
4638
4717
|
C: (f, a) => f(...a)
|
|
4639
4718
|
});
|
|
@@ -4644,7 +4723,7 @@ var ServiceContext = class extends Resource {
|
|
|
4644
4723
|
} catch (err) {
|
|
4645
4724
|
log12.catch(err, void 0, {
|
|
4646
4725
|
F: __dxlog_file14,
|
|
4647
|
-
L:
|
|
4726
|
+
L: 282,
|
|
4648
4727
|
S: this,
|
|
4649
4728
|
C: (f, a) => f(...a)
|
|
4650
4729
|
});
|
|
@@ -4694,11 +4773,11 @@ import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
|
4694
4773
|
import { credentialTypeFilter } from "@dxos/credentials";
|
|
4695
4774
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4696
4775
|
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
4697
|
-
import { SpaceMember as
|
|
4776
|
+
import { SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4698
4777
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4699
4778
|
|
|
4700
4779
|
// packages/sdk/client-services/src/version.ts
|
|
4701
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4780
|
+
var DXOS_VERSION = "0.4.10-main.c9da257";
|
|
4702
4781
|
|
|
4703
4782
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4704
4783
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4820,7 +4899,7 @@ var getSpaceStats = async (space) => {
|
|
|
4820
4899
|
displayName: member.assertion.profile?.displayName
|
|
4821
4900
|
}
|
|
4822
4901
|
},
|
|
4823
|
-
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
|
|
4824
4903
|
})),
|
|
4825
4904
|
pipeline: {
|
|
4826
4905
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4942,11 +5021,10 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
4942
5021
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4943
5022
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4944
5023
|
import { Context as Context11 } from "@dxos/context";
|
|
4945
|
-
import {
|
|
5024
|
+
import { encodeReference } from "@dxos/echo-pipeline";
|
|
4946
5025
|
import { getTypeReference } from "@dxos/echo-schema";
|
|
4947
|
-
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4948
5026
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4949
|
-
import { PublicKey as
|
|
5027
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
4950
5028
|
import { log as log16 } from "@dxos/log";
|
|
4951
5029
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4952
5030
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
@@ -5165,7 +5243,7 @@ var isLocked = (lockPath) => {
|
|
|
5165
5243
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5166
5244
|
import { Event as Event8 } from "@dxos/async";
|
|
5167
5245
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5168
|
-
import { PublicKey as
|
|
5246
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5169
5247
|
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
5170
5248
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5171
5249
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
@@ -5173,7 +5251,7 @@ var LoggingServiceImpl = class {
|
|
|
5173
5251
|
constructor() {
|
|
5174
5252
|
this._logs = new Event8();
|
|
5175
5253
|
this._started = Date.now();
|
|
5176
|
-
this._sessionId =
|
|
5254
|
+
this._sessionId = PublicKey12.random().toHex();
|
|
5177
5255
|
this._logProcessor = (_config, entry2) => {
|
|
5178
5256
|
this._logs.emit(entry2);
|
|
5179
5257
|
};
|
|
@@ -5384,10 +5462,10 @@ var toStorageType = (type) => {
|
|
|
5384
5462
|
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
5385
5463
|
import { Level } from "level";
|
|
5386
5464
|
import path from "@dxos/node-std/path";
|
|
5387
|
-
import { PublicKey as
|
|
5465
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
5388
5466
|
var createLevel = async (config) => {
|
|
5389
5467
|
const persistent = isPersistent(config);
|
|
5390
|
-
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5468
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey13.random().toHex()}`;
|
|
5391
5469
|
const level = new Level(storagePath);
|
|
5392
5470
|
await level.open();
|
|
5393
5471
|
return level;
|
|
@@ -5551,7 +5629,7 @@ var ClientServicesHost = class {
|
|
|
5551
5629
|
initialize({ config, ...options }) {
|
|
5552
5630
|
invariant16(!this._open, "service host is open", {
|
|
5553
5631
|
F: __dxlog_file19,
|
|
5554
|
-
L:
|
|
5632
|
+
L: 190,
|
|
5555
5633
|
S: this,
|
|
5556
5634
|
A: [
|
|
5557
5635
|
"!this._open",
|
|
@@ -5560,14 +5638,14 @@ var ClientServicesHost = class {
|
|
|
5560
5638
|
});
|
|
5561
5639
|
log16("initializing...", void 0, {
|
|
5562
5640
|
F: __dxlog_file19,
|
|
5563
|
-
L:
|
|
5641
|
+
L: 191,
|
|
5564
5642
|
S: this,
|
|
5565
5643
|
C: (f, a) => f(...a)
|
|
5566
5644
|
});
|
|
5567
5645
|
if (config) {
|
|
5568
5646
|
invariant16(!this._config, "config already set", {
|
|
5569
5647
|
F: __dxlog_file19,
|
|
5570
|
-
L:
|
|
5648
|
+
L: 194,
|
|
5571
5649
|
S: this,
|
|
5572
5650
|
A: [
|
|
5573
5651
|
"!this._config",
|
|
@@ -5582,7 +5660,7 @@ var ClientServicesHost = class {
|
|
|
5582
5660
|
if (!options.signalManager) {
|
|
5583
5661
|
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5584
5662
|
F: __dxlog_file19,
|
|
5585
|
-
L:
|
|
5663
|
+
L: 202,
|
|
5586
5664
|
S: this,
|
|
5587
5665
|
C: (f, a) => f(...a)
|
|
5588
5666
|
});
|
|
@@ -5593,7 +5671,7 @@ var ClientServicesHost = class {
|
|
|
5593
5671
|
this._signalManager = signalManager;
|
|
5594
5672
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5595
5673
|
F: __dxlog_file19,
|
|
5596
|
-
L:
|
|
5674
|
+
L: 213,
|
|
5597
5675
|
S: this,
|
|
5598
5676
|
A: [
|
|
5599
5677
|
"!this._networkManager",
|
|
@@ -5607,7 +5685,7 @@ var ClientServicesHost = class {
|
|
|
5607
5685
|
});
|
|
5608
5686
|
log16("initialized", void 0, {
|
|
5609
5687
|
F: __dxlog_file19,
|
|
5610
|
-
L:
|
|
5688
|
+
L: 220,
|
|
5611
5689
|
S: this,
|
|
5612
5690
|
C: (f, a) => f(...a)
|
|
5613
5691
|
});
|
|
@@ -5616,18 +5694,18 @@ var ClientServicesHost = class {
|
|
|
5616
5694
|
if (this._open) {
|
|
5617
5695
|
return;
|
|
5618
5696
|
}
|
|
5619
|
-
const traceId =
|
|
5697
|
+
const traceId = PublicKey14.random().toHex();
|
|
5620
5698
|
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5621
5699
|
id: traceId
|
|
5622
5700
|
}), {
|
|
5623
5701
|
F: __dxlog_file19,
|
|
5624
|
-
L:
|
|
5702
|
+
L: 231,
|
|
5625
5703
|
S: this,
|
|
5626
5704
|
C: (f, a) => f(...a)
|
|
5627
5705
|
});
|
|
5628
5706
|
invariant16(this._config, "config not set", {
|
|
5629
5707
|
F: __dxlog_file19,
|
|
5630
|
-
L:
|
|
5708
|
+
L: 233,
|
|
5631
5709
|
S: this,
|
|
5632
5710
|
A: [
|
|
5633
5711
|
"this._config",
|
|
@@ -5636,7 +5714,7 @@ var ClientServicesHost = class {
|
|
|
5636
5714
|
});
|
|
5637
5715
|
invariant16(this._storage, "storage not set", {
|
|
5638
5716
|
F: __dxlog_file19,
|
|
5639
|
-
L:
|
|
5717
|
+
L: 234,
|
|
5640
5718
|
S: this,
|
|
5641
5719
|
A: [
|
|
5642
5720
|
"this._storage",
|
|
@@ -5645,7 +5723,7 @@ var ClientServicesHost = class {
|
|
|
5645
5723
|
});
|
|
5646
5724
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5647
5725
|
F: __dxlog_file19,
|
|
5648
|
-
L:
|
|
5726
|
+
L: 235,
|
|
5649
5727
|
S: this,
|
|
5650
5728
|
A: [
|
|
5651
5729
|
"this._signalManager",
|
|
@@ -5654,7 +5732,7 @@ var ClientServicesHost = class {
|
|
|
5654
5732
|
});
|
|
5655
5733
|
invariant16(this._networkManager, "network manager not set", {
|
|
5656
5734
|
F: __dxlog_file19,
|
|
5657
|
-
L:
|
|
5735
|
+
L: 236,
|
|
5658
5736
|
S: this,
|
|
5659
5737
|
A: [
|
|
5660
5738
|
"this._networkManager",
|
|
@@ -5666,7 +5744,7 @@ var ClientServicesHost = class {
|
|
|
5666
5744
|
lockKey: this._resourceLock?.lockKey
|
|
5667
5745
|
}, {
|
|
5668
5746
|
F: __dxlog_file19,
|
|
5669
|
-
L:
|
|
5747
|
+
L: 239,
|
|
5670
5748
|
S: this,
|
|
5671
5749
|
C: (f, a) => f(...a)
|
|
5672
5750
|
});
|
|
@@ -5680,17 +5758,14 @@ var ClientServicesHost = class {
|
|
|
5680
5758
|
this._serviceRegistry.setServices({
|
|
5681
5759
|
SystemService: this._systemService,
|
|
5682
5760
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5683
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5761
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5684
5762
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5685
5763
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5686
5764
|
await this._serviceContext.initialized.wait();
|
|
5687
5765
|
return this._serviceContext.dataSpaceManager;
|
|
5688
5766
|
}),
|
|
5689
|
-
DataService:
|
|
5690
|
-
|
|
5691
|
-
indexer: this._serviceContext.indexer,
|
|
5692
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5693
|
-
}),
|
|
5767
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5768
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5694
5769
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5695
5770
|
LoggingService: this._loggingService,
|
|
5696
5771
|
TracingService: this._tracingService,
|
|
@@ -5702,24 +5777,6 @@ var ClientServicesHost = class {
|
|
|
5702
5777
|
})
|
|
5703
5778
|
});
|
|
5704
5779
|
await this._serviceContext.open(ctx);
|
|
5705
|
-
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5706
|
-
F: __dxlog_file19,
|
|
5707
|
-
L: 314,
|
|
5708
|
-
S: this,
|
|
5709
|
-
A: [
|
|
5710
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5711
|
-
""
|
|
5712
|
-
]
|
|
5713
|
-
});
|
|
5714
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5715
|
-
log16("loaded persistent invitations", {
|
|
5716
|
-
count: loadedInvitations.invitations?.length
|
|
5717
|
-
}, {
|
|
5718
|
-
F: __dxlog_file19,
|
|
5719
|
-
L: 317,
|
|
5720
|
-
S: this,
|
|
5721
|
-
C: (f, a) => f(...a)
|
|
5722
|
-
});
|
|
5723
5780
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5724
5781
|
if (devtoolsProxy) {
|
|
5725
5782
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5739,7 +5796,7 @@ var ClientServicesHost = class {
|
|
|
5739
5796
|
deviceKey
|
|
5740
5797
|
}, {
|
|
5741
5798
|
F: __dxlog_file19,
|
|
5742
|
-
L:
|
|
5799
|
+
L: 315,
|
|
5743
5800
|
S: this,
|
|
5744
5801
|
C: (f, a) => f(...a)
|
|
5745
5802
|
});
|
|
@@ -5747,7 +5804,7 @@ var ClientServicesHost = class {
|
|
|
5747
5804
|
id: traceId
|
|
5748
5805
|
}), {
|
|
5749
5806
|
F: __dxlog_file19,
|
|
5750
|
-
L:
|
|
5807
|
+
L: 316,
|
|
5751
5808
|
S: this,
|
|
5752
5809
|
C: (f, a) => f(...a)
|
|
5753
5810
|
});
|
|
@@ -5761,7 +5818,7 @@ var ClientServicesHost = class {
|
|
|
5761
5818
|
deviceKey
|
|
5762
5819
|
}, {
|
|
5763
5820
|
F: __dxlog_file19,
|
|
5764
|
-
L:
|
|
5821
|
+
L: 327,
|
|
5765
5822
|
S: this,
|
|
5766
5823
|
C: (f, a) => f(...a)
|
|
5767
5824
|
});
|
|
@@ -5779,24 +5836,24 @@ var ClientServicesHost = class {
|
|
|
5779
5836
|
deviceKey
|
|
5780
5837
|
}, {
|
|
5781
5838
|
F: __dxlog_file19,
|
|
5782
|
-
L:
|
|
5839
|
+
L: 336,
|
|
5783
5840
|
S: this,
|
|
5784
5841
|
C: (f, a) => f(...a)
|
|
5785
5842
|
});
|
|
5786
5843
|
}
|
|
5787
5844
|
async reset() {
|
|
5788
|
-
const traceId =
|
|
5845
|
+
const traceId = PublicKey14.random().toHex();
|
|
5789
5846
|
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5790
5847
|
id: traceId
|
|
5791
5848
|
}), {
|
|
5792
5849
|
F: __dxlog_file19,
|
|
5793
|
-
L:
|
|
5850
|
+
L: 341,
|
|
5794
5851
|
S: this,
|
|
5795
5852
|
C: (f, a) => f(...a)
|
|
5796
5853
|
});
|
|
5797
5854
|
log16("resetting...", void 0, {
|
|
5798
5855
|
F: __dxlog_file19,
|
|
5799
|
-
L:
|
|
5856
|
+
L: 343,
|
|
5800
5857
|
S: this,
|
|
5801
5858
|
C: (f, a) => f(...a)
|
|
5802
5859
|
});
|
|
@@ -5804,7 +5861,7 @@ var ClientServicesHost = class {
|
|
|
5804
5861
|
await this._storage.reset();
|
|
5805
5862
|
log16("reset", void 0, {
|
|
5806
5863
|
F: __dxlog_file19,
|
|
5807
|
-
L:
|
|
5864
|
+
L: 346,
|
|
5808
5865
|
S: this,
|
|
5809
5866
|
C: (f, a) => f(...a)
|
|
5810
5867
|
});
|
|
@@ -5812,7 +5869,7 @@ var ClientServicesHost = class {
|
|
|
5812
5869
|
id: traceId
|
|
5813
5870
|
}), {
|
|
5814
5871
|
F: __dxlog_file19,
|
|
5815
|
-
L:
|
|
5872
|
+
L: 347,
|
|
5816
5873
|
S: this,
|
|
5817
5874
|
C: (f, a) => f(...a)
|
|
5818
5875
|
});
|
|
@@ -5825,14 +5882,14 @@ var ClientServicesHost = class {
|
|
|
5825
5882
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5826
5883
|
invariant16(automergeIndex, void 0, {
|
|
5827
5884
|
F: __dxlog_file19,
|
|
5828
|
-
L:
|
|
5885
|
+
L: 359,
|
|
5829
5886
|
S: this,
|
|
5830
5887
|
A: [
|
|
5831
5888
|
"automergeIndex",
|
|
5832
5889
|
""
|
|
5833
5890
|
]
|
|
5834
5891
|
});
|
|
5835
|
-
const document = await this._serviceContext.
|
|
5892
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5836
5893
|
await document.whenReady();
|
|
5837
5894
|
const properties = {
|
|
5838
5895
|
system: {
|
|
@@ -5845,14 +5902,14 @@ var ClientServicesHost = class {
|
|
|
5845
5902
|
keys: []
|
|
5846
5903
|
}
|
|
5847
5904
|
};
|
|
5848
|
-
const propertiesId =
|
|
5905
|
+
const propertiesId = PublicKey14.random().toHex();
|
|
5849
5906
|
document.change((doc) => {
|
|
5850
5907
|
assignDeep2(doc, [
|
|
5851
5908
|
"objects",
|
|
5852
5909
|
propertiesId
|
|
5853
5910
|
], properties);
|
|
5854
5911
|
});
|
|
5855
|
-
await this._serviceContext.
|
|
5912
|
+
await this._serviceContext.echoHost.flush();
|
|
5856
5913
|
return identity;
|
|
5857
5914
|
}
|
|
5858
5915
|
};
|
|
@@ -5875,7 +5932,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5875
5932
|
], ClientServicesHost);
|
|
5876
5933
|
|
|
5877
5934
|
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
5878
|
-
import { PublicKey as
|
|
5935
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5879
5936
|
import { humanize } from "@dxos/util";
|
|
5880
5937
|
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5881
5938
|
|
|
@@ -5934,6 +5991,7 @@ export {
|
|
|
5934
5991
|
createAdmissionKeypair,
|
|
5935
5992
|
InvitationsServiceImpl,
|
|
5936
5993
|
SpaceInvitationProtocol,
|
|
5994
|
+
InvitationsManager,
|
|
5937
5995
|
ClientRpcServer,
|
|
5938
5996
|
DataSpace,
|
|
5939
5997
|
DataSpaceManager,
|
|
@@ -5951,4 +6009,4 @@ export {
|
|
|
5951
6009
|
ClientServicesHost,
|
|
5952
6010
|
ClientServicesProviderResource
|
|
5953
6011
|
};
|
|
5954
|
-
//# sourceMappingURL=chunk-
|
|
6012
|
+
//# sourceMappingURL=chunk-NMSMHDG6.mjs.map
|