@dxos/client-services 0.3.11-main.4feb9c9 → 0.3.11-main.5052d1a
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-PLJC2KIW.mjs → chunk-6V5E3NKF.mjs} +210 -108
- package/dist/lib/browser/chunk-6V5E3NKF.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-W4V257LR.cjs → chunk-C6YKNXGE.cjs} +342 -240
- package/dist/lib/node/chunk-C6YKNXGE.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 +5 -2
- 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 +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +2 -1
- 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 +19 -17
- 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 +1 -0
- package/src/packlets/services/diagnostics.ts +20 -1
- 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 +21 -1
- package/src/packlets/spaces/spaces-service.ts +1 -1
- package/src/packlets/system/system-service.ts +6 -0
- package/src/packlets/testing/invitation-utils.ts +2 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-PLJC2KIW.mjs.map +0 -7
- package/dist/lib/node/chunk-W4V257LR.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,7 +1969,7 @@ 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
|
});
|
|
@@ -1975,7 +1982,7 @@ var InvitationsHandler = class {
|
|
|
1975
1982
|
id: traceId
|
|
1976
1983
|
}), {
|
|
1977
1984
|
F: __dxlog_file7,
|
|
1978
|
-
L:
|
|
1985
|
+
L: 322,
|
|
1979
1986
|
S: this,
|
|
1980
1987
|
C: (f, a) => f(...a)
|
|
1981
1988
|
});
|
|
@@ -1985,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1985
1992
|
...protocol.toJSON()
|
|
1986
1993
|
}, {
|
|
1987
1994
|
F: __dxlog_file7,
|
|
1988
|
-
L:
|
|
1995
|
+
L: 325,
|
|
1989
1996
|
S: this,
|
|
1990
1997
|
C: (f, a) => f(...a)
|
|
1991
1998
|
});
|
|
@@ -1995,7 +2002,7 @@ var InvitationsHandler = class {
|
|
|
1995
2002
|
} else {
|
|
1996
2003
|
log5("auth failed", err, {
|
|
1997
2004
|
F: __dxlog_file7,
|
|
1998
|
-
L:
|
|
2005
|
+
L: 328,
|
|
1999
2006
|
S: this,
|
|
2000
2007
|
C: (f, a) => f(...a)
|
|
2001
2008
|
});
|
|
@@ -2006,7 +2013,7 @@ var InvitationsHandler = class {
|
|
|
2006
2013
|
error: err
|
|
2007
2014
|
}), {
|
|
2008
2015
|
F: __dxlog_file7,
|
|
2009
|
-
L:
|
|
2016
|
+
L: 331,
|
|
2010
2017
|
S: this,
|
|
2011
2018
|
C: (f, a) => f(...a)
|
|
2012
2019
|
});
|
|
@@ -2024,7 +2031,7 @@ var InvitationsHandler = class {
|
|
|
2024
2031
|
...protocol.toJSON()
|
|
2025
2032
|
}, {
|
|
2026
2033
|
F: __dxlog_file7,
|
|
2027
|
-
L:
|
|
2034
|
+
L: 342,
|
|
2028
2035
|
S: this,
|
|
2029
2036
|
C: (f, a) => f(...a)
|
|
2030
2037
|
});
|
|
@@ -2034,7 +2041,7 @@ var InvitationsHandler = class {
|
|
|
2034
2041
|
} else {
|
|
2035
2042
|
log5("auth failed", err, {
|
|
2036
2043
|
F: __dxlog_file7,
|
|
2037
|
-
L:
|
|
2044
|
+
L: 345,
|
|
2038
2045
|
S: this,
|
|
2039
2046
|
C: (f, a) => f(...a)
|
|
2040
2047
|
});
|
|
@@ -2045,29 +2052,34 @@ var InvitationsHandler = class {
|
|
|
2045
2052
|
return extension;
|
|
2046
2053
|
};
|
|
2047
2054
|
scheduleTask2(ctx, async () => {
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
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
|
+
}
|
|
2071
2083
|
});
|
|
2072
2084
|
const observable = new AuthenticatingInvitation({
|
|
2073
2085
|
initialInvitation: invitation,
|
|
@@ -2273,6 +2285,7 @@ import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/creden
|
|
|
2273
2285
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2274
2286
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2275
2287
|
import { log as log7 } from "@dxos/log";
|
|
2288
|
+
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2276
2289
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2277
2290
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2278
2291
|
var SpaceInvitationProtocol = class {
|
|
@@ -2297,7 +2310,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2297
2310
|
async admit(request, guestProfile) {
|
|
2298
2311
|
invariant8(this._spaceKey, void 0, {
|
|
2299
2312
|
F: __dxlog_file9,
|
|
2300
|
-
L:
|
|
2313
|
+
L: 47,
|
|
2301
2314
|
S: this,
|
|
2302
2315
|
A: [
|
|
2303
2316
|
"this._spaceKey",
|
|
@@ -2307,7 +2320,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2307
2320
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2308
2321
|
invariant8(space, void 0, {
|
|
2309
2322
|
F: __dxlog_file9,
|
|
2310
|
-
L:
|
|
2323
|
+
L: 49,
|
|
2311
2324
|
S: this,
|
|
2312
2325
|
A: [
|
|
2313
2326
|
"space",
|
|
@@ -2316,7 +2329,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2316
2329
|
});
|
|
2317
2330
|
invariant8(request.space, void 0, {
|
|
2318
2331
|
F: __dxlog_file9,
|
|
2319
|
-
L:
|
|
2332
|
+
L: 51,
|
|
2320
2333
|
S: this,
|
|
2321
2334
|
A: [
|
|
2322
2335
|
"request.space",
|
|
@@ -2329,14 +2342,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2329
2342
|
guest: deviceKey
|
|
2330
2343
|
}, {
|
|
2331
2344
|
F: __dxlog_file9,
|
|
2332
|
-
L:
|
|
2345
|
+
L: 54,
|
|
2333
2346
|
S: this,
|
|
2334
2347
|
C: (f, a) => f(...a)
|
|
2335
2348
|
});
|
|
2336
2349
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2337
2350
|
invariant8(credentials[0].credential, void 0, {
|
|
2338
2351
|
F: __dxlog_file9,
|
|
2339
|
-
L:
|
|
2352
|
+
L: 65,
|
|
2340
2353
|
S: this,
|
|
2341
2354
|
A: [
|
|
2342
2355
|
"credentials[0].credential",
|
|
@@ -2346,7 +2359,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2346
2359
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2347
2360
|
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2348
2361
|
F: __dxlog_file9,
|
|
2349
|
-
L:
|
|
2362
|
+
L: 67,
|
|
2350
2363
|
S: this,
|
|
2351
2364
|
A: [
|
|
2352
2365
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2362,6 +2375,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2362
2375
|
}
|
|
2363
2376
|
};
|
|
2364
2377
|
}
|
|
2378
|
+
checkInvitation(invitation) {
|
|
2379
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2380
|
+
return new AlreadyJoinedError2("Already joined space.");
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2365
2383
|
createIntroduction() {
|
|
2366
2384
|
return {
|
|
2367
2385
|
profile: this._signingContext.getProfile()
|
|
@@ -2382,7 +2400,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2382
2400
|
async accept(response) {
|
|
2383
2401
|
invariant8(response.space, void 0, {
|
|
2384
2402
|
F: __dxlog_file9,
|
|
2385
|
-
L:
|
|
2403
|
+
L: 108,
|
|
2386
2404
|
S: this,
|
|
2387
2405
|
A: [
|
|
2388
2406
|
"response.space",
|
|
@@ -2393,7 +2411,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2393
2411
|
const assertion = getCredentialAssertion(credential);
|
|
2394
2412
|
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2395
2413
|
F: __dxlog_file9,
|
|
2396
|
-
L:
|
|
2414
|
+
L: 111,
|
|
2397
2415
|
S: this,
|
|
2398
2416
|
A: [
|
|
2399
2417
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2402,13 +2420,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2402
2420
|
});
|
|
2403
2421
|
invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2404
2422
|
F: __dxlog_file9,
|
|
2405
|
-
L:
|
|
2423
|
+
L: 112,
|
|
2406
2424
|
S: this,
|
|
2407
2425
|
A: [
|
|
2408
2426
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2409
2427
|
""
|
|
2410
2428
|
]
|
|
2411
2429
|
});
|
|
2430
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2431
|
+
throw new AlreadyJoinedError2("Already joined space.");
|
|
2432
|
+
}
|
|
2412
2433
|
await this._spaceManager.acceptSpace({
|
|
2413
2434
|
spaceKey: assertion.spaceKey,
|
|
2414
2435
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2437,7 +2458,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2437
2458
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2438
2459
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2439
2460
|
}
|
|
2440
|
-
var ClientRpcServer = class
|
|
2461
|
+
var ClientRpcServer = class {
|
|
2441
2462
|
constructor(params) {
|
|
2442
2463
|
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2443
2464
|
this._callMetrics = new MapCounter();
|
|
@@ -2514,27 +2535,29 @@ import { STORAGE_VERSION } from "@dxos/protocols";
|
|
|
2514
2535
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2515
2536
|
|
|
2516
2537
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2538
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
2517
2539
|
var getPlatform = () => {
|
|
2518
2540
|
if (process.browser) {
|
|
2519
2541
|
if (typeof window !== "undefined") {
|
|
2520
2542
|
const { userAgent } = window.navigator;
|
|
2521
2543
|
return {
|
|
2522
|
-
type:
|
|
2544
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
2523
2545
|
userAgent,
|
|
2524
2546
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2525
2547
|
};
|
|
2526
2548
|
} else {
|
|
2527
2549
|
return {
|
|
2528
|
-
type:
|
|
2550
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2529
2551
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2530
2552
|
};
|
|
2531
2553
|
}
|
|
2532
2554
|
} else {
|
|
2533
2555
|
const { platform: platform2, version, arch } = process;
|
|
2534
2556
|
return {
|
|
2535
|
-
type:
|
|
2536
|
-
platform:
|
|
2537
|
-
|
|
2557
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
2558
|
+
platform: platform2,
|
|
2559
|
+
arch,
|
|
2560
|
+
runtime: version,
|
|
2538
2561
|
uptime: Math.floor(process.uptime()),
|
|
2539
2562
|
memory: process.memoryUsage()
|
|
2540
2563
|
};
|
|
@@ -2542,7 +2565,7 @@ var getPlatform = () => {
|
|
|
2542
2565
|
};
|
|
2543
2566
|
|
|
2544
2567
|
// packages/sdk/client-services/src/version.ts
|
|
2545
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2568
|
+
var DXOS_VERSION = "0.3.11-main.5052d1a";
|
|
2546
2569
|
|
|
2547
2570
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2548
2571
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2561,7 +2584,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2561
2584
|
{
|
|
2562
2585
|
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2563
2586
|
F: __dxlog_file10,
|
|
2564
|
-
L:
|
|
2587
|
+
L: 94,
|
|
2565
2588
|
S: void 0,
|
|
2566
2589
|
A: [
|
|
2567
2590
|
"clientServices.LoggingService",
|
|
@@ -2572,6 +2595,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2572
2595
|
timeout: DEFAULT_TIMEOUT
|
|
2573
2596
|
}).catch(() => void 0);
|
|
2574
2597
|
}
|
|
2598
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2599
|
+
const map = /* @__PURE__ */ new Map();
|
|
2600
|
+
const dir = await navigator.storage.getDirectory();
|
|
2601
|
+
for await (const filename of dir?.keys()) {
|
|
2602
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2603
|
+
if (idx === -1) {
|
|
2604
|
+
continue;
|
|
2605
|
+
}
|
|
2606
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2607
|
+
}
|
|
2608
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2609
|
+
file,
|
|
2610
|
+
count
|
|
2611
|
+
}));
|
|
2612
|
+
}
|
|
2575
2613
|
const identity = serviceContext.identityManager.identity;
|
|
2576
2614
|
if (identity) {
|
|
2577
2615
|
diagnostics.identity = {
|
|
@@ -2612,7 +2650,7 @@ var getProperties = (space) => {
|
|
|
2612
2650
|
} catch (err) {
|
|
2613
2651
|
log8.warn(err.message, void 0, {
|
|
2614
2652
|
F: __dxlog_file10,
|
|
2615
|
-
L:
|
|
2653
|
+
L: 179,
|
|
2616
2654
|
S: void 0,
|
|
2617
2655
|
C: (f, a) => f(...a)
|
|
2618
2656
|
});
|
|
@@ -2673,6 +2711,7 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
|
2673
2711
|
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2674
2712
|
import { timed } from "@dxos/debug";
|
|
2675
2713
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2714
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
2676
2715
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2677
2716
|
import { log as log10 } from "@dxos/log";
|
|
2678
2717
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2685,7 +2724,8 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
|
2685
2724
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2686
2725
|
import { checkCredentialType } from "@dxos/credentials";
|
|
2687
2726
|
var AutomergeSpaceState = class {
|
|
2688
|
-
constructor() {
|
|
2727
|
+
constructor(_onNewRoot) {
|
|
2728
|
+
this._onNewRoot = _onNewRoot;
|
|
2689
2729
|
this.rootUrl = void 0;
|
|
2690
2730
|
this.lastEpoch = void 0;
|
|
2691
2731
|
}
|
|
@@ -2696,6 +2736,7 @@ var AutomergeSpaceState = class {
|
|
|
2696
2736
|
this.lastEpoch = credential;
|
|
2697
2737
|
if (credential.subject.assertion.automergeRoot) {
|
|
2698
2738
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2739
|
+
this._onNewRoot(this.rootUrl);
|
|
2699
2740
|
}
|
|
2700
2741
|
}
|
|
2701
2742
|
};
|
|
@@ -2981,13 +3022,13 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2981
3022
|
}
|
|
2982
3023
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2983
3024
|
var ENABLE_FEED_PURGE = false;
|
|
2984
|
-
var DataSpace = class
|
|
3025
|
+
var DataSpace = class {
|
|
2985
3026
|
constructor(params) {
|
|
2986
3027
|
this._ctx = new Context7();
|
|
2987
3028
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2988
3029
|
this._cache = void 0;
|
|
2989
3030
|
// TODO(dmaretskyi): Move into Space?
|
|
2990
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3031
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
2991
3032
|
this._state = SpaceState.CLOSED;
|
|
2992
3033
|
/**
|
|
2993
3034
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -3016,7 +3057,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3016
3057
|
state: SpaceState[this._state]
|
|
3017
3058
|
}, {
|
|
3018
3059
|
F: __dxlog_file12,
|
|
3019
|
-
L:
|
|
3060
|
+
L: 138,
|
|
3020
3061
|
S: this,
|
|
3021
3062
|
C: (f, a) => f(...a)
|
|
3022
3063
|
});
|
|
@@ -3063,7 +3104,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3063
3104
|
state: SpaceState[this._state]
|
|
3064
3105
|
}, {
|
|
3065
3106
|
F: __dxlog_file12,
|
|
3066
|
-
L:
|
|
3107
|
+
L: 190,
|
|
3067
3108
|
S: this,
|
|
3068
3109
|
C: (f, a) => f(...a)
|
|
3069
3110
|
});
|
|
@@ -3081,7 +3122,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3081
3122
|
state: SpaceState[this._state]
|
|
3082
3123
|
}, {
|
|
3083
3124
|
F: __dxlog_file12,
|
|
3084
|
-
L:
|
|
3125
|
+
L: 204,
|
|
3085
3126
|
S: this,
|
|
3086
3127
|
C: (f, a) => f(...a)
|
|
3087
3128
|
});
|
|
@@ -3113,7 +3154,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3113
3154
|
if (err instanceof CancelledError) {
|
|
3114
3155
|
log10("data pipeline initialization cancelled", err, {
|
|
3115
3156
|
F: __dxlog_file12,
|
|
3116
|
-
L:
|
|
3157
|
+
L: 237,
|
|
3117
3158
|
S: this,
|
|
3118
3159
|
C: (f, a) => f(...a)
|
|
3119
3160
|
});
|
|
@@ -3121,7 +3162,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3121
3162
|
}
|
|
3122
3163
|
log10.error("Error initializing data pipeline", err, {
|
|
3123
3164
|
F: __dxlog_file12,
|
|
3124
|
-
L:
|
|
3165
|
+
L: 241,
|
|
3125
3166
|
S: this,
|
|
3126
3167
|
C: (f, a) => f(...a)
|
|
3127
3168
|
});
|
|
@@ -3130,7 +3171,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3130
3171
|
state: SpaceState[this._state]
|
|
3131
3172
|
}, {
|
|
3132
3173
|
F: __dxlog_file12,
|
|
3133
|
-
L:
|
|
3174
|
+
L: 243,
|
|
3134
3175
|
S: this,
|
|
3135
3176
|
C: (f, a) => f(...a)
|
|
3136
3177
|
});
|
|
@@ -3150,7 +3191,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3150
3191
|
state: SpaceState[this._state]
|
|
3151
3192
|
}, {
|
|
3152
3193
|
F: __dxlog_file12,
|
|
3153
|
-
L:
|
|
3194
|
+
L: 259,
|
|
3154
3195
|
S: this,
|
|
3155
3196
|
C: (f, a) => f(...a)
|
|
3156
3197
|
});
|
|
@@ -3161,7 +3202,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3161
3202
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3162
3203
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3163
3204
|
F: __dxlog_file12,
|
|
3164
|
-
L:
|
|
3205
|
+
L: 273,
|
|
3165
3206
|
S: this,
|
|
3166
3207
|
C: (f, a) => f(...a)
|
|
3167
3208
|
});
|
|
@@ -3172,7 +3213,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3172
3213
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3173
3214
|
log10("data pipeline ready", void 0, {
|
|
3174
3215
|
F: __dxlog_file12,
|
|
3175
|
-
L:
|
|
3216
|
+
L: 282,
|
|
3176
3217
|
S: this,
|
|
3177
3218
|
C: (f, a) => f(...a)
|
|
3178
3219
|
});
|
|
@@ -3182,7 +3223,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3182
3223
|
state: SpaceState[this._state]
|
|
3183
3224
|
}, {
|
|
3184
3225
|
F: __dxlog_file12,
|
|
3185
|
-
L:
|
|
3226
|
+
L: 286,
|
|
3186
3227
|
S: this,
|
|
3187
3228
|
C: (f, a) => f(...a)
|
|
3188
3229
|
});
|
|
@@ -3198,7 +3239,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3198
3239
|
await this._createWritableFeeds();
|
|
3199
3240
|
log10("writable feeds created", void 0, {
|
|
3200
3241
|
F: __dxlog_file12,
|
|
3201
|
-
L:
|
|
3242
|
+
L: 302,
|
|
3202
3243
|
S: this,
|
|
3203
3244
|
C: (f, a) => f(...a)
|
|
3204
3245
|
});
|
|
@@ -3255,6 +3296,40 @@ var DataSpace = class DataSpace2 {
|
|
|
3255
3296
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3256
3297
|
}
|
|
3257
3298
|
}
|
|
3299
|
+
_onNewAutomergeRoot(rootUrl) {
|
|
3300
|
+
log10.info("loading automerge root doc for space", {
|
|
3301
|
+
space: this.key,
|
|
3302
|
+
rootUrl
|
|
3303
|
+
}, {
|
|
3304
|
+
F: __dxlog_file12,
|
|
3305
|
+
L: 368,
|
|
3306
|
+
S: this,
|
|
3307
|
+
C: (f, a) => f(...a)
|
|
3308
|
+
});
|
|
3309
|
+
const handle = this._automergeHost.repo.find(rootUrl);
|
|
3310
|
+
queueMicrotask(async () => {
|
|
3311
|
+
try {
|
|
3312
|
+
await handle.whenReady();
|
|
3313
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
3314
|
+
if (!doc.experimental_spaceKey) {
|
|
3315
|
+
handle.change((doc2) => {
|
|
3316
|
+
doc2.experimental_spaceKey = this.key.toHex();
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
} catch (err) {
|
|
3320
|
+
log10.warn("error loading automerge root doc", {
|
|
3321
|
+
space: this.key,
|
|
3322
|
+
rootUrl,
|
|
3323
|
+
err
|
|
3324
|
+
}, {
|
|
3325
|
+
F: __dxlog_file12,
|
|
3326
|
+
L: 381,
|
|
3327
|
+
S: this,
|
|
3328
|
+
C: (f, a) => f(...a)
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3258
3333
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3259
3334
|
async updateOwnProfile(profile) {
|
|
3260
3335
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3338,7 +3413,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3338
3413
|
state: SpaceState[this._state]
|
|
3339
3414
|
}, {
|
|
3340
3415
|
F: __dxlog_file12,
|
|
3341
|
-
L:
|
|
3416
|
+
L: 470,
|
|
3342
3417
|
S: this,
|
|
3343
3418
|
C: (f, a) => f(...a)
|
|
3344
3419
|
});
|
|
@@ -3470,7 +3545,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3470
3545
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3471
3546
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3472
3547
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3473
|
-
var DataSpaceManager = class
|
|
3548
|
+
var DataSpaceManager = class {
|
|
3474
3549
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3475
3550
|
this._spaceManager = _spaceManager;
|
|
3476
3551
|
this._metadataStore = _metadataStore;
|
|
@@ -3597,12 +3672,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3597
3672
|
});
|
|
3598
3673
|
const space = await this._constructSpace(metadata);
|
|
3599
3674
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3675
|
+
automergeRoot.change((doc) => {
|
|
3676
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3677
|
+
});
|
|
3600
3678
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3601
3679
|
await this._metadataStore.addSpace(metadata);
|
|
3602
3680
|
const memberCredential = credentials[1];
|
|
3603
3681
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3604
3682
|
F: __dxlog_file13,
|
|
3605
|
-
L:
|
|
3683
|
+
L: 154,
|
|
3606
3684
|
S: this,
|
|
3607
3685
|
A: [
|
|
3608
3686
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3620,13 +3698,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3620
3698
|
opts
|
|
3621
3699
|
}, {
|
|
3622
3700
|
F: __dxlog_file13,
|
|
3623
|
-
L:
|
|
3701
|
+
L: 166,
|
|
3624
3702
|
S: this,
|
|
3625
3703
|
C: (f, a) => f(...a)
|
|
3626
3704
|
});
|
|
3627
3705
|
invariant11(this._isOpen, "Not open.", {
|
|
3628
3706
|
F: __dxlog_file13,
|
|
3629
|
-
L:
|
|
3707
|
+
L: 167,
|
|
3630
3708
|
S: this,
|
|
3631
3709
|
A: [
|
|
3632
3710
|
"this._isOpen",
|
|
@@ -3635,7 +3713,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3635
3713
|
});
|
|
3636
3714
|
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3637
3715
|
F: __dxlog_file13,
|
|
3638
|
-
L:
|
|
3716
|
+
L: 168,
|
|
3639
3717
|
S: this,
|
|
3640
3718
|
A: [
|
|
3641
3719
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3670,7 +3748,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3670
3748
|
metadata
|
|
3671
3749
|
}, {
|
|
3672
3750
|
F: __dxlog_file13,
|
|
3673
|
-
L:
|
|
3751
|
+
L: 201,
|
|
3674
3752
|
S: this,
|
|
3675
3753
|
C: (f, a) => f(...a)
|
|
3676
3754
|
});
|
|
@@ -3697,17 +3775,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3697
3775
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3698
3776
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
3699
3777
|
},
|
|
3700
|
-
|
|
3778
|
+
onAuthorizedConnection: (session) => {
|
|
3701
3779
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3702
3780
|
remotePeerId: session.remotePeerId
|
|
3703
3781
|
}));
|
|
3704
3782
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3783
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3705
3784
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3706
3785
|
},
|
|
3707
3786
|
onAuthFailure: () => {
|
|
3708
3787
|
log11.warn("auth failure", void 0, {
|
|
3709
3788
|
F: __dxlog_file13,
|
|
3710
|
-
L:
|
|
3789
|
+
L: 238,
|
|
3711
3790
|
S: this,
|
|
3712
3791
|
C: (f, a) => f(...a)
|
|
3713
3792
|
});
|
|
@@ -3731,7 +3810,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3731
3810
|
space: space.key
|
|
3732
3811
|
}, {
|
|
3733
3812
|
F: __dxlog_file13,
|
|
3734
|
-
L:
|
|
3813
|
+
L: 256,
|
|
3735
3814
|
S: this,
|
|
3736
3815
|
C: (f, a) => f(...a)
|
|
3737
3816
|
});
|
|
@@ -3743,7 +3822,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3743
3822
|
open: this._isOpen
|
|
3744
3823
|
}, {
|
|
3745
3824
|
F: __dxlog_file13,
|
|
3746
|
-
L:
|
|
3825
|
+
L: 263,
|
|
3747
3826
|
S: this,
|
|
3748
3827
|
C: (f, a) => f(...a)
|
|
3749
3828
|
});
|
|
@@ -3756,7 +3835,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3756
3835
|
space: space.key
|
|
3757
3836
|
}, {
|
|
3758
3837
|
F: __dxlog_file13,
|
|
3759
|
-
L:
|
|
3838
|
+
L: 269,
|
|
3760
3839
|
S: this,
|
|
3761
3840
|
C: (f, a) => f(...a)
|
|
3762
3841
|
});
|
|
@@ -3813,7 +3892,7 @@ var SpacesServiceImpl = class {
|
|
|
3813
3892
|
}
|
|
3814
3893
|
async createSpace() {
|
|
3815
3894
|
if (!this._identityManager.identity) {
|
|
3816
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
3895
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
3817
3896
|
}
|
|
3818
3897
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3819
3898
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -4043,7 +4122,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4043
4122
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4044
4123
|
}
|
|
4045
4124
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4046
|
-
var ServiceContext = class
|
|
4125
|
+
var ServiceContext = class {
|
|
4047
4126
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
4048
4127
|
this.storage = storage;
|
|
4049
4128
|
this.networkManager = networkManager;
|
|
@@ -4344,7 +4423,7 @@ var Lock = class {
|
|
|
4344
4423
|
}
|
|
4345
4424
|
async acquire() {
|
|
4346
4425
|
this._broadcastChannel.postMessage({
|
|
4347
|
-
message:
|
|
4426
|
+
message: "acquiring"
|
|
4348
4427
|
});
|
|
4349
4428
|
try {
|
|
4350
4429
|
log14("aquiring lock...", void 0, {
|
|
@@ -4380,7 +4459,7 @@ var Lock = class {
|
|
|
4380
4459
|
this._releaseTrigger.wake();
|
|
4381
4460
|
}
|
|
4382
4461
|
_onMessage(event) {
|
|
4383
|
-
if (event.data.message ===
|
|
4462
|
+
if (event.data.message === "acquiring") {
|
|
4384
4463
|
this._releaseTrigger.wake();
|
|
4385
4464
|
}
|
|
4386
4465
|
}
|
|
@@ -4490,7 +4569,7 @@ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protoc
|
|
|
4490
4569
|
import { Context as Context10 } from "@dxos/context";
|
|
4491
4570
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4492
4571
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4493
|
-
import { base } from "@dxos/echo-schema";
|
|
4572
|
+
import { base, getRawDoc } from "@dxos/echo-schema";
|
|
4494
4573
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4495
4574
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4496
4575
|
import { log as log16 } from "@dxos/log";
|
|
@@ -4676,6 +4755,7 @@ var NetworkServiceImpl = class {
|
|
|
4676
4755
|
const update = () => {
|
|
4677
4756
|
next({
|
|
4678
4757
|
swarm: this.networkManager.connectionState,
|
|
4758
|
+
connectionInfo: this.networkManager.connectionLog?.swarms,
|
|
4679
4759
|
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
4680
4760
|
server: host,
|
|
4681
4761
|
state
|
|
@@ -4725,6 +4805,9 @@ var SystemServiceImpl = class {
|
|
|
4725
4805
|
})))
|
|
4726
4806
|
};
|
|
4727
4807
|
}
|
|
4808
|
+
async getPlatform() {
|
|
4809
|
+
return getPlatform();
|
|
4810
|
+
}
|
|
4728
4811
|
async updateStatus({ status }) {
|
|
4729
4812
|
await this._onUpdateStatus(status);
|
|
4730
4813
|
}
|
|
@@ -4777,7 +4860,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
|
|
|
4777
4860
|
}
|
|
4778
4861
|
};
|
|
4779
4862
|
};
|
|
4780
|
-
var ClientServicesHost = class
|
|
4863
|
+
var ClientServicesHost = class {
|
|
4781
4864
|
constructor({
|
|
4782
4865
|
config,
|
|
4783
4866
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4979,7 +5062,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4979
5062
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4980
5063
|
this._serviceRegistry.setServices({
|
|
4981
5064
|
SystemService: this._systemService,
|
|
4982
|
-
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5065
|
+
IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4983
5066
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4984
5067
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4985
5068
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -5093,25 +5176,44 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5093
5176
|
});
|
|
5094
5177
|
await this._callbacks?.onReset?.();
|
|
5095
5178
|
}
|
|
5096
|
-
async _createIdentity(params) {
|
|
5179
|
+
async _createIdentity(params, useAutomerge) {
|
|
5097
5180
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5098
5181
|
await this._serviceContext.initialized.wait();
|
|
5099
5182
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5100
5183
|
const obj = new Properties(void 0, {
|
|
5101
|
-
automerge:
|
|
5184
|
+
automerge: useAutomerge
|
|
5102
5185
|
});
|
|
5103
5186
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5187
|
+
if (!useAutomerge) {
|
|
5188
|
+
await this._serviceRegistry.services.DataService.write({
|
|
5189
|
+
spaceKey: space.key,
|
|
5190
|
+
batch: {
|
|
5191
|
+
objects: [
|
|
5192
|
+
createGenesisMutationFromTypedObject(obj)
|
|
5193
|
+
]
|
|
5194
|
+
}
|
|
5195
|
+
});
|
|
5196
|
+
await this._serviceRegistry.services.DataService.flush({
|
|
5197
|
+
spaceKey: space.key
|
|
5198
|
+
});
|
|
5199
|
+
} else {
|
|
5200
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5201
|
+
invariant14(automergeIndex, void 0, {
|
|
5202
|
+
F: __dxlog_file17,
|
|
5203
|
+
L: 375,
|
|
5204
|
+
S: this,
|
|
5205
|
+
A: [
|
|
5206
|
+
"automergeIndex",
|
|
5207
|
+
""
|
|
5109
5208
|
]
|
|
5110
|
-
}
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5209
|
+
});
|
|
5210
|
+
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5211
|
+
await document.whenReady();
|
|
5212
|
+
document.change((doc) => {
|
|
5213
|
+
doc.objects ??= {};
|
|
5214
|
+
doc.objects[obj[base]._id] = getRawDoc(obj).handle.docSync();
|
|
5215
|
+
});
|
|
5216
|
+
}
|
|
5115
5217
|
return identity;
|
|
5116
5218
|
}
|
|
5117
5219
|
};
|
|
@@ -5167,4 +5269,4 @@ export {
|
|
|
5167
5269
|
createDefaultModelFactory,
|
|
5168
5270
|
ClientServicesHost
|
|
5169
5271
|
};
|
|
5170
|
-
//# sourceMappingURL=chunk-
|
|
5272
|
+
//# sourceMappingURL=chunk-6V5E3NKF.mjs.map
|