@dxos/client-services 0.5.9-main.9e81cb9 → 0.5.9-main.a50ff17
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-DJUHMW47.mjs → chunk-K6NPH6LF.mjs} +692 -537
- package/dist/lib/browser/chunk-K6NPH6LF.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 +1 -1
- package/dist/lib/node/{chunk-QKO73PFC.cjs → chunk-E6AQJD5I.cjs} +843 -691
- package/dist/lib/node/chunk-E6AQJD5I.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 +8 -8
- package/dist/types/src/packlets/identity/identity-service.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/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/identity-service.ts +33 -7
- 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 +73 -145
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +4 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-DJUHMW47.mjs.map +0 -7
- package/dist/lib/node/chunk-QKO73PFC.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.a50ff17";
|
|
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,7 +2859,7 @@ var InvitationsHandler = class {
|
|
|
2832
2859
|
};
|
|
2833
2860
|
}
|
|
2834
2861
|
_logStateUpdate(invitation, actor, newState) {
|
|
2835
|
-
|
|
2862
|
+
log10("invitation state update", {
|
|
2836
2863
|
actor: actor?.constructor.name,
|
|
2837
2864
|
newState: stateToString(newState),
|
|
2838
2865
|
oldState: stateToString(invitation.state)
|
|
@@ -2854,7 +2881,7 @@ var InvitationsHandler = class {
|
|
|
2854
2881
|
}
|
|
2855
2882
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2856
2883
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2857
|
-
|
|
2884
|
+
log10("guest waiting for authentication code...", void 0, {
|
|
2858
2885
|
F: __dxlog_file12,
|
|
2859
2886
|
L: 462,
|
|
2860
2887
|
S: this,
|
|
@@ -2862,7 +2889,7 @@ var InvitationsHandler = class {
|
|
|
2862
2889
|
});
|
|
2863
2890
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2864
2891
|
const authCode = await authenticated.wait(options);
|
|
2865
|
-
|
|
2892
|
+
log10("sending authentication request", void 0, {
|
|
2866
2893
|
F: __dxlog_file12,
|
|
2867
2894
|
L: 466,
|
|
2868
2895
|
S: this,
|
|
@@ -2879,7 +2906,7 @@ var InvitationsHandler = class {
|
|
|
2879
2906
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2880
2907
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2881
2908
|
} else {
|
|
2882
|
-
|
|
2909
|
+
log10("retrying invalid code", {
|
|
2883
2910
|
attempt
|
|
2884
2911
|
}, {
|
|
2885
2912
|
F: __dxlog_file12,
|
|
@@ -2899,7 +2926,7 @@ var InvitationsHandler = class {
|
|
|
2899
2926
|
if (introductionResponse.challenge == null) {
|
|
2900
2927
|
throw new Error("challenge missing in the introduction");
|
|
2901
2928
|
}
|
|
2902
|
-
|
|
2929
|
+
log10("sending authentication request", void 0, {
|
|
2903
2930
|
F: __dxlog_file12,
|
|
2904
2931
|
L: 496,
|
|
2905
2932
|
S: this,
|
|
@@ -3024,7 +3051,7 @@ var InvitationsServiceImpl = class {
|
|
|
3024
3051
|
import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3025
3052
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
3026
3053
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3027
|
-
import { log as
|
|
3054
|
+
import { log as log11 } from "@dxos/log";
|
|
3028
3055
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
3029
3056
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3030
3057
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -3094,7 +3121,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3094
3121
|
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
3095
3122
|
throw new AlreadyJoinedError2();
|
|
3096
3123
|
}
|
|
3097
|
-
|
|
3124
|
+
log11("writing guest credentials", {
|
|
3098
3125
|
host: this._signingContext.deviceKey,
|
|
3099
3126
|
guest: deviceKey
|
|
3100
3127
|
}, {
|
|
@@ -3162,7 +3189,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3162
3189
|
]
|
|
3163
3190
|
});
|
|
3164
3191
|
}
|
|
3165
|
-
|
|
3192
|
+
log11("writing delegate space invitation", {
|
|
3166
3193
|
host: this._signingContext.deviceKey,
|
|
3167
3194
|
id: invitation.invitationId
|
|
3168
3195
|
}, {
|
|
@@ -3223,7 +3250,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3223
3250
|
""
|
|
3224
3251
|
]
|
|
3225
3252
|
});
|
|
3226
|
-
|
|
3253
|
+
log11("cancelling delegated space invitation", {
|
|
3227
3254
|
host: this._signingContext.deviceKey,
|
|
3228
3255
|
id: invitation.invitationId
|
|
3229
3256
|
}, {
|
|
@@ -3318,14 +3345,14 @@ var SpaceInvitationProtocol = class {
|
|
|
3318
3345
|
};
|
|
3319
3346
|
|
|
3320
3347
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
3321
|
-
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as
|
|
3348
|
+
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger6 } from "@dxos/async";
|
|
3322
3349
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3323
3350
|
import { Context as Context6 } from "@dxos/context";
|
|
3324
3351
|
import { generatePasscode } from "@dxos/credentials";
|
|
3325
3352
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3326
3353
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3327
3354
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3328
|
-
import { log as
|
|
3355
|
+
import { log as log12 } from "@dxos/log";
|
|
3329
3356
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3330
3357
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3331
3358
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
@@ -3370,7 +3397,7 @@ var InvitationsManager = class {
|
|
|
3370
3397
|
try {
|
|
3371
3398
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3372
3399
|
} catch (err) {
|
|
3373
|
-
|
|
3400
|
+
log12.catch(err, void 0, {
|
|
3374
3401
|
F: __dxlog_file14,
|
|
3375
3402
|
L: 82,
|
|
3376
3403
|
S: this,
|
|
@@ -3412,7 +3439,7 @@ var InvitationsManager = class {
|
|
|
3412
3439
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3413
3440
|
};
|
|
3414
3441
|
} catch (err) {
|
|
3415
|
-
|
|
3442
|
+
log12.catch(err, void 0, {
|
|
3416
3443
|
F: __dxlog_file14,
|
|
3417
3444
|
L: 110,
|
|
3418
3445
|
S: this,
|
|
@@ -3444,7 +3471,7 @@ var InvitationsManager = class {
|
|
|
3444
3471
|
return invitation;
|
|
3445
3472
|
}
|
|
3446
3473
|
async authenticate({ invitationId, authCode }) {
|
|
3447
|
-
|
|
3474
|
+
log12("authenticating...", void 0, {
|
|
3448
3475
|
F: __dxlog_file14,
|
|
3449
3476
|
L: 140,
|
|
3450
3477
|
S: this,
|
|
@@ -3461,7 +3488,7 @@ var InvitationsManager = class {
|
|
|
3461
3488
|
});
|
|
3462
3489
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3463
3490
|
if (!observable) {
|
|
3464
|
-
|
|
3491
|
+
log12.warn("invalid invitation", {
|
|
3465
3492
|
invitationId
|
|
3466
3493
|
}, {
|
|
3467
3494
|
F: __dxlog_file14,
|
|
@@ -3474,7 +3501,7 @@ var InvitationsManager = class {
|
|
|
3474
3501
|
}
|
|
3475
3502
|
}
|
|
3476
3503
|
async cancelInvitation({ invitationId }) {
|
|
3477
|
-
|
|
3504
|
+
log12("cancelInvitation...", {
|
|
3478
3505
|
invitationId
|
|
3479
3506
|
}, {
|
|
3480
3507
|
F: __dxlog_file14,
|
|
@@ -3559,7 +3586,7 @@ var InvitationsManager = class {
|
|
|
3559
3586
|
}
|
|
3560
3587
|
});
|
|
3561
3588
|
ctx.onDispose(() => {
|
|
3562
|
-
|
|
3589
|
+
log12("complete", {
|
|
3563
3590
|
...handler.toJSON()
|
|
3564
3591
|
}, {
|
|
3565
3592
|
F: __dxlog_file14,
|
|
@@ -3587,12 +3614,12 @@ var InvitationsManager = class {
|
|
|
3587
3614
|
};
|
|
3588
3615
|
}
|
|
3589
3616
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3590
|
-
const otpEnteredTrigger = new
|
|
3617
|
+
const otpEnteredTrigger = new Trigger6();
|
|
3591
3618
|
const stream = new PushStream();
|
|
3592
3619
|
const ctx = new Context6({
|
|
3593
3620
|
onError: (err) => {
|
|
3594
3621
|
if (err instanceof TimeoutError2) {
|
|
3595
|
-
|
|
3622
|
+
log12("timeout", {
|
|
3596
3623
|
...handler.toJSON()
|
|
3597
3624
|
}, {
|
|
3598
3625
|
F: __dxlog_file14,
|
|
@@ -3605,7 +3632,7 @@ var InvitationsManager = class {
|
|
|
3605
3632
|
state: Invitation6.State.TIMEOUT
|
|
3606
3633
|
});
|
|
3607
3634
|
} else {
|
|
3608
|
-
|
|
3635
|
+
log12.warn("auth failed", err, {
|
|
3609
3636
|
F: __dxlog_file14,
|
|
3610
3637
|
L: 264,
|
|
3611
3638
|
S: this,
|
|
@@ -3620,7 +3647,7 @@ var InvitationsManager = class {
|
|
|
3620
3647
|
}
|
|
3621
3648
|
});
|
|
3622
3649
|
ctx.onDispose(() => {
|
|
3623
|
-
|
|
3650
|
+
log12("complete", {
|
|
3624
3651
|
...handler.toJSON()
|
|
3625
3652
|
}, {
|
|
3626
3653
|
F: __dxlog_file14,
|
|
@@ -3667,7 +3694,7 @@ var InvitationsManager = class {
|
|
|
3667
3694
|
try {
|
|
3668
3695
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3669
3696
|
} catch (err) {
|
|
3670
|
-
|
|
3697
|
+
log12.catch(err, void 0, {
|
|
3671
3698
|
F: __dxlog_file14,
|
|
3672
3699
|
L: 307,
|
|
3673
3700
|
S: this,
|
|
@@ -3683,33 +3710,40 @@ var InvitationsManager = class {
|
|
|
3683
3710
|
};
|
|
3684
3711
|
|
|
3685
3712
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3686
|
-
import { Event as Event6,
|
|
3713
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3687
3714
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3688
|
-
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as
|
|
3715
|
+
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
3689
3716
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3690
|
-
import {
|
|
3691
|
-
import {
|
|
3692
|
-
import { failedInvariant
|
|
3717
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3718
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3719
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3693
3720
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3694
|
-
import { log as
|
|
3721
|
+
import { log as log15 } from "@dxos/log";
|
|
3695
3722
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3696
|
-
import {
|
|
3723
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3697
3724
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3698
3725
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3699
3726
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3700
|
-
import { ComplexSet as ComplexSet5
|
|
3727
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3701
3728
|
|
|
3702
3729
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3703
3730
|
import { Event as Event4 } from "@dxos/async";
|
|
3731
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3704
3732
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3705
|
-
var AutomergeSpaceState = class {
|
|
3733
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3706
3734
|
constructor(_onNewRoot) {
|
|
3735
|
+
super();
|
|
3707
3736
|
this._onNewRoot = _onNewRoot;
|
|
3708
3737
|
this.rootUrl = void 0;
|
|
3709
3738
|
this.lastEpoch = void 0;
|
|
3710
3739
|
this.onNewEpoch = new Event4();
|
|
3711
3740
|
this._isProcessingRootDocs = false;
|
|
3712
3741
|
}
|
|
3742
|
+
async _open(ctx) {
|
|
3743
|
+
}
|
|
3744
|
+
async _close(ctx) {
|
|
3745
|
+
this._isProcessingRootDocs = false;
|
|
3746
|
+
}
|
|
3713
3747
|
async processCredential(credential) {
|
|
3714
3748
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3715
3749
|
return;
|
|
@@ -3737,16 +3771,162 @@ var AutomergeSpaceState = class {
|
|
|
3737
3771
|
}
|
|
3738
3772
|
};
|
|
3739
3773
|
|
|
3774
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3775
|
+
import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
3776
|
+
import { next as am } from "@dxos/automerge/automerge";
|
|
3777
|
+
import { cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3778
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3779
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
3780
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3781
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3782
|
+
import { log as log13 } from "@dxos/log";
|
|
3783
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3784
|
+
import { assignDeep } from "@dxos/util";
|
|
3785
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3786
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3787
|
+
switch (context.migration) {
|
|
3788
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3789
|
+
const document = context.repo.create();
|
|
3790
|
+
await context.repo.flush();
|
|
3791
|
+
return {
|
|
3792
|
+
newRoot: document.url
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3795
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3796
|
+
if (!context.currentRoot) {
|
|
3797
|
+
throw new Error("Space does not have an automerge root");
|
|
3798
|
+
}
|
|
3799
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3800
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3801
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3802
|
+
await context.repo.flush();
|
|
3803
|
+
return {
|
|
3804
|
+
newRoot: newRoot.url
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3808
|
+
log13.info("Fragmenting", void 0, {
|
|
3809
|
+
F: __dxlog_file15,
|
|
3810
|
+
L: 63,
|
|
3811
|
+
S: void 0,
|
|
3812
|
+
C: (f, a) => f(...a)
|
|
3813
|
+
});
|
|
3814
|
+
const currentRootUrl = context.currentRoot;
|
|
3815
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3816
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3817
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3818
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3819
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3820
|
+
invariant12(properties, "Properties not found", {
|
|
3821
|
+
F: __dxlog_file15,
|
|
3822
|
+
L: 73,
|
|
3823
|
+
S: void 0,
|
|
3824
|
+
A: [
|
|
3825
|
+
"properties",
|
|
3826
|
+
"'Properties not found'"
|
|
3827
|
+
]
|
|
3828
|
+
});
|
|
3829
|
+
const newSpaceDoc = {
|
|
3830
|
+
...rootHandle.docSync(),
|
|
3831
|
+
objects: Object.fromEntries([
|
|
3832
|
+
properties
|
|
3833
|
+
])
|
|
3834
|
+
};
|
|
3835
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3836
|
+
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3837
|
+
F: __dxlog_file15,
|
|
3838
|
+
L: 78,
|
|
3839
|
+
S: void 0,
|
|
3840
|
+
A: [
|
|
3841
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3842
|
+
""
|
|
3843
|
+
]
|
|
3844
|
+
});
|
|
3845
|
+
const docLoader = new AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3846
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3847
|
+
rootUrl: newRoot.url
|
|
3848
|
+
});
|
|
3849
|
+
otherObjects.forEach(([key, value]) => {
|
|
3850
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3851
|
+
handle.change((doc) => {
|
|
3852
|
+
assignDeep(doc, [
|
|
3853
|
+
"objects",
|
|
3854
|
+
key
|
|
3855
|
+
], value);
|
|
3856
|
+
});
|
|
3857
|
+
});
|
|
3858
|
+
await context.repo.flush();
|
|
3859
|
+
return {
|
|
3860
|
+
newRoot: newRoot.url
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
case CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3864
|
+
const currentRootUrl = context.currentRoot;
|
|
3865
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3866
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3867
|
+
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3868
|
+
F: __dxlog_file15,
|
|
3869
|
+
L: 100,
|
|
3870
|
+
S: void 0,
|
|
3871
|
+
A: [
|
|
3872
|
+
"rootHandle.docSync()",
|
|
3873
|
+
"'Root doc not found'"
|
|
3874
|
+
]
|
|
3875
|
+
});
|
|
3876
|
+
const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
|
|
3877
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3878
|
+
const handle = context.repo.find(url);
|
|
3879
|
+
await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
|
|
3880
|
+
invariant12(handle.docSync(), "Doc not found", {
|
|
3881
|
+
F: __dxlog_file15,
|
|
3882
|
+
L: 107,
|
|
3883
|
+
S: void 0,
|
|
3884
|
+
A: [
|
|
3885
|
+
"handle.docSync()",
|
|
3886
|
+
"'Doc not found'"
|
|
3887
|
+
]
|
|
3888
|
+
});
|
|
3889
|
+
const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
|
|
3890
|
+
const migratedDoc = migrateDocument(handle.docSync(), newDoc);
|
|
3891
|
+
const newHandle = context.repo.import(am.save(migratedDoc));
|
|
3892
|
+
newRootContent.links[id] = newHandle.url;
|
|
3893
|
+
}
|
|
3894
|
+
const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
|
|
3895
|
+
const newRoot = context.repo.import(am.save(migratedRoot));
|
|
3896
|
+
await context.repo.flush();
|
|
3897
|
+
return {
|
|
3898
|
+
newRoot: newRoot.url
|
|
3899
|
+
};
|
|
3900
|
+
}
|
|
3901
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3902
|
+
invariant12(context.newAutomergeRoot, void 0, {
|
|
3903
|
+
F: __dxlog_file15,
|
|
3904
|
+
L: 124,
|
|
3905
|
+
S: void 0,
|
|
3906
|
+
A: [
|
|
3907
|
+
"context.newAutomergeRoot",
|
|
3908
|
+
""
|
|
3909
|
+
]
|
|
3910
|
+
});
|
|
3911
|
+
await context.repo.flush();
|
|
3912
|
+
return {
|
|
3913
|
+
newRoot: context.newAutomergeRoot
|
|
3914
|
+
};
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
return {};
|
|
3918
|
+
};
|
|
3919
|
+
|
|
3740
3920
|
// 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
|
|
3921
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
|
|
3742
3922
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3743
|
-
import { invariant as
|
|
3923
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3744
3924
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3745
|
-
import { log as
|
|
3925
|
+
import { log as log14 } from "@dxos/log";
|
|
3746
3926
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3747
3927
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3748
3928
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3749
|
-
var
|
|
3929
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3750
3930
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3751
3931
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3752
3932
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3771,16 +3951,16 @@ var NotarizationPlugin = class {
|
|
|
3771
3951
|
* Request credentials to be notarized.
|
|
3772
3952
|
*/
|
|
3773
3953
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3774
|
-
|
|
3954
|
+
log14("notarize", {
|
|
3775
3955
|
credentials
|
|
3776
3956
|
}, {
|
|
3777
|
-
F:
|
|
3957
|
+
F: __dxlog_file16,
|
|
3778
3958
|
L: 90,
|
|
3779
3959
|
S: this,
|
|
3780
3960
|
C: (f, a) => f(...a)
|
|
3781
3961
|
});
|
|
3782
|
-
|
|
3783
|
-
F:
|
|
3962
|
+
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3963
|
+
F: __dxlog_file16,
|
|
3784
3964
|
L: 91,
|
|
3785
3965
|
S: this,
|
|
3786
3966
|
A: [
|
|
@@ -3788,13 +3968,13 @@ var NotarizationPlugin = class {
|
|
|
3788
3968
|
"'Credentials must have an id'"
|
|
3789
3969
|
]
|
|
3790
3970
|
});
|
|
3791
|
-
const errors = new
|
|
3971
|
+
const errors = new Trigger7();
|
|
3792
3972
|
const ctx = this._ctx.derive({
|
|
3793
3973
|
onError: (err) => {
|
|
3794
|
-
|
|
3974
|
+
log14.warn("Notarization error", {
|
|
3795
3975
|
err
|
|
3796
3976
|
}, {
|
|
3797
|
-
F:
|
|
3977
|
+
F: __dxlog_file16,
|
|
3798
3978
|
L: 99,
|
|
3799
3979
|
S: this,
|
|
3800
3980
|
C: (f, a) => f(...a)
|
|
@@ -3806,11 +3986,11 @@ var NotarizationPlugin = class {
|
|
|
3806
3986
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3807
3987
|
if (timeout !== 0) {
|
|
3808
3988
|
scheduleTask4(ctx, () => {
|
|
3809
|
-
|
|
3989
|
+
log14.warn("Notarization timeout", {
|
|
3810
3990
|
timeout,
|
|
3811
3991
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3812
3992
|
}, {
|
|
3813
|
-
F:
|
|
3993
|
+
F: __dxlog_file16,
|
|
3814
3994
|
L: 111,
|
|
3815
3995
|
S: this,
|
|
3816
3996
|
C: (f, a) => f(...a)
|
|
@@ -3830,10 +4010,10 @@ var NotarizationPlugin = class {
|
|
|
3830
4010
|
...this._extensions
|
|
3831
4011
|
].find((peer2) => !peersTried.has(peer2));
|
|
3832
4012
|
if (!peer) {
|
|
3833
|
-
|
|
4013
|
+
log14.info("Exhausted all peers to notarize with", {
|
|
3834
4014
|
retryIn: retryTimeout
|
|
3835
4015
|
}, {
|
|
3836
|
-
F:
|
|
4016
|
+
F: __dxlog_file16,
|
|
3837
4017
|
L: 136,
|
|
3838
4018
|
S: this,
|
|
3839
4019
|
C: (f, a) => f(...a)
|
|
@@ -3843,11 +4023,11 @@ var NotarizationPlugin = class {
|
|
|
3843
4023
|
return;
|
|
3844
4024
|
}
|
|
3845
4025
|
peersTried.add(peer);
|
|
3846
|
-
|
|
4026
|
+
log14("try notarizing", {
|
|
3847
4027
|
peer: peer.localPeerId,
|
|
3848
4028
|
credentialId: credentials.map((credential) => credential.id)
|
|
3849
4029
|
}, {
|
|
3850
|
-
F:
|
|
4030
|
+
F: __dxlog_file16,
|
|
3851
4031
|
L: 143,
|
|
3852
4032
|
S: this,
|
|
3853
4033
|
C: (f, a) => f(...a)
|
|
@@ -3855,17 +4035,17 @@ var NotarizationPlugin = class {
|
|
|
3855
4035
|
await peer.rpc.NotarizationService.notarize({
|
|
3856
4036
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3857
4037
|
});
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
4038
|
+
log14("success", void 0, {
|
|
4039
|
+
F: __dxlog_file16,
|
|
3860
4040
|
L: 147,
|
|
3861
4041
|
S: this,
|
|
3862
4042
|
C: (f, a) => f(...a)
|
|
3863
4043
|
});
|
|
3864
|
-
await
|
|
4044
|
+
await sleep2(successDelay);
|
|
3865
4045
|
} catch (err) {
|
|
3866
4046
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3867
|
-
|
|
3868
|
-
F:
|
|
4047
|
+
log14.info("error notarizing (recoverable)", err, {
|
|
4048
|
+
F: __dxlog_file16,
|
|
3869
4049
|
L: 151,
|
|
3870
4050
|
S: this,
|
|
3871
4051
|
C: (f, a) => f(...a)
|
|
@@ -3882,8 +4062,8 @@ var NotarizationPlugin = class {
|
|
|
3882
4062
|
allNotarized,
|
|
3883
4063
|
errors.wait()
|
|
3884
4064
|
]);
|
|
3885
|
-
|
|
3886
|
-
F:
|
|
4065
|
+
log14("done", void 0, {
|
|
4066
|
+
F: __dxlog_file16,
|
|
3887
4067
|
L: 162,
|
|
3888
4068
|
S: this,
|
|
3889
4069
|
C: (f, a) => f(...a)
|
|
@@ -3904,8 +4084,8 @@ var NotarizationPlugin = class {
|
|
|
3904
4084
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3905
4085
|
}
|
|
3906
4086
|
setWriter(writer) {
|
|
3907
|
-
|
|
3908
|
-
F:
|
|
4087
|
+
invariant13(!this._writer, "Writer already set.", {
|
|
4088
|
+
F: __dxlog_file16,
|
|
3909
4089
|
L: 181,
|
|
3910
4090
|
S: this,
|
|
3911
4091
|
A: [
|
|
@@ -3919,7 +4099,7 @@ var NotarizationPlugin = class {
|
|
|
3919
4099
|
if (this._processedCredentials.has(id)) {
|
|
3920
4100
|
return;
|
|
3921
4101
|
}
|
|
3922
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4102
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger7()).value.wait();
|
|
3923
4103
|
}
|
|
3924
4104
|
/**
|
|
3925
4105
|
* Requests from other peers to notarize credentials.
|
|
@@ -3929,8 +4109,8 @@ var NotarizationPlugin = class {
|
|
|
3929
4109
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3930
4110
|
}
|
|
3931
4111
|
for (const credential of request.credentials ?? []) {
|
|
3932
|
-
|
|
3933
|
-
F:
|
|
4112
|
+
invariant13(credential.id, "Credential must have an id", {
|
|
4113
|
+
F: __dxlog_file16,
|
|
3934
4114
|
L: 200,
|
|
3935
4115
|
S: this,
|
|
3936
4116
|
A: [
|
|
@@ -3947,10 +4127,10 @@ var NotarizationPlugin = class {
|
|
|
3947
4127
|
createExtension() {
|
|
3948
4128
|
const extension = new NotarizationTeleportExtension({
|
|
3949
4129
|
onOpen: async () => {
|
|
3950
|
-
|
|
4130
|
+
log14("extension opened", {
|
|
3951
4131
|
peer: extension.localPeerId
|
|
3952
4132
|
}, {
|
|
3953
|
-
F:
|
|
4133
|
+
F: __dxlog_file16,
|
|
3954
4134
|
L: 211,
|
|
3955
4135
|
S: this,
|
|
3956
4136
|
C: (f, a) => f(...a)
|
|
@@ -3959,10 +4139,10 @@ var NotarizationPlugin = class {
|
|
|
3959
4139
|
this._extensionOpened.emit();
|
|
3960
4140
|
},
|
|
3961
4141
|
onClose: async () => {
|
|
3962
|
-
|
|
4142
|
+
log14("extension closed", {
|
|
3963
4143
|
peer: extension.localPeerId
|
|
3964
4144
|
}, {
|
|
3965
|
-
F:
|
|
4145
|
+
F: __dxlog_file16,
|
|
3966
4146
|
L: 216,
|
|
3967
4147
|
S: this,
|
|
3968
4148
|
C: (f, a) => f(...a)
|
|
@@ -4016,7 +4196,70 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4016
4196
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4017
4197
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4018
4198
|
}
|
|
4019
|
-
|
|
4199
|
+
function _using_ctx() {
|
|
4200
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4201
|
+
var err = new Error();
|
|
4202
|
+
err.name = "SuppressedError";
|
|
4203
|
+
err.suppressed = suppressed;
|
|
4204
|
+
err.error = error;
|
|
4205
|
+
return err;
|
|
4206
|
+
}, empty = {}, stack = [];
|
|
4207
|
+
function using(isAwait, value) {
|
|
4208
|
+
if (value != null) {
|
|
4209
|
+
if (Object(value) !== value) {
|
|
4210
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4211
|
+
}
|
|
4212
|
+
if (isAwait) {
|
|
4213
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4214
|
+
}
|
|
4215
|
+
if (dispose == null) {
|
|
4216
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4217
|
+
}
|
|
4218
|
+
if (typeof dispose !== "function") {
|
|
4219
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4220
|
+
}
|
|
4221
|
+
stack.push({
|
|
4222
|
+
v: value,
|
|
4223
|
+
d: dispose,
|
|
4224
|
+
a: isAwait
|
|
4225
|
+
});
|
|
4226
|
+
} else if (isAwait) {
|
|
4227
|
+
stack.push({
|
|
4228
|
+
d: value,
|
|
4229
|
+
a: isAwait
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
4232
|
+
return value;
|
|
4233
|
+
}
|
|
4234
|
+
return {
|
|
4235
|
+
e: empty,
|
|
4236
|
+
u: using.bind(null, false),
|
|
4237
|
+
a: using.bind(null, true),
|
|
4238
|
+
d: function() {
|
|
4239
|
+
var error = this.e;
|
|
4240
|
+
function next() {
|
|
4241
|
+
while (resource = stack.pop()) {
|
|
4242
|
+
try {
|
|
4243
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4244
|
+
if (resource.a) {
|
|
4245
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4246
|
+
}
|
|
4247
|
+
} catch (e) {
|
|
4248
|
+
return err(e);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
if (error !== empty)
|
|
4252
|
+
throw error;
|
|
4253
|
+
}
|
|
4254
|
+
function err(e) {
|
|
4255
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4256
|
+
return next();
|
|
4257
|
+
}
|
|
4258
|
+
return next();
|
|
4259
|
+
}
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4020
4263
|
var DataSpace = class {
|
|
4021
4264
|
constructor(params) {
|
|
4022
4265
|
this._ctx = new Context8();
|
|
@@ -4024,7 +4267,9 @@ var DataSpace = class {
|
|
|
4024
4267
|
this._cache = void 0;
|
|
4025
4268
|
// TODO(dmaretskyi): Move into Space?
|
|
4026
4269
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4270
|
+
this._epochProcessingMutex = new Mutex2();
|
|
4027
4271
|
this._state = SpaceState2.CLOSED;
|
|
4272
|
+
this._databaseRoot = null;
|
|
4028
4273
|
/**
|
|
4029
4274
|
* Error for _state === SpaceState.ERROR.
|
|
4030
4275
|
*/
|
|
@@ -4048,11 +4293,11 @@ var DataSpace = class {
|
|
|
4048
4293
|
});
|
|
4049
4294
|
this._cache = params.cache;
|
|
4050
4295
|
this._state = params.initialState;
|
|
4051
|
-
|
|
4296
|
+
log15("new state", {
|
|
4052
4297
|
state: SpaceState2[this._state]
|
|
4053
4298
|
}, {
|
|
4054
|
-
F:
|
|
4055
|
-
L:
|
|
4299
|
+
F: __dxlog_file17,
|
|
4300
|
+
L: 146,
|
|
4056
4301
|
S: this,
|
|
4057
4302
|
C: (f, a) => f(...a)
|
|
4058
4303
|
});
|
|
@@ -4085,6 +4330,9 @@ var DataSpace = class {
|
|
|
4085
4330
|
get automergeSpaceState() {
|
|
4086
4331
|
return this._automergeSpaceState;
|
|
4087
4332
|
}
|
|
4333
|
+
get databaseRoot() {
|
|
4334
|
+
return this._databaseRoot;
|
|
4335
|
+
}
|
|
4088
4336
|
get _automergeInfo() {
|
|
4089
4337
|
return {
|
|
4090
4338
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4101,14 +4349,15 @@ var DataSpace = class {
|
|
|
4101
4349
|
await this._gossip.open();
|
|
4102
4350
|
await this._notarizationPlugin.open();
|
|
4103
4351
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4352
|
+
await this._automergeSpaceState.open();
|
|
4104
4353
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4105
4354
|
await this._inner.open(new Context8());
|
|
4106
4355
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
-
|
|
4356
|
+
log15("new state", {
|
|
4108
4357
|
state: SpaceState2[this._state]
|
|
4109
4358
|
}, {
|
|
4110
|
-
F:
|
|
4111
|
-
L:
|
|
4359
|
+
F: __dxlog_file17,
|
|
4360
|
+
L: 217,
|
|
4112
4361
|
S: this,
|
|
4113
4362
|
C: (f, a) => f(...a)
|
|
4114
4363
|
});
|
|
@@ -4122,11 +4371,11 @@ var DataSpace = class {
|
|
|
4122
4371
|
async _close() {
|
|
4123
4372
|
await this._callbacks.beforeClose?.();
|
|
4124
4373
|
this._state = SpaceState2.CLOSED;
|
|
4125
|
-
|
|
4374
|
+
log15("new state", {
|
|
4126
4375
|
state: SpaceState2[this._state]
|
|
4127
4376
|
}, {
|
|
4128
|
-
F:
|
|
4129
|
-
L:
|
|
4377
|
+
F: __dxlog_file17,
|
|
4378
|
+
L: 231,
|
|
4130
4379
|
S: this,
|
|
4131
4380
|
C: (f, a) => f(...a)
|
|
4132
4381
|
});
|
|
@@ -4135,6 +4384,7 @@ var DataSpace = class {
|
|
|
4135
4384
|
await this.authVerifier.close();
|
|
4136
4385
|
await this._inner.close();
|
|
4137
4386
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4387
|
+
await this._automergeSpaceState.close();
|
|
4138
4388
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4139
4389
|
await this._notarizationPlugin.close();
|
|
4140
4390
|
await this._presence.close();
|
|
@@ -4156,26 +4406,26 @@ var DataSpace = class {
|
|
|
4156
4406
|
await this.initializeDataPipeline();
|
|
4157
4407
|
} catch (err) {
|
|
4158
4408
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4159
|
-
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4409
|
+
log15("data pipeline initialization cancelled", err, {
|
|
4410
|
+
F: __dxlog_file17,
|
|
4411
|
+
L: 265,
|
|
4162
4412
|
S: this,
|
|
4163
4413
|
C: (f, a) => f(...a)
|
|
4164
4414
|
});
|
|
4165
4415
|
return;
|
|
4166
4416
|
}
|
|
4167
|
-
|
|
4168
|
-
F:
|
|
4169
|
-
L:
|
|
4417
|
+
log15.error("Error initializing data pipeline", err, {
|
|
4418
|
+
F: __dxlog_file17,
|
|
4419
|
+
L: 269,
|
|
4170
4420
|
S: this,
|
|
4171
4421
|
C: (f, a) => f(...a)
|
|
4172
4422
|
});
|
|
4173
4423
|
this._state = SpaceState2.ERROR;
|
|
4174
|
-
|
|
4424
|
+
log15("new state", {
|
|
4175
4425
|
state: SpaceState2[this._state]
|
|
4176
4426
|
}, {
|
|
4177
|
-
F:
|
|
4178
|
-
L:
|
|
4427
|
+
F: __dxlog_file17,
|
|
4428
|
+
L: 271,
|
|
4179
4429
|
S: this,
|
|
4180
4430
|
C: (f, a) => f(...a)
|
|
4181
4431
|
});
|
|
@@ -4191,31 +4441,28 @@ var DataSpace = class {
|
|
|
4191
4441
|
throw new SystemError("Invalid operation");
|
|
4192
4442
|
}
|
|
4193
4443
|
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
-
|
|
4444
|
+
log15("new state", {
|
|
4195
4445
|
state: SpaceState2[this._state]
|
|
4196
4446
|
}, {
|
|
4197
|
-
F:
|
|
4198
|
-
L:
|
|
4447
|
+
F: __dxlog_file17,
|
|
4448
|
+
L: 287,
|
|
4199
4449
|
S: this,
|
|
4200
4450
|
C: (f, a) => f(...a)
|
|
4201
4451
|
});
|
|
4202
4452
|
await this._initializeAndReadControlPipeline();
|
|
4203
|
-
await
|
|
4453
|
+
await sleep3(1);
|
|
4454
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4204
4455
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4205
|
-
await
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
L: 290,
|
|
4209
|
-
S: this,
|
|
4210
|
-
C: (f, a) => f(...a)
|
|
4211
|
-
});
|
|
4456
|
+
await ready;
|
|
4457
|
+
}
|
|
4458
|
+
async _enterReadyState() {
|
|
4212
4459
|
await this._callbacks.beforeReady?.();
|
|
4213
4460
|
this._state = SpaceState2.READY;
|
|
4214
|
-
|
|
4461
|
+
log15("new state", {
|
|
4215
4462
|
state: SpaceState2[this._state]
|
|
4216
4463
|
}, {
|
|
4217
|
-
F:
|
|
4218
|
-
L:
|
|
4464
|
+
F: __dxlog_file17,
|
|
4465
|
+
L: 306,
|
|
4219
4466
|
S: this,
|
|
4220
4467
|
C: (f, a) => f(...a)
|
|
4221
4468
|
});
|
|
@@ -4229,9 +4476,9 @@ var DataSpace = class {
|
|
|
4229
4476
|
});
|
|
4230
4477
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4231
4478
|
await this._createWritableFeeds();
|
|
4232
|
-
|
|
4233
|
-
F:
|
|
4234
|
-
L:
|
|
4479
|
+
log15("writable feeds created", void 0, {
|
|
4480
|
+
F: __dxlog_file17,
|
|
4481
|
+
L: 322,
|
|
4235
4482
|
S: this,
|
|
4236
4483
|
C: (f, a) => f(...a)
|
|
4237
4484
|
});
|
|
@@ -4289,12 +4536,12 @@ var DataSpace = class {
|
|
|
4289
4536
|
}
|
|
4290
4537
|
}
|
|
4291
4538
|
_onNewAutomergeRoot(rootUrl) {
|
|
4292
|
-
|
|
4539
|
+
log15("loading automerge root doc for space", {
|
|
4293
4540
|
space: this.key,
|
|
4294
4541
|
rootUrl
|
|
4295
4542
|
}, {
|
|
4296
|
-
F:
|
|
4297
|
-
L:
|
|
4543
|
+
F: __dxlog_file17,
|
|
4544
|
+
L: 388,
|
|
4298
4545
|
S: this,
|
|
4299
4546
|
C: (f, a) => f(...a)
|
|
4300
4547
|
});
|
|
@@ -4302,44 +4549,52 @@ var DataSpace = class {
|
|
|
4302
4549
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4303
4550
|
queueMicrotask(async () => {
|
|
4304
4551
|
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)
|
|
4552
|
+
try {
|
|
4553
|
+
var _usingCtx = _using_ctx();
|
|
4554
|
+
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4555
|
+
await cancelWithContext5(this._ctx, handle.whenReady());
|
|
4330
4556
|
});
|
|
4557
|
+
if (this._ctx.disposed) {
|
|
4558
|
+
return;
|
|
4559
|
+
}
|
|
4560
|
+
const _guard = (
|
|
4561
|
+
// Ensure only one root is processed at a time.
|
|
4562
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4563
|
+
);
|
|
4564
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
4565
|
+
if (!doc.access?.spaceKey) {
|
|
4566
|
+
handle.change((doc2) => {
|
|
4567
|
+
doc2.access = {
|
|
4568
|
+
spaceKey: this.key.toHex()
|
|
4569
|
+
};
|
|
4570
|
+
});
|
|
4571
|
+
}
|
|
4572
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4573
|
+
this._databaseRoot = root;
|
|
4574
|
+
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
4575
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4576
|
+
this.stateUpdate.emit();
|
|
4577
|
+
} else {
|
|
4578
|
+
if (this._state !== SpaceState2.READY) {
|
|
4579
|
+
await this._enterReadyState();
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
} catch (_) {
|
|
4583
|
+
_usingCtx.e = _;
|
|
4584
|
+
} finally {
|
|
4585
|
+
_usingCtx.d();
|
|
4331
4586
|
}
|
|
4332
4587
|
} catch (err) {
|
|
4333
4588
|
if (err instanceof ContextDisposedError3) {
|
|
4334
4589
|
return;
|
|
4335
4590
|
}
|
|
4336
|
-
|
|
4591
|
+
log15.warn("error loading automerge root doc", {
|
|
4337
4592
|
space: this.key,
|
|
4338
4593
|
rootUrl,
|
|
4339
4594
|
err
|
|
4340
4595
|
}, {
|
|
4341
|
-
F:
|
|
4342
|
-
L:
|
|
4596
|
+
F: __dxlog_file17,
|
|
4597
|
+
L: 431,
|
|
4343
4598
|
S: this,
|
|
4344
4599
|
C: (f, a) => f(...a)
|
|
4345
4600
|
});
|
|
@@ -4362,148 +4617,34 @@ var DataSpace = class {
|
|
|
4362
4617
|
});
|
|
4363
4618
|
}
|
|
4364
4619
|
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;
|
|
4620
|
+
const ctx = this._ctx.derive();
|
|
4621
|
+
if (!options?.migration) {
|
|
4622
|
+
return null;
|
|
4497
4623
|
}
|
|
4624
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4625
|
+
repo: this._echoHost.automergeRepo,
|
|
4626
|
+
spaceId: this.id,
|
|
4627
|
+
spaceKey: this.key,
|
|
4628
|
+
migration: options.migration,
|
|
4629
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4630
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4631
|
+
});
|
|
4632
|
+
const epoch = {
|
|
4633
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4634
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4635
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4636
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4637
|
+
};
|
|
4638
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4639
|
+
subject: this.key,
|
|
4640
|
+
assertion: {
|
|
4641
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4642
|
+
...epoch
|
|
4643
|
+
}
|
|
4644
|
+
});
|
|
4498
4645
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4499
4646
|
credential: {
|
|
4500
|
-
credential
|
|
4501
|
-
subject: this.key,
|
|
4502
|
-
assertion: {
|
|
4503
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4504
|
-
...epoch
|
|
4505
|
-
}
|
|
4506
|
-
})
|
|
4647
|
+
credential
|
|
4507
4648
|
}
|
|
4508
4649
|
});
|
|
4509
4650
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
@@ -4513,6 +4654,7 @@ var DataSpace = class {
|
|
|
4513
4654
|
]
|
|
4514
4655
|
]));
|
|
4515
4656
|
await this._echoHost.updateIndexes();
|
|
4657
|
+
return credential;
|
|
4516
4658
|
}
|
|
4517
4659
|
async activate() {
|
|
4518
4660
|
if (![
|
|
@@ -4534,11 +4676,11 @@ var DataSpace = class {
|
|
|
4534
4676
|
await this._close();
|
|
4535
4677
|
}
|
|
4536
4678
|
this._state = SpaceState2.INACTIVE;
|
|
4537
|
-
|
|
4679
|
+
log15("new state", {
|
|
4538
4680
|
state: SpaceState2[this._state]
|
|
4539
4681
|
}, {
|
|
4540
|
-
F:
|
|
4541
|
-
L:
|
|
4682
|
+
F: __dxlog_file17,
|
|
4683
|
+
L: 512,
|
|
4542
4684
|
S: this,
|
|
4543
4685
|
C: (f, a) => f(...a)
|
|
4544
4686
|
});
|
|
@@ -4593,36 +4735,25 @@ DataSpace = _ts_decorate4([
|
|
|
4593
4735
|
trackLeaks("open", "close"),
|
|
4594
4736
|
trace6.resource()
|
|
4595
4737
|
], 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
4738
|
|
|
4609
4739
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4610
4740
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
4741
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4612
|
-
import {
|
|
4742
|
+
import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
|
|
4613
4743
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4744
|
+
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4614
4745
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
-
import { encodeReference } from "@dxos/echo-protocol";
|
|
4616
|
-
import { getTypeReference } from "@dxos/echo-schema";
|
|
4746
|
+
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
4747
|
+
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4617
4748
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4618
4749
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4619
|
-
import { log as
|
|
4750
|
+
import { log as log16 } from "@dxos/log";
|
|
4620
4751
|
import { trace as Trace2 } from "@dxos/protocols";
|
|
4621
4752
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4622
4753
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4623
4754
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4624
4755
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4625
|
-
import {
|
|
4756
|
+
import { ComplexMap as ComplexMap3, assignDeep as assignDeep2, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4626
4757
|
|
|
4627
4758
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4628
4759
|
import { createCredential } from "@dxos/credentials";
|
|
@@ -4705,7 +4836,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4705
4836
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4706
4837
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4707
4838
|
}
|
|
4708
|
-
var
|
|
4839
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4709
4840
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4710
4841
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
4842
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4732,7 +4863,7 @@ var DataSpaceManager = class {
|
|
|
4732
4863
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4733
4864
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4734
4865
|
const rootDoc = rootHandle?.docSync();
|
|
4735
|
-
const properties = rootDoc &&
|
|
4866
|
+
const properties = rootDoc && findInlineObjectOfType2(rootDoc, TYPE_PROPERTIES2);
|
|
4736
4867
|
return {
|
|
4737
4868
|
key: space.key.toHex(),
|
|
4738
4869
|
state: SpaceState3[space.state],
|
|
@@ -4752,46 +4883,46 @@ var DataSpaceManager = class {
|
|
|
4752
4883
|
return this._spaces;
|
|
4753
4884
|
}
|
|
4754
4885
|
async open() {
|
|
4755
|
-
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4886
|
+
log16("open", void 0, {
|
|
4887
|
+
F: __dxlog_file18,
|
|
4888
|
+
L: 146,
|
|
4758
4889
|
S: this,
|
|
4759
4890
|
C: (f, a) => f(...a)
|
|
4760
4891
|
});
|
|
4761
|
-
|
|
4892
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4762
4893
|
id: this._instanceId
|
|
4763
4894
|
}), {
|
|
4764
|
-
F:
|
|
4765
|
-
L:
|
|
4895
|
+
F: __dxlog_file18,
|
|
4896
|
+
L: 147,
|
|
4766
4897
|
S: this,
|
|
4767
4898
|
C: (f, a) => f(...a)
|
|
4768
4899
|
});
|
|
4769
|
-
|
|
4900
|
+
log16("metadata loaded", {
|
|
4770
4901
|
spaces: this._metadataStore.spaces.length
|
|
4771
4902
|
}, {
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
4903
|
+
F: __dxlog_file18,
|
|
4904
|
+
L: 148,
|
|
4774
4905
|
S: this,
|
|
4775
4906
|
C: (f, a) => f(...a)
|
|
4776
4907
|
});
|
|
4777
4908
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4778
4909
|
try {
|
|
4779
|
-
|
|
4910
|
+
log16("load space", {
|
|
4780
4911
|
spaceMetadata
|
|
4781
4912
|
}, {
|
|
4782
|
-
F:
|
|
4783
|
-
L:
|
|
4913
|
+
F: __dxlog_file18,
|
|
4914
|
+
L: 152,
|
|
4784
4915
|
S: this,
|
|
4785
4916
|
C: (f, a) => f(...a)
|
|
4786
4917
|
});
|
|
4787
4918
|
await this._constructSpace(spaceMetadata);
|
|
4788
4919
|
} catch (err) {
|
|
4789
|
-
|
|
4920
|
+
log16.error("Error loading space", {
|
|
4790
4921
|
spaceMetadata,
|
|
4791
4922
|
err
|
|
4792
4923
|
}, {
|
|
4793
|
-
F:
|
|
4794
|
-
L:
|
|
4924
|
+
F: __dxlog_file18,
|
|
4925
|
+
L: 155,
|
|
4795
4926
|
S: this,
|
|
4796
4927
|
C: (f, a) => f(...a)
|
|
4797
4928
|
});
|
|
@@ -4799,19 +4930,19 @@ var DataSpaceManager = class {
|
|
|
4799
4930
|
});
|
|
4800
4931
|
this._isOpen = true;
|
|
4801
4932
|
this.updated.emit();
|
|
4802
|
-
|
|
4933
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4803
4934
|
id: this._instanceId
|
|
4804
4935
|
}), {
|
|
4805
|
-
F:
|
|
4806
|
-
L:
|
|
4936
|
+
F: __dxlog_file18,
|
|
4937
|
+
L: 162,
|
|
4807
4938
|
S: this,
|
|
4808
4939
|
C: (f, a) => f(...a)
|
|
4809
4940
|
});
|
|
4810
4941
|
}
|
|
4811
4942
|
async close() {
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4814
|
-
L:
|
|
4943
|
+
log16("close", void 0, {
|
|
4944
|
+
F: __dxlog_file18,
|
|
4945
|
+
L: 167,
|
|
4815
4946
|
S: this,
|
|
4816
4947
|
C: (f, a) => f(...a)
|
|
4817
4948
|
});
|
|
@@ -4827,8 +4958,8 @@ var DataSpaceManager = class {
|
|
|
4827
4958
|
*/
|
|
4828
4959
|
async createSpace() {
|
|
4829
4960
|
invariant14(this._isOpen, "Not open.", {
|
|
4830
|
-
F:
|
|
4831
|
-
L:
|
|
4961
|
+
F: __dxlog_file18,
|
|
4962
|
+
L: 181,
|
|
4832
4963
|
S: this,
|
|
4833
4964
|
A: [
|
|
4834
4965
|
"this._isOpen",
|
|
@@ -4845,11 +4976,11 @@ var DataSpaceManager = class {
|
|
|
4845
4976
|
dataFeedKey,
|
|
4846
4977
|
state: SpaceState3.ACTIVE
|
|
4847
4978
|
};
|
|
4848
|
-
|
|
4979
|
+
log16("creating space...", {
|
|
4849
4980
|
spaceKey
|
|
4850
4981
|
}, {
|
|
4851
|
-
F:
|
|
4852
|
-
L:
|
|
4982
|
+
F: __dxlog_file18,
|
|
4983
|
+
L: 193,
|
|
4853
4984
|
S: this,
|
|
4854
4985
|
C: (f, a) => f(...a)
|
|
4855
4986
|
});
|
|
@@ -4860,8 +4991,8 @@ var DataSpaceManager = class {
|
|
|
4860
4991
|
await this._metadataStore.addSpace(metadata);
|
|
4861
4992
|
const memberCredential = credentials[1];
|
|
4862
4993
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
4994
|
+
F: __dxlog_file18,
|
|
4995
|
+
L: 203,
|
|
4865
4996
|
S: this,
|
|
4866
4997
|
A: [
|
|
4867
4998
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4874,9 +5005,31 @@ var DataSpaceManager = class {
|
|
|
4874
5005
|
return space;
|
|
4875
5006
|
}
|
|
4876
5007
|
async isDefaultSpace(space) {
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
5008
|
+
if (!space.databaseRoot) {
|
|
5009
|
+
return false;
|
|
5010
|
+
}
|
|
5011
|
+
switch (space.databaseRoot.getVersion()) {
|
|
5012
|
+
case SpaceDocVersion2.CURRENT: {
|
|
5013
|
+
const [_, properties] = findInlineObjectOfType2(space.databaseRoot.docSync(), TYPE_PROPERTIES2) ?? [];
|
|
5014
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5015
|
+
}
|
|
5016
|
+
case SpaceDocVersion2.LEGACY: {
|
|
5017
|
+
const convertedDoc = await convertLegacyReferences2(space.databaseRoot.docSync());
|
|
5018
|
+
const [_, properties] = findInlineObjectOfType2(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
5019
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5020
|
+
}
|
|
5021
|
+
default:
|
|
5022
|
+
log16.warn("unknown space version", {
|
|
5023
|
+
version: space.databaseRoot.getVersion(),
|
|
5024
|
+
spaceId: space.id
|
|
5025
|
+
}, {
|
|
5026
|
+
F: __dxlog_file18,
|
|
5027
|
+
L: 228,
|
|
5028
|
+
S: this,
|
|
5029
|
+
C: (f, a) => f(...a)
|
|
5030
|
+
});
|
|
5031
|
+
return false;
|
|
5032
|
+
}
|
|
4880
5033
|
}
|
|
4881
5034
|
async createDefaultSpace() {
|
|
4882
5035
|
const space = await this.createSpace();
|
|
@@ -4892,7 +5045,7 @@ var DataSpaceManager = class {
|
|
|
4892
5045
|
keys: []
|
|
4893
5046
|
}
|
|
4894
5047
|
};
|
|
4895
|
-
const propertiesId =
|
|
5048
|
+
const propertiesId = generateEchoId();
|
|
4896
5049
|
document.change((doc) => {
|
|
4897
5050
|
assignDeep2(doc, [
|
|
4898
5051
|
"objects",
|
|
@@ -4905,8 +5058,8 @@ var DataSpaceManager = class {
|
|
|
4905
5058
|
async _getSpaceRootDocument(space) {
|
|
4906
5059
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
5060
|
invariant14(automergeIndex, void 0, {
|
|
4908
|
-
F:
|
|
4909
|
-
L:
|
|
5061
|
+
F: __dxlog_file18,
|
|
5062
|
+
L: 261,
|
|
4910
5063
|
S: this,
|
|
4911
5064
|
A: [
|
|
4912
5065
|
"automergeIndex",
|
|
@@ -4919,17 +5072,17 @@ var DataSpaceManager = class {
|
|
|
4919
5072
|
}
|
|
4920
5073
|
// TODO(burdon): Rename join space.
|
|
4921
5074
|
async acceptSpace(opts) {
|
|
4922
|
-
|
|
5075
|
+
log16("accept space", {
|
|
4923
5076
|
opts
|
|
4924
5077
|
}, {
|
|
4925
|
-
F:
|
|
4926
|
-
L:
|
|
5078
|
+
F: __dxlog_file18,
|
|
5079
|
+
L: 270,
|
|
4927
5080
|
S: this,
|
|
4928
5081
|
C: (f, a) => f(...a)
|
|
4929
5082
|
});
|
|
4930
5083
|
invariant14(this._isOpen, "Not open.", {
|
|
4931
|
-
F:
|
|
4932
|
-
L:
|
|
5084
|
+
F: __dxlog_file18,
|
|
5085
|
+
L: 271,
|
|
4933
5086
|
S: this,
|
|
4934
5087
|
A: [
|
|
4935
5088
|
"this._isOpen",
|
|
@@ -4937,8 +5090,8 @@ var DataSpaceManager = class {
|
|
|
4937
5090
|
]
|
|
4938
5091
|
});
|
|
4939
5092
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4940
|
-
F:
|
|
4941
|
-
L:
|
|
5093
|
+
F: __dxlog_file18,
|
|
5094
|
+
L: 272,
|
|
4942
5095
|
S: this,
|
|
4943
5096
|
A: [
|
|
4944
5097
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4964,17 +5117,17 @@ var DataSpaceManager = class {
|
|
|
4964
5117
|
* TODO(dmaretskyi): Consider removing.
|
|
4965
5118
|
*/
|
|
4966
5119
|
async waitUntilSpaceReady(spaceKey) {
|
|
4967
|
-
await
|
|
5120
|
+
await cancelWithContext6(this._ctx, this.updated.waitForCondition(() => {
|
|
4968
5121
|
const space = this._spaces.get(spaceKey);
|
|
4969
5122
|
return !!space && space.state === SpaceState3.READY;
|
|
4970
5123
|
}));
|
|
4971
5124
|
}
|
|
4972
5125
|
async _constructSpace(metadata) {
|
|
4973
|
-
|
|
5126
|
+
log16("construct space", {
|
|
4974
5127
|
metadata
|
|
4975
5128
|
}, {
|
|
4976
|
-
F:
|
|
4977
|
-
L:
|
|
5129
|
+
F: __dxlog_file18,
|
|
5130
|
+
L: 306,
|
|
4978
5131
|
S: this,
|
|
4979
5132
|
C: (f, a) => f(...a)
|
|
4980
5133
|
});
|
|
@@ -5010,9 +5163,9 @@ var DataSpaceManager = class {
|
|
|
5010
5163
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5011
5164
|
},
|
|
5012
5165
|
onAuthFailure: () => {
|
|
5013
|
-
|
|
5014
|
-
F:
|
|
5015
|
-
L:
|
|
5166
|
+
log16.warn("auth failure", void 0, {
|
|
5167
|
+
F: __dxlog_file18,
|
|
5168
|
+
L: 343,
|
|
5016
5169
|
S: this,
|
|
5017
5170
|
C: (f, a) => f(...a)
|
|
5018
5171
|
});
|
|
@@ -5041,22 +5194,22 @@ var DataSpaceManager = class {
|
|
|
5041
5194
|
signingContext: this._signingContext,
|
|
5042
5195
|
callbacks: {
|
|
5043
5196
|
beforeReady: async () => {
|
|
5044
|
-
|
|
5197
|
+
log16("before space ready", {
|
|
5045
5198
|
space: space.key
|
|
5046
5199
|
}, {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5200
|
+
F: __dxlog_file18,
|
|
5201
|
+
L: 370,
|
|
5049
5202
|
S: this,
|
|
5050
5203
|
C: (f, a) => f(...a)
|
|
5051
5204
|
});
|
|
5052
5205
|
},
|
|
5053
5206
|
afterReady: async () => {
|
|
5054
|
-
|
|
5207
|
+
log16("after space ready", {
|
|
5055
5208
|
space: space.key,
|
|
5056
5209
|
open: this._isOpen
|
|
5057
5210
|
}, {
|
|
5058
|
-
F:
|
|
5059
|
-
L:
|
|
5211
|
+
F: __dxlog_file18,
|
|
5212
|
+
L: 373,
|
|
5060
5213
|
S: this,
|
|
5061
5214
|
C: (f, a) => f(...a)
|
|
5062
5215
|
});
|
|
@@ -5071,11 +5224,11 @@ var DataSpaceManager = class {
|
|
|
5071
5224
|
}
|
|
5072
5225
|
},
|
|
5073
5226
|
beforeClose: async () => {
|
|
5074
|
-
|
|
5227
|
+
log16("before space close", {
|
|
5075
5228
|
space: space.key
|
|
5076
5229
|
}, {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5230
|
+
F: __dxlog_file18,
|
|
5231
|
+
L: 381,
|
|
5079
5232
|
S: this,
|
|
5080
5233
|
C: (f, a) => f(...a)
|
|
5081
5234
|
});
|
|
@@ -5106,17 +5259,17 @@ var DataSpaceManager = class {
|
|
|
5106
5259
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5107
5260
|
});
|
|
5108
5261
|
sessionsToClose.forEach((session) => {
|
|
5109
|
-
void session.close().catch(
|
|
5262
|
+
void session.close().catch(log16.error);
|
|
5110
5263
|
});
|
|
5111
5264
|
closedSessions += sessionsToClose.length;
|
|
5112
5265
|
}
|
|
5113
|
-
|
|
5266
|
+
log16("processed member role changes", {
|
|
5114
5267
|
roleChangeCount: memberInfo.length,
|
|
5115
5268
|
peersOnline: presence.getPeersOnline().length,
|
|
5116
5269
|
closedSessions
|
|
5117
5270
|
}, {
|
|
5118
|
-
F:
|
|
5119
|
-
L:
|
|
5271
|
+
F: __dxlog_file18,
|
|
5272
|
+
L: 417,
|
|
5120
5273
|
S: this,
|
|
5121
5274
|
C: (f, a) => f(...a)
|
|
5122
5275
|
});
|
|
@@ -5127,15 +5280,15 @@ var DataSpaceManager = class {
|
|
|
5127
5280
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5128
5281
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5129
5282
|
if (session != null) {
|
|
5130
|
-
|
|
5283
|
+
log16("closing a session with a removed peer", {
|
|
5131
5284
|
peerId: peerState.peerId
|
|
5132
5285
|
}, {
|
|
5133
|
-
F:
|
|
5134
|
-
L:
|
|
5286
|
+
F: __dxlog_file18,
|
|
5287
|
+
L: 431,
|
|
5135
5288
|
S: this,
|
|
5136
5289
|
C: (f, a) => f(...a)
|
|
5137
5290
|
});
|
|
5138
|
-
void session.close().catch(
|
|
5291
|
+
void session.close().catch(log16.error);
|
|
5139
5292
|
}
|
|
5140
5293
|
}
|
|
5141
5294
|
}
|
|
@@ -5198,11 +5351,11 @@ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentia
|
|
|
5198
5351
|
import { raise as raise2 } from "@dxos/debug";
|
|
5199
5352
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
5200
5353
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5201
|
-
import { log as
|
|
5354
|
+
import { log as log17 } from "@dxos/log";
|
|
5202
5355
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5203
5356
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5204
5357
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5205
|
-
var
|
|
5358
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5206
5359
|
var SpacesServiceImpl = class {
|
|
5207
5360
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5208
5361
|
this._identityManager = _identityManager;
|
|
@@ -5246,8 +5399,8 @@ var SpacesServiceImpl = class {
|
|
|
5246
5399
|
}
|
|
5247
5400
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5248
5401
|
invariant15(credentials[0].credential, void 0, {
|
|
5249
|
-
F:
|
|
5250
|
-
L:
|
|
5402
|
+
F: __dxlog_file19,
|
|
5403
|
+
L: 98,
|
|
5251
5404
|
S: this,
|
|
5252
5405
|
A: [
|
|
5253
5406
|
"credentials[0].credential",
|
|
@@ -5256,8 +5409,8 @@ var SpacesServiceImpl = class {
|
|
|
5256
5409
|
});
|
|
5257
5410
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5258
5411
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
-
F:
|
|
5260
|
-
L:
|
|
5412
|
+
F: __dxlog_file19,
|
|
5413
|
+
L: 100,
|
|
5261
5414
|
S: this,
|
|
5262
5415
|
A: [
|
|
5263
5416
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5271,11 +5424,11 @@ var SpacesServiceImpl = class {
|
|
|
5271
5424
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5272
5425
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5273
5426
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5274
|
-
|
|
5427
|
+
log17("update", {
|
|
5275
5428
|
spaces
|
|
5276
5429
|
}, {
|
|
5277
|
-
F:
|
|
5278
|
-
L:
|
|
5430
|
+
F: __dxlog_file19,
|
|
5431
|
+
L: 111,
|
|
5279
5432
|
S: this,
|
|
5280
5433
|
C: (f, a) => f(...a)
|
|
5281
5434
|
});
|
|
@@ -5358,8 +5511,8 @@ var SpacesServiceImpl = class {
|
|
|
5358
5511
|
});
|
|
5359
5512
|
} else {
|
|
5360
5513
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5361
|
-
F:
|
|
5362
|
-
L:
|
|
5514
|
+
F: __dxlog_file19,
|
|
5515
|
+
L: 199,
|
|
5363
5516
|
S: this,
|
|
5364
5517
|
A: [
|
|
5365
5518
|
"!credential.id",
|
|
@@ -5367,8 +5520,8 @@ var SpacesServiceImpl = class {
|
|
|
5367
5520
|
]
|
|
5368
5521
|
});
|
|
5369
5522
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5523
|
+
F: __dxlog_file19,
|
|
5524
|
+
L: 200,
|
|
5372
5525
|
S: this,
|
|
5373
5526
|
A: [
|
|
5374
5527
|
"this._identityManager.identity",
|
|
@@ -5377,8 +5530,8 @@ var SpacesServiceImpl = class {
|
|
|
5377
5530
|
});
|
|
5378
5531
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5379
5532
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5380
|
-
F:
|
|
5381
|
-
L:
|
|
5533
|
+
F: __dxlog_file19,
|
|
5534
|
+
L: 202,
|
|
5382
5535
|
S: this,
|
|
5383
5536
|
A: [
|
|
5384
5537
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5400,10 +5553,13 @@ var SpacesServiceImpl = class {
|
|
|
5400
5553
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5401
5554
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5402
5555
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5403
|
-
await space.createEpoch({
|
|
5556
|
+
const credential = await space.createEpoch({
|
|
5404
5557
|
migration,
|
|
5405
5558
|
newAutomergeRoot: automergeRootUrl
|
|
5406
5559
|
});
|
|
5560
|
+
return {
|
|
5561
|
+
epochCredential: credential ?? void 0
|
|
5562
|
+
};
|
|
5407
5563
|
}
|
|
5408
5564
|
_serializeSpace(space) {
|
|
5409
5565
|
return {
|
|
@@ -5466,8 +5622,8 @@ var SpacesServiceImpl = class {
|
|
|
5466
5622
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5467
5623
|
|
|
5468
5624
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5469
|
-
import { Trigger as
|
|
5470
|
-
import { Context as Context10, Resource as
|
|
5625
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
5626
|
+
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5471
5627
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5472
5628
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5473
5629
|
import { EchoHost } from "@dxos/echo-db";
|
|
@@ -5476,7 +5632,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5476
5632
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5477
5633
|
import { Keyring } from "@dxos/keyring";
|
|
5478
5634
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5479
|
-
import { log as
|
|
5635
|
+
import { log as log18 } from "@dxos/log";
|
|
5480
5636
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5481
5637
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5482
5638
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5492,8 +5648,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5492
5648
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5493
5649
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5494
5650
|
}
|
|
5495
|
-
var
|
|
5496
|
-
var ServiceContext = class extends
|
|
5651
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5652
|
+
var ServiceContext = class extends Resource3 {
|
|
5497
5653
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5498
5654
|
super();
|
|
5499
5655
|
this.storage = storage;
|
|
@@ -5501,7 +5657,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5501
5657
|
this.networkManager = networkManager;
|
|
5502
5658
|
this.signalManager = signalManager;
|
|
5503
5659
|
this._runtimeParams = _runtimeParams;
|
|
5504
|
-
this.initialized = new
|
|
5660
|
+
this.initialized = new Trigger8();
|
|
5505
5661
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5506
5662
|
this._instanceId = PublicKey12.random().toHex();
|
|
5507
5663
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5535,16 +5691,16 @@ var ServiceContext = class extends Resource2 {
|
|
|
5535
5691
|
}
|
|
5536
5692
|
async _open(ctx) {
|
|
5537
5693
|
await this._checkStorageVersion();
|
|
5538
|
-
|
|
5539
|
-
F:
|
|
5694
|
+
log18("opening...", void 0, {
|
|
5695
|
+
F: __dxlog_file20,
|
|
5540
5696
|
L: 149,
|
|
5541
5697
|
S: this,
|
|
5542
5698
|
C: (f, a) => f(...a)
|
|
5543
5699
|
});
|
|
5544
|
-
|
|
5700
|
+
log18.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5545
5701
|
id: this._instanceId
|
|
5546
5702
|
}), {
|
|
5547
|
-
F:
|
|
5703
|
+
F: __dxlog_file20,
|
|
5548
5704
|
L: 150,
|
|
5549
5705
|
S: this,
|
|
5550
5706
|
C: (f, a) => f(...a)
|
|
@@ -5559,32 +5715,32 @@ var ServiceContext = class extends Resource2 {
|
|
|
5559
5715
|
await this._initialize(ctx);
|
|
5560
5716
|
}
|
|
5561
5717
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5562
|
-
|
|
5718
|
+
log18("loaded persistent invitations", {
|
|
5563
5719
|
count: loadedInvitations.invitations?.length
|
|
5564
5720
|
}, {
|
|
5565
|
-
F:
|
|
5721
|
+
F: __dxlog_file20,
|
|
5566
5722
|
L: 163,
|
|
5567
5723
|
S: this,
|
|
5568
5724
|
C: (f, a) => f(...a)
|
|
5569
5725
|
});
|
|
5570
|
-
|
|
5726
|
+
log18.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5571
5727
|
id: this._instanceId
|
|
5572
5728
|
}), {
|
|
5573
|
-
F:
|
|
5729
|
+
F: __dxlog_file20,
|
|
5574
5730
|
L: 165,
|
|
5575
5731
|
S: this,
|
|
5576
5732
|
C: (f, a) => f(...a)
|
|
5577
5733
|
});
|
|
5578
|
-
|
|
5579
|
-
F:
|
|
5734
|
+
log18("opened", void 0, {
|
|
5735
|
+
F: __dxlog_file20,
|
|
5580
5736
|
L: 166,
|
|
5581
5737
|
S: this,
|
|
5582
5738
|
C: (f, a) => f(...a)
|
|
5583
5739
|
});
|
|
5584
5740
|
}
|
|
5585
5741
|
async _close(ctx) {
|
|
5586
|
-
|
|
5587
|
-
F:
|
|
5742
|
+
log18("closing...", void 0, {
|
|
5743
|
+
F: __dxlog_file20,
|
|
5588
5744
|
L: 170,
|
|
5589
5745
|
S: this,
|
|
5590
5746
|
C: (f, a) => f(...a)
|
|
@@ -5600,8 +5756,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5600
5756
|
await this.echoHost.close(ctx);
|
|
5601
5757
|
await this.networkManager.close();
|
|
5602
5758
|
await this.signalManager.close();
|
|
5603
|
-
|
|
5604
|
-
F:
|
|
5759
|
+
log18("closed", void 0, {
|
|
5760
|
+
F: __dxlog_file20,
|
|
5605
5761
|
L: 182,
|
|
5606
5762
|
S: this,
|
|
5607
5763
|
C: (f, a) => f(...a)
|
|
@@ -5615,7 +5771,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5615
5771
|
getInvitationHandler(invitation) {
|
|
5616
5772
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5617
5773
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5618
|
-
F:
|
|
5774
|
+
F: __dxlog_file20,
|
|
5619
5775
|
L: 193,
|
|
5620
5776
|
S: this,
|
|
5621
5777
|
A: [
|
|
@@ -5646,8 +5802,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5646
5802
|
}
|
|
5647
5803
|
// Called when identity is created.
|
|
5648
5804
|
async _initialize(ctx) {
|
|
5649
|
-
|
|
5650
|
-
F:
|
|
5805
|
+
log18("initializing spaces...", void 0, {
|
|
5806
|
+
F: __dxlog_file20,
|
|
5651
5807
|
L: 224,
|
|
5652
5808
|
S: this,
|
|
5653
5809
|
C: (f, a) => f(...a)
|
|
@@ -5670,7 +5826,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5670
5826
|
await this.dataSpaceManager.open();
|
|
5671
5827
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5672
5828
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5673
|
-
F:
|
|
5829
|
+
F: __dxlog_file20,
|
|
5674
5830
|
L: 249,
|
|
5675
5831
|
S: this,
|
|
5676
5832
|
A: [
|
|
@@ -5691,10 +5847,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5691
5847
|
return;
|
|
5692
5848
|
}
|
|
5693
5849
|
if (!this.dataSpaceManager) {
|
|
5694
|
-
|
|
5850
|
+
log18("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5695
5851
|
details: assertion
|
|
5696
5852
|
}, {
|
|
5697
|
-
F:
|
|
5853
|
+
F: __dxlog_file20,
|
|
5698
5854
|
L: 265,
|
|
5699
5855
|
S: this,
|
|
5700
5856
|
C: (f, a) => f(...a)
|
|
@@ -5702,10 +5858,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5702
5858
|
return;
|
|
5703
5859
|
}
|
|
5704
5860
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5705
|
-
|
|
5861
|
+
log18("space already exists, ignoring space admission", {
|
|
5706
5862
|
details: assertion
|
|
5707
5863
|
}, {
|
|
5708
|
-
F:
|
|
5864
|
+
F: __dxlog_file20,
|
|
5709
5865
|
L: 269,
|
|
5710
5866
|
S: this,
|
|
5711
5867
|
C: (f, a) => f(...a)
|
|
@@ -5713,10 +5869,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5713
5869
|
return;
|
|
5714
5870
|
}
|
|
5715
5871
|
try {
|
|
5716
|
-
|
|
5872
|
+
log18("accepting space recorded in halo", {
|
|
5717
5873
|
details: assertion
|
|
5718
5874
|
}, {
|
|
5719
|
-
F:
|
|
5875
|
+
F: __dxlog_file20,
|
|
5720
5876
|
L: 274,
|
|
5721
5877
|
S: this,
|
|
5722
5878
|
C: (f, a) => f(...a)
|
|
@@ -5726,8 +5882,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5726
5882
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5727
5883
|
});
|
|
5728
5884
|
} catch (err) {
|
|
5729
|
-
|
|
5730
|
-
F:
|
|
5885
|
+
log18.catch(err, void 0, {
|
|
5886
|
+
F: __dxlog_file20,
|
|
5731
5887
|
L: 280,
|
|
5732
5888
|
S: this,
|
|
5733
5889
|
C: (f, a) => f(...a)
|
|
@@ -5774,9 +5930,9 @@ var ServiceRegistry = class {
|
|
|
5774
5930
|
};
|
|
5775
5931
|
|
|
5776
5932
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5777
|
-
import { asyncTimeout as asyncTimeout3, Trigger as
|
|
5933
|
+
import { asyncTimeout as asyncTimeout3, Trigger as Trigger9 } from "@dxos/async";
|
|
5778
5934
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5779
|
-
import { log as
|
|
5935
|
+
import { log as log19, logInfo } from "@dxos/log";
|
|
5780
5936
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5781
5937
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5782
5938
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5787,7 +5943,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5787
5943
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5788
5944
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5789
5945
|
}
|
|
5790
|
-
var
|
|
5946
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5791
5947
|
var Message;
|
|
5792
5948
|
(function(Message2) {
|
|
5793
5949
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5795,7 +5951,7 @@ var Message;
|
|
|
5795
5951
|
var Lock = class {
|
|
5796
5952
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5797
5953
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5798
|
-
this._releaseTrigger = new
|
|
5954
|
+
this._releaseTrigger = new Trigger9();
|
|
5799
5955
|
this._lockKey = lockKey;
|
|
5800
5956
|
this._onAcquire = onAcquire;
|
|
5801
5957
|
this._onRelease = onRelease;
|
|
@@ -5809,29 +5965,29 @@ var Lock = class {
|
|
|
5809
5965
|
message: "acquiring"
|
|
5810
5966
|
});
|
|
5811
5967
|
try {
|
|
5812
|
-
|
|
5813
|
-
F:
|
|
5968
|
+
log19("aquiring lock...", void 0, {
|
|
5969
|
+
F: __dxlog_file21,
|
|
5814
5970
|
L: 42,
|
|
5815
5971
|
S: this,
|
|
5816
5972
|
C: (f, a) => f(...a)
|
|
5817
5973
|
});
|
|
5818
5974
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5819
|
-
|
|
5820
|
-
F:
|
|
5975
|
+
log19("acquired lock", void 0, {
|
|
5976
|
+
F: __dxlog_file21,
|
|
5821
5977
|
L: 44,
|
|
5822
5978
|
S: this,
|
|
5823
5979
|
C: (f, a) => f(...a)
|
|
5824
5980
|
});
|
|
5825
5981
|
} catch {
|
|
5826
|
-
|
|
5827
|
-
F:
|
|
5982
|
+
log19("stealing lock...", void 0, {
|
|
5983
|
+
F: __dxlog_file21,
|
|
5828
5984
|
L: 46,
|
|
5829
5985
|
S: this,
|
|
5830
5986
|
C: (f, a) => f(...a)
|
|
5831
5987
|
});
|
|
5832
5988
|
await this._requestLock(true);
|
|
5833
|
-
|
|
5834
|
-
F:
|
|
5989
|
+
log19("stolen lock", void 0, {
|
|
5990
|
+
F: __dxlog_file21,
|
|
5835
5991
|
L: 48,
|
|
5836
5992
|
S: this,
|
|
5837
5993
|
C: (f, a) => f(...a)
|
|
@@ -5847,31 +6003,31 @@ var Lock = class {
|
|
|
5847
6003
|
}
|
|
5848
6004
|
}
|
|
5849
6005
|
async _requestLock(steal = false) {
|
|
5850
|
-
|
|
6006
|
+
log19("requesting lock...", {
|
|
5851
6007
|
steal
|
|
5852
6008
|
}, {
|
|
5853
|
-
F:
|
|
6009
|
+
F: __dxlog_file21,
|
|
5854
6010
|
L: 63,
|
|
5855
6011
|
S: this,
|
|
5856
6012
|
C: (f, a) => f(...a)
|
|
5857
6013
|
});
|
|
5858
|
-
const acquired = new
|
|
6014
|
+
const acquired = new Trigger9();
|
|
5859
6015
|
void navigator.locks.request(this._lockKey, {
|
|
5860
6016
|
steal
|
|
5861
6017
|
}, async () => {
|
|
5862
6018
|
await this._onAcquire?.();
|
|
5863
6019
|
acquired.wake();
|
|
5864
|
-
this._releaseTrigger = new
|
|
6020
|
+
this._releaseTrigger = new Trigger9();
|
|
5865
6021
|
await this._releaseTrigger.wait();
|
|
5866
|
-
|
|
5867
|
-
F:
|
|
6022
|
+
log19("releasing lock...", void 0, {
|
|
6023
|
+
F: __dxlog_file21,
|
|
5868
6024
|
L: 72,
|
|
5869
6025
|
S: this,
|
|
5870
6026
|
C: (f, a) => f(...a)
|
|
5871
6027
|
});
|
|
5872
6028
|
await this._onRelease?.();
|
|
5873
|
-
|
|
5874
|
-
F:
|
|
6029
|
+
log19("released lock", void 0, {
|
|
6030
|
+
F: __dxlog_file21,
|
|
5875
6031
|
L: 74,
|
|
5876
6032
|
S: this,
|
|
5877
6033
|
C: (f, a) => f(...a)
|
|
@@ -5880,10 +6036,10 @@ var Lock = class {
|
|
|
5880
6036
|
await this._onRelease?.();
|
|
5881
6037
|
});
|
|
5882
6038
|
await acquired.wait();
|
|
5883
|
-
|
|
6039
|
+
log19("recieved lock", {
|
|
5884
6040
|
steal
|
|
5885
6041
|
}, {
|
|
5886
|
-
F:
|
|
6042
|
+
F: __dxlog_file21,
|
|
5887
6043
|
L: 81,
|
|
5888
6044
|
S: this,
|
|
5889
6045
|
C: (f, a) => f(...a)
|
|
@@ -5977,7 +6133,7 @@ import { clientServiceBundle } from "@dxos/client-protocol";
|
|
|
5977
6133
|
import { Context as Context11 } from "@dxos/context";
|
|
5978
6134
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5979
6135
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
5980
|
-
import { log as
|
|
6136
|
+
import { log as log21 } from "@dxos/log";
|
|
5981
6137
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5982
6138
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5983
6139
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -5990,7 +6146,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
|
5990
6146
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5991
6147
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
5992
6148
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5993
|
-
var
|
|
6149
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5994
6150
|
var DevicesServiceImpl = class {
|
|
5995
6151
|
constructor(_identityManager) {
|
|
5996
6152
|
this._identityManager = _identityManager;
|
|
@@ -6008,7 +6164,7 @@ var DevicesServiceImpl = class {
|
|
|
6008
6164
|
});
|
|
6009
6165
|
} else {
|
|
6010
6166
|
invariant17(this._identityManager.identity?.presence, "presence not present", {
|
|
6011
|
-
F:
|
|
6167
|
+
F: __dxlog_file22,
|
|
6012
6168
|
L: 32,
|
|
6013
6169
|
S: this,
|
|
6014
6170
|
A: [
|
|
@@ -6118,7 +6274,7 @@ var findConfigs = () => {
|
|
|
6118
6274
|
import { Event as Event8 } from "@dxos/async";
|
|
6119
6275
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6120
6276
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6121
|
-
import { getContextFromEntry, log as
|
|
6277
|
+
import { getContextFromEntry, log as log20 } from "@dxos/log";
|
|
6122
6278
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6123
6279
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6124
6280
|
var LoggingServiceImpl = class {
|
|
@@ -6131,11 +6287,11 @@ var LoggingServiceImpl = class {
|
|
|
6131
6287
|
};
|
|
6132
6288
|
}
|
|
6133
6289
|
async open() {
|
|
6134
|
-
|
|
6290
|
+
log20.runtimeConfig.processors.push(this._logProcessor);
|
|
6135
6291
|
}
|
|
6136
6292
|
async close() {
|
|
6137
|
-
const index =
|
|
6138
|
-
|
|
6293
|
+
const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6294
|
+
log20.runtimeConfig.processors.splice(index, 1);
|
|
6139
6295
|
}
|
|
6140
6296
|
async controlMetrics({ reset, record }) {
|
|
6141
6297
|
if (reset) {
|
|
@@ -6339,7 +6495,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6339
6495
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6340
6496
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6341
6497
|
}
|
|
6342
|
-
var
|
|
6498
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6343
6499
|
var ClientServicesHost = class {
|
|
6344
6500
|
constructor({
|
|
6345
6501
|
config,
|
|
@@ -6428,7 +6584,7 @@ var ClientServicesHost = class {
|
|
|
6428
6584
|
*/
|
|
6429
6585
|
initialize({ config, ...options }) {
|
|
6430
6586
|
invariant18(!this._open, "service host is open", {
|
|
6431
|
-
F:
|
|
6587
|
+
F: __dxlog_file23,
|
|
6432
6588
|
L: 186,
|
|
6433
6589
|
S: this,
|
|
6434
6590
|
A: [
|
|
@@ -6436,15 +6592,15 @@ var ClientServicesHost = class {
|
|
|
6436
6592
|
"'service host is open'"
|
|
6437
6593
|
]
|
|
6438
6594
|
});
|
|
6439
|
-
|
|
6440
|
-
F:
|
|
6595
|
+
log21("initializing...", void 0, {
|
|
6596
|
+
F: __dxlog_file23,
|
|
6441
6597
|
L: 187,
|
|
6442
6598
|
S: this,
|
|
6443
6599
|
C: (f, a) => f(...a)
|
|
6444
6600
|
});
|
|
6445
6601
|
if (config) {
|
|
6446
6602
|
invariant18(!this._config, "config already set", {
|
|
6447
|
-
F:
|
|
6603
|
+
F: __dxlog_file23,
|
|
6448
6604
|
L: 190,
|
|
6449
6605
|
S: this,
|
|
6450
6606
|
A: [
|
|
@@ -6458,8 +6614,8 @@ var ClientServicesHost = class {
|
|
|
6458
6614
|
}
|
|
6459
6615
|
}
|
|
6460
6616
|
if (!options.signalManager) {
|
|
6461
|
-
|
|
6462
|
-
F:
|
|
6617
|
+
log21.warn("running signaling without telemetry metadata.", void 0, {
|
|
6618
|
+
F: __dxlog_file23,
|
|
6463
6619
|
L: 198,
|
|
6464
6620
|
S: this,
|
|
6465
6621
|
C: (f, a) => f(...a)
|
|
@@ -6470,7 +6626,7 @@ var ClientServicesHost = class {
|
|
|
6470
6626
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6471
6627
|
this._signalManager = signalManager;
|
|
6472
6628
|
invariant18(!this._networkManager, "network manager already set", {
|
|
6473
|
-
F:
|
|
6629
|
+
F: __dxlog_file23,
|
|
6474
6630
|
L: 209,
|
|
6475
6631
|
S: this,
|
|
6476
6632
|
A: [
|
|
@@ -6483,8 +6639,8 @@ var ClientServicesHost = class {
|
|
|
6483
6639
|
transportFactory,
|
|
6484
6640
|
signalManager
|
|
6485
6641
|
});
|
|
6486
|
-
|
|
6487
|
-
F:
|
|
6642
|
+
log21("initialized", void 0, {
|
|
6643
|
+
F: __dxlog_file23,
|
|
6488
6644
|
L: 216,
|
|
6489
6645
|
S: this,
|
|
6490
6646
|
C: (f, a) => f(...a)
|
|
@@ -6495,16 +6651,16 @@ var ClientServicesHost = class {
|
|
|
6495
6651
|
return;
|
|
6496
6652
|
}
|
|
6497
6653
|
const traceId = PublicKey16.random().toHex();
|
|
6498
|
-
|
|
6654
|
+
log21.trace("dxos.client-services.host.open", trace10.begin({
|
|
6499
6655
|
id: traceId
|
|
6500
6656
|
}), {
|
|
6501
|
-
F:
|
|
6657
|
+
F: __dxlog_file23,
|
|
6502
6658
|
L: 227,
|
|
6503
6659
|
S: this,
|
|
6504
6660
|
C: (f, a) => f(...a)
|
|
6505
6661
|
});
|
|
6506
6662
|
invariant18(this._config, "config not set", {
|
|
6507
|
-
F:
|
|
6663
|
+
F: __dxlog_file23,
|
|
6508
6664
|
L: 229,
|
|
6509
6665
|
S: this,
|
|
6510
6666
|
A: [
|
|
@@ -6513,7 +6669,7 @@ var ClientServicesHost = class {
|
|
|
6513
6669
|
]
|
|
6514
6670
|
});
|
|
6515
6671
|
invariant18(this._storage, "storage not set", {
|
|
6516
|
-
F:
|
|
6672
|
+
F: __dxlog_file23,
|
|
6517
6673
|
L: 230,
|
|
6518
6674
|
S: this,
|
|
6519
6675
|
A: [
|
|
@@ -6522,7 +6678,7 @@ var ClientServicesHost = class {
|
|
|
6522
6678
|
]
|
|
6523
6679
|
});
|
|
6524
6680
|
invariant18(this._signalManager, "signal manager not set", {
|
|
6525
|
-
F:
|
|
6681
|
+
F: __dxlog_file23,
|
|
6526
6682
|
L: 231,
|
|
6527
6683
|
S: this,
|
|
6528
6684
|
A: [
|
|
@@ -6531,7 +6687,7 @@ var ClientServicesHost = class {
|
|
|
6531
6687
|
]
|
|
6532
6688
|
});
|
|
6533
6689
|
invariant18(this._networkManager, "network manager not set", {
|
|
6534
|
-
F:
|
|
6690
|
+
F: __dxlog_file23,
|
|
6535
6691
|
L: 232,
|
|
6536
6692
|
S: this,
|
|
6537
6693
|
A: [
|
|
@@ -6540,10 +6696,10 @@ var ClientServicesHost = class {
|
|
|
6540
6696
|
]
|
|
6541
6697
|
});
|
|
6542
6698
|
this._opening = true;
|
|
6543
|
-
|
|
6699
|
+
log21("opening...", {
|
|
6544
6700
|
lockKey: this._resourceLock?.lockKey
|
|
6545
6701
|
}, {
|
|
6546
|
-
F:
|
|
6702
|
+
F: __dxlog_file23,
|
|
6547
6703
|
L: 235,
|
|
6548
6704
|
S: this,
|
|
6549
6705
|
C: (f, a) => f(...a)
|
|
@@ -6594,18 +6750,18 @@ var ClientServicesHost = class {
|
|
|
6594
6750
|
this._open = true;
|
|
6595
6751
|
this._statusUpdate.emit();
|
|
6596
6752
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6597
|
-
|
|
6753
|
+
log21("opened", {
|
|
6598
6754
|
deviceKey
|
|
6599
6755
|
}, {
|
|
6600
|
-
F:
|
|
6756
|
+
F: __dxlog_file23,
|
|
6601
6757
|
L: 314,
|
|
6602
6758
|
S: this,
|
|
6603
6759
|
C: (f, a) => f(...a)
|
|
6604
6760
|
});
|
|
6605
|
-
|
|
6761
|
+
log21.trace("dxos.client-services.host.open", trace10.end({
|
|
6606
6762
|
id: traceId
|
|
6607
6763
|
}), {
|
|
6608
|
-
F:
|
|
6764
|
+
F: __dxlog_file23,
|
|
6609
6765
|
L: 315,
|
|
6610
6766
|
S: this,
|
|
6611
6767
|
C: (f, a) => f(...a)
|
|
@@ -6616,10 +6772,10 @@ var ClientServicesHost = class {
|
|
|
6616
6772
|
return;
|
|
6617
6773
|
}
|
|
6618
6774
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6619
|
-
|
|
6775
|
+
log21("closing...", {
|
|
6620
6776
|
deviceKey
|
|
6621
6777
|
}, {
|
|
6622
|
-
F:
|
|
6778
|
+
F: __dxlog_file23,
|
|
6623
6779
|
L: 326,
|
|
6624
6780
|
S: this,
|
|
6625
6781
|
C: (f, a) => f(...a)
|
|
@@ -6634,10 +6790,10 @@ var ClientServicesHost = class {
|
|
|
6634
6790
|
await this._level?.close();
|
|
6635
6791
|
this._open = false;
|
|
6636
6792
|
this._statusUpdate.emit();
|
|
6637
|
-
|
|
6793
|
+
log21("closed", {
|
|
6638
6794
|
deviceKey
|
|
6639
6795
|
}, {
|
|
6640
|
-
F:
|
|
6796
|
+
F: __dxlog_file23,
|
|
6641
6797
|
L: 335,
|
|
6642
6798
|
S: this,
|
|
6643
6799
|
C: (f, a) => f(...a)
|
|
@@ -6645,32 +6801,32 @@ var ClientServicesHost = class {
|
|
|
6645
6801
|
}
|
|
6646
6802
|
async reset() {
|
|
6647
6803
|
const traceId = PublicKey16.random().toHex();
|
|
6648
|
-
|
|
6804
|
+
log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6649
6805
|
id: traceId
|
|
6650
6806
|
}), {
|
|
6651
|
-
F:
|
|
6807
|
+
F: __dxlog_file23,
|
|
6652
6808
|
L: 340,
|
|
6653
6809
|
S: this,
|
|
6654
6810
|
C: (f, a) => f(...a)
|
|
6655
6811
|
});
|
|
6656
|
-
|
|
6657
|
-
F:
|
|
6812
|
+
log21.info("resetting...", void 0, {
|
|
6813
|
+
F: __dxlog_file23,
|
|
6658
6814
|
L: 342,
|
|
6659
6815
|
S: this,
|
|
6660
6816
|
C: (f, a) => f(...a)
|
|
6661
6817
|
});
|
|
6662
6818
|
await this._serviceContext?.close();
|
|
6663
6819
|
await this._storage.reset();
|
|
6664
|
-
|
|
6665
|
-
F:
|
|
6820
|
+
log21.info("reset", void 0, {
|
|
6821
|
+
F: __dxlog_file23,
|
|
6666
6822
|
L: 345,
|
|
6667
6823
|
S: this,
|
|
6668
6824
|
C: (f, a) => f(...a)
|
|
6669
6825
|
});
|
|
6670
|
-
|
|
6826
|
+
log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6671
6827
|
id: traceId
|
|
6672
6828
|
}), {
|
|
6673
|
-
F:
|
|
6829
|
+
F: __dxlog_file23,
|
|
6674
6830
|
L: 346,
|
|
6675
6831
|
S: this,
|
|
6676
6832
|
C: (f, a) => f(...a)
|
|
@@ -6729,7 +6885,6 @@ export {
|
|
|
6729
6885
|
SpaceInvitationProtocol,
|
|
6730
6886
|
InvitationsManager,
|
|
6731
6887
|
DataSpace,
|
|
6732
|
-
findPropertiesObject,
|
|
6733
6888
|
DataSpaceManager,
|
|
6734
6889
|
SpacesServiceImpl,
|
|
6735
6890
|
ServiceContext,
|
|
@@ -6742,4 +6897,4 @@ export {
|
|
|
6742
6897
|
ClientServicesProviderResource,
|
|
6743
6898
|
DiagnosticsCollector
|
|
6744
6899
|
};
|
|
6745
|
-
//# sourceMappingURL=chunk-
|
|
6900
|
+
//# sourceMappingURL=chunk-K6NPH6LF.mjs.map
|