@dxos/client-services 0.3.11-main.e716c43 → 0.3.11-main.ea1c9ce
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-UF37WM4G.mjs → chunk-PVIR3NPQ.mjs} +245 -117
- package/dist/lib/browser/chunk-PVIR3NPQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- 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 +4 -11
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-HLMSSTB7.cjs → chunk-XFI5CBRW.cjs} +384 -256
- package/dist/lib/node/chunk-XFI5CBRW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- 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 +11 -18
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -0
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +28 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -0
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +32 -16
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +1 -14
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
- 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 +2 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +3 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/identity/identity-manager.ts +1 -1
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/identity/identity-service.ts +6 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +14 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +14 -0
- package/src/packlets/invitations/invitation-protocol.ts +44 -6
- package/src/packlets/invitations/invitations-handler.ts +20 -18
- package/src/packlets/invitations/space-invitation-protocol.test.ts +28 -0
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -0
- package/src/packlets/network/network-service.ts +5 -1
- package/src/packlets/services/diagnostics.ts +52 -16
- package/src/packlets/services/platform.ts +7 -19
- package/src/packlets/services/service-host.ts +27 -12
- package/src/packlets/spaces/automerge-space-state.ts +4 -0
- package/src/packlets/spaces/data-space-manager.ts +5 -1
- package/src/packlets/spaces/data-space.ts +37 -4
- package/src/packlets/spaces/spaces-service.ts +3 -3
- package/src/packlets/system/system-service.ts +7 -1
- package/src/packlets/testing/invitation-utils.ts +2 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-UF37WM4G.mjs.map +0 -7
- package/dist/lib/node/chunk-HLMSSTB7.cjs.map +0 -7
|
@@ -483,7 +483,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
483
483
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
484
484
|
}
|
|
485
485
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
486
|
-
var Identity = class
|
|
486
|
+
var Identity = class {
|
|
487
487
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
488
488
|
this.stateUpdate = new Event();
|
|
489
489
|
this.space = space;
|
|
@@ -665,7 +665,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
665
665
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
666
666
|
}
|
|
667
667
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
668
|
-
var IdentityManager = class
|
|
668
|
+
var IdentityManager = class {
|
|
669
669
|
// TODO(burdon): IdentityManagerParams.
|
|
670
670
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
671
671
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -996,7 +996,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
996
996
|
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
997
997
|
},
|
|
998
998
|
swarmIdentity,
|
|
999
|
-
|
|
999
|
+
onAuthorizedConnection: () => {
|
|
1000
1000
|
},
|
|
1001
1001
|
onAuthFailure: () => {
|
|
1002
1002
|
log3.warn("auth failure", void 0, {
|
|
@@ -1025,6 +1025,7 @@ import { signPresentation } from "@dxos/credentials";
|
|
|
1025
1025
|
import { todo } from "@dxos/debug";
|
|
1026
1026
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1027
1027
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1028
|
+
var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
|
|
1028
1029
|
var IdentityServiceImpl = class {
|
|
1029
1030
|
constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
|
|
1030
1031
|
this._createIdentity = _createIdentity;
|
|
@@ -1033,7 +1034,7 @@ var IdentityServiceImpl = class {
|
|
|
1033
1034
|
this._onProfileUpdate = _onProfileUpdate;
|
|
1034
1035
|
}
|
|
1035
1036
|
async createIdentity(request) {
|
|
1036
|
-
await this._createIdentity(request);
|
|
1037
|
+
await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
|
|
1037
1038
|
return this._getIdentity();
|
|
1038
1039
|
}
|
|
1039
1040
|
async recoverIdentity(request) {
|
|
@@ -1061,7 +1062,7 @@ var IdentityServiceImpl = class {
|
|
|
1061
1062
|
async updateProfile(profile) {
|
|
1062
1063
|
invariant3(this._identityManager.identity, "Identity not initialized.", {
|
|
1063
1064
|
F: __dxlog_file4,
|
|
1064
|
-
L:
|
|
1065
|
+
L: 63,
|
|
1065
1066
|
S: this,
|
|
1066
1067
|
A: [
|
|
1067
1068
|
"this._identityManager.identity",
|
|
@@ -1075,7 +1076,7 @@ var IdentityServiceImpl = class {
|
|
|
1075
1076
|
async signPresentation({ presentation, nonce }) {
|
|
1076
1077
|
invariant3(this._identityManager.identity, "Identity not initialized.", {
|
|
1077
1078
|
F: __dxlog_file4,
|
|
1078
|
-
L:
|
|
1079
|
+
L: 70,
|
|
1079
1080
|
S: this,
|
|
1080
1081
|
A: [
|
|
1081
1082
|
"this._identityManager.identity",
|
|
@@ -1094,6 +1095,7 @@ var IdentityServiceImpl = class {
|
|
|
1094
1095
|
|
|
1095
1096
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
1096
1097
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1098
|
+
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1097
1099
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1098
1100
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1099
1101
|
var DeviceInvitationProtocol = class {
|
|
@@ -1113,7 +1115,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1113
1115
|
async admit(request) {
|
|
1114
1116
|
invariant4(request.device, void 0, {
|
|
1115
1117
|
F: __dxlog_file5,
|
|
1116
|
-
L:
|
|
1118
|
+
L: 36,
|
|
1117
1119
|
S: this,
|
|
1118
1120
|
A: [
|
|
1119
1121
|
"request.device",
|
|
@@ -1131,6 +1133,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1131
1133
|
}
|
|
1132
1134
|
};
|
|
1133
1135
|
}
|
|
1136
|
+
checkInvitation(invitation) {
|
|
1137
|
+
try {
|
|
1138
|
+
const identity = this._getIdentity();
|
|
1139
|
+
if (identity) {
|
|
1140
|
+
return new AlreadyJoinedError("Currently only one identity per client is supported.");
|
|
1141
|
+
}
|
|
1142
|
+
} catch {
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1134
1145
|
createIntroduction() {
|
|
1135
1146
|
return {};
|
|
1136
1147
|
}
|
|
@@ -1149,7 +1160,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1149
1160
|
async accept(response, request) {
|
|
1150
1161
|
invariant4(response.device, void 0, {
|
|
1151
1162
|
F: __dxlog_file5,
|
|
1152
|
-
L:
|
|
1163
|
+
L: 80,
|
|
1153
1164
|
S: this,
|
|
1154
1165
|
A: [
|
|
1155
1166
|
"response.device",
|
|
@@ -1159,7 +1170,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1159
1170
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1160
1171
|
invariant4(request.device, void 0, {
|
|
1161
1172
|
F: __dxlog_file5,
|
|
1162
|
-
L:
|
|
1173
|
+
L: 83,
|
|
1163
1174
|
S: this,
|
|
1164
1175
|
A: [
|
|
1165
1176
|
"request.device",
|
|
@@ -1941,16 +1952,12 @@ var InvitationsHandler = class {
|
|
|
1941
1952
|
}
|
|
1942
1953
|
}
|
|
1943
1954
|
}
|
|
1944
|
-
} else {
|
|
1945
|
-
setState({
|
|
1946
|
-
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
1947
|
-
});
|
|
1948
1955
|
}
|
|
1949
1956
|
log5("request admission", {
|
|
1950
1957
|
...protocol.toJSON()
|
|
1951
1958
|
}, {
|
|
1952
1959
|
F: __dxlog_file7,
|
|
1953
|
-
L:
|
|
1960
|
+
L: 309,
|
|
1954
1961
|
S: this,
|
|
1955
1962
|
C: (f, a) => f(...a)
|
|
1956
1963
|
});
|
|
@@ -1962,19 +1969,20 @@ var InvitationsHandler = class {
|
|
|
1962
1969
|
...protocol.toJSON()
|
|
1963
1970
|
}, {
|
|
1964
1971
|
F: __dxlog_file7,
|
|
1965
|
-
L:
|
|
1972
|
+
L: 320,
|
|
1966
1973
|
S: this,
|
|
1967
1974
|
C: (f, a) => f(...a)
|
|
1968
1975
|
});
|
|
1969
1976
|
setState({
|
|
1970
1977
|
...result,
|
|
1978
|
+
target: invitation.target,
|
|
1971
1979
|
state: Invitation3.State.SUCCESS
|
|
1972
1980
|
});
|
|
1973
1981
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
|
|
1974
1982
|
id: traceId
|
|
1975
1983
|
}), {
|
|
1976
1984
|
F: __dxlog_file7,
|
|
1977
|
-
L:
|
|
1985
|
+
L: 322,
|
|
1978
1986
|
S: this,
|
|
1979
1987
|
C: (f, a) => f(...a)
|
|
1980
1988
|
});
|
|
@@ -1984,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1984
1992
|
...protocol.toJSON()
|
|
1985
1993
|
}, {
|
|
1986
1994
|
F: __dxlog_file7,
|
|
1987
|
-
L:
|
|
1995
|
+
L: 325,
|
|
1988
1996
|
S: this,
|
|
1989
1997
|
C: (f, a) => f(...a)
|
|
1990
1998
|
});
|
|
@@ -1994,7 +2002,7 @@ var InvitationsHandler = class {
|
|
|
1994
2002
|
} else {
|
|
1995
2003
|
log5("auth failed", err, {
|
|
1996
2004
|
F: __dxlog_file7,
|
|
1997
|
-
L:
|
|
2005
|
+
L: 328,
|
|
1998
2006
|
S: this,
|
|
1999
2007
|
C: (f, a) => f(...a)
|
|
2000
2008
|
});
|
|
@@ -2005,7 +2013,7 @@ var InvitationsHandler = class {
|
|
|
2005
2013
|
error: err
|
|
2006
2014
|
}), {
|
|
2007
2015
|
F: __dxlog_file7,
|
|
2008
|
-
L:
|
|
2016
|
+
L: 331,
|
|
2009
2017
|
S: this,
|
|
2010
2018
|
C: (f, a) => f(...a)
|
|
2011
2019
|
});
|
|
@@ -2023,7 +2031,7 @@ var InvitationsHandler = class {
|
|
|
2023
2031
|
...protocol.toJSON()
|
|
2024
2032
|
}, {
|
|
2025
2033
|
F: __dxlog_file7,
|
|
2026
|
-
L:
|
|
2034
|
+
L: 342,
|
|
2027
2035
|
S: this,
|
|
2028
2036
|
C: (f, a) => f(...a)
|
|
2029
2037
|
});
|
|
@@ -2033,7 +2041,7 @@ var InvitationsHandler = class {
|
|
|
2033
2041
|
} else {
|
|
2034
2042
|
log5("auth failed", err, {
|
|
2035
2043
|
F: __dxlog_file7,
|
|
2036
|
-
L:
|
|
2044
|
+
L: 345,
|
|
2037
2045
|
S: this,
|
|
2038
2046
|
C: (f, a) => f(...a)
|
|
2039
2047
|
});
|
|
@@ -2044,29 +2052,34 @@ var InvitationsHandler = class {
|
|
|
2044
2052
|
return extension;
|
|
2045
2053
|
};
|
|
2046
2054
|
scheduleTask2(ctx, async () => {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2055
|
+
const error = protocol.checkInvitation(invitation);
|
|
2056
|
+
if (error) {
|
|
2057
|
+
stream.error(error);
|
|
2058
|
+
} else {
|
|
2059
|
+
invariant6(invitation.swarmKey, void 0, {
|
|
2060
|
+
F: __dxlog_file7,
|
|
2061
|
+
L: 359,
|
|
2062
|
+
S: this,
|
|
2063
|
+
A: [
|
|
2064
|
+
"invitation.swarmKey",
|
|
2065
|
+
""
|
|
2066
|
+
]
|
|
2067
|
+
});
|
|
2068
|
+
const topic = invitation.swarmKey;
|
|
2069
|
+
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2070
|
+
topic,
|
|
2071
|
+
peerId: PublicKey6.random(),
|
|
2072
|
+
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
2073
|
+
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2074
|
+
}),
|
|
2075
|
+
topology: new StarTopology(topic),
|
|
2076
|
+
label: "invitation guest"
|
|
2077
|
+
});
|
|
2078
|
+
ctx.onDispose(() => swarmConnection.close());
|
|
2079
|
+
setState({
|
|
2080
|
+
state: Invitation3.State.CONNECTING
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2070
2083
|
});
|
|
2071
2084
|
const observable = new AuthenticatingInvitation({
|
|
2072
2085
|
initialInvitation: invitation,
|
|
@@ -2272,6 +2285,7 @@ import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/creden
|
|
|
2272
2285
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2273
2286
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2274
2287
|
import { log as log7 } from "@dxos/log";
|
|
2288
|
+
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2275
2289
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2276
2290
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2277
2291
|
var SpaceInvitationProtocol = class {
|
|
@@ -2296,7 +2310,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2296
2310
|
async admit(request, guestProfile) {
|
|
2297
2311
|
invariant8(this._spaceKey, void 0, {
|
|
2298
2312
|
F: __dxlog_file9,
|
|
2299
|
-
L:
|
|
2313
|
+
L: 47,
|
|
2300
2314
|
S: this,
|
|
2301
2315
|
A: [
|
|
2302
2316
|
"this._spaceKey",
|
|
@@ -2306,7 +2320,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2306
2320
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2307
2321
|
invariant8(space, void 0, {
|
|
2308
2322
|
F: __dxlog_file9,
|
|
2309
|
-
L:
|
|
2323
|
+
L: 49,
|
|
2310
2324
|
S: this,
|
|
2311
2325
|
A: [
|
|
2312
2326
|
"space",
|
|
@@ -2315,7 +2329,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2315
2329
|
});
|
|
2316
2330
|
invariant8(request.space, void 0, {
|
|
2317
2331
|
F: __dxlog_file9,
|
|
2318
|
-
L:
|
|
2332
|
+
L: 51,
|
|
2319
2333
|
S: this,
|
|
2320
2334
|
A: [
|
|
2321
2335
|
"request.space",
|
|
@@ -2328,14 +2342,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2328
2342
|
guest: deviceKey
|
|
2329
2343
|
}, {
|
|
2330
2344
|
F: __dxlog_file9,
|
|
2331
|
-
L:
|
|
2345
|
+
L: 54,
|
|
2332
2346
|
S: this,
|
|
2333
2347
|
C: (f, a) => f(...a)
|
|
2334
2348
|
});
|
|
2335
2349
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2336
2350
|
invariant8(credentials[0].credential, void 0, {
|
|
2337
2351
|
F: __dxlog_file9,
|
|
2338
|
-
L:
|
|
2352
|
+
L: 65,
|
|
2339
2353
|
S: this,
|
|
2340
2354
|
A: [
|
|
2341
2355
|
"credentials[0].credential",
|
|
@@ -2345,7 +2359,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2345
2359
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2346
2360
|
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2347
2361
|
F: __dxlog_file9,
|
|
2348
|
-
L:
|
|
2362
|
+
L: 67,
|
|
2349
2363
|
S: this,
|
|
2350
2364
|
A: [
|
|
2351
2365
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2361,6 +2375,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2361
2375
|
}
|
|
2362
2376
|
};
|
|
2363
2377
|
}
|
|
2378
|
+
checkInvitation(invitation) {
|
|
2379
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2380
|
+
return new AlreadyJoinedError2("Already joined space.");
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2364
2383
|
createIntroduction() {
|
|
2365
2384
|
return {
|
|
2366
2385
|
profile: this._signingContext.getProfile()
|
|
@@ -2381,7 +2400,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2381
2400
|
async accept(response) {
|
|
2382
2401
|
invariant8(response.space, void 0, {
|
|
2383
2402
|
F: __dxlog_file9,
|
|
2384
|
-
L:
|
|
2403
|
+
L: 108,
|
|
2385
2404
|
S: this,
|
|
2386
2405
|
A: [
|
|
2387
2406
|
"response.space",
|
|
@@ -2392,7 +2411,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2392
2411
|
const assertion = getCredentialAssertion(credential);
|
|
2393
2412
|
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2394
2413
|
F: __dxlog_file9,
|
|
2395
|
-
L:
|
|
2414
|
+
L: 111,
|
|
2396
2415
|
S: this,
|
|
2397
2416
|
A: [
|
|
2398
2417
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2401,13 +2420,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2401
2420
|
});
|
|
2402
2421
|
invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2403
2422
|
F: __dxlog_file9,
|
|
2404
|
-
L:
|
|
2423
|
+
L: 112,
|
|
2405
2424
|
S: this,
|
|
2406
2425
|
A: [
|
|
2407
2426
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2408
2427
|
""
|
|
2409
2428
|
]
|
|
2410
2429
|
});
|
|
2430
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2431
|
+
throw new AlreadyJoinedError2("Already joined space.");
|
|
2432
|
+
}
|
|
2411
2433
|
await this._spaceManager.acceptSpace({
|
|
2412
2434
|
spaceKey: assertion.spaceKey,
|
|
2413
2435
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2436,7 +2458,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2436
2458
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2437
2459
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2438
2460
|
}
|
|
2439
|
-
var ClientRpcServer = class
|
|
2461
|
+
var ClientRpcServer = class {
|
|
2440
2462
|
constructor(params) {
|
|
2441
2463
|
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2442
2464
|
this._callMetrics = new MapCounter();
|
|
@@ -2511,29 +2533,32 @@ import { invariant as invariant9 } from "@dxos/invariant";
|
|
|
2511
2533
|
import { log as log8 } from "@dxos/log";
|
|
2512
2534
|
import { STORAGE_VERSION } from "@dxos/protocols";
|
|
2513
2535
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2536
|
+
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
2514
2537
|
|
|
2515
2538
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2539
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
2516
2540
|
var getPlatform = () => {
|
|
2517
2541
|
if (process.browser) {
|
|
2518
2542
|
if (typeof window !== "undefined") {
|
|
2519
2543
|
const { userAgent } = window.navigator;
|
|
2520
2544
|
return {
|
|
2521
|
-
type:
|
|
2545
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
2522
2546
|
userAgent,
|
|
2523
2547
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2524
2548
|
};
|
|
2525
2549
|
} else {
|
|
2526
2550
|
return {
|
|
2527
|
-
type:
|
|
2551
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2528
2552
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2529
2553
|
};
|
|
2530
2554
|
}
|
|
2531
2555
|
} else {
|
|
2532
2556
|
const { platform: platform2, version, arch } = process;
|
|
2533
2557
|
return {
|
|
2534
|
-
type:
|
|
2535
|
-
platform:
|
|
2536
|
-
|
|
2558
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
2559
|
+
platform: platform2,
|
|
2560
|
+
arch,
|
|
2561
|
+
runtime: version,
|
|
2537
2562
|
uptime: Math.floor(process.uptime()),
|
|
2538
2563
|
memory: process.memoryUsage()
|
|
2539
2564
|
};
|
|
@@ -2541,7 +2566,7 @@ var getPlatform = () => {
|
|
|
2541
2566
|
};
|
|
2542
2567
|
|
|
2543
2568
|
// packages/sdk/client-services/src/version.ts
|
|
2544
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2569
|
+
var DXOS_VERSION = "0.3.11-main.ea1c9ce";
|
|
2545
2570
|
|
|
2546
2571
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2547
2572
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2555,12 +2580,13 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2555
2580
|
storage: {
|
|
2556
2581
|
version: STORAGE_VERSION
|
|
2557
2582
|
}
|
|
2558
|
-
}
|
|
2583
|
+
},
|
|
2584
|
+
trace: TRACE_PROCESSOR.getDiagnostics()
|
|
2559
2585
|
};
|
|
2560
2586
|
{
|
|
2561
2587
|
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2562
2588
|
F: __dxlog_file10,
|
|
2563
|
-
L:
|
|
2589
|
+
L: 111,
|
|
2564
2590
|
S: void 0,
|
|
2565
2591
|
A: [
|
|
2566
2592
|
"clientServices.LoggingService",
|
|
@@ -2571,6 +2597,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2571
2597
|
timeout: DEFAULT_TIMEOUT
|
|
2572
2598
|
}).catch(() => void 0);
|
|
2573
2599
|
}
|
|
2600
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2601
|
+
const map = /* @__PURE__ */ new Map();
|
|
2602
|
+
const dir = await navigator.storage.getDirectory();
|
|
2603
|
+
for await (const filename of dir?.keys()) {
|
|
2604
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2605
|
+
if (idx === -1) {
|
|
2606
|
+
continue;
|
|
2607
|
+
}
|
|
2608
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2609
|
+
}
|
|
2610
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2611
|
+
file,
|
|
2612
|
+
count
|
|
2613
|
+
}));
|
|
2614
|
+
}
|
|
2574
2615
|
const identity = serviceContext.identityManager.identity;
|
|
2575
2616
|
if (identity) {
|
|
2576
2617
|
diagnostics.identity = {
|
|
@@ -2611,7 +2652,7 @@ var getProperties = (space) => {
|
|
|
2611
2652
|
} catch (err) {
|
|
2612
2653
|
log8.warn(err.message, void 0, {
|
|
2613
2654
|
F: __dxlog_file10,
|
|
2614
|
-
L:
|
|
2655
|
+
L: 196,
|
|
2615
2656
|
S: void 0,
|
|
2616
2657
|
C: (f, a) => f(...a)
|
|
2617
2658
|
});
|
|
@@ -2667,11 +2708,12 @@ var getSpaceStats = async (space) => {
|
|
|
2667
2708
|
};
|
|
2668
2709
|
|
|
2669
2710
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2670
|
-
import { Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2711
|
+
import { Event as Event5, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2671
2712
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2672
|
-
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2713
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7, ContextDisposedError } from "@dxos/context";
|
|
2673
2714
|
import { timed } from "@dxos/debug";
|
|
2674
2715
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2716
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
2675
2717
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2676
2718
|
import { log as log10 } from "@dxos/log";
|
|
2677
2719
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2684,7 +2726,8 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
|
2684
2726
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2685
2727
|
import { checkCredentialType } from "@dxos/credentials";
|
|
2686
2728
|
var AutomergeSpaceState = class {
|
|
2687
|
-
constructor() {
|
|
2729
|
+
constructor(_onNewRoot) {
|
|
2730
|
+
this._onNewRoot = _onNewRoot;
|
|
2688
2731
|
this.rootUrl = void 0;
|
|
2689
2732
|
this.lastEpoch = void 0;
|
|
2690
2733
|
}
|
|
@@ -2695,6 +2738,7 @@ var AutomergeSpaceState = class {
|
|
|
2695
2738
|
this.lastEpoch = credential;
|
|
2696
2739
|
if (credential.subject.assertion.automergeRoot) {
|
|
2697
2740
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2741
|
+
this._onNewRoot(this.rootUrl);
|
|
2698
2742
|
}
|
|
2699
2743
|
}
|
|
2700
2744
|
};
|
|
@@ -2980,13 +3024,13 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2980
3024
|
}
|
|
2981
3025
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2982
3026
|
var ENABLE_FEED_PURGE = false;
|
|
2983
|
-
var DataSpace = class
|
|
3027
|
+
var DataSpace = class {
|
|
2984
3028
|
constructor(params) {
|
|
2985
3029
|
this._ctx = new Context7();
|
|
2986
3030
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2987
3031
|
this._cache = void 0;
|
|
2988
3032
|
// TODO(dmaretskyi): Move into Space?
|
|
2989
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3033
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
2990
3034
|
this._state = SpaceState.CLOSED;
|
|
2991
3035
|
/**
|
|
2992
3036
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -3015,7 +3059,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3015
3059
|
state: SpaceState[this._state]
|
|
3016
3060
|
}, {
|
|
3017
3061
|
F: __dxlog_file12,
|
|
3018
|
-
L:
|
|
3062
|
+
L: 141,
|
|
3019
3063
|
S: this,
|
|
3020
3064
|
C: (f, a) => f(...a)
|
|
3021
3065
|
});
|
|
@@ -3048,6 +3092,12 @@ var DataSpace = class DataSpace2 {
|
|
|
3048
3092
|
get automergeSpaceState() {
|
|
3049
3093
|
return this._automergeSpaceState;
|
|
3050
3094
|
}
|
|
3095
|
+
get _automergeInfo() {
|
|
3096
|
+
return {
|
|
3097
|
+
rootUrl: this._automergeSpaceState.rootUrl,
|
|
3098
|
+
lastEpoch: this._automergeSpaceState.lastEpoch
|
|
3099
|
+
};
|
|
3100
|
+
}
|
|
3051
3101
|
async open() {
|
|
3052
3102
|
await this._open();
|
|
3053
3103
|
}
|
|
@@ -3062,7 +3112,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3062
3112
|
state: SpaceState[this._state]
|
|
3063
3113
|
}, {
|
|
3064
3114
|
F: __dxlog_file12,
|
|
3065
|
-
L:
|
|
3115
|
+
L: 203,
|
|
3066
3116
|
S: this,
|
|
3067
3117
|
C: (f, a) => f(...a)
|
|
3068
3118
|
});
|
|
@@ -3080,7 +3130,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3080
3130
|
state: SpaceState[this._state]
|
|
3081
3131
|
}, {
|
|
3082
3132
|
F: __dxlog_file12,
|
|
3083
|
-
L:
|
|
3133
|
+
L: 217,
|
|
3084
3134
|
S: this,
|
|
3085
3135
|
C: (f, a) => f(...a)
|
|
3086
3136
|
});
|
|
@@ -3109,10 +3159,10 @@ var DataSpace = class DataSpace2 {
|
|
|
3109
3159
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3110
3160
|
await this.initializeDataPipeline();
|
|
3111
3161
|
} catch (err) {
|
|
3112
|
-
if (err instanceof CancelledError) {
|
|
3162
|
+
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3113
3163
|
log10("data pipeline initialization cancelled", err, {
|
|
3114
3164
|
F: __dxlog_file12,
|
|
3115
|
-
L:
|
|
3165
|
+
L: 250,
|
|
3116
3166
|
S: this,
|
|
3117
3167
|
C: (f, a) => f(...a)
|
|
3118
3168
|
});
|
|
@@ -3120,7 +3170,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3120
3170
|
}
|
|
3121
3171
|
log10.error("Error initializing data pipeline", err, {
|
|
3122
3172
|
F: __dxlog_file12,
|
|
3123
|
-
L:
|
|
3173
|
+
L: 254,
|
|
3124
3174
|
S: this,
|
|
3125
3175
|
C: (f, a) => f(...a)
|
|
3126
3176
|
});
|
|
@@ -3129,7 +3179,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3129
3179
|
state: SpaceState[this._state]
|
|
3130
3180
|
}, {
|
|
3131
3181
|
F: __dxlog_file12,
|
|
3132
|
-
L:
|
|
3182
|
+
L: 256,
|
|
3133
3183
|
S: this,
|
|
3134
3184
|
C: (f, a) => f(...a)
|
|
3135
3185
|
});
|
|
@@ -3149,7 +3199,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3149
3199
|
state: SpaceState[this._state]
|
|
3150
3200
|
}, {
|
|
3151
3201
|
F: __dxlog_file12,
|
|
3152
|
-
L:
|
|
3202
|
+
L: 272,
|
|
3153
3203
|
S: this,
|
|
3154
3204
|
C: (f, a) => f(...a)
|
|
3155
3205
|
});
|
|
@@ -3160,7 +3210,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3160
3210
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3161
3211
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3162
3212
|
F: __dxlog_file12,
|
|
3163
|
-
L:
|
|
3213
|
+
L: 286,
|
|
3164
3214
|
S: this,
|
|
3165
3215
|
C: (f, a) => f(...a)
|
|
3166
3216
|
});
|
|
@@ -3171,7 +3221,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3171
3221
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3172
3222
|
log10("data pipeline ready", void 0, {
|
|
3173
3223
|
F: __dxlog_file12,
|
|
3174
|
-
L:
|
|
3224
|
+
L: 295,
|
|
3175
3225
|
S: this,
|
|
3176
3226
|
C: (f, a) => f(...a)
|
|
3177
3227
|
});
|
|
@@ -3181,7 +3231,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3181
3231
|
state: SpaceState[this._state]
|
|
3182
3232
|
}, {
|
|
3183
3233
|
F: __dxlog_file12,
|
|
3184
|
-
L:
|
|
3234
|
+
L: 299,
|
|
3185
3235
|
S: this,
|
|
3186
3236
|
C: (f, a) => f(...a)
|
|
3187
3237
|
});
|
|
@@ -3197,7 +3247,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3197
3247
|
await this._createWritableFeeds();
|
|
3198
3248
|
log10("writable feeds created", void 0, {
|
|
3199
3249
|
F: __dxlog_file12,
|
|
3200
|
-
L:
|
|
3250
|
+
L: 315,
|
|
3201
3251
|
S: this,
|
|
3202
3252
|
C: (f, a) => f(...a)
|
|
3203
3253
|
});
|
|
@@ -3254,6 +3304,40 @@ var DataSpace = class DataSpace2 {
|
|
|
3254
3304
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3255
3305
|
}
|
|
3256
3306
|
}
|
|
3307
|
+
_onNewAutomergeRoot(rootUrl) {
|
|
3308
|
+
log10("loading automerge root doc for space", {
|
|
3309
|
+
space: this.key,
|
|
3310
|
+
rootUrl
|
|
3311
|
+
}, {
|
|
3312
|
+
F: __dxlog_file12,
|
|
3313
|
+
L: 381,
|
|
3314
|
+
S: this,
|
|
3315
|
+
C: (f, a) => f(...a)
|
|
3316
|
+
});
|
|
3317
|
+
const handle = this._automergeHost.repo.find(rootUrl);
|
|
3318
|
+
queueMicrotask(async () => {
|
|
3319
|
+
try {
|
|
3320
|
+
await asyncTimeout(handle.whenReady(), 5e3);
|
|
3321
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
3322
|
+
if (!doc.experimental_spaceKey) {
|
|
3323
|
+
handle.change((doc2) => {
|
|
3324
|
+
doc2.experimental_spaceKey = this.key.toHex();
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
} catch (err) {
|
|
3328
|
+
log10.warn("error loading automerge root doc", {
|
|
3329
|
+
space: this.key,
|
|
3330
|
+
rootUrl,
|
|
3331
|
+
err
|
|
3332
|
+
}, {
|
|
3333
|
+
F: __dxlog_file12,
|
|
3334
|
+
L: 394,
|
|
3335
|
+
S: this,
|
|
3336
|
+
C: (f, a) => f(...a)
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3257
3341
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3258
3342
|
async updateOwnProfile(profile) {
|
|
3259
3343
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3337,13 +3421,29 @@ var DataSpace = class DataSpace2 {
|
|
|
3337
3421
|
state: SpaceState[this._state]
|
|
3338
3422
|
}, {
|
|
3339
3423
|
F: __dxlog_file12,
|
|
3340
|
-
L:
|
|
3424
|
+
L: 483,
|
|
3341
3425
|
S: this,
|
|
3342
3426
|
C: (f, a) => f(...a)
|
|
3343
3427
|
});
|
|
3344
3428
|
this.stateUpdate.emit();
|
|
3345
3429
|
}
|
|
3346
3430
|
};
|
|
3431
|
+
_ts_decorate4([
|
|
3432
|
+
trace6.info()
|
|
3433
|
+
], DataSpace.prototype, "_inner", void 0);
|
|
3434
|
+
_ts_decorate4([
|
|
3435
|
+
trace6.info()
|
|
3436
|
+
], DataSpace.prototype, "key", null);
|
|
3437
|
+
_ts_decorate4([
|
|
3438
|
+
trace6.info({
|
|
3439
|
+
enum: SpaceState
|
|
3440
|
+
})
|
|
3441
|
+
], DataSpace.prototype, "state", null);
|
|
3442
|
+
_ts_decorate4([
|
|
3443
|
+
trace6.info({
|
|
3444
|
+
depth: null
|
|
3445
|
+
})
|
|
3446
|
+
], DataSpace.prototype, "_automergeInfo", null);
|
|
3347
3447
|
_ts_decorate4([
|
|
3348
3448
|
synchronized
|
|
3349
3449
|
], DataSpace.prototype, "open", null);
|
|
@@ -3370,7 +3470,8 @@ _ts_decorate4([
|
|
|
3370
3470
|
synchronized
|
|
3371
3471
|
], DataSpace.prototype, "deactivate", null);
|
|
3372
3472
|
DataSpace = _ts_decorate4([
|
|
3373
|
-
trackLeaks("open", "close")
|
|
3473
|
+
trackLeaks("open", "close"),
|
|
3474
|
+
trace6.resource()
|
|
3374
3475
|
], DataSpace);
|
|
3375
3476
|
|
|
3376
3477
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
@@ -3469,7 +3570,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3469
3570
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3470
3571
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3471
3572
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3472
|
-
var DataSpaceManager = class
|
|
3573
|
+
var DataSpaceManager = class {
|
|
3473
3574
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3474
3575
|
this._spaceManager = _spaceManager;
|
|
3475
3576
|
this._metadataStore = _metadataStore;
|
|
@@ -3596,12 +3697,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3596
3697
|
});
|
|
3597
3698
|
const space = await this._constructSpace(metadata);
|
|
3598
3699
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3700
|
+
automergeRoot.change((doc) => {
|
|
3701
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3702
|
+
});
|
|
3599
3703
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3600
3704
|
await this._metadataStore.addSpace(metadata);
|
|
3601
3705
|
const memberCredential = credentials[1];
|
|
3602
3706
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3603
3707
|
F: __dxlog_file13,
|
|
3604
|
-
L:
|
|
3708
|
+
L: 154,
|
|
3605
3709
|
S: this,
|
|
3606
3710
|
A: [
|
|
3607
3711
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3619,13 +3723,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3619
3723
|
opts
|
|
3620
3724
|
}, {
|
|
3621
3725
|
F: __dxlog_file13,
|
|
3622
|
-
L:
|
|
3726
|
+
L: 166,
|
|
3623
3727
|
S: this,
|
|
3624
3728
|
C: (f, a) => f(...a)
|
|
3625
3729
|
});
|
|
3626
3730
|
invariant11(this._isOpen, "Not open.", {
|
|
3627
3731
|
F: __dxlog_file13,
|
|
3628
|
-
L:
|
|
3732
|
+
L: 167,
|
|
3629
3733
|
S: this,
|
|
3630
3734
|
A: [
|
|
3631
3735
|
"this._isOpen",
|
|
@@ -3634,7 +3738,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3634
3738
|
});
|
|
3635
3739
|
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3636
3740
|
F: __dxlog_file13,
|
|
3637
|
-
L:
|
|
3741
|
+
L: 168,
|
|
3638
3742
|
S: this,
|
|
3639
3743
|
A: [
|
|
3640
3744
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3669,7 +3773,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3669
3773
|
metadata
|
|
3670
3774
|
}, {
|
|
3671
3775
|
F: __dxlog_file13,
|
|
3672
|
-
L:
|
|
3776
|
+
L: 201,
|
|
3673
3777
|
S: this,
|
|
3674
3778
|
C: (f, a) => f(...a)
|
|
3675
3779
|
});
|
|
@@ -3696,17 +3800,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3696
3800
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3697
3801
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
3698
3802
|
},
|
|
3699
|
-
|
|
3803
|
+
onAuthorizedConnection: (session) => {
|
|
3700
3804
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3701
3805
|
remotePeerId: session.remotePeerId
|
|
3702
3806
|
}));
|
|
3703
3807
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3808
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3704
3809
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3705
3810
|
},
|
|
3706
3811
|
onAuthFailure: () => {
|
|
3707
3812
|
log11.warn("auth failure", void 0, {
|
|
3708
3813
|
F: __dxlog_file13,
|
|
3709
|
-
L:
|
|
3814
|
+
L: 238,
|
|
3710
3815
|
S: this,
|
|
3711
3816
|
C: (f, a) => f(...a)
|
|
3712
3817
|
});
|
|
@@ -3730,7 +3835,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3730
3835
|
space: space.key
|
|
3731
3836
|
}, {
|
|
3732
3837
|
F: __dxlog_file13,
|
|
3733
|
-
L:
|
|
3838
|
+
L: 256,
|
|
3734
3839
|
S: this,
|
|
3735
3840
|
C: (f, a) => f(...a)
|
|
3736
3841
|
});
|
|
@@ -3742,7 +3847,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3742
3847
|
open: this._isOpen
|
|
3743
3848
|
}, {
|
|
3744
3849
|
F: __dxlog_file13,
|
|
3745
|
-
L:
|
|
3850
|
+
L: 263,
|
|
3746
3851
|
S: this,
|
|
3747
3852
|
C: (f, a) => f(...a)
|
|
3748
3853
|
});
|
|
@@ -3755,7 +3860,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3755
3860
|
space: space.key
|
|
3756
3861
|
}, {
|
|
3757
3862
|
F: __dxlog_file13,
|
|
3758
|
-
L:
|
|
3863
|
+
L: 269,
|
|
3759
3864
|
S: this,
|
|
3760
3865
|
C: (f, a) => f(...a)
|
|
3761
3866
|
});
|
|
@@ -3812,7 +3917,7 @@ var SpacesServiceImpl = class {
|
|
|
3812
3917
|
}
|
|
3813
3918
|
async createSpace() {
|
|
3814
3919
|
if (!this._identityManager.identity) {
|
|
3815
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
3920
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
3816
3921
|
}
|
|
3817
3922
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3818
3923
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -4042,7 +4147,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4042
4147
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4043
4148
|
}
|
|
4044
4149
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4045
|
-
var ServiceContext = class
|
|
4150
|
+
var ServiceContext = class {
|
|
4046
4151
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
4047
4152
|
this.storage = storage;
|
|
4048
4153
|
this.networkManager = networkManager;
|
|
@@ -4311,7 +4416,7 @@ var ServiceRegistry = class {
|
|
|
4311
4416
|
};
|
|
4312
4417
|
|
|
4313
4418
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4314
|
-
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
4419
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
4315
4420
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4316
4421
|
import { log as log14, logInfo } from "@dxos/log";
|
|
4317
4422
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
@@ -4343,7 +4448,7 @@ var Lock = class {
|
|
|
4343
4448
|
}
|
|
4344
4449
|
async acquire() {
|
|
4345
4450
|
this._broadcastChannel.postMessage({
|
|
4346
|
-
message:
|
|
4451
|
+
message: "acquiring"
|
|
4347
4452
|
});
|
|
4348
4453
|
try {
|
|
4349
4454
|
log14("aquiring lock...", void 0, {
|
|
@@ -4352,7 +4457,7 @@ var Lock = class {
|
|
|
4352
4457
|
S: this,
|
|
4353
4458
|
C: (f, a) => f(...a)
|
|
4354
4459
|
});
|
|
4355
|
-
await
|
|
4460
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4356
4461
|
log14("acquired lock", void 0, {
|
|
4357
4462
|
F: __dxlog_file16,
|
|
4358
4463
|
L: 44,
|
|
@@ -4379,7 +4484,7 @@ var Lock = class {
|
|
|
4379
4484
|
this._releaseTrigger.wake();
|
|
4380
4485
|
}
|
|
4381
4486
|
_onMessage(event) {
|
|
4382
|
-
if (event.data.message ===
|
|
4487
|
+
if (event.data.message === "acquiring") {
|
|
4383
4488
|
this._releaseTrigger.wake();
|
|
4384
4489
|
}
|
|
4385
4490
|
}
|
|
@@ -4489,7 +4594,7 @@ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protoc
|
|
|
4489
4594
|
import { Context as Context10 } from "@dxos/context";
|
|
4490
4595
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4491
4596
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4492
|
-
import { base } from "@dxos/echo-schema";
|
|
4597
|
+
import { base, getRawDoc } from "@dxos/echo-schema";
|
|
4493
4598
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4494
4599
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4495
4600
|
import { log as log16 } from "@dxos/log";
|
|
@@ -4499,7 +4604,7 @@ import { createSimplePeerTransportFactory, NetworkManager } from "@dxos/network-
|
|
|
4499
4604
|
import { trace as trace9 } from "@dxos/protocols";
|
|
4500
4605
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4501
4606
|
import { TextModel } from "@dxos/text-model";
|
|
4502
|
-
import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
|
|
4607
|
+
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
|
|
4503
4608
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
4504
4609
|
|
|
4505
4610
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
@@ -4675,6 +4780,7 @@ var NetworkServiceImpl = class {
|
|
|
4675
4780
|
const update = () => {
|
|
4676
4781
|
next({
|
|
4677
4782
|
swarm: this.networkManager.connectionState,
|
|
4783
|
+
connectionInfo: this.networkManager.connectionLog?.swarms,
|
|
4678
4784
|
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
4679
4785
|
server: host,
|
|
4680
4786
|
state
|
|
@@ -4724,6 +4830,9 @@ var SystemServiceImpl = class {
|
|
|
4724
4830
|
})))
|
|
4725
4831
|
};
|
|
4726
4832
|
}
|
|
4833
|
+
async getPlatform() {
|
|
4834
|
+
return getPlatform();
|
|
4835
|
+
}
|
|
4727
4836
|
async updateStatus({ status }) {
|
|
4728
4837
|
await this._onUpdateStatus(status);
|
|
4729
4838
|
}
|
|
@@ -4776,7 +4885,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
|
|
|
4776
4885
|
}
|
|
4777
4886
|
};
|
|
4778
4887
|
};
|
|
4779
|
-
var ClientServicesHost = class
|
|
4888
|
+
var ClientServicesHost = class {
|
|
4780
4889
|
constructor({
|
|
4781
4890
|
config,
|
|
4782
4891
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4787,7 +4896,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4787
4896
|
lockKey,
|
|
4788
4897
|
callbacks
|
|
4789
4898
|
} = {}) {
|
|
4790
|
-
this._tracingService =
|
|
4899
|
+
this._tracingService = TRACE_PROCESSOR2.createTraceSender();
|
|
4791
4900
|
this._statusUpdate = new Event8();
|
|
4792
4901
|
this._opening = false;
|
|
4793
4902
|
this._open = false;
|
|
@@ -4978,7 +5087,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4978
5087
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4979
5088
|
this._serviceRegistry.setServices({
|
|
4980
5089
|
SystemService: this._systemService,
|
|
4981
|
-
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5090
|
+
IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4982
5091
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4983
5092
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4984
5093
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -5092,25 +5201,44 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5092
5201
|
});
|
|
5093
5202
|
await this._callbacks?.onReset?.();
|
|
5094
5203
|
}
|
|
5095
|
-
async _createIdentity(params) {
|
|
5204
|
+
async _createIdentity(params, useAutomerge) {
|
|
5096
5205
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5097
5206
|
await this._serviceContext.initialized.wait();
|
|
5098
5207
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5099
5208
|
const obj = new Properties(void 0, {
|
|
5100
|
-
automerge:
|
|
5209
|
+
automerge: useAutomerge
|
|
5101
5210
|
});
|
|
5102
5211
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5212
|
+
if (!useAutomerge) {
|
|
5213
|
+
await this._serviceRegistry.services.DataService.write({
|
|
5214
|
+
spaceKey: space.key,
|
|
5215
|
+
batch: {
|
|
5216
|
+
objects: [
|
|
5217
|
+
createGenesisMutationFromTypedObject(obj)
|
|
5218
|
+
]
|
|
5219
|
+
}
|
|
5220
|
+
});
|
|
5221
|
+
await this._serviceRegistry.services.DataService.flush({
|
|
5222
|
+
spaceKey: space.key
|
|
5223
|
+
});
|
|
5224
|
+
} else {
|
|
5225
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5226
|
+
invariant14(automergeIndex, void 0, {
|
|
5227
|
+
F: __dxlog_file17,
|
|
5228
|
+
L: 375,
|
|
5229
|
+
S: this,
|
|
5230
|
+
A: [
|
|
5231
|
+
"automergeIndex",
|
|
5232
|
+
""
|
|
5108
5233
|
]
|
|
5109
|
-
}
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5234
|
+
});
|
|
5235
|
+
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5236
|
+
await document.whenReady();
|
|
5237
|
+
document.change((doc) => {
|
|
5238
|
+
doc.objects ??= {};
|
|
5239
|
+
doc.objects[obj[base]._id] = getRawDoc(obj).handle.docSync();
|
|
5240
|
+
});
|
|
5241
|
+
}
|
|
5114
5242
|
return identity;
|
|
5115
5243
|
}
|
|
5116
5244
|
};
|
|
@@ -5166,4 +5294,4 @@ export {
|
|
|
5166
5294
|
createDefaultModelFactory,
|
|
5167
5295
|
ClientServicesHost
|
|
5168
5296
|
};
|
|
5169
|
-
//# sourceMappingURL=chunk-
|
|
5297
|
+
//# sourceMappingURL=chunk-PVIR3NPQ.mjs.map
|