@dxos/client-services 0.5.9-main.21b00b3 → 0.5.9-main.2ba0c7f
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-6Y4QMNUK.mjs → chunk-PWXD5WKD.mjs} +744 -568
- package/dist/lib/browser/chunk-PWXD5WKD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +2 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-FYT7BPEG.cjs → chunk-XVII53G2.cjs} +895 -722
- package/dist/lib/node/chunk-XVII53G2.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -43
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +9 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +2 -2
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/identity-service.ts +33 -7
- package/src/packlets/invitations/invitations-handler.ts +13 -5
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +35 -14
- package/src/packlets/spaces/data-space.ts +76 -148
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +16 -4
- package/src/packlets/testing/test-builder.ts +1 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-6Y4QMNUK.mjs.map +0 -7
- package/dist/lib/node/chunk-FYT7BPEG.cjs.map +0 -7
|
@@ -355,7 +355,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
355
355
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
356
356
|
|
|
357
357
|
// packages/sdk/client-services/src/version.ts
|
|
358
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
358
|
+
var DXOS_VERSION = "0.5.9-main.2ba0c7f";
|
|
359
359
|
|
|
360
360
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
361
361
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1519,13 +1519,17 @@ IdentityManager = _ts_decorate3([
|
|
|
1519
1519
|
], IdentityManager);
|
|
1520
1520
|
|
|
1521
1521
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
1522
|
+
import { Trigger as Trigger3, sleep } from "@dxos/async";
|
|
1522
1523
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1523
1524
|
import { Resource } from "@dxos/context";
|
|
1524
1525
|
import { signPresentation } from "@dxos/credentials";
|
|
1525
1526
|
import { todo } from "@dxos/debug";
|
|
1526
1527
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1528
|
+
import { log as log6 } from "@dxos/log";
|
|
1527
1529
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
1530
|
+
import { safeAwaitAll } from "@dxos/util";
|
|
1528
1531
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1532
|
+
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
1529
1533
|
var IdentityServiceImpl = class extends Resource {
|
|
1530
1534
|
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1531
1535
|
super();
|
|
@@ -1555,7 +1559,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1555
1559
|
const identity = this._identityManager.identity;
|
|
1556
1560
|
invariant4(identity, void 0, {
|
|
1557
1561
|
F: __dxlog_file7,
|
|
1558
|
-
L:
|
|
1562
|
+
L: 59,
|
|
1559
1563
|
S: this,
|
|
1560
1564
|
A: [
|
|
1561
1565
|
"identity",
|
|
@@ -1589,7 +1593,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1589
1593
|
async updateProfile(profile) {
|
|
1590
1594
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1591
1595
|
F: __dxlog_file7,
|
|
1592
|
-
L:
|
|
1596
|
+
L: 89,
|
|
1593
1597
|
S: this,
|
|
1594
1598
|
A: [
|
|
1595
1599
|
"this._identityManager.identity",
|
|
@@ -1603,7 +1607,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1603
1607
|
async signPresentation({ presentation, nonce }) {
|
|
1604
1608
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1605
1609
|
F: __dxlog_file7,
|
|
1606
|
-
L:
|
|
1610
|
+
L: 96,
|
|
1607
1611
|
S: this,
|
|
1608
1612
|
A: [
|
|
1609
1613
|
"this._identityManager.identity",
|
|
@@ -1619,20 +1623,43 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1619
1623
|
});
|
|
1620
1624
|
}
|
|
1621
1625
|
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1622
|
-
let
|
|
1626
|
+
let recodedDefaultSpace = false;
|
|
1627
|
+
let foundDefaultSpace = false;
|
|
1623
1628
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1624
|
-
|
|
1629
|
+
const recordedDefaultSpaceTrigger = new Trigger3();
|
|
1630
|
+
const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
|
|
1625
1631
|
if (space.state === SpaceState.CLOSED) {
|
|
1626
1632
|
await space.open();
|
|
1627
|
-
|
|
1633
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.REQUIRES_MIGRATION);
|
|
1634
|
+
await Promise.race([
|
|
1635
|
+
space.initializeDataPipeline(),
|
|
1636
|
+
requiresMigration
|
|
1637
|
+
]);
|
|
1628
1638
|
}
|
|
1629
1639
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1640
|
+
if (foundDefaultSpace) {
|
|
1641
|
+
log6.warn("Multiple default spaces found. Using the first one.", {
|
|
1642
|
+
duplicate: space.id
|
|
1643
|
+
}, {
|
|
1644
|
+
F: __dxlog_file7,
|
|
1645
|
+
L: 127,
|
|
1646
|
+
S: this,
|
|
1647
|
+
C: (f, a) => f(...a)
|
|
1648
|
+
});
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
foundDefaultSpace = true;
|
|
1630
1652
|
await identity.updateDefaultSpace(space.id);
|
|
1631
|
-
|
|
1632
|
-
|
|
1653
|
+
recodedDefaultSpace = true;
|
|
1654
|
+
recordedDefaultSpaceTrigger.wake();
|
|
1633
1655
|
}
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1656
|
+
});
|
|
1657
|
+
await Promise.race([
|
|
1658
|
+
allProcessed,
|
|
1659
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1660
|
+
sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1661
|
+
]);
|
|
1662
|
+
if (!recodedDefaultSpace) {
|
|
1636
1663
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1637
1664
|
}
|
|
1638
1665
|
}
|
|
@@ -1756,7 +1783,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
|
1756
1783
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1757
1784
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1758
1785
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1759
|
-
import { log as
|
|
1786
|
+
import { log as log10 } from "@dxos/log";
|
|
1760
1787
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1761
1788
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
|
|
1762
1789
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1765,10 +1792,10 @@ import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations
|
|
|
1765
1792
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
1766
1793
|
|
|
1767
1794
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1768
|
-
import { Trigger as
|
|
1795
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
1769
1796
|
import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
|
|
1770
1797
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1771
|
-
import { log as
|
|
1798
|
+
import { log as log7 } from "@dxos/log";
|
|
1772
1799
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1773
1800
|
import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1774
1801
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1808,7 +1835,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1808
1835
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1809
1836
|
this._callbacks = _callbacks;
|
|
1810
1837
|
this._ctx = new Context4();
|
|
1811
|
-
this._remoteOptionsTrigger = new
|
|
1838
|
+
this._remoteOptionsTrigger = new Trigger4();
|
|
1812
1839
|
this._invitationFlowLock = null;
|
|
1813
1840
|
}
|
|
1814
1841
|
hasFlowLock() {
|
|
@@ -1845,14 +1872,14 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1845
1872
|
async onOpen(context) {
|
|
1846
1873
|
await super.onOpen(context);
|
|
1847
1874
|
try {
|
|
1848
|
-
|
|
1875
|
+
log7("guest acquire lock", void 0, {
|
|
1849
1876
|
F: __dxlog_file9,
|
|
1850
1877
|
L: 84,
|
|
1851
1878
|
S: this,
|
|
1852
1879
|
C: (f, a) => f(...a)
|
|
1853
1880
|
});
|
|
1854
1881
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1855
|
-
|
|
1882
|
+
log7("guest lock acquired", void 0, {
|
|
1856
1883
|
F: __dxlog_file9,
|
|
1857
1884
|
L: 86,
|
|
1858
1885
|
S: this,
|
|
@@ -1861,7 +1888,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1861
1888
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1862
1889
|
role: Options.Role.GUEST
|
|
1863
1890
|
}));
|
|
1864
|
-
|
|
1891
|
+
log7("options sent", void 0, {
|
|
1865
1892
|
F: __dxlog_file9,
|
|
1866
1893
|
L: 88,
|
|
1867
1894
|
S: this,
|
|
@@ -1870,7 +1897,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1870
1897
|
await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1871
1898
|
timeout: OPTIONS_TIMEOUT
|
|
1872
1899
|
}));
|
|
1873
|
-
|
|
1900
|
+
log7("options received", void 0, {
|
|
1874
1901
|
F: __dxlog_file9,
|
|
1875
1902
|
L: 90,
|
|
1876
1903
|
S: this,
|
|
@@ -1904,7 +1931,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1904
1931
|
if (this._invitationFlowLock != null) {
|
|
1905
1932
|
this._invitationFlowLock.release();
|
|
1906
1933
|
this._invitationFlowLock = null;
|
|
1907
|
-
|
|
1934
|
+
log7("invitation flow lock released", void 0, {
|
|
1908
1935
|
F: __dxlog_file9,
|
|
1909
1936
|
L: 123,
|
|
1910
1937
|
S: this,
|
|
@@ -1915,12 +1942,12 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1915
1942
|
};
|
|
1916
1943
|
|
|
1917
1944
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
1918
|
-
import { Trigger as
|
|
1945
|
+
import { Trigger as Trigger5, scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
1919
1946
|
import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@dxos/context";
|
|
1920
1947
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
1921
1948
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1922
1949
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1923
|
-
import { log as
|
|
1950
|
+
import { log as log8 } from "@dxos/log";
|
|
1924
1951
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
|
|
1925
1952
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1926
1953
|
import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
@@ -1941,12 +1968,12 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1941
1968
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1942
1969
|
this._callbacks = _callbacks;
|
|
1943
1970
|
this._ctx = new Context5();
|
|
1944
|
-
this._remoteOptionsTrigger = new
|
|
1971
|
+
this._remoteOptionsTrigger = new Trigger5();
|
|
1945
1972
|
this._challenge = void 0;
|
|
1946
1973
|
this.guestProfile = void 0;
|
|
1947
1974
|
this.authenticationPassed = false;
|
|
1948
1975
|
this.authenticationRetry = 0;
|
|
1949
|
-
this.completedTrigger = new
|
|
1976
|
+
this.completedTrigger = new Trigger5();
|
|
1950
1977
|
this._invitationFlowLock = null;
|
|
1951
1978
|
}
|
|
1952
1979
|
hasFlowLock() {
|
|
@@ -1973,7 +2000,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1973
2000
|
introduce: async (request) => {
|
|
1974
2001
|
const { profile, invitationId } = request;
|
|
1975
2002
|
const traceId = PublicKey5.random().toHex();
|
|
1976
|
-
|
|
2003
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
|
|
1977
2004
|
id: traceId
|
|
1978
2005
|
}), {
|
|
1979
2006
|
F: __dxlog_file10,
|
|
@@ -1984,7 +2011,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1984
2011
|
const invitation = this._requireActiveInvitation();
|
|
1985
2012
|
this._assertInvitationState(Invitation3.State.CONNECTED);
|
|
1986
2013
|
if (invitationId !== invitation?.invitationId) {
|
|
1987
|
-
|
|
2014
|
+
log8.warn("incorrect invitationId", {
|
|
1988
2015
|
expected: invitation.invitationId,
|
|
1989
2016
|
actual: invitationId
|
|
1990
2017
|
}, {
|
|
@@ -1999,7 +2026,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1999
2026
|
authMethod: Invitation3.AuthMethod.NONE
|
|
2000
2027
|
};
|
|
2001
2028
|
}
|
|
2002
|
-
|
|
2029
|
+
log8("guest introduced themselves", {
|
|
2003
2030
|
guestProfile: profile
|
|
2004
2031
|
}, {
|
|
2005
2032
|
F: __dxlog_file10,
|
|
@@ -2010,7 +2037,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2010
2037
|
this.guestProfile = profile;
|
|
2011
2038
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
2012
2039
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
2013
|
-
|
|
2040
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
|
|
2014
2041
|
id: traceId
|
|
2015
2042
|
}), {
|
|
2016
2043
|
F: __dxlog_file10,
|
|
@@ -2025,7 +2052,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2025
2052
|
},
|
|
2026
2053
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2027
2054
|
const traceId = PublicKey5.random().toHex();
|
|
2028
|
-
|
|
2055
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
|
|
2029
2056
|
id: traceId
|
|
2030
2057
|
}), {
|
|
2031
2058
|
F: __dxlog_file10,
|
|
@@ -2034,7 +2061,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2034
2061
|
C: (f, a) => f(...a)
|
|
2035
2062
|
});
|
|
2036
2063
|
const invitation = this._requireActiveInvitation();
|
|
2037
|
-
|
|
2064
|
+
log8("received authentication request", {
|
|
2038
2065
|
authCode: code
|
|
2039
2066
|
}, {
|
|
2040
2067
|
F: __dxlog_file10,
|
|
@@ -2050,7 +2077,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2050
2077
|
this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
|
|
2051
2078
|
switch (invitation.authMethod) {
|
|
2052
2079
|
case Invitation3.AuthMethod.NONE: {
|
|
2053
|
-
|
|
2080
|
+
log8("authentication not required", void 0, {
|
|
2054
2081
|
F: __dxlog_file10,
|
|
2055
2082
|
L: 152,
|
|
2056
2083
|
S: this,
|
|
@@ -2086,7 +2113,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2086
2113
|
break;
|
|
2087
2114
|
}
|
|
2088
2115
|
default: {
|
|
2089
|
-
|
|
2116
|
+
log8.error("invalid authentication method", {
|
|
2090
2117
|
authMethod: invitation.authMethod
|
|
2091
2118
|
}, {
|
|
2092
2119
|
F: __dxlog_file10,
|
|
@@ -2108,7 +2135,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2108
2135
|
status
|
|
2109
2136
|
};
|
|
2110
2137
|
}
|
|
2111
|
-
|
|
2138
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
|
|
2112
2139
|
id: traceId,
|
|
2113
2140
|
data: {
|
|
2114
2141
|
status
|
|
@@ -2125,7 +2152,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2125
2152
|
},
|
|
2126
2153
|
admit: async (request) => {
|
|
2127
2154
|
const traceId = PublicKey5.random().toHex();
|
|
2128
|
-
|
|
2155
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
|
|
2129
2156
|
id: traceId
|
|
2130
2157
|
}), {
|
|
2131
2158
|
F: __dxlog_file10,
|
|
@@ -2142,7 +2169,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2142
2169
|
}
|
|
2143
2170
|
}
|
|
2144
2171
|
const response = await this._callbacks.admit(request);
|
|
2145
|
-
|
|
2172
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
|
|
2146
2173
|
id: traceId
|
|
2147
2174
|
}), {
|
|
2148
2175
|
F: __dxlog_file10,
|
|
@@ -2162,14 +2189,14 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2162
2189
|
async onOpen(context) {
|
|
2163
2190
|
await super.onOpen(context);
|
|
2164
2191
|
try {
|
|
2165
|
-
|
|
2192
|
+
log8("host acquire lock", void 0, {
|
|
2166
2193
|
F: __dxlog_file10,
|
|
2167
2194
|
L: 237,
|
|
2168
2195
|
S: this,
|
|
2169
2196
|
C: (f, a) => f(...a)
|
|
2170
2197
|
});
|
|
2171
2198
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2172
|
-
|
|
2199
|
+
log8("host lock acquired", void 0, {
|
|
2173
2200
|
F: __dxlog_file10,
|
|
2174
2201
|
L: 239,
|
|
2175
2202
|
S: this,
|
|
@@ -2180,7 +2207,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2180
2207
|
await this.rpc.InvitationHostService.options({
|
|
2181
2208
|
role: Options2.Role.HOST
|
|
2182
2209
|
});
|
|
2183
|
-
|
|
2210
|
+
log8("options sent", void 0, {
|
|
2184
2211
|
F: __dxlog_file10,
|
|
2185
2212
|
L: 243,
|
|
2186
2213
|
S: this,
|
|
@@ -2189,7 +2216,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2189
2216
|
await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2190
2217
|
timeout: OPTIONS_TIMEOUT2
|
|
2191
2218
|
}));
|
|
2192
|
-
|
|
2219
|
+
log8("options received", void 0, {
|
|
2193
2220
|
F: __dxlog_file10,
|
|
2194
2221
|
L: 245,
|
|
2195
2222
|
S: this,
|
|
@@ -2243,7 +2270,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2243
2270
|
if (this._invitationFlowLock != null) {
|
|
2244
2271
|
this._invitationFlowLock?.release();
|
|
2245
2272
|
this._invitationFlowLock = null;
|
|
2246
|
-
|
|
2273
|
+
log8("invitation flow lock released", void 0, {
|
|
2247
2274
|
F: __dxlog_file10,
|
|
2248
2275
|
L: 300,
|
|
2249
2276
|
S: this,
|
|
@@ -2257,7 +2284,7 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2257
2284
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
2258
2285
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2259
2286
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2260
|
-
import { log as
|
|
2287
|
+
import { log as log9 } from "@dxos/log";
|
|
2261
2288
|
import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2262
2289
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2263
2290
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
@@ -2299,7 +2326,7 @@ var InvitationTopology = class {
|
|
|
2299
2326
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2300
2327
|
this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2301
2328
|
if (firstUnknownPeer != null) {
|
|
2302
|
-
|
|
2329
|
+
log9("invitation connect", {
|
|
2303
2330
|
ownPeerId,
|
|
2304
2331
|
remotePeerId: firstUnknownPeer
|
|
2305
2332
|
}, {
|
|
@@ -2384,7 +2411,7 @@ var InvitationsHandler = class {
|
|
|
2384
2411
|
scheduleTask3(connectionCtx, async () => {
|
|
2385
2412
|
const traceId = PublicKey7.random().toHex();
|
|
2386
2413
|
try {
|
|
2387
|
-
|
|
2414
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
|
|
2388
2415
|
id: traceId
|
|
2389
2416
|
}), {
|
|
2390
2417
|
F: __dxlog_file12,
|
|
@@ -2392,7 +2419,7 @@ var InvitationsHandler = class {
|
|
|
2392
2419
|
S: this,
|
|
2393
2420
|
C: (f, a) => f(...a)
|
|
2394
2421
|
});
|
|
2395
|
-
|
|
2422
|
+
log10("connected", {
|
|
2396
2423
|
...protocol.toJSON()
|
|
2397
2424
|
}, {
|
|
2398
2425
|
F: __dxlog_file12,
|
|
@@ -2403,7 +2430,7 @@ var InvitationsHandler = class {
|
|
|
2403
2430
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2404
2431
|
timeout: invitation.timeout
|
|
2405
2432
|
});
|
|
2406
|
-
|
|
2433
|
+
log10("admitted guest", {
|
|
2407
2434
|
guest: deviceKey,
|
|
2408
2435
|
...protocol.toJSON()
|
|
2409
2436
|
}, {
|
|
@@ -2413,7 +2440,7 @@ var InvitationsHandler = class {
|
|
|
2413
2440
|
C: (f, a) => f(...a)
|
|
2414
2441
|
});
|
|
2415
2442
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2416
|
-
|
|
2443
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
|
|
2417
2444
|
id: traceId
|
|
2418
2445
|
}), {
|
|
2419
2446
|
F: __dxlog_file12,
|
|
@@ -2428,7 +2455,7 @@ var InvitationsHandler = class {
|
|
|
2428
2455
|
} catch (err) {
|
|
2429
2456
|
if (err instanceof TimeoutError) {
|
|
2430
2457
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2431
|
-
|
|
2458
|
+
log10("timeout", {
|
|
2432
2459
|
...protocol.toJSON()
|
|
2433
2460
|
}, {
|
|
2434
2461
|
F: __dxlog_file12,
|
|
@@ -2439,7 +2466,7 @@ var InvitationsHandler = class {
|
|
|
2439
2466
|
}
|
|
2440
2467
|
} else {
|
|
2441
2468
|
if (guardedState.error(extension, err)) {
|
|
2442
|
-
|
|
2469
|
+
log10.error("failed", err, {
|
|
2443
2470
|
F: __dxlog_file12,
|
|
2444
2471
|
L: 133,
|
|
2445
2472
|
S: this,
|
|
@@ -2447,7 +2474,7 @@ var InvitationsHandler = class {
|
|
|
2447
2474
|
});
|
|
2448
2475
|
}
|
|
2449
2476
|
}
|
|
2450
|
-
|
|
2477
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
|
|
2451
2478
|
id: traceId,
|
|
2452
2479
|
error: err
|
|
2453
2480
|
}), {
|
|
@@ -2462,7 +2489,7 @@ var InvitationsHandler = class {
|
|
|
2462
2489
|
},
|
|
2463
2490
|
onError: (err) => {
|
|
2464
2491
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
2465
|
-
|
|
2492
|
+
log10("invalid role", {
|
|
2466
2493
|
...err.context
|
|
2467
2494
|
}, {
|
|
2468
2495
|
F: __dxlog_file12,
|
|
@@ -2474,7 +2501,7 @@ var InvitationsHandler = class {
|
|
|
2474
2501
|
}
|
|
2475
2502
|
if (err instanceof TimeoutError) {
|
|
2476
2503
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2477
|
-
|
|
2504
|
+
log10("timeout", {
|
|
2478
2505
|
err
|
|
2479
2506
|
}, {
|
|
2480
2507
|
F: __dxlog_file12,
|
|
@@ -2485,7 +2512,7 @@ var InvitationsHandler = class {
|
|
|
2485
2512
|
}
|
|
2486
2513
|
} else {
|
|
2487
2514
|
if (guardedState.error(extension, err)) {
|
|
2488
|
-
|
|
2515
|
+
log10.error("failed", err, {
|
|
2489
2516
|
F: __dxlog_file12,
|
|
2490
2517
|
L: 153,
|
|
2491
2518
|
S: this,
|
|
@@ -2499,7 +2526,7 @@ var InvitationsHandler = class {
|
|
|
2499
2526
|
};
|
|
2500
2527
|
if (invitation.lifetime && invitation.created) {
|
|
2501
2528
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2502
|
-
|
|
2529
|
+
log10.warn("invitation has already expired", void 0, {
|
|
2503
2530
|
F: __dxlog_file12,
|
|
2504
2531
|
L: 164,
|
|
2505
2532
|
S: this,
|
|
@@ -2536,7 +2563,7 @@ var InvitationsHandler = class {
|
|
|
2536
2563
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2537
2564
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2538
2565
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2539
|
-
|
|
2566
|
+
log10("should cancel invitation flow", {
|
|
2540
2567
|
isLockedByAnotherConnection,
|
|
2541
2568
|
invitationType: Invitation4.Type.DELEGATED,
|
|
2542
2569
|
triedPeers: triedPeersIds.size
|
|
@@ -2564,7 +2591,7 @@ var InvitationsHandler = class {
|
|
|
2564
2591
|
return;
|
|
2565
2592
|
}
|
|
2566
2593
|
connectionCtx.onDispose(async () => {
|
|
2567
|
-
|
|
2594
|
+
log10("extension disposed", {
|
|
2568
2595
|
admitted,
|
|
2569
2596
|
currentState: guardedState.current.state
|
|
2570
2597
|
}, {
|
|
@@ -2583,7 +2610,7 @@ var InvitationsHandler = class {
|
|
|
2583
2610
|
scheduleTask3(connectionCtx, async () => {
|
|
2584
2611
|
const traceId = PublicKey7.random().toHex();
|
|
2585
2612
|
try {
|
|
2586
|
-
|
|
2613
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
|
|
2587
2614
|
id: traceId
|
|
2588
2615
|
}), {
|
|
2589
2616
|
F: __dxlog_file12,
|
|
@@ -2595,7 +2622,7 @@ var InvitationsHandler = class {
|
|
|
2595
2622
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2596
2623
|
extensionCtx.close();
|
|
2597
2624
|
}, timeout);
|
|
2598
|
-
|
|
2625
|
+
log10("connected", {
|
|
2599
2626
|
...protocol.toJSON()
|
|
2600
2627
|
}, {
|
|
2601
2628
|
F: __dxlog_file12,
|
|
@@ -2604,7 +2631,7 @@ var InvitationsHandler = class {
|
|
|
2604
2631
|
C: (f, a) => f(...a)
|
|
2605
2632
|
});
|
|
2606
2633
|
guardedState.set(extension, Invitation4.State.CONNECTED);
|
|
2607
|
-
|
|
2634
|
+
log10("introduce", {
|
|
2608
2635
|
...protocol.toJSON()
|
|
2609
2636
|
}, {
|
|
2610
2637
|
F: __dxlog_file12,
|
|
@@ -2616,7 +2643,7 @@ var InvitationsHandler = class {
|
|
|
2616
2643
|
invitationId: invitation.invitationId,
|
|
2617
2644
|
...protocol.createIntroduction()
|
|
2618
2645
|
});
|
|
2619
|
-
|
|
2646
|
+
log10("introduce response", {
|
|
2620
2647
|
...protocol.toJSON(),
|
|
2621
2648
|
response: introductionResponse
|
|
2622
2649
|
}, {
|
|
@@ -2638,7 +2665,7 @@ var InvitationsHandler = class {
|
|
|
2638
2665
|
break;
|
|
2639
2666
|
}
|
|
2640
2667
|
}
|
|
2641
|
-
|
|
2668
|
+
log10("request admission", {
|
|
2642
2669
|
...protocol.toJSON()
|
|
2643
2670
|
}, {
|
|
2644
2671
|
F: __dxlog_file12,
|
|
@@ -2650,7 +2677,7 @@ var InvitationsHandler = class {
|
|
|
2650
2677
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2651
2678
|
admitted = true;
|
|
2652
2679
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2653
|
-
|
|
2680
|
+
log10("admitted by host", {
|
|
2654
2681
|
...protocol.toJSON()
|
|
2655
2682
|
}, {
|
|
2656
2683
|
F: __dxlog_file12,
|
|
@@ -2663,7 +2690,7 @@ var InvitationsHandler = class {
|
|
|
2663
2690
|
...result,
|
|
2664
2691
|
state: Invitation4.State.SUCCESS
|
|
2665
2692
|
});
|
|
2666
|
-
|
|
2693
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
|
|
2667
2694
|
id: traceId
|
|
2668
2695
|
}), {
|
|
2669
2696
|
F: __dxlog_file12,
|
|
@@ -2673,7 +2700,7 @@ var InvitationsHandler = class {
|
|
|
2673
2700
|
});
|
|
2674
2701
|
} catch (err) {
|
|
2675
2702
|
if (err instanceof TimeoutError) {
|
|
2676
|
-
|
|
2703
|
+
log10("timeout", {
|
|
2677
2704
|
...protocol.toJSON()
|
|
2678
2705
|
}, {
|
|
2679
2706
|
F: __dxlog_file12,
|
|
@@ -2683,7 +2710,7 @@ var InvitationsHandler = class {
|
|
|
2683
2710
|
});
|
|
2684
2711
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2685
2712
|
} else {
|
|
2686
|
-
|
|
2713
|
+
log10("auth failed", err, {
|
|
2687
2714
|
F: __dxlog_file12,
|
|
2688
2715
|
L: 314,
|
|
2689
2716
|
S: this,
|
|
@@ -2692,7 +2719,7 @@ var InvitationsHandler = class {
|
|
|
2692
2719
|
guardedState.error(extension, err);
|
|
2693
2720
|
}
|
|
2694
2721
|
extensionCtx.close(err);
|
|
2695
|
-
|
|
2722
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
|
|
2696
2723
|
id: traceId,
|
|
2697
2724
|
error: err
|
|
2698
2725
|
}), {
|
|
@@ -2709,7 +2736,7 @@ var InvitationsHandler = class {
|
|
|
2709
2736
|
return;
|
|
2710
2737
|
}
|
|
2711
2738
|
if (err instanceof TimeoutError) {
|
|
2712
|
-
|
|
2739
|
+
log10("timeout", {
|
|
2713
2740
|
...protocol.toJSON()
|
|
2714
2741
|
}, {
|
|
2715
2742
|
F: __dxlog_file12,
|
|
@@ -2719,7 +2746,7 @@ var InvitationsHandler = class {
|
|
|
2719
2746
|
});
|
|
2720
2747
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2721
2748
|
} else {
|
|
2722
|
-
|
|
2749
|
+
log10("auth failed", err, {
|
|
2723
2750
|
F: __dxlog_file12,
|
|
2724
2751
|
L: 330,
|
|
2725
2752
|
S: this,
|
|
@@ -2832,16 +2859,29 @@ var InvitationsHandler = class {
|
|
|
2832
2859
|
};
|
|
2833
2860
|
}
|
|
2834
2861
|
_logStateUpdate(invitation, actor, newState) {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2862
|
+
if (this._isNotTerminal(newState)) {
|
|
2863
|
+
log10("invitation state update", {
|
|
2864
|
+
actor: actor?.constructor.name,
|
|
2865
|
+
newState: stateToString(newState),
|
|
2866
|
+
oldState: stateToString(invitation.state)
|
|
2867
|
+
}, {
|
|
2868
|
+
F: __dxlog_file12,
|
|
2869
|
+
L: 439,
|
|
2870
|
+
S: this,
|
|
2871
|
+
C: (f, a) => f(...a)
|
|
2872
|
+
});
|
|
2873
|
+
} else {
|
|
2874
|
+
log10.info("invitation state update", {
|
|
2875
|
+
actor: actor?.constructor.name,
|
|
2876
|
+
newState: stateToString(newState),
|
|
2877
|
+
oldState: stateToString(invitation.state)
|
|
2878
|
+
}, {
|
|
2879
|
+
F: __dxlog_file12,
|
|
2880
|
+
L: 445,
|
|
2881
|
+
S: this,
|
|
2882
|
+
C: (f, a) => f(...a)
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2845
2885
|
}
|
|
2846
2886
|
_isNotTerminal(currentState) {
|
|
2847
2887
|
return ![
|
|
@@ -2854,17 +2894,17 @@ var InvitationsHandler = class {
|
|
|
2854
2894
|
}
|
|
2855
2895
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2856
2896
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2857
|
-
|
|
2897
|
+
log10("guest waiting for authentication code...", void 0, {
|
|
2858
2898
|
F: __dxlog_file12,
|
|
2859
|
-
L:
|
|
2899
|
+
L: 470,
|
|
2860
2900
|
S: this,
|
|
2861
2901
|
C: (f, a) => f(...a)
|
|
2862
2902
|
});
|
|
2863
2903
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2864
2904
|
const authCode = await authenticated.wait(options);
|
|
2865
|
-
|
|
2905
|
+
log10("sending authentication request", void 0, {
|
|
2866
2906
|
F: __dxlog_file12,
|
|
2867
|
-
L:
|
|
2907
|
+
L: 474,
|
|
2868
2908
|
S: this,
|
|
2869
2909
|
C: (f, a) => f(...a)
|
|
2870
2910
|
});
|
|
@@ -2879,11 +2919,11 @@ var InvitationsHandler = class {
|
|
|
2879
2919
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2880
2920
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2881
2921
|
} else {
|
|
2882
|
-
|
|
2922
|
+
log10("retrying invalid code", {
|
|
2883
2923
|
attempt
|
|
2884
2924
|
}, {
|
|
2885
2925
|
F: __dxlog_file12,
|
|
2886
|
-
L:
|
|
2926
|
+
L: 485,
|
|
2887
2927
|
S: this,
|
|
2888
2928
|
C: (f, a) => f(...a)
|
|
2889
2929
|
});
|
|
@@ -2899,9 +2939,9 @@ var InvitationsHandler = class {
|
|
|
2899
2939
|
if (introductionResponse.challenge == null) {
|
|
2900
2940
|
throw new Error("challenge missing in the introduction");
|
|
2901
2941
|
}
|
|
2902
|
-
|
|
2942
|
+
log10("sending authentication request", void 0, {
|
|
2903
2943
|
F: __dxlog_file12,
|
|
2904
|
-
L:
|
|
2944
|
+
L: 504,
|
|
2905
2945
|
S: this,
|
|
2906
2946
|
C: (f, a) => f(...a)
|
|
2907
2947
|
});
|
|
@@ -3024,7 +3064,7 @@ var InvitationsServiceImpl = class {
|
|
|
3024
3064
|
import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3025
3065
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
3026
3066
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3027
|
-
import { log as
|
|
3067
|
+
import { log as log11 } from "@dxos/log";
|
|
3028
3068
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
3029
3069
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3030
3070
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -3094,7 +3134,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3094
3134
|
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
3095
3135
|
throw new AlreadyJoinedError2();
|
|
3096
3136
|
}
|
|
3097
|
-
|
|
3137
|
+
log11("writing guest credentials", {
|
|
3098
3138
|
host: this._signingContext.deviceKey,
|
|
3099
3139
|
guest: deviceKey
|
|
3100
3140
|
}, {
|
|
@@ -3162,7 +3202,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3162
3202
|
]
|
|
3163
3203
|
});
|
|
3164
3204
|
}
|
|
3165
|
-
|
|
3205
|
+
log11("writing delegate space invitation", {
|
|
3166
3206
|
host: this._signingContext.deviceKey,
|
|
3167
3207
|
id: invitation.invitationId
|
|
3168
3208
|
}, {
|
|
@@ -3223,7 +3263,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3223
3263
|
""
|
|
3224
3264
|
]
|
|
3225
3265
|
});
|
|
3226
|
-
|
|
3266
|
+
log11("cancelling delegated space invitation", {
|
|
3227
3267
|
host: this._signingContext.deviceKey,
|
|
3228
3268
|
id: invitation.invitationId
|
|
3229
3269
|
}, {
|
|
@@ -3318,14 +3358,14 @@ var SpaceInvitationProtocol = class {
|
|
|
3318
3358
|
};
|
|
3319
3359
|
|
|
3320
3360
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
3321
|
-
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as
|
|
3361
|
+
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger6 } from "@dxos/async";
|
|
3322
3362
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3323
3363
|
import { Context as Context6 } from "@dxos/context";
|
|
3324
3364
|
import { generatePasscode } from "@dxos/credentials";
|
|
3325
3365
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3326
3366
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3327
3367
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3328
|
-
import { log as
|
|
3368
|
+
import { log as log12 } from "@dxos/log";
|
|
3329
3369
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3330
3370
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3331
3371
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
@@ -3370,7 +3410,7 @@ var InvitationsManager = class {
|
|
|
3370
3410
|
try {
|
|
3371
3411
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3372
3412
|
} catch (err) {
|
|
3373
|
-
|
|
3413
|
+
log12.catch(err, void 0, {
|
|
3374
3414
|
F: __dxlog_file14,
|
|
3375
3415
|
L: 82,
|
|
3376
3416
|
S: this,
|
|
@@ -3412,7 +3452,7 @@ var InvitationsManager = class {
|
|
|
3412
3452
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3413
3453
|
};
|
|
3414
3454
|
} catch (err) {
|
|
3415
|
-
|
|
3455
|
+
log12.catch(err, void 0, {
|
|
3416
3456
|
F: __dxlog_file14,
|
|
3417
3457
|
L: 110,
|
|
3418
3458
|
S: this,
|
|
@@ -3444,7 +3484,7 @@ var InvitationsManager = class {
|
|
|
3444
3484
|
return invitation;
|
|
3445
3485
|
}
|
|
3446
3486
|
async authenticate({ invitationId, authCode }) {
|
|
3447
|
-
|
|
3487
|
+
log12("authenticating...", void 0, {
|
|
3448
3488
|
F: __dxlog_file14,
|
|
3449
3489
|
L: 140,
|
|
3450
3490
|
S: this,
|
|
@@ -3461,7 +3501,7 @@ var InvitationsManager = class {
|
|
|
3461
3501
|
});
|
|
3462
3502
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3463
3503
|
if (!observable) {
|
|
3464
|
-
|
|
3504
|
+
log12.warn("invalid invitation", {
|
|
3465
3505
|
invitationId
|
|
3466
3506
|
}, {
|
|
3467
3507
|
F: __dxlog_file14,
|
|
@@ -3474,7 +3514,7 @@ var InvitationsManager = class {
|
|
|
3474
3514
|
}
|
|
3475
3515
|
}
|
|
3476
3516
|
async cancelInvitation({ invitationId }) {
|
|
3477
|
-
|
|
3517
|
+
log12("cancelInvitation...", {
|
|
3478
3518
|
invitationId
|
|
3479
3519
|
}, {
|
|
3480
3520
|
F: __dxlog_file14,
|
|
@@ -3559,7 +3599,7 @@ var InvitationsManager = class {
|
|
|
3559
3599
|
}
|
|
3560
3600
|
});
|
|
3561
3601
|
ctx.onDispose(() => {
|
|
3562
|
-
|
|
3602
|
+
log12("complete", {
|
|
3563
3603
|
...handler.toJSON()
|
|
3564
3604
|
}, {
|
|
3565
3605
|
F: __dxlog_file14,
|
|
@@ -3587,12 +3627,12 @@ var InvitationsManager = class {
|
|
|
3587
3627
|
};
|
|
3588
3628
|
}
|
|
3589
3629
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3590
|
-
const otpEnteredTrigger = new
|
|
3630
|
+
const otpEnteredTrigger = new Trigger6();
|
|
3591
3631
|
const stream = new PushStream();
|
|
3592
3632
|
const ctx = new Context6({
|
|
3593
3633
|
onError: (err) => {
|
|
3594
3634
|
if (err instanceof TimeoutError2) {
|
|
3595
|
-
|
|
3635
|
+
log12("timeout", {
|
|
3596
3636
|
...handler.toJSON()
|
|
3597
3637
|
}, {
|
|
3598
3638
|
F: __dxlog_file14,
|
|
@@ -3605,7 +3645,7 @@ var InvitationsManager = class {
|
|
|
3605
3645
|
state: Invitation6.State.TIMEOUT
|
|
3606
3646
|
});
|
|
3607
3647
|
} else {
|
|
3608
|
-
|
|
3648
|
+
log12.warn("auth failed", err, {
|
|
3609
3649
|
F: __dxlog_file14,
|
|
3610
3650
|
L: 264,
|
|
3611
3651
|
S: this,
|
|
@@ -3620,7 +3660,7 @@ var InvitationsManager = class {
|
|
|
3620
3660
|
}
|
|
3621
3661
|
});
|
|
3622
3662
|
ctx.onDispose(() => {
|
|
3623
|
-
|
|
3663
|
+
log12("complete", {
|
|
3624
3664
|
...handler.toJSON()
|
|
3625
3665
|
}, {
|
|
3626
3666
|
F: __dxlog_file14,
|
|
@@ -3667,7 +3707,7 @@ var InvitationsManager = class {
|
|
|
3667
3707
|
try {
|
|
3668
3708
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3669
3709
|
} catch (err) {
|
|
3670
|
-
|
|
3710
|
+
log12.catch(err, void 0, {
|
|
3671
3711
|
F: __dxlog_file14,
|
|
3672
3712
|
L: 307,
|
|
3673
3713
|
S: this,
|
|
@@ -3683,33 +3723,40 @@ var InvitationsManager = class {
|
|
|
3683
3723
|
};
|
|
3684
3724
|
|
|
3685
3725
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3686
|
-
import { Event as Event6,
|
|
3726
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3687
3727
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3688
|
-
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as
|
|
3728
|
+
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
3689
3729
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3690
|
-
import {
|
|
3691
|
-
import {
|
|
3692
|
-
import { failedInvariant
|
|
3730
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3731
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3732
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3693
3733
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3694
|
-
import { log as
|
|
3734
|
+
import { log as log15 } from "@dxos/log";
|
|
3695
3735
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3696
|
-
import {
|
|
3736
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3697
3737
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3698
3738
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3699
3739
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3700
|
-
import { ComplexSet as ComplexSet5
|
|
3740
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3701
3741
|
|
|
3702
3742
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3703
3743
|
import { Event as Event4 } from "@dxos/async";
|
|
3744
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3704
3745
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3705
|
-
var AutomergeSpaceState = class {
|
|
3746
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3706
3747
|
constructor(_onNewRoot) {
|
|
3748
|
+
super();
|
|
3707
3749
|
this._onNewRoot = _onNewRoot;
|
|
3708
3750
|
this.rootUrl = void 0;
|
|
3709
3751
|
this.lastEpoch = void 0;
|
|
3710
3752
|
this.onNewEpoch = new Event4();
|
|
3711
3753
|
this._isProcessingRootDocs = false;
|
|
3712
3754
|
}
|
|
3755
|
+
async _open(ctx) {
|
|
3756
|
+
}
|
|
3757
|
+
async _close(ctx) {
|
|
3758
|
+
this._isProcessingRootDocs = false;
|
|
3759
|
+
}
|
|
3713
3760
|
async processCredential(credential) {
|
|
3714
3761
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3715
3762
|
return;
|
|
@@ -3737,16 +3784,162 @@ var AutomergeSpaceState = class {
|
|
|
3737
3784
|
}
|
|
3738
3785
|
};
|
|
3739
3786
|
|
|
3787
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3788
|
+
import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
3789
|
+
import { next as am } from "@dxos/automerge/automerge";
|
|
3790
|
+
import { cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3791
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3792
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
3793
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3794
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3795
|
+
import { log as log13 } from "@dxos/log";
|
|
3796
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3797
|
+
import { assignDeep } from "@dxos/util";
|
|
3798
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3799
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3800
|
+
switch (context.migration) {
|
|
3801
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3802
|
+
const document = context.repo.create();
|
|
3803
|
+
await context.repo.flush();
|
|
3804
|
+
return {
|
|
3805
|
+
newRoot: document.url
|
|
3806
|
+
};
|
|
3807
|
+
}
|
|
3808
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3809
|
+
if (!context.currentRoot) {
|
|
3810
|
+
throw new Error("Space does not have an automerge root");
|
|
3811
|
+
}
|
|
3812
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3813
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3814
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3815
|
+
await context.repo.flush();
|
|
3816
|
+
return {
|
|
3817
|
+
newRoot: newRoot.url
|
|
3818
|
+
};
|
|
3819
|
+
}
|
|
3820
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3821
|
+
log13.info("Fragmenting", void 0, {
|
|
3822
|
+
F: __dxlog_file15,
|
|
3823
|
+
L: 63,
|
|
3824
|
+
S: void 0,
|
|
3825
|
+
C: (f, a) => f(...a)
|
|
3826
|
+
});
|
|
3827
|
+
const currentRootUrl = context.currentRoot;
|
|
3828
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3829
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3830
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3831
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3832
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3833
|
+
invariant12(properties, "Properties not found", {
|
|
3834
|
+
F: __dxlog_file15,
|
|
3835
|
+
L: 73,
|
|
3836
|
+
S: void 0,
|
|
3837
|
+
A: [
|
|
3838
|
+
"properties",
|
|
3839
|
+
"'Properties not found'"
|
|
3840
|
+
]
|
|
3841
|
+
});
|
|
3842
|
+
const newSpaceDoc = {
|
|
3843
|
+
...rootHandle.docSync(),
|
|
3844
|
+
objects: Object.fromEntries([
|
|
3845
|
+
properties
|
|
3846
|
+
])
|
|
3847
|
+
};
|
|
3848
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3849
|
+
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3850
|
+
F: __dxlog_file15,
|
|
3851
|
+
L: 78,
|
|
3852
|
+
S: void 0,
|
|
3853
|
+
A: [
|
|
3854
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3855
|
+
""
|
|
3856
|
+
]
|
|
3857
|
+
});
|
|
3858
|
+
const docLoader = new AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3859
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3860
|
+
rootUrl: newRoot.url
|
|
3861
|
+
});
|
|
3862
|
+
otherObjects.forEach(([key, value]) => {
|
|
3863
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3864
|
+
handle.change((doc) => {
|
|
3865
|
+
assignDeep(doc, [
|
|
3866
|
+
"objects",
|
|
3867
|
+
key
|
|
3868
|
+
], value);
|
|
3869
|
+
});
|
|
3870
|
+
});
|
|
3871
|
+
await context.repo.flush();
|
|
3872
|
+
return {
|
|
3873
|
+
newRoot: newRoot.url
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
case CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3877
|
+
const currentRootUrl = context.currentRoot;
|
|
3878
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3879
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3880
|
+
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3881
|
+
F: __dxlog_file15,
|
|
3882
|
+
L: 100,
|
|
3883
|
+
S: void 0,
|
|
3884
|
+
A: [
|
|
3885
|
+
"rootHandle.docSync()",
|
|
3886
|
+
"'Root doc not found'"
|
|
3887
|
+
]
|
|
3888
|
+
});
|
|
3889
|
+
const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
|
|
3890
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3891
|
+
const handle = context.repo.find(url);
|
|
3892
|
+
await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
|
|
3893
|
+
invariant12(handle.docSync(), "Doc not found", {
|
|
3894
|
+
F: __dxlog_file15,
|
|
3895
|
+
L: 107,
|
|
3896
|
+
S: void 0,
|
|
3897
|
+
A: [
|
|
3898
|
+
"handle.docSync()",
|
|
3899
|
+
"'Doc not found'"
|
|
3900
|
+
]
|
|
3901
|
+
});
|
|
3902
|
+
const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
|
|
3903
|
+
const migratedDoc = migrateDocument(handle.docSync(), newDoc);
|
|
3904
|
+
const newHandle = context.repo.import(am.save(migratedDoc));
|
|
3905
|
+
newRootContent.links[id] = newHandle.url;
|
|
3906
|
+
}
|
|
3907
|
+
const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
|
|
3908
|
+
const newRoot = context.repo.import(am.save(migratedRoot));
|
|
3909
|
+
await context.repo.flush();
|
|
3910
|
+
return {
|
|
3911
|
+
newRoot: newRoot.url
|
|
3912
|
+
};
|
|
3913
|
+
}
|
|
3914
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3915
|
+
invariant12(context.newAutomergeRoot, void 0, {
|
|
3916
|
+
F: __dxlog_file15,
|
|
3917
|
+
L: 124,
|
|
3918
|
+
S: void 0,
|
|
3919
|
+
A: [
|
|
3920
|
+
"context.newAutomergeRoot",
|
|
3921
|
+
""
|
|
3922
|
+
]
|
|
3923
|
+
});
|
|
3924
|
+
await context.repo.flush();
|
|
3925
|
+
return {
|
|
3926
|
+
newRoot: context.newAutomergeRoot
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
return {};
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3740
3933
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
3741
|
-
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as
|
|
3934
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
|
|
3742
3935
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3743
|
-
import { invariant as
|
|
3936
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3744
3937
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3745
|
-
import { log as
|
|
3938
|
+
import { log as log14 } from "@dxos/log";
|
|
3746
3939
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3747
3940
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3748
3941
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3749
|
-
var
|
|
3942
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3750
3943
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3751
3944
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3752
3945
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3771,16 +3964,16 @@ var NotarizationPlugin = class {
|
|
|
3771
3964
|
* Request credentials to be notarized.
|
|
3772
3965
|
*/
|
|
3773
3966
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3774
|
-
|
|
3967
|
+
log14("notarize", {
|
|
3775
3968
|
credentials
|
|
3776
3969
|
}, {
|
|
3777
|
-
F:
|
|
3970
|
+
F: __dxlog_file16,
|
|
3778
3971
|
L: 90,
|
|
3779
3972
|
S: this,
|
|
3780
3973
|
C: (f, a) => f(...a)
|
|
3781
3974
|
});
|
|
3782
|
-
|
|
3783
|
-
F:
|
|
3975
|
+
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3976
|
+
F: __dxlog_file16,
|
|
3784
3977
|
L: 91,
|
|
3785
3978
|
S: this,
|
|
3786
3979
|
A: [
|
|
@@ -3788,13 +3981,13 @@ var NotarizationPlugin = class {
|
|
|
3788
3981
|
"'Credentials must have an id'"
|
|
3789
3982
|
]
|
|
3790
3983
|
});
|
|
3791
|
-
const errors = new
|
|
3984
|
+
const errors = new Trigger7();
|
|
3792
3985
|
const ctx = this._ctx.derive({
|
|
3793
3986
|
onError: (err) => {
|
|
3794
|
-
|
|
3987
|
+
log14.warn("Notarization error", {
|
|
3795
3988
|
err
|
|
3796
3989
|
}, {
|
|
3797
|
-
F:
|
|
3990
|
+
F: __dxlog_file16,
|
|
3798
3991
|
L: 99,
|
|
3799
3992
|
S: this,
|
|
3800
3993
|
C: (f, a) => f(...a)
|
|
@@ -3806,11 +3999,11 @@ var NotarizationPlugin = class {
|
|
|
3806
3999
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3807
4000
|
if (timeout !== 0) {
|
|
3808
4001
|
scheduleTask4(ctx, () => {
|
|
3809
|
-
|
|
4002
|
+
log14.warn("Notarization timeout", {
|
|
3810
4003
|
timeout,
|
|
3811
4004
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3812
4005
|
}, {
|
|
3813
|
-
F:
|
|
4006
|
+
F: __dxlog_file16,
|
|
3814
4007
|
L: 111,
|
|
3815
4008
|
S: this,
|
|
3816
4009
|
C: (f, a) => f(...a)
|
|
@@ -3830,10 +4023,10 @@ var NotarizationPlugin = class {
|
|
|
3830
4023
|
...this._extensions
|
|
3831
4024
|
].find((peer2) => !peersTried.has(peer2));
|
|
3832
4025
|
if (!peer) {
|
|
3833
|
-
|
|
4026
|
+
log14.info("Exhausted all peers to notarize with", {
|
|
3834
4027
|
retryIn: retryTimeout
|
|
3835
4028
|
}, {
|
|
3836
|
-
F:
|
|
4029
|
+
F: __dxlog_file16,
|
|
3837
4030
|
L: 136,
|
|
3838
4031
|
S: this,
|
|
3839
4032
|
C: (f, a) => f(...a)
|
|
@@ -3843,11 +4036,11 @@ var NotarizationPlugin = class {
|
|
|
3843
4036
|
return;
|
|
3844
4037
|
}
|
|
3845
4038
|
peersTried.add(peer);
|
|
3846
|
-
|
|
4039
|
+
log14("try notarizing", {
|
|
3847
4040
|
peer: peer.localPeerId,
|
|
3848
4041
|
credentialId: credentials.map((credential) => credential.id)
|
|
3849
4042
|
}, {
|
|
3850
|
-
F:
|
|
4043
|
+
F: __dxlog_file16,
|
|
3851
4044
|
L: 143,
|
|
3852
4045
|
S: this,
|
|
3853
4046
|
C: (f, a) => f(...a)
|
|
@@ -3855,17 +4048,17 @@ var NotarizationPlugin = class {
|
|
|
3855
4048
|
await peer.rpc.NotarizationService.notarize({
|
|
3856
4049
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3857
4050
|
});
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
4051
|
+
log14("success", void 0, {
|
|
4052
|
+
F: __dxlog_file16,
|
|
3860
4053
|
L: 147,
|
|
3861
4054
|
S: this,
|
|
3862
4055
|
C: (f, a) => f(...a)
|
|
3863
4056
|
});
|
|
3864
|
-
await
|
|
4057
|
+
await sleep2(successDelay);
|
|
3865
4058
|
} catch (err) {
|
|
3866
4059
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3867
|
-
|
|
3868
|
-
F:
|
|
4060
|
+
log14.info("error notarizing (recoverable)", err, {
|
|
4061
|
+
F: __dxlog_file16,
|
|
3869
4062
|
L: 151,
|
|
3870
4063
|
S: this,
|
|
3871
4064
|
C: (f, a) => f(...a)
|
|
@@ -3882,8 +4075,8 @@ var NotarizationPlugin = class {
|
|
|
3882
4075
|
allNotarized,
|
|
3883
4076
|
errors.wait()
|
|
3884
4077
|
]);
|
|
3885
|
-
|
|
3886
|
-
F:
|
|
4078
|
+
log14("done", void 0, {
|
|
4079
|
+
F: __dxlog_file16,
|
|
3887
4080
|
L: 162,
|
|
3888
4081
|
S: this,
|
|
3889
4082
|
C: (f, a) => f(...a)
|
|
@@ -3904,8 +4097,8 @@ var NotarizationPlugin = class {
|
|
|
3904
4097
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3905
4098
|
}
|
|
3906
4099
|
setWriter(writer) {
|
|
3907
|
-
|
|
3908
|
-
F:
|
|
4100
|
+
invariant13(!this._writer, "Writer already set.", {
|
|
4101
|
+
F: __dxlog_file16,
|
|
3909
4102
|
L: 181,
|
|
3910
4103
|
S: this,
|
|
3911
4104
|
A: [
|
|
@@ -3919,7 +4112,7 @@ var NotarizationPlugin = class {
|
|
|
3919
4112
|
if (this._processedCredentials.has(id)) {
|
|
3920
4113
|
return;
|
|
3921
4114
|
}
|
|
3922
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4115
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger7()).value.wait();
|
|
3923
4116
|
}
|
|
3924
4117
|
/**
|
|
3925
4118
|
* Requests from other peers to notarize credentials.
|
|
@@ -3929,8 +4122,8 @@ var NotarizationPlugin = class {
|
|
|
3929
4122
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3930
4123
|
}
|
|
3931
4124
|
for (const credential of request.credentials ?? []) {
|
|
3932
|
-
|
|
3933
|
-
F:
|
|
4125
|
+
invariant13(credential.id, "Credential must have an id", {
|
|
4126
|
+
F: __dxlog_file16,
|
|
3934
4127
|
L: 200,
|
|
3935
4128
|
S: this,
|
|
3936
4129
|
A: [
|
|
@@ -3947,10 +4140,10 @@ var NotarizationPlugin = class {
|
|
|
3947
4140
|
createExtension() {
|
|
3948
4141
|
const extension = new NotarizationTeleportExtension({
|
|
3949
4142
|
onOpen: async () => {
|
|
3950
|
-
|
|
4143
|
+
log14("extension opened", {
|
|
3951
4144
|
peer: extension.localPeerId
|
|
3952
4145
|
}, {
|
|
3953
|
-
F:
|
|
4146
|
+
F: __dxlog_file16,
|
|
3954
4147
|
L: 211,
|
|
3955
4148
|
S: this,
|
|
3956
4149
|
C: (f, a) => f(...a)
|
|
@@ -3959,10 +4152,10 @@ var NotarizationPlugin = class {
|
|
|
3959
4152
|
this._extensionOpened.emit();
|
|
3960
4153
|
},
|
|
3961
4154
|
onClose: async () => {
|
|
3962
|
-
|
|
4155
|
+
log14("extension closed", {
|
|
3963
4156
|
peer: extension.localPeerId
|
|
3964
4157
|
}, {
|
|
3965
|
-
F:
|
|
4158
|
+
F: __dxlog_file16,
|
|
3966
4159
|
L: 216,
|
|
3967
4160
|
S: this,
|
|
3968
4161
|
C: (f, a) => f(...a)
|
|
@@ -4016,7 +4209,70 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4016
4209
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4017
4210
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4018
4211
|
}
|
|
4019
|
-
|
|
4212
|
+
function _using_ctx() {
|
|
4213
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4214
|
+
var err = new Error();
|
|
4215
|
+
err.name = "SuppressedError";
|
|
4216
|
+
err.suppressed = suppressed;
|
|
4217
|
+
err.error = error;
|
|
4218
|
+
return err;
|
|
4219
|
+
}, empty = {}, stack = [];
|
|
4220
|
+
function using(isAwait, value) {
|
|
4221
|
+
if (value != null) {
|
|
4222
|
+
if (Object(value) !== value) {
|
|
4223
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4224
|
+
}
|
|
4225
|
+
if (isAwait) {
|
|
4226
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4227
|
+
}
|
|
4228
|
+
if (dispose == null) {
|
|
4229
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4230
|
+
}
|
|
4231
|
+
if (typeof dispose !== "function") {
|
|
4232
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4233
|
+
}
|
|
4234
|
+
stack.push({
|
|
4235
|
+
v: value,
|
|
4236
|
+
d: dispose,
|
|
4237
|
+
a: isAwait
|
|
4238
|
+
});
|
|
4239
|
+
} else if (isAwait) {
|
|
4240
|
+
stack.push({
|
|
4241
|
+
d: value,
|
|
4242
|
+
a: isAwait
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
return value;
|
|
4246
|
+
}
|
|
4247
|
+
return {
|
|
4248
|
+
e: empty,
|
|
4249
|
+
u: using.bind(null, false),
|
|
4250
|
+
a: using.bind(null, true),
|
|
4251
|
+
d: function() {
|
|
4252
|
+
var error = this.e;
|
|
4253
|
+
function next() {
|
|
4254
|
+
while (resource = stack.pop()) {
|
|
4255
|
+
try {
|
|
4256
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4257
|
+
if (resource.a) {
|
|
4258
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4259
|
+
}
|
|
4260
|
+
} catch (e) {
|
|
4261
|
+
return err(e);
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
if (error !== empty)
|
|
4265
|
+
throw error;
|
|
4266
|
+
}
|
|
4267
|
+
function err(e) {
|
|
4268
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4269
|
+
return next();
|
|
4270
|
+
}
|
|
4271
|
+
return next();
|
|
4272
|
+
}
|
|
4273
|
+
};
|
|
4274
|
+
}
|
|
4275
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4020
4276
|
var DataSpace = class {
|
|
4021
4277
|
constructor(params) {
|
|
4022
4278
|
this._ctx = new Context8();
|
|
@@ -4024,7 +4280,9 @@ var DataSpace = class {
|
|
|
4024
4280
|
this._cache = void 0;
|
|
4025
4281
|
// TODO(dmaretskyi): Move into Space?
|
|
4026
4282
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4283
|
+
this._epochProcessingMutex = new Mutex2();
|
|
4027
4284
|
this._state = SpaceState2.CLOSED;
|
|
4285
|
+
this._databaseRoot = null;
|
|
4028
4286
|
/**
|
|
4029
4287
|
* Error for _state === SpaceState.ERROR.
|
|
4030
4288
|
*/
|
|
@@ -4048,11 +4306,11 @@ var DataSpace = class {
|
|
|
4048
4306
|
});
|
|
4049
4307
|
this._cache = params.cache;
|
|
4050
4308
|
this._state = params.initialState;
|
|
4051
|
-
|
|
4309
|
+
log15("new state", {
|
|
4052
4310
|
state: SpaceState2[this._state]
|
|
4053
4311
|
}, {
|
|
4054
|
-
F:
|
|
4055
|
-
L:
|
|
4312
|
+
F: __dxlog_file17,
|
|
4313
|
+
L: 146,
|
|
4056
4314
|
S: this,
|
|
4057
4315
|
C: (f, a) => f(...a)
|
|
4058
4316
|
});
|
|
@@ -4085,6 +4343,9 @@ var DataSpace = class {
|
|
|
4085
4343
|
get automergeSpaceState() {
|
|
4086
4344
|
return this._automergeSpaceState;
|
|
4087
4345
|
}
|
|
4346
|
+
get databaseRoot() {
|
|
4347
|
+
return this._databaseRoot;
|
|
4348
|
+
}
|
|
4088
4349
|
get _automergeInfo() {
|
|
4089
4350
|
return {
|
|
4090
4351
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4101,14 +4362,15 @@ var DataSpace = class {
|
|
|
4101
4362
|
await this._gossip.open();
|
|
4102
4363
|
await this._notarizationPlugin.open();
|
|
4103
4364
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4365
|
+
await this._automergeSpaceState.open();
|
|
4104
4366
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4105
4367
|
await this._inner.open(new Context8());
|
|
4106
4368
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
-
|
|
4369
|
+
log15("new state", {
|
|
4108
4370
|
state: SpaceState2[this._state]
|
|
4109
4371
|
}, {
|
|
4110
|
-
F:
|
|
4111
|
-
L:
|
|
4372
|
+
F: __dxlog_file17,
|
|
4373
|
+
L: 217,
|
|
4112
4374
|
S: this,
|
|
4113
4375
|
C: (f, a) => f(...a)
|
|
4114
4376
|
});
|
|
@@ -4122,11 +4384,11 @@ var DataSpace = class {
|
|
|
4122
4384
|
async _close() {
|
|
4123
4385
|
await this._callbacks.beforeClose?.();
|
|
4124
4386
|
this._state = SpaceState2.CLOSED;
|
|
4125
|
-
|
|
4387
|
+
log15("new state", {
|
|
4126
4388
|
state: SpaceState2[this._state]
|
|
4127
4389
|
}, {
|
|
4128
|
-
F:
|
|
4129
|
-
L:
|
|
4390
|
+
F: __dxlog_file17,
|
|
4391
|
+
L: 231,
|
|
4130
4392
|
S: this,
|
|
4131
4393
|
C: (f, a) => f(...a)
|
|
4132
4394
|
});
|
|
@@ -4135,6 +4397,7 @@ var DataSpace = class {
|
|
|
4135
4397
|
await this.authVerifier.close();
|
|
4136
4398
|
await this._inner.close();
|
|
4137
4399
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4400
|
+
await this._automergeSpaceState.close();
|
|
4138
4401
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4139
4402
|
await this._notarizationPlugin.close();
|
|
4140
4403
|
await this._presence.close();
|
|
@@ -4156,26 +4419,26 @@ var DataSpace = class {
|
|
|
4156
4419
|
await this.initializeDataPipeline();
|
|
4157
4420
|
} catch (err) {
|
|
4158
4421
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4159
|
-
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4422
|
+
log15("data pipeline initialization cancelled", err, {
|
|
4423
|
+
F: __dxlog_file17,
|
|
4424
|
+
L: 265,
|
|
4162
4425
|
S: this,
|
|
4163
4426
|
C: (f, a) => f(...a)
|
|
4164
4427
|
});
|
|
4165
4428
|
return;
|
|
4166
4429
|
}
|
|
4167
|
-
|
|
4168
|
-
F:
|
|
4169
|
-
L:
|
|
4430
|
+
log15.error("Error initializing data pipeline", err, {
|
|
4431
|
+
F: __dxlog_file17,
|
|
4432
|
+
L: 269,
|
|
4170
4433
|
S: this,
|
|
4171
4434
|
C: (f, a) => f(...a)
|
|
4172
4435
|
});
|
|
4173
4436
|
this._state = SpaceState2.ERROR;
|
|
4174
|
-
|
|
4437
|
+
log15("new state", {
|
|
4175
4438
|
state: SpaceState2[this._state]
|
|
4176
4439
|
}, {
|
|
4177
|
-
F:
|
|
4178
|
-
L:
|
|
4440
|
+
F: __dxlog_file17,
|
|
4441
|
+
L: 271,
|
|
4179
4442
|
S: this,
|
|
4180
4443
|
C: (f, a) => f(...a)
|
|
4181
4444
|
});
|
|
@@ -4191,31 +4454,28 @@ var DataSpace = class {
|
|
|
4191
4454
|
throw new SystemError("Invalid operation");
|
|
4192
4455
|
}
|
|
4193
4456
|
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
-
|
|
4457
|
+
log15("new state", {
|
|
4195
4458
|
state: SpaceState2[this._state]
|
|
4196
4459
|
}, {
|
|
4197
|
-
F:
|
|
4198
|
-
L:
|
|
4460
|
+
F: __dxlog_file17,
|
|
4461
|
+
L: 287,
|
|
4199
4462
|
S: this,
|
|
4200
4463
|
C: (f, a) => f(...a)
|
|
4201
4464
|
});
|
|
4202
4465
|
await this._initializeAndReadControlPipeline();
|
|
4203
|
-
await
|
|
4466
|
+
await sleep3(1);
|
|
4467
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4204
4468
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4205
|
-
await
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
L: 290,
|
|
4209
|
-
S: this,
|
|
4210
|
-
C: (f, a) => f(...a)
|
|
4211
|
-
});
|
|
4469
|
+
await ready;
|
|
4470
|
+
}
|
|
4471
|
+
async _enterReadyState() {
|
|
4212
4472
|
await this._callbacks.beforeReady?.();
|
|
4213
4473
|
this._state = SpaceState2.READY;
|
|
4214
|
-
|
|
4474
|
+
log15("new state", {
|
|
4215
4475
|
state: SpaceState2[this._state]
|
|
4216
4476
|
}, {
|
|
4217
|
-
F:
|
|
4218
|
-
L:
|
|
4477
|
+
F: __dxlog_file17,
|
|
4478
|
+
L: 306,
|
|
4219
4479
|
S: this,
|
|
4220
4480
|
C: (f, a) => f(...a)
|
|
4221
4481
|
});
|
|
@@ -4229,9 +4489,9 @@ var DataSpace = class {
|
|
|
4229
4489
|
});
|
|
4230
4490
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4231
4491
|
await this._createWritableFeeds();
|
|
4232
|
-
|
|
4233
|
-
F:
|
|
4234
|
-
L:
|
|
4492
|
+
log15("writable feeds created", void 0, {
|
|
4493
|
+
F: __dxlog_file17,
|
|
4494
|
+
L: 322,
|
|
4235
4495
|
S: this,
|
|
4236
4496
|
C: (f, a) => f(...a)
|
|
4237
4497
|
});
|
|
@@ -4289,57 +4549,66 @@ var DataSpace = class {
|
|
|
4289
4549
|
}
|
|
4290
4550
|
}
|
|
4291
4551
|
_onNewAutomergeRoot(rootUrl) {
|
|
4292
|
-
|
|
4552
|
+
log15("loading automerge root doc for space", {
|
|
4293
4553
|
space: this.key,
|
|
4294
4554
|
rootUrl
|
|
4295
4555
|
}, {
|
|
4296
|
-
F:
|
|
4297
|
-
L:
|
|
4556
|
+
F: __dxlog_file17,
|
|
4557
|
+
L: 388,
|
|
4298
4558
|
S: this,
|
|
4299
4559
|
C: (f, a) => f(...a)
|
|
4300
4560
|
});
|
|
4301
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4302
4561
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4303
4562
|
queueMicrotask(async () => {
|
|
4304
4563
|
try {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
return;
|
|
4310
|
-
}
|
|
4311
|
-
const doc = handle.docSync() ?? failedInvariant();
|
|
4312
|
-
if (!doc.access?.spaceKey) {
|
|
4313
|
-
handle.change((doc2) => {
|
|
4314
|
-
doc2.access = {
|
|
4315
|
-
spaceKey: this.key.toHex()
|
|
4316
|
-
};
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4320
|
-
await this._echoHost.openSpaceRoot(handle.url);
|
|
4321
|
-
} else {
|
|
4322
|
-
log13.warn("echo database root already exists", {
|
|
4323
|
-
space: this.key,
|
|
4324
|
-
rootUrl
|
|
4325
|
-
}, {
|
|
4326
|
-
F: __dxlog_file16,
|
|
4327
|
-
L: 403,
|
|
4328
|
-
S: this,
|
|
4329
|
-
C: (f, a) => f(...a)
|
|
4564
|
+
try {
|
|
4565
|
+
var _usingCtx = _using_ctx();
|
|
4566
|
+
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4567
|
+
await cancelWithContext5(this._ctx, handle.whenReady());
|
|
4330
4568
|
});
|
|
4569
|
+
if (this._ctx.disposed) {
|
|
4570
|
+
return;
|
|
4571
|
+
}
|
|
4572
|
+
const _guard = (
|
|
4573
|
+
// Ensure only one root is processed at a time.
|
|
4574
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4575
|
+
);
|
|
4576
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
4577
|
+
if (!doc.access?.spaceKey) {
|
|
4578
|
+
handle.change((doc2) => {
|
|
4579
|
+
doc2.access = {
|
|
4580
|
+
spaceKey: this.key.toHex()
|
|
4581
|
+
};
|
|
4582
|
+
});
|
|
4583
|
+
}
|
|
4584
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4585
|
+
this._databaseRoot = root;
|
|
4586
|
+
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
4587
|
+
if (this._state !== SpaceState2.REQUIRES_MIGRATION) {
|
|
4588
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4589
|
+
this.stateUpdate.emit();
|
|
4590
|
+
}
|
|
4591
|
+
} else {
|
|
4592
|
+
if (this._state !== SpaceState2.READY) {
|
|
4593
|
+
await this._enterReadyState();
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
} catch (_) {
|
|
4597
|
+
_usingCtx.e = _;
|
|
4598
|
+
} finally {
|
|
4599
|
+
_usingCtx.d();
|
|
4331
4600
|
}
|
|
4332
4601
|
} catch (err) {
|
|
4333
4602
|
if (err instanceof ContextDisposedError3) {
|
|
4334
4603
|
return;
|
|
4335
4604
|
}
|
|
4336
|
-
|
|
4605
|
+
log15.warn("error loading automerge root doc", {
|
|
4337
4606
|
space: this.key,
|
|
4338
4607
|
rootUrl,
|
|
4339
4608
|
err
|
|
4340
4609
|
}, {
|
|
4341
|
-
F:
|
|
4342
|
-
L:
|
|
4610
|
+
F: __dxlog_file17,
|
|
4611
|
+
L: 431,
|
|
4343
4612
|
S: this,
|
|
4344
4613
|
C: (f, a) => f(...a)
|
|
4345
4614
|
});
|
|
@@ -4362,148 +4631,34 @@ var DataSpace = class {
|
|
|
4362
4631
|
});
|
|
4363
4632
|
}
|
|
4364
4633
|
async createEpoch(options) {
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
case CreateEpochRequest.Migration.NONE:
|
|
4369
|
-
{
|
|
4370
|
-
epoch = {
|
|
4371
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4372
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4373
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4374
|
-
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4375
|
-
};
|
|
4376
|
-
}
|
|
4377
|
-
break;
|
|
4378
|
-
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4379
|
-
{
|
|
4380
|
-
const document = this._echoHost.automergeRepo.create();
|
|
4381
|
-
epoch = {
|
|
4382
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4383
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4384
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4385
|
-
automergeRoot: document.url
|
|
4386
|
-
};
|
|
4387
|
-
}
|
|
4388
|
-
break;
|
|
4389
|
-
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4390
|
-
{
|
|
4391
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4392
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4393
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4394
|
-
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4395
|
-
await this._echoHost.automergeRepo.flush([
|
|
4396
|
-
newRoot.documentId
|
|
4397
|
-
]);
|
|
4398
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4399
|
-
F: __dxlog_file16,
|
|
4400
|
-
L: 460,
|
|
4401
|
-
S: this,
|
|
4402
|
-
A: [
|
|
4403
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4404
|
-
""
|
|
4405
|
-
]
|
|
4406
|
-
});
|
|
4407
|
-
epoch = {
|
|
4408
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4409
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4410
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4411
|
-
automergeRoot: newRoot.url
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
break;
|
|
4415
|
-
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4416
|
-
{
|
|
4417
|
-
log13.info("Fragmenting", void 0, {
|
|
4418
|
-
F: __dxlog_file16,
|
|
4419
|
-
L: 472,
|
|
4420
|
-
S: this,
|
|
4421
|
-
C: (f, a) => f(...a)
|
|
4422
|
-
});
|
|
4423
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4424
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4425
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4426
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4427
|
-
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4428
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4429
|
-
invariant13(properties, "Properties not found", {
|
|
4430
|
-
F: __dxlog_file16,
|
|
4431
|
-
L: 482,
|
|
4432
|
-
S: this,
|
|
4433
|
-
A: [
|
|
4434
|
-
"properties",
|
|
4435
|
-
"'Properties not found'"
|
|
4436
|
-
]
|
|
4437
|
-
});
|
|
4438
|
-
const newSpaceDoc = {
|
|
4439
|
-
...rootHandle.docSync(),
|
|
4440
|
-
objects: Object.fromEntries([
|
|
4441
|
-
properties
|
|
4442
|
-
])
|
|
4443
|
-
};
|
|
4444
|
-
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4445
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4446
|
-
F: __dxlog_file16,
|
|
4447
|
-
L: 487,
|
|
4448
|
-
S: this,
|
|
4449
|
-
A: [
|
|
4450
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4451
|
-
""
|
|
4452
|
-
]
|
|
4453
|
-
});
|
|
4454
|
-
const docLoader = new AutomergeDocumentLoaderImpl(await createIdFromSpaceKey(this.key), this._echoHost.automergeRepo, this.key);
|
|
4455
|
-
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
4456
|
-
rootUrl: newRoot.url
|
|
4457
|
-
});
|
|
4458
|
-
otherObjects.forEach(([key, value]) => {
|
|
4459
|
-
const handle = docLoader.createDocumentForObject(key);
|
|
4460
|
-
handle.change((doc) => {
|
|
4461
|
-
assignDeep(doc, [
|
|
4462
|
-
"objects",
|
|
4463
|
-
key
|
|
4464
|
-
], value);
|
|
4465
|
-
});
|
|
4466
|
-
});
|
|
4467
|
-
epoch = {
|
|
4468
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4469
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4470
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4471
|
-
automergeRoot: newRoot.url
|
|
4472
|
-
};
|
|
4473
|
-
}
|
|
4474
|
-
break;
|
|
4475
|
-
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4476
|
-
{
|
|
4477
|
-
invariant13(options.newAutomergeRoot, void 0, {
|
|
4478
|
-
F: __dxlog_file16,
|
|
4479
|
-
L: 517,
|
|
4480
|
-
S: this,
|
|
4481
|
-
A: [
|
|
4482
|
-
"options.newAutomergeRoot",
|
|
4483
|
-
""
|
|
4484
|
-
]
|
|
4485
|
-
});
|
|
4486
|
-
epoch = {
|
|
4487
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4488
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4489
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4490
|
-
automergeRoot: options.newAutomergeRoot
|
|
4491
|
-
};
|
|
4492
|
-
}
|
|
4493
|
-
break;
|
|
4494
|
-
}
|
|
4495
|
-
if (!epoch) {
|
|
4496
|
-
return;
|
|
4634
|
+
const ctx = this._ctx.derive();
|
|
4635
|
+
if (!options?.migration) {
|
|
4636
|
+
return null;
|
|
4497
4637
|
}
|
|
4638
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4639
|
+
repo: this._echoHost.automergeRepo,
|
|
4640
|
+
spaceId: this.id,
|
|
4641
|
+
spaceKey: this.key,
|
|
4642
|
+
migration: options.migration,
|
|
4643
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4644
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4645
|
+
});
|
|
4646
|
+
const epoch = {
|
|
4647
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4648
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4649
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4650
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4651
|
+
};
|
|
4652
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4653
|
+
subject: this.key,
|
|
4654
|
+
assertion: {
|
|
4655
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4656
|
+
...epoch
|
|
4657
|
+
}
|
|
4658
|
+
});
|
|
4498
4659
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4499
4660
|
credential: {
|
|
4500
|
-
credential
|
|
4501
|
-
subject: this.key,
|
|
4502
|
-
assertion: {
|
|
4503
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4504
|
-
...epoch
|
|
4505
|
-
}
|
|
4506
|
-
})
|
|
4661
|
+
credential
|
|
4507
4662
|
}
|
|
4508
4663
|
});
|
|
4509
4664
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
@@ -4513,6 +4668,7 @@ var DataSpace = class {
|
|
|
4513
4668
|
]
|
|
4514
4669
|
]));
|
|
4515
4670
|
await this._echoHost.updateIndexes();
|
|
4671
|
+
return credential;
|
|
4516
4672
|
}
|
|
4517
4673
|
async activate() {
|
|
4518
4674
|
if (![
|
|
@@ -4534,11 +4690,11 @@ var DataSpace = class {
|
|
|
4534
4690
|
await this._close();
|
|
4535
4691
|
}
|
|
4536
4692
|
this._state = SpaceState2.INACTIVE;
|
|
4537
|
-
|
|
4693
|
+
log15("new state", {
|
|
4538
4694
|
state: SpaceState2[this._state]
|
|
4539
4695
|
}, {
|
|
4540
|
-
F:
|
|
4541
|
-
L:
|
|
4696
|
+
F: __dxlog_file17,
|
|
4697
|
+
L: 512,
|
|
4542
4698
|
S: this,
|
|
4543
4699
|
C: (f, a) => f(...a)
|
|
4544
4700
|
});
|
|
@@ -4593,36 +4749,25 @@ DataSpace = _ts_decorate4([
|
|
|
4593
4749
|
trackLeaks("open", "close"),
|
|
4594
4750
|
trace6.resource()
|
|
4595
4751
|
], DataSpace);
|
|
4596
|
-
var findPropertiesObject = (spaceDoc) => {
|
|
4597
|
-
for (const id in spaceDoc.objects ?? {}) {
|
|
4598
|
-
const obj = spaceDoc.objects[id];
|
|
4599
|
-
if (obj.system.type?.itemId === TYPE_PROPERTIES) {
|
|
4600
|
-
return [
|
|
4601
|
-
id,
|
|
4602
|
-
obj
|
|
4603
|
-
];
|
|
4604
|
-
}
|
|
4605
|
-
}
|
|
4606
|
-
return void 0;
|
|
4607
|
-
};
|
|
4608
4752
|
|
|
4609
4753
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4610
4754
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
4755
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4612
|
-
import {
|
|
4756
|
+
import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
|
|
4613
4757
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4758
|
+
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4614
4759
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
-
import { encodeReference } from "@dxos/echo-protocol";
|
|
4616
|
-
import { getTypeReference } from "@dxos/echo-schema";
|
|
4760
|
+
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
4761
|
+
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4617
4762
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4618
4763
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4619
|
-
import { log as
|
|
4764
|
+
import { log as log16 } from "@dxos/log";
|
|
4620
4765
|
import { trace as Trace2 } from "@dxos/protocols";
|
|
4621
4766
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4622
4767
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4623
4768
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4624
4769
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4625
|
-
import {
|
|
4770
|
+
import { ComplexMap as ComplexMap3, assignDeep as assignDeep2, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4626
4771
|
|
|
4627
4772
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4628
4773
|
import { createCredential } from "@dxos/credentials";
|
|
@@ -4705,7 +4850,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4705
4850
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4706
4851
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4707
4852
|
}
|
|
4708
|
-
var
|
|
4853
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4709
4854
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4710
4855
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
4856
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4732,7 +4877,7 @@ var DataSpaceManager = class {
|
|
|
4732
4877
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4733
4878
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4734
4879
|
const rootDoc = rootHandle?.docSync();
|
|
4735
|
-
const properties = rootDoc &&
|
|
4880
|
+
const properties = rootDoc && findInlineObjectOfType2(rootDoc, TYPE_PROPERTIES2);
|
|
4736
4881
|
return {
|
|
4737
4882
|
key: space.key.toHex(),
|
|
4738
4883
|
state: SpaceState3[space.state],
|
|
@@ -4752,46 +4897,46 @@ var DataSpaceManager = class {
|
|
|
4752
4897
|
return this._spaces;
|
|
4753
4898
|
}
|
|
4754
4899
|
async open() {
|
|
4755
|
-
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4900
|
+
log16("open", void 0, {
|
|
4901
|
+
F: __dxlog_file18,
|
|
4902
|
+
L: 146,
|
|
4758
4903
|
S: this,
|
|
4759
4904
|
C: (f, a) => f(...a)
|
|
4760
4905
|
});
|
|
4761
|
-
|
|
4906
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4762
4907
|
id: this._instanceId
|
|
4763
4908
|
}), {
|
|
4764
|
-
F:
|
|
4765
|
-
L:
|
|
4909
|
+
F: __dxlog_file18,
|
|
4910
|
+
L: 147,
|
|
4766
4911
|
S: this,
|
|
4767
4912
|
C: (f, a) => f(...a)
|
|
4768
4913
|
});
|
|
4769
|
-
|
|
4914
|
+
log16("metadata loaded", {
|
|
4770
4915
|
spaces: this._metadataStore.spaces.length
|
|
4771
4916
|
}, {
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
4917
|
+
F: __dxlog_file18,
|
|
4918
|
+
L: 148,
|
|
4774
4919
|
S: this,
|
|
4775
4920
|
C: (f, a) => f(...a)
|
|
4776
4921
|
});
|
|
4777
4922
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4778
4923
|
try {
|
|
4779
|
-
|
|
4924
|
+
log16("load space", {
|
|
4780
4925
|
spaceMetadata
|
|
4781
4926
|
}, {
|
|
4782
|
-
F:
|
|
4783
|
-
L:
|
|
4927
|
+
F: __dxlog_file18,
|
|
4928
|
+
L: 152,
|
|
4784
4929
|
S: this,
|
|
4785
4930
|
C: (f, a) => f(...a)
|
|
4786
4931
|
});
|
|
4787
4932
|
await this._constructSpace(spaceMetadata);
|
|
4788
4933
|
} catch (err) {
|
|
4789
|
-
|
|
4934
|
+
log16.error("Error loading space", {
|
|
4790
4935
|
spaceMetadata,
|
|
4791
4936
|
err
|
|
4792
4937
|
}, {
|
|
4793
|
-
F:
|
|
4794
|
-
L:
|
|
4938
|
+
F: __dxlog_file18,
|
|
4939
|
+
L: 155,
|
|
4795
4940
|
S: this,
|
|
4796
4941
|
C: (f, a) => f(...a)
|
|
4797
4942
|
});
|
|
@@ -4799,19 +4944,19 @@ var DataSpaceManager = class {
|
|
|
4799
4944
|
});
|
|
4800
4945
|
this._isOpen = true;
|
|
4801
4946
|
this.updated.emit();
|
|
4802
|
-
|
|
4947
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4803
4948
|
id: this._instanceId
|
|
4804
4949
|
}), {
|
|
4805
|
-
F:
|
|
4806
|
-
L:
|
|
4950
|
+
F: __dxlog_file18,
|
|
4951
|
+
L: 162,
|
|
4807
4952
|
S: this,
|
|
4808
4953
|
C: (f, a) => f(...a)
|
|
4809
4954
|
});
|
|
4810
4955
|
}
|
|
4811
4956
|
async close() {
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4814
|
-
L:
|
|
4957
|
+
log16("close", void 0, {
|
|
4958
|
+
F: __dxlog_file18,
|
|
4959
|
+
L: 167,
|
|
4815
4960
|
S: this,
|
|
4816
4961
|
C: (f, a) => f(...a)
|
|
4817
4962
|
});
|
|
@@ -4827,8 +4972,8 @@ var DataSpaceManager = class {
|
|
|
4827
4972
|
*/
|
|
4828
4973
|
async createSpace() {
|
|
4829
4974
|
invariant14(this._isOpen, "Not open.", {
|
|
4830
|
-
F:
|
|
4831
|
-
L:
|
|
4975
|
+
F: __dxlog_file18,
|
|
4976
|
+
L: 181,
|
|
4832
4977
|
S: this,
|
|
4833
4978
|
A: [
|
|
4834
4979
|
"this._isOpen",
|
|
@@ -4845,11 +4990,11 @@ var DataSpaceManager = class {
|
|
|
4845
4990
|
dataFeedKey,
|
|
4846
4991
|
state: SpaceState3.ACTIVE
|
|
4847
4992
|
};
|
|
4848
|
-
|
|
4993
|
+
log16("creating space...", {
|
|
4849
4994
|
spaceKey
|
|
4850
4995
|
}, {
|
|
4851
|
-
F:
|
|
4852
|
-
L:
|
|
4996
|
+
F: __dxlog_file18,
|
|
4997
|
+
L: 193,
|
|
4853
4998
|
S: this,
|
|
4854
4999
|
C: (f, a) => f(...a)
|
|
4855
5000
|
});
|
|
@@ -4860,8 +5005,8 @@ var DataSpaceManager = class {
|
|
|
4860
5005
|
await this._metadataStore.addSpace(metadata);
|
|
4861
5006
|
const memberCredential = credentials[1];
|
|
4862
5007
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
5008
|
+
F: __dxlog_file18,
|
|
5009
|
+
L: 203,
|
|
4865
5010
|
S: this,
|
|
4866
5011
|
A: [
|
|
4867
5012
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4874,9 +5019,31 @@ var DataSpaceManager = class {
|
|
|
4874
5019
|
return space;
|
|
4875
5020
|
}
|
|
4876
5021
|
async isDefaultSpace(space) {
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
5022
|
+
if (!space.databaseRoot) {
|
|
5023
|
+
return false;
|
|
5024
|
+
}
|
|
5025
|
+
switch (space.databaseRoot.getVersion()) {
|
|
5026
|
+
case SpaceDocVersion2.CURRENT: {
|
|
5027
|
+
const [_, properties] = findInlineObjectOfType2(space.databaseRoot.docSync(), TYPE_PROPERTIES2) ?? [];
|
|
5028
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5029
|
+
}
|
|
5030
|
+
case SpaceDocVersion2.LEGACY: {
|
|
5031
|
+
const convertedDoc = await convertLegacyReferences2(space.databaseRoot.docSync());
|
|
5032
|
+
const [_, properties] = findInlineObjectOfType2(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
5033
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5034
|
+
}
|
|
5035
|
+
default:
|
|
5036
|
+
log16.warn("unknown space version", {
|
|
5037
|
+
version: space.databaseRoot.getVersion(),
|
|
5038
|
+
spaceId: space.id
|
|
5039
|
+
}, {
|
|
5040
|
+
F: __dxlog_file18,
|
|
5041
|
+
L: 228,
|
|
5042
|
+
S: this,
|
|
5043
|
+
C: (f, a) => f(...a)
|
|
5044
|
+
});
|
|
5045
|
+
return false;
|
|
5046
|
+
}
|
|
4880
5047
|
}
|
|
4881
5048
|
async createDefaultSpace() {
|
|
4882
5049
|
const space = await this.createSpace();
|
|
@@ -4892,7 +5059,7 @@ var DataSpaceManager = class {
|
|
|
4892
5059
|
keys: []
|
|
4893
5060
|
}
|
|
4894
5061
|
};
|
|
4895
|
-
const propertiesId =
|
|
5062
|
+
const propertiesId = generateEchoId();
|
|
4896
5063
|
document.change((doc) => {
|
|
4897
5064
|
assignDeep2(doc, [
|
|
4898
5065
|
"objects",
|
|
@@ -4905,8 +5072,8 @@ var DataSpaceManager = class {
|
|
|
4905
5072
|
async _getSpaceRootDocument(space) {
|
|
4906
5073
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
5074
|
invariant14(automergeIndex, void 0, {
|
|
4908
|
-
F:
|
|
4909
|
-
L:
|
|
5075
|
+
F: __dxlog_file18,
|
|
5076
|
+
L: 261,
|
|
4910
5077
|
S: this,
|
|
4911
5078
|
A: [
|
|
4912
5079
|
"automergeIndex",
|
|
@@ -4919,17 +5086,17 @@ var DataSpaceManager = class {
|
|
|
4919
5086
|
}
|
|
4920
5087
|
// TODO(burdon): Rename join space.
|
|
4921
5088
|
async acceptSpace(opts) {
|
|
4922
|
-
|
|
5089
|
+
log16("accept space", {
|
|
4923
5090
|
opts
|
|
4924
5091
|
}, {
|
|
4925
|
-
F:
|
|
4926
|
-
L:
|
|
5092
|
+
F: __dxlog_file18,
|
|
5093
|
+
L: 270,
|
|
4927
5094
|
S: this,
|
|
4928
5095
|
C: (f, a) => f(...a)
|
|
4929
5096
|
});
|
|
4930
5097
|
invariant14(this._isOpen, "Not open.", {
|
|
4931
|
-
F:
|
|
4932
|
-
L:
|
|
5098
|
+
F: __dxlog_file18,
|
|
5099
|
+
L: 271,
|
|
4933
5100
|
S: this,
|
|
4934
5101
|
A: [
|
|
4935
5102
|
"this._isOpen",
|
|
@@ -4937,8 +5104,8 @@ var DataSpaceManager = class {
|
|
|
4937
5104
|
]
|
|
4938
5105
|
});
|
|
4939
5106
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4940
|
-
F:
|
|
4941
|
-
L:
|
|
5107
|
+
F: __dxlog_file18,
|
|
5108
|
+
L: 272,
|
|
4942
5109
|
S: this,
|
|
4943
5110
|
A: [
|
|
4944
5111
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4964,17 +5131,17 @@ var DataSpaceManager = class {
|
|
|
4964
5131
|
* TODO(dmaretskyi): Consider removing.
|
|
4965
5132
|
*/
|
|
4966
5133
|
async waitUntilSpaceReady(spaceKey) {
|
|
4967
|
-
await
|
|
5134
|
+
await cancelWithContext6(this._ctx, this.updated.waitForCondition(() => {
|
|
4968
5135
|
const space = this._spaces.get(spaceKey);
|
|
4969
5136
|
return !!space && space.state === SpaceState3.READY;
|
|
4970
5137
|
}));
|
|
4971
5138
|
}
|
|
4972
5139
|
async _constructSpace(metadata) {
|
|
4973
|
-
|
|
5140
|
+
log16("construct space", {
|
|
4974
5141
|
metadata
|
|
4975
5142
|
}, {
|
|
4976
|
-
F:
|
|
4977
|
-
L:
|
|
5143
|
+
F: __dxlog_file18,
|
|
5144
|
+
L: 306,
|
|
4978
5145
|
S: this,
|
|
4979
5146
|
C: (f, a) => f(...a)
|
|
4980
5147
|
});
|
|
@@ -5010,9 +5177,9 @@ var DataSpaceManager = class {
|
|
|
5010
5177
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5011
5178
|
},
|
|
5012
5179
|
onAuthFailure: () => {
|
|
5013
|
-
|
|
5014
|
-
F:
|
|
5015
|
-
L:
|
|
5180
|
+
log16.warn("auth failure", void 0, {
|
|
5181
|
+
F: __dxlog_file18,
|
|
5182
|
+
L: 343,
|
|
5016
5183
|
S: this,
|
|
5017
5184
|
C: (f, a) => f(...a)
|
|
5018
5185
|
});
|
|
@@ -5041,22 +5208,22 @@ var DataSpaceManager = class {
|
|
|
5041
5208
|
signingContext: this._signingContext,
|
|
5042
5209
|
callbacks: {
|
|
5043
5210
|
beforeReady: async () => {
|
|
5044
|
-
|
|
5211
|
+
log16("before space ready", {
|
|
5045
5212
|
space: space.key
|
|
5046
5213
|
}, {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5214
|
+
F: __dxlog_file18,
|
|
5215
|
+
L: 370,
|
|
5049
5216
|
S: this,
|
|
5050
5217
|
C: (f, a) => f(...a)
|
|
5051
5218
|
});
|
|
5052
5219
|
},
|
|
5053
5220
|
afterReady: async () => {
|
|
5054
|
-
|
|
5221
|
+
log16("after space ready", {
|
|
5055
5222
|
space: space.key,
|
|
5056
5223
|
open: this._isOpen
|
|
5057
5224
|
}, {
|
|
5058
|
-
F:
|
|
5059
|
-
L:
|
|
5225
|
+
F: __dxlog_file18,
|
|
5226
|
+
L: 373,
|
|
5060
5227
|
S: this,
|
|
5061
5228
|
C: (f, a) => f(...a)
|
|
5062
5229
|
});
|
|
@@ -5071,11 +5238,11 @@ var DataSpaceManager = class {
|
|
|
5071
5238
|
}
|
|
5072
5239
|
},
|
|
5073
5240
|
beforeClose: async () => {
|
|
5074
|
-
|
|
5241
|
+
log16("before space close", {
|
|
5075
5242
|
space: space.key
|
|
5076
5243
|
}, {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5244
|
+
F: __dxlog_file18,
|
|
5245
|
+
L: 381,
|
|
5079
5246
|
S: this,
|
|
5080
5247
|
C: (f, a) => f(...a)
|
|
5081
5248
|
});
|
|
@@ -5106,17 +5273,17 @@ var DataSpaceManager = class {
|
|
|
5106
5273
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5107
5274
|
});
|
|
5108
5275
|
sessionsToClose.forEach((session) => {
|
|
5109
|
-
void session.close().catch(
|
|
5276
|
+
void session.close().catch(log16.error);
|
|
5110
5277
|
});
|
|
5111
5278
|
closedSessions += sessionsToClose.length;
|
|
5112
5279
|
}
|
|
5113
|
-
|
|
5280
|
+
log16("processed member role changes", {
|
|
5114
5281
|
roleChangeCount: memberInfo.length,
|
|
5115
5282
|
peersOnline: presence.getPeersOnline().length,
|
|
5116
5283
|
closedSessions
|
|
5117
5284
|
}, {
|
|
5118
|
-
F:
|
|
5119
|
-
L:
|
|
5285
|
+
F: __dxlog_file18,
|
|
5286
|
+
L: 417,
|
|
5120
5287
|
S: this,
|
|
5121
5288
|
C: (f, a) => f(...a)
|
|
5122
5289
|
});
|
|
@@ -5127,15 +5294,15 @@ var DataSpaceManager = class {
|
|
|
5127
5294
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5128
5295
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5129
5296
|
if (session != null) {
|
|
5130
|
-
|
|
5297
|
+
log16("closing a session with a removed peer", {
|
|
5131
5298
|
peerId: peerState.peerId
|
|
5132
5299
|
}, {
|
|
5133
|
-
F:
|
|
5134
|
-
L:
|
|
5300
|
+
F: __dxlog_file18,
|
|
5301
|
+
L: 431,
|
|
5135
5302
|
S: this,
|
|
5136
5303
|
C: (f, a) => f(...a)
|
|
5137
5304
|
});
|
|
5138
|
-
void session.close().catch(
|
|
5305
|
+
void session.close().catch(log16.error);
|
|
5139
5306
|
}
|
|
5140
5307
|
}
|
|
5141
5308
|
}
|
|
@@ -5198,11 +5365,11 @@ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentia
|
|
|
5198
5365
|
import { raise as raise2 } from "@dxos/debug";
|
|
5199
5366
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
5200
5367
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5201
|
-
import { log as
|
|
5368
|
+
import { log as log17 } from "@dxos/log";
|
|
5202
5369
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5203
5370
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5204
5371
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5205
|
-
var
|
|
5372
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5206
5373
|
var SpacesServiceImpl = class {
|
|
5207
5374
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5208
5375
|
this._identityManager = _identityManager;
|
|
@@ -5246,8 +5413,8 @@ var SpacesServiceImpl = class {
|
|
|
5246
5413
|
}
|
|
5247
5414
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5248
5415
|
invariant15(credentials[0].credential, void 0, {
|
|
5249
|
-
F:
|
|
5250
|
-
L:
|
|
5416
|
+
F: __dxlog_file19,
|
|
5417
|
+
L: 98,
|
|
5251
5418
|
S: this,
|
|
5252
5419
|
A: [
|
|
5253
5420
|
"credentials[0].credential",
|
|
@@ -5256,8 +5423,8 @@ var SpacesServiceImpl = class {
|
|
|
5256
5423
|
});
|
|
5257
5424
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5258
5425
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
-
F:
|
|
5260
|
-
L:
|
|
5426
|
+
F: __dxlog_file19,
|
|
5427
|
+
L: 100,
|
|
5261
5428
|
S: this,
|
|
5262
5429
|
A: [
|
|
5263
5430
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5271,11 +5438,11 @@ var SpacesServiceImpl = class {
|
|
|
5271
5438
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5272
5439
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5273
5440
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5274
|
-
|
|
5441
|
+
log17("update", {
|
|
5275
5442
|
spaces
|
|
5276
5443
|
}, {
|
|
5277
|
-
F:
|
|
5278
|
-
L:
|
|
5444
|
+
F: __dxlog_file19,
|
|
5445
|
+
L: 111,
|
|
5279
5446
|
S: this,
|
|
5280
5447
|
C: (f, a) => f(...a)
|
|
5281
5448
|
});
|
|
@@ -5293,7 +5460,15 @@ var SpacesServiceImpl = class {
|
|
|
5293
5460
|
const subscribeSpaces = () => {
|
|
5294
5461
|
subscriptions.clear();
|
|
5295
5462
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5296
|
-
|
|
5463
|
+
let lastState;
|
|
5464
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => {
|
|
5465
|
+
if (space.state !== lastState) {
|
|
5466
|
+
scheduler.forceTrigger();
|
|
5467
|
+
} else {
|
|
5468
|
+
scheduler.trigger();
|
|
5469
|
+
}
|
|
5470
|
+
lastState = space.state;
|
|
5471
|
+
}));
|
|
5297
5472
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5298
5473
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5299
5474
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5358,8 +5533,8 @@ var SpacesServiceImpl = class {
|
|
|
5358
5533
|
});
|
|
5359
5534
|
} else {
|
|
5360
5535
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5361
|
-
F:
|
|
5362
|
-
L:
|
|
5536
|
+
F: __dxlog_file19,
|
|
5537
|
+
L: 209,
|
|
5363
5538
|
S: this,
|
|
5364
5539
|
A: [
|
|
5365
5540
|
"!credential.id",
|
|
@@ -5367,8 +5542,8 @@ var SpacesServiceImpl = class {
|
|
|
5367
5542
|
]
|
|
5368
5543
|
});
|
|
5369
5544
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5545
|
+
F: __dxlog_file19,
|
|
5546
|
+
L: 210,
|
|
5372
5547
|
S: this,
|
|
5373
5548
|
A: [
|
|
5374
5549
|
"this._identityManager.identity",
|
|
@@ -5377,8 +5552,8 @@ var SpacesServiceImpl = class {
|
|
|
5377
5552
|
});
|
|
5378
5553
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5379
5554
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5380
|
-
F:
|
|
5381
|
-
L:
|
|
5555
|
+
F: __dxlog_file19,
|
|
5556
|
+
L: 212,
|
|
5382
5557
|
S: this,
|
|
5383
5558
|
A: [
|
|
5384
5559
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5400,10 +5575,13 @@ var SpacesServiceImpl = class {
|
|
|
5400
5575
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5401
5576
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5402
5577
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5403
|
-
await space.createEpoch({
|
|
5578
|
+
const credential = await space.createEpoch({
|
|
5404
5579
|
migration,
|
|
5405
5580
|
newAutomergeRoot: automergeRootUrl
|
|
5406
5581
|
});
|
|
5582
|
+
return {
|
|
5583
|
+
epochCredential: credential ?? void 0
|
|
5584
|
+
};
|
|
5407
5585
|
}
|
|
5408
5586
|
_serializeSpace(space) {
|
|
5409
5587
|
return {
|
|
@@ -5466,8 +5644,8 @@ var SpacesServiceImpl = class {
|
|
|
5466
5644
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5467
5645
|
|
|
5468
5646
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5469
|
-
import { Trigger as
|
|
5470
|
-
import { Context as Context10, Resource as
|
|
5647
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
5648
|
+
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5471
5649
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5472
5650
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5473
5651
|
import { EchoHost } from "@dxos/echo-db";
|
|
@@ -5476,7 +5654,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5476
5654
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5477
5655
|
import { Keyring } from "@dxos/keyring";
|
|
5478
5656
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5479
|
-
import { log as
|
|
5657
|
+
import { log as log18 } from "@dxos/log";
|
|
5480
5658
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5481
5659
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5482
5660
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5492,8 +5670,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5492
5670
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5493
5671
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5494
5672
|
}
|
|
5495
|
-
var
|
|
5496
|
-
var ServiceContext = class extends
|
|
5673
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5674
|
+
var ServiceContext = class extends Resource3 {
|
|
5497
5675
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5498
5676
|
super();
|
|
5499
5677
|
this.storage = storage;
|
|
@@ -5501,7 +5679,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5501
5679
|
this.networkManager = networkManager;
|
|
5502
5680
|
this.signalManager = signalManager;
|
|
5503
5681
|
this._runtimeParams = _runtimeParams;
|
|
5504
|
-
this.initialized = new
|
|
5682
|
+
this.initialized = new Trigger8();
|
|
5505
5683
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5506
5684
|
this._instanceId = PublicKey12.random().toHex();
|
|
5507
5685
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5527,8 +5705,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5527
5705
|
});
|
|
5528
5706
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5529
5707
|
this.echoHost = new EchoHost({
|
|
5530
|
-
kv: this.level
|
|
5531
|
-
storage: this.storage
|
|
5708
|
+
kv: this.level
|
|
5532
5709
|
});
|
|
5533
5710
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5534
5711
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -5536,17 +5713,17 @@ var ServiceContext = class extends Resource2 {
|
|
|
5536
5713
|
}
|
|
5537
5714
|
async _open(ctx) {
|
|
5538
5715
|
await this._checkStorageVersion();
|
|
5539
|
-
|
|
5540
|
-
F:
|
|
5541
|
-
L:
|
|
5716
|
+
log18("opening...", void 0, {
|
|
5717
|
+
F: __dxlog_file20,
|
|
5718
|
+
L: 149,
|
|
5542
5719
|
S: this,
|
|
5543
5720
|
C: (f, a) => f(...a)
|
|
5544
5721
|
});
|
|
5545
|
-
|
|
5722
|
+
log18.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5546
5723
|
id: this._instanceId
|
|
5547
5724
|
}), {
|
|
5548
|
-
F:
|
|
5549
|
-
L:
|
|
5725
|
+
F: __dxlog_file20,
|
|
5726
|
+
L: 150,
|
|
5550
5727
|
S: this,
|
|
5551
5728
|
C: (f, a) => f(...a)
|
|
5552
5729
|
});
|
|
@@ -5560,33 +5737,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5560
5737
|
await this._initialize(ctx);
|
|
5561
5738
|
}
|
|
5562
5739
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5563
|
-
|
|
5740
|
+
log18("loaded persistent invitations", {
|
|
5564
5741
|
count: loadedInvitations.invitations?.length
|
|
5565
5742
|
}, {
|
|
5566
|
-
F:
|
|
5567
|
-
L:
|
|
5743
|
+
F: __dxlog_file20,
|
|
5744
|
+
L: 163,
|
|
5568
5745
|
S: this,
|
|
5569
5746
|
C: (f, a) => f(...a)
|
|
5570
5747
|
});
|
|
5571
|
-
|
|
5748
|
+
log18.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5572
5749
|
id: this._instanceId
|
|
5573
5750
|
}), {
|
|
5574
|
-
F:
|
|
5575
|
-
L:
|
|
5751
|
+
F: __dxlog_file20,
|
|
5752
|
+
L: 165,
|
|
5576
5753
|
S: this,
|
|
5577
5754
|
C: (f, a) => f(...a)
|
|
5578
5755
|
});
|
|
5579
|
-
|
|
5580
|
-
F:
|
|
5581
|
-
L:
|
|
5756
|
+
log18("opened", void 0, {
|
|
5757
|
+
F: __dxlog_file20,
|
|
5758
|
+
L: 166,
|
|
5582
5759
|
S: this,
|
|
5583
5760
|
C: (f, a) => f(...a)
|
|
5584
5761
|
});
|
|
5585
5762
|
}
|
|
5586
5763
|
async _close(ctx) {
|
|
5587
|
-
|
|
5588
|
-
F:
|
|
5589
|
-
L:
|
|
5764
|
+
log18("closing...", void 0, {
|
|
5765
|
+
F: __dxlog_file20,
|
|
5766
|
+
L: 170,
|
|
5590
5767
|
S: this,
|
|
5591
5768
|
C: (f, a) => f(...a)
|
|
5592
5769
|
});
|
|
@@ -5601,9 +5778,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5601
5778
|
await this.echoHost.close(ctx);
|
|
5602
5779
|
await this.networkManager.close();
|
|
5603
5780
|
await this.signalManager.close();
|
|
5604
|
-
|
|
5605
|
-
F:
|
|
5606
|
-
L:
|
|
5781
|
+
log18("closed", void 0, {
|
|
5782
|
+
F: __dxlog_file20,
|
|
5783
|
+
L: 182,
|
|
5607
5784
|
S: this,
|
|
5608
5785
|
C: (f, a) => f(...a)
|
|
5609
5786
|
});
|
|
@@ -5616,8 +5793,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5616
5793
|
getInvitationHandler(invitation) {
|
|
5617
5794
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5618
5795
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5619
|
-
F:
|
|
5620
|
-
L:
|
|
5796
|
+
F: __dxlog_file20,
|
|
5797
|
+
L: 193,
|
|
5621
5798
|
S: this,
|
|
5622
5799
|
A: [
|
|
5623
5800
|
"factory",
|
|
@@ -5647,9 +5824,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5647
5824
|
}
|
|
5648
5825
|
// Called when identity is created.
|
|
5649
5826
|
async _initialize(ctx) {
|
|
5650
|
-
|
|
5651
|
-
F:
|
|
5652
|
-
L:
|
|
5827
|
+
log18("initializing spaces...", void 0, {
|
|
5828
|
+
F: __dxlog_file20,
|
|
5829
|
+
L: 224,
|
|
5653
5830
|
S: this,
|
|
5654
5831
|
C: (f, a) => f(...a)
|
|
5655
5832
|
});
|
|
@@ -5671,8 +5848,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5671
5848
|
await this.dataSpaceManager.open();
|
|
5672
5849
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5673
5850
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5674
|
-
F:
|
|
5675
|
-
L:
|
|
5851
|
+
F: __dxlog_file20,
|
|
5852
|
+
L: 249,
|
|
5676
5853
|
S: this,
|
|
5677
5854
|
A: [
|
|
5678
5855
|
"this.dataSpaceManager",
|
|
@@ -5692,33 +5869,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5692
5869
|
return;
|
|
5693
5870
|
}
|
|
5694
5871
|
if (!this.dataSpaceManager) {
|
|
5695
|
-
|
|
5872
|
+
log18("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5696
5873
|
details: assertion
|
|
5697
5874
|
}, {
|
|
5698
|
-
F:
|
|
5699
|
-
L:
|
|
5875
|
+
F: __dxlog_file20,
|
|
5876
|
+
L: 265,
|
|
5700
5877
|
S: this,
|
|
5701
5878
|
C: (f, a) => f(...a)
|
|
5702
5879
|
});
|
|
5703
5880
|
return;
|
|
5704
5881
|
}
|
|
5705
5882
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5706
|
-
|
|
5883
|
+
log18("space already exists, ignoring space admission", {
|
|
5707
5884
|
details: assertion
|
|
5708
5885
|
}, {
|
|
5709
|
-
F:
|
|
5710
|
-
L:
|
|
5886
|
+
F: __dxlog_file20,
|
|
5887
|
+
L: 269,
|
|
5711
5888
|
S: this,
|
|
5712
5889
|
C: (f, a) => f(...a)
|
|
5713
5890
|
});
|
|
5714
5891
|
return;
|
|
5715
5892
|
}
|
|
5716
5893
|
try {
|
|
5717
|
-
|
|
5894
|
+
log18("accepting space recorded in halo", {
|
|
5718
5895
|
details: assertion
|
|
5719
5896
|
}, {
|
|
5720
|
-
F:
|
|
5721
|
-
L:
|
|
5897
|
+
F: __dxlog_file20,
|
|
5898
|
+
L: 274,
|
|
5722
5899
|
S: this,
|
|
5723
5900
|
C: (f, a) => f(...a)
|
|
5724
5901
|
});
|
|
@@ -5727,9 +5904,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5727
5904
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5728
5905
|
});
|
|
5729
5906
|
} catch (err) {
|
|
5730
|
-
|
|
5731
|
-
F:
|
|
5732
|
-
L:
|
|
5907
|
+
log18.catch(err, void 0, {
|
|
5908
|
+
F: __dxlog_file20,
|
|
5909
|
+
L: 280,
|
|
5733
5910
|
S: this,
|
|
5734
5911
|
C: (f, a) => f(...a)
|
|
5735
5912
|
});
|
|
@@ -5775,9 +5952,9 @@ var ServiceRegistry = class {
|
|
|
5775
5952
|
};
|
|
5776
5953
|
|
|
5777
5954
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5778
|
-
import { asyncTimeout as asyncTimeout3, Trigger as
|
|
5955
|
+
import { asyncTimeout as asyncTimeout3, Trigger as Trigger9 } from "@dxos/async";
|
|
5779
5956
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5780
|
-
import { log as
|
|
5957
|
+
import { log as log19, logInfo } from "@dxos/log";
|
|
5781
5958
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5782
5959
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5783
5960
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5788,7 +5965,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5788
5965
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5789
5966
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5790
5967
|
}
|
|
5791
|
-
var
|
|
5968
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5792
5969
|
var Message;
|
|
5793
5970
|
(function(Message2) {
|
|
5794
5971
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5796,7 +5973,7 @@ var Message;
|
|
|
5796
5973
|
var Lock = class {
|
|
5797
5974
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5798
5975
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5799
|
-
this._releaseTrigger = new
|
|
5976
|
+
this._releaseTrigger = new Trigger9();
|
|
5800
5977
|
this._lockKey = lockKey;
|
|
5801
5978
|
this._onAcquire = onAcquire;
|
|
5802
5979
|
this._onRelease = onRelease;
|
|
@@ -5810,29 +5987,29 @@ var Lock = class {
|
|
|
5810
5987
|
message: "acquiring"
|
|
5811
5988
|
});
|
|
5812
5989
|
try {
|
|
5813
|
-
|
|
5814
|
-
F:
|
|
5990
|
+
log19("aquiring lock...", void 0, {
|
|
5991
|
+
F: __dxlog_file21,
|
|
5815
5992
|
L: 42,
|
|
5816
5993
|
S: this,
|
|
5817
5994
|
C: (f, a) => f(...a)
|
|
5818
5995
|
});
|
|
5819
5996
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5820
|
-
|
|
5821
|
-
F:
|
|
5997
|
+
log19("acquired lock", void 0, {
|
|
5998
|
+
F: __dxlog_file21,
|
|
5822
5999
|
L: 44,
|
|
5823
6000
|
S: this,
|
|
5824
6001
|
C: (f, a) => f(...a)
|
|
5825
6002
|
});
|
|
5826
6003
|
} catch {
|
|
5827
|
-
|
|
5828
|
-
F:
|
|
6004
|
+
log19("stealing lock...", void 0, {
|
|
6005
|
+
F: __dxlog_file21,
|
|
5829
6006
|
L: 46,
|
|
5830
6007
|
S: this,
|
|
5831
6008
|
C: (f, a) => f(...a)
|
|
5832
6009
|
});
|
|
5833
6010
|
await this._requestLock(true);
|
|
5834
|
-
|
|
5835
|
-
F:
|
|
6011
|
+
log19("stolen lock", void 0, {
|
|
6012
|
+
F: __dxlog_file21,
|
|
5836
6013
|
L: 48,
|
|
5837
6014
|
S: this,
|
|
5838
6015
|
C: (f, a) => f(...a)
|
|
@@ -5848,31 +6025,31 @@ var Lock = class {
|
|
|
5848
6025
|
}
|
|
5849
6026
|
}
|
|
5850
6027
|
async _requestLock(steal = false) {
|
|
5851
|
-
|
|
6028
|
+
log19("requesting lock...", {
|
|
5852
6029
|
steal
|
|
5853
6030
|
}, {
|
|
5854
|
-
F:
|
|
6031
|
+
F: __dxlog_file21,
|
|
5855
6032
|
L: 63,
|
|
5856
6033
|
S: this,
|
|
5857
6034
|
C: (f, a) => f(...a)
|
|
5858
6035
|
});
|
|
5859
|
-
const acquired = new
|
|
6036
|
+
const acquired = new Trigger9();
|
|
5860
6037
|
void navigator.locks.request(this._lockKey, {
|
|
5861
6038
|
steal
|
|
5862
6039
|
}, async () => {
|
|
5863
6040
|
await this._onAcquire?.();
|
|
5864
6041
|
acquired.wake();
|
|
5865
|
-
this._releaseTrigger = new
|
|
6042
|
+
this._releaseTrigger = new Trigger9();
|
|
5866
6043
|
await this._releaseTrigger.wait();
|
|
5867
|
-
|
|
5868
|
-
F:
|
|
6044
|
+
log19("releasing lock...", void 0, {
|
|
6045
|
+
F: __dxlog_file21,
|
|
5869
6046
|
L: 72,
|
|
5870
6047
|
S: this,
|
|
5871
6048
|
C: (f, a) => f(...a)
|
|
5872
6049
|
});
|
|
5873
6050
|
await this._onRelease?.();
|
|
5874
|
-
|
|
5875
|
-
F:
|
|
6051
|
+
log19("released lock", void 0, {
|
|
6052
|
+
F: __dxlog_file21,
|
|
5876
6053
|
L: 74,
|
|
5877
6054
|
S: this,
|
|
5878
6055
|
C: (f, a) => f(...a)
|
|
@@ -5881,10 +6058,10 @@ var Lock = class {
|
|
|
5881
6058
|
await this._onRelease?.();
|
|
5882
6059
|
});
|
|
5883
6060
|
await acquired.wait();
|
|
5884
|
-
|
|
6061
|
+
log19("recieved lock", {
|
|
5885
6062
|
steal
|
|
5886
6063
|
}, {
|
|
5887
|
-
F:
|
|
6064
|
+
F: __dxlog_file21,
|
|
5888
6065
|
L: 81,
|
|
5889
6066
|
S: this,
|
|
5890
6067
|
C: (f, a) => f(...a)
|
|
@@ -5978,7 +6155,7 @@ import { clientServiceBundle } from "@dxos/client-protocol";
|
|
|
5978
6155
|
import { Context as Context11 } from "@dxos/context";
|
|
5979
6156
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5980
6157
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
5981
|
-
import { log as
|
|
6158
|
+
import { log as log21 } from "@dxos/log";
|
|
5982
6159
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5983
6160
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5984
6161
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -5991,7 +6168,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
|
5991
6168
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5992
6169
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
5993
6170
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5994
|
-
var
|
|
6171
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5995
6172
|
var DevicesServiceImpl = class {
|
|
5996
6173
|
constructor(_identityManager) {
|
|
5997
6174
|
this._identityManager = _identityManager;
|
|
@@ -6009,7 +6186,7 @@ var DevicesServiceImpl = class {
|
|
|
6009
6186
|
});
|
|
6010
6187
|
} else {
|
|
6011
6188
|
invariant17(this._identityManager.identity?.presence, "presence not present", {
|
|
6012
|
-
F:
|
|
6189
|
+
F: __dxlog_file22,
|
|
6013
6190
|
L: 32,
|
|
6014
6191
|
S: this,
|
|
6015
6192
|
A: [
|
|
@@ -6119,7 +6296,7 @@ var findConfigs = () => {
|
|
|
6119
6296
|
import { Event as Event8 } from "@dxos/async";
|
|
6120
6297
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6121
6298
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6122
|
-
import { getContextFromEntry, log as
|
|
6299
|
+
import { getContextFromEntry, log as log20 } from "@dxos/log";
|
|
6123
6300
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6124
6301
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6125
6302
|
var LoggingServiceImpl = class {
|
|
@@ -6132,11 +6309,11 @@ var LoggingServiceImpl = class {
|
|
|
6132
6309
|
};
|
|
6133
6310
|
}
|
|
6134
6311
|
async open() {
|
|
6135
|
-
|
|
6312
|
+
log20.runtimeConfig.processors.push(this._logProcessor);
|
|
6136
6313
|
}
|
|
6137
6314
|
async close() {
|
|
6138
|
-
const index =
|
|
6139
|
-
|
|
6315
|
+
const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6316
|
+
log20.runtimeConfig.processors.splice(index, 1);
|
|
6140
6317
|
}
|
|
6141
6318
|
async controlMetrics({ reset, record }) {
|
|
6142
6319
|
if (reset) {
|
|
@@ -6340,7 +6517,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6340
6517
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6341
6518
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6342
6519
|
}
|
|
6343
|
-
var
|
|
6520
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6344
6521
|
var ClientServicesHost = class {
|
|
6345
6522
|
constructor({
|
|
6346
6523
|
config,
|
|
@@ -6429,7 +6606,7 @@ var ClientServicesHost = class {
|
|
|
6429
6606
|
*/
|
|
6430
6607
|
initialize({ config, ...options }) {
|
|
6431
6608
|
invariant18(!this._open, "service host is open", {
|
|
6432
|
-
F:
|
|
6609
|
+
F: __dxlog_file23,
|
|
6433
6610
|
L: 186,
|
|
6434
6611
|
S: this,
|
|
6435
6612
|
A: [
|
|
@@ -6437,15 +6614,15 @@ var ClientServicesHost = class {
|
|
|
6437
6614
|
"'service host is open'"
|
|
6438
6615
|
]
|
|
6439
6616
|
});
|
|
6440
|
-
|
|
6441
|
-
F:
|
|
6617
|
+
log21("initializing...", void 0, {
|
|
6618
|
+
F: __dxlog_file23,
|
|
6442
6619
|
L: 187,
|
|
6443
6620
|
S: this,
|
|
6444
6621
|
C: (f, a) => f(...a)
|
|
6445
6622
|
});
|
|
6446
6623
|
if (config) {
|
|
6447
6624
|
invariant18(!this._config, "config already set", {
|
|
6448
|
-
F:
|
|
6625
|
+
F: __dxlog_file23,
|
|
6449
6626
|
L: 190,
|
|
6450
6627
|
S: this,
|
|
6451
6628
|
A: [
|
|
@@ -6459,8 +6636,8 @@ var ClientServicesHost = class {
|
|
|
6459
6636
|
}
|
|
6460
6637
|
}
|
|
6461
6638
|
if (!options.signalManager) {
|
|
6462
|
-
|
|
6463
|
-
F:
|
|
6639
|
+
log21.warn("running signaling without telemetry metadata.", void 0, {
|
|
6640
|
+
F: __dxlog_file23,
|
|
6464
6641
|
L: 198,
|
|
6465
6642
|
S: this,
|
|
6466
6643
|
C: (f, a) => f(...a)
|
|
@@ -6471,7 +6648,7 @@ var ClientServicesHost = class {
|
|
|
6471
6648
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6472
6649
|
this._signalManager = signalManager;
|
|
6473
6650
|
invariant18(!this._networkManager, "network manager already set", {
|
|
6474
|
-
F:
|
|
6651
|
+
F: __dxlog_file23,
|
|
6475
6652
|
L: 209,
|
|
6476
6653
|
S: this,
|
|
6477
6654
|
A: [
|
|
@@ -6484,8 +6661,8 @@ var ClientServicesHost = class {
|
|
|
6484
6661
|
transportFactory,
|
|
6485
6662
|
signalManager
|
|
6486
6663
|
});
|
|
6487
|
-
|
|
6488
|
-
F:
|
|
6664
|
+
log21("initialized", void 0, {
|
|
6665
|
+
F: __dxlog_file23,
|
|
6489
6666
|
L: 216,
|
|
6490
6667
|
S: this,
|
|
6491
6668
|
C: (f, a) => f(...a)
|
|
@@ -6496,16 +6673,16 @@ var ClientServicesHost = class {
|
|
|
6496
6673
|
return;
|
|
6497
6674
|
}
|
|
6498
6675
|
const traceId = PublicKey16.random().toHex();
|
|
6499
|
-
|
|
6676
|
+
log21.trace("dxos.client-services.host.open", trace10.begin({
|
|
6500
6677
|
id: traceId
|
|
6501
6678
|
}), {
|
|
6502
|
-
F:
|
|
6679
|
+
F: __dxlog_file23,
|
|
6503
6680
|
L: 227,
|
|
6504
6681
|
S: this,
|
|
6505
6682
|
C: (f, a) => f(...a)
|
|
6506
6683
|
});
|
|
6507
6684
|
invariant18(this._config, "config not set", {
|
|
6508
|
-
F:
|
|
6685
|
+
F: __dxlog_file23,
|
|
6509
6686
|
L: 229,
|
|
6510
6687
|
S: this,
|
|
6511
6688
|
A: [
|
|
@@ -6514,7 +6691,7 @@ var ClientServicesHost = class {
|
|
|
6514
6691
|
]
|
|
6515
6692
|
});
|
|
6516
6693
|
invariant18(this._storage, "storage not set", {
|
|
6517
|
-
F:
|
|
6694
|
+
F: __dxlog_file23,
|
|
6518
6695
|
L: 230,
|
|
6519
6696
|
S: this,
|
|
6520
6697
|
A: [
|
|
@@ -6523,7 +6700,7 @@ var ClientServicesHost = class {
|
|
|
6523
6700
|
]
|
|
6524
6701
|
});
|
|
6525
6702
|
invariant18(this._signalManager, "signal manager not set", {
|
|
6526
|
-
F:
|
|
6703
|
+
F: __dxlog_file23,
|
|
6527
6704
|
L: 231,
|
|
6528
6705
|
S: this,
|
|
6529
6706
|
A: [
|
|
@@ -6532,7 +6709,7 @@ var ClientServicesHost = class {
|
|
|
6532
6709
|
]
|
|
6533
6710
|
});
|
|
6534
6711
|
invariant18(this._networkManager, "network manager not set", {
|
|
6535
|
-
F:
|
|
6712
|
+
F: __dxlog_file23,
|
|
6536
6713
|
L: 232,
|
|
6537
6714
|
S: this,
|
|
6538
6715
|
A: [
|
|
@@ -6541,10 +6718,10 @@ var ClientServicesHost = class {
|
|
|
6541
6718
|
]
|
|
6542
6719
|
});
|
|
6543
6720
|
this._opening = true;
|
|
6544
|
-
|
|
6721
|
+
log21("opening...", {
|
|
6545
6722
|
lockKey: this._resourceLock?.lockKey
|
|
6546
6723
|
}, {
|
|
6547
|
-
F:
|
|
6724
|
+
F: __dxlog_file23,
|
|
6548
6725
|
L: 235,
|
|
6549
6726
|
S: this,
|
|
6550
6727
|
C: (f, a) => f(...a)
|
|
@@ -6595,18 +6772,18 @@ var ClientServicesHost = class {
|
|
|
6595
6772
|
this._open = true;
|
|
6596
6773
|
this._statusUpdate.emit();
|
|
6597
6774
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6598
|
-
|
|
6775
|
+
log21("opened", {
|
|
6599
6776
|
deviceKey
|
|
6600
6777
|
}, {
|
|
6601
|
-
F:
|
|
6778
|
+
F: __dxlog_file23,
|
|
6602
6779
|
L: 314,
|
|
6603
6780
|
S: this,
|
|
6604
6781
|
C: (f, a) => f(...a)
|
|
6605
6782
|
});
|
|
6606
|
-
|
|
6783
|
+
log21.trace("dxos.client-services.host.open", trace10.end({
|
|
6607
6784
|
id: traceId
|
|
6608
6785
|
}), {
|
|
6609
|
-
F:
|
|
6786
|
+
F: __dxlog_file23,
|
|
6610
6787
|
L: 315,
|
|
6611
6788
|
S: this,
|
|
6612
6789
|
C: (f, a) => f(...a)
|
|
@@ -6617,10 +6794,10 @@ var ClientServicesHost = class {
|
|
|
6617
6794
|
return;
|
|
6618
6795
|
}
|
|
6619
6796
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6620
|
-
|
|
6797
|
+
log21("closing...", {
|
|
6621
6798
|
deviceKey
|
|
6622
6799
|
}, {
|
|
6623
|
-
F:
|
|
6800
|
+
F: __dxlog_file23,
|
|
6624
6801
|
L: 326,
|
|
6625
6802
|
S: this,
|
|
6626
6803
|
C: (f, a) => f(...a)
|
|
@@ -6635,10 +6812,10 @@ var ClientServicesHost = class {
|
|
|
6635
6812
|
await this._level?.close();
|
|
6636
6813
|
this._open = false;
|
|
6637
6814
|
this._statusUpdate.emit();
|
|
6638
|
-
|
|
6815
|
+
log21("closed", {
|
|
6639
6816
|
deviceKey
|
|
6640
6817
|
}, {
|
|
6641
|
-
F:
|
|
6818
|
+
F: __dxlog_file23,
|
|
6642
6819
|
L: 335,
|
|
6643
6820
|
S: this,
|
|
6644
6821
|
C: (f, a) => f(...a)
|
|
@@ -6646,32 +6823,32 @@ var ClientServicesHost = class {
|
|
|
6646
6823
|
}
|
|
6647
6824
|
async reset() {
|
|
6648
6825
|
const traceId = PublicKey16.random().toHex();
|
|
6649
|
-
|
|
6826
|
+
log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6650
6827
|
id: traceId
|
|
6651
6828
|
}), {
|
|
6652
|
-
F:
|
|
6829
|
+
F: __dxlog_file23,
|
|
6653
6830
|
L: 340,
|
|
6654
6831
|
S: this,
|
|
6655
6832
|
C: (f, a) => f(...a)
|
|
6656
6833
|
});
|
|
6657
|
-
|
|
6658
|
-
F:
|
|
6834
|
+
log21.info("resetting...", void 0, {
|
|
6835
|
+
F: __dxlog_file23,
|
|
6659
6836
|
L: 342,
|
|
6660
6837
|
S: this,
|
|
6661
6838
|
C: (f, a) => f(...a)
|
|
6662
6839
|
});
|
|
6663
6840
|
await this._serviceContext?.close();
|
|
6664
6841
|
await this._storage.reset();
|
|
6665
|
-
|
|
6666
|
-
F:
|
|
6842
|
+
log21.info("reset", void 0, {
|
|
6843
|
+
F: __dxlog_file23,
|
|
6667
6844
|
L: 345,
|
|
6668
6845
|
S: this,
|
|
6669
6846
|
C: (f, a) => f(...a)
|
|
6670
6847
|
});
|
|
6671
|
-
|
|
6848
|
+
log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6672
6849
|
id: traceId
|
|
6673
6850
|
}), {
|
|
6674
|
-
F:
|
|
6851
|
+
F: __dxlog_file23,
|
|
6675
6852
|
L: 346,
|
|
6676
6853
|
S: this,
|
|
6677
6854
|
C: (f, a) => f(...a)
|
|
@@ -6730,7 +6907,6 @@ export {
|
|
|
6730
6907
|
SpaceInvitationProtocol,
|
|
6731
6908
|
InvitationsManager,
|
|
6732
6909
|
DataSpace,
|
|
6733
|
-
findPropertiesObject,
|
|
6734
6910
|
DataSpaceManager,
|
|
6735
6911
|
SpacesServiceImpl,
|
|
6736
6912
|
ServiceContext,
|
|
@@ -6743,4 +6919,4 @@ export {
|
|
|
6743
6919
|
ClientServicesProviderResource,
|
|
6744
6920
|
DiagnosticsCollector
|
|
6745
6921
|
};
|
|
6746
|
-
//# sourceMappingURL=chunk-
|
|
6922
|
+
//# sourceMappingURL=chunk-PWXD5WKD.mjs.map
|