@dxos/client-services 0.3.11-main.7ff9773 → 0.3.11-main.800163e
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-5EFJSN6A.mjs → chunk-GUFT4GX3.mjs} +164 -82
- package/dist/lib/browser/chunk-GUFT4GX3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +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-34H4H2HZ.cjs → chunk-GNBZGQOY.cjs} +300 -218
- package/dist/lib/node/chunk-GNBZGQOY.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- 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/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/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/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/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-5EFJSN6A.mjs.map +0 -7
- package/dist/lib/node/chunk-34H4H2HZ.cjs.map +0 -7
|
@@ -996,7 +996,7 @@ var IdentityManager = class {
|
|
|
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, {
|
|
@@ -1095,6 +1095,7 @@ var IdentityServiceImpl = class {
|
|
|
1095
1095
|
|
|
1096
1096
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
1097
1097
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1098
|
+
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1098
1099
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1099
1100
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1100
1101
|
var DeviceInvitationProtocol = class {
|
|
@@ -1114,7 +1115,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1114
1115
|
async admit(request) {
|
|
1115
1116
|
invariant4(request.device, void 0, {
|
|
1116
1117
|
F: __dxlog_file5,
|
|
1117
|
-
L:
|
|
1118
|
+
L: 36,
|
|
1118
1119
|
S: this,
|
|
1119
1120
|
A: [
|
|
1120
1121
|
"request.device",
|
|
@@ -1132,6 +1133,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1132
1133
|
}
|
|
1133
1134
|
};
|
|
1134
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
|
+
}
|
|
1135
1145
|
createIntroduction() {
|
|
1136
1146
|
return {};
|
|
1137
1147
|
}
|
|
@@ -1150,7 +1160,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1150
1160
|
async accept(response, request) {
|
|
1151
1161
|
invariant4(response.device, void 0, {
|
|
1152
1162
|
F: __dxlog_file5,
|
|
1153
|
-
L:
|
|
1163
|
+
L: 80,
|
|
1154
1164
|
S: this,
|
|
1155
1165
|
A: [
|
|
1156
1166
|
"response.device",
|
|
@@ -1160,7 +1170,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1160
1170
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1161
1171
|
invariant4(request.device, void 0, {
|
|
1162
1172
|
F: __dxlog_file5,
|
|
1163
|
-
L:
|
|
1173
|
+
L: 83,
|
|
1164
1174
|
S: this,
|
|
1165
1175
|
A: [
|
|
1166
1176
|
"request.device",
|
|
@@ -1942,16 +1952,12 @@ var InvitationsHandler = class {
|
|
|
1942
1952
|
}
|
|
1943
1953
|
}
|
|
1944
1954
|
}
|
|
1945
|
-
} else {
|
|
1946
|
-
setState({
|
|
1947
|
-
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
1948
|
-
});
|
|
1949
1955
|
}
|
|
1950
1956
|
log5("request admission", {
|
|
1951
1957
|
...protocol.toJSON()
|
|
1952
1958
|
}, {
|
|
1953
1959
|
F: __dxlog_file7,
|
|
1954
|
-
L:
|
|
1960
|
+
L: 309,
|
|
1955
1961
|
S: this,
|
|
1956
1962
|
C: (f, a) => f(...a)
|
|
1957
1963
|
});
|
|
@@ -1963,7 +1969,7 @@ var InvitationsHandler = class {
|
|
|
1963
1969
|
...protocol.toJSON()
|
|
1964
1970
|
}, {
|
|
1965
1971
|
F: __dxlog_file7,
|
|
1966
|
-
L:
|
|
1972
|
+
L: 320,
|
|
1967
1973
|
S: this,
|
|
1968
1974
|
C: (f, a) => f(...a)
|
|
1969
1975
|
});
|
|
@@ -1976,7 +1982,7 @@ var InvitationsHandler = class {
|
|
|
1976
1982
|
id: traceId
|
|
1977
1983
|
}), {
|
|
1978
1984
|
F: __dxlog_file7,
|
|
1979
|
-
L:
|
|
1985
|
+
L: 322,
|
|
1980
1986
|
S: this,
|
|
1981
1987
|
C: (f, a) => f(...a)
|
|
1982
1988
|
});
|
|
@@ -1986,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1986
1992
|
...protocol.toJSON()
|
|
1987
1993
|
}, {
|
|
1988
1994
|
F: __dxlog_file7,
|
|
1989
|
-
L:
|
|
1995
|
+
L: 325,
|
|
1990
1996
|
S: this,
|
|
1991
1997
|
C: (f, a) => f(...a)
|
|
1992
1998
|
});
|
|
@@ -1996,7 +2002,7 @@ var InvitationsHandler = class {
|
|
|
1996
2002
|
} else {
|
|
1997
2003
|
log5("auth failed", err, {
|
|
1998
2004
|
F: __dxlog_file7,
|
|
1999
|
-
L:
|
|
2005
|
+
L: 328,
|
|
2000
2006
|
S: this,
|
|
2001
2007
|
C: (f, a) => f(...a)
|
|
2002
2008
|
});
|
|
@@ -2007,7 +2013,7 @@ var InvitationsHandler = class {
|
|
|
2007
2013
|
error: err
|
|
2008
2014
|
}), {
|
|
2009
2015
|
F: __dxlog_file7,
|
|
2010
|
-
L:
|
|
2016
|
+
L: 331,
|
|
2011
2017
|
S: this,
|
|
2012
2018
|
C: (f, a) => f(...a)
|
|
2013
2019
|
});
|
|
@@ -2025,7 +2031,7 @@ var InvitationsHandler = class {
|
|
|
2025
2031
|
...protocol.toJSON()
|
|
2026
2032
|
}, {
|
|
2027
2033
|
F: __dxlog_file7,
|
|
2028
|
-
L:
|
|
2034
|
+
L: 342,
|
|
2029
2035
|
S: this,
|
|
2030
2036
|
C: (f, a) => f(...a)
|
|
2031
2037
|
});
|
|
@@ -2035,7 +2041,7 @@ var InvitationsHandler = class {
|
|
|
2035
2041
|
} else {
|
|
2036
2042
|
log5("auth failed", err, {
|
|
2037
2043
|
F: __dxlog_file7,
|
|
2038
|
-
L:
|
|
2044
|
+
L: 345,
|
|
2039
2045
|
S: this,
|
|
2040
2046
|
C: (f, a) => f(...a)
|
|
2041
2047
|
});
|
|
@@ -2046,29 +2052,34 @@ var InvitationsHandler = class {
|
|
|
2046
2052
|
return extension;
|
|
2047
2053
|
};
|
|
2048
2054
|
scheduleTask2(ctx, async () => {
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
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
|
+
}
|
|
2072
2083
|
});
|
|
2073
2084
|
const observable = new AuthenticatingInvitation({
|
|
2074
2085
|
initialInvitation: invitation,
|
|
@@ -2274,6 +2285,7 @@ import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/creden
|
|
|
2274
2285
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2275
2286
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2276
2287
|
import { log as log7 } from "@dxos/log";
|
|
2288
|
+
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2277
2289
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2278
2290
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2279
2291
|
var SpaceInvitationProtocol = class {
|
|
@@ -2298,7 +2310,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2298
2310
|
async admit(request, guestProfile) {
|
|
2299
2311
|
invariant8(this._spaceKey, void 0, {
|
|
2300
2312
|
F: __dxlog_file9,
|
|
2301
|
-
L:
|
|
2313
|
+
L: 47,
|
|
2302
2314
|
S: this,
|
|
2303
2315
|
A: [
|
|
2304
2316
|
"this._spaceKey",
|
|
@@ -2308,7 +2320,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2308
2320
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2309
2321
|
invariant8(space, void 0, {
|
|
2310
2322
|
F: __dxlog_file9,
|
|
2311
|
-
L:
|
|
2323
|
+
L: 49,
|
|
2312
2324
|
S: this,
|
|
2313
2325
|
A: [
|
|
2314
2326
|
"space",
|
|
@@ -2317,7 +2329,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2317
2329
|
});
|
|
2318
2330
|
invariant8(request.space, void 0, {
|
|
2319
2331
|
F: __dxlog_file9,
|
|
2320
|
-
L:
|
|
2332
|
+
L: 51,
|
|
2321
2333
|
S: this,
|
|
2322
2334
|
A: [
|
|
2323
2335
|
"request.space",
|
|
@@ -2330,14 +2342,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2330
2342
|
guest: deviceKey
|
|
2331
2343
|
}, {
|
|
2332
2344
|
F: __dxlog_file9,
|
|
2333
|
-
L:
|
|
2345
|
+
L: 54,
|
|
2334
2346
|
S: this,
|
|
2335
2347
|
C: (f, a) => f(...a)
|
|
2336
2348
|
});
|
|
2337
2349
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2338
2350
|
invariant8(credentials[0].credential, void 0, {
|
|
2339
2351
|
F: __dxlog_file9,
|
|
2340
|
-
L:
|
|
2352
|
+
L: 65,
|
|
2341
2353
|
S: this,
|
|
2342
2354
|
A: [
|
|
2343
2355
|
"credentials[0].credential",
|
|
@@ -2347,7 +2359,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2347
2359
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2348
2360
|
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2349
2361
|
F: __dxlog_file9,
|
|
2350
|
-
L:
|
|
2362
|
+
L: 67,
|
|
2351
2363
|
S: this,
|
|
2352
2364
|
A: [
|
|
2353
2365
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2363,6 +2375,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2363
2375
|
}
|
|
2364
2376
|
};
|
|
2365
2377
|
}
|
|
2378
|
+
checkInvitation(invitation) {
|
|
2379
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2380
|
+
return new AlreadyJoinedError2("Already joined space.");
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2366
2383
|
createIntroduction() {
|
|
2367
2384
|
return {
|
|
2368
2385
|
profile: this._signingContext.getProfile()
|
|
@@ -2383,7 +2400,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2383
2400
|
async accept(response) {
|
|
2384
2401
|
invariant8(response.space, void 0, {
|
|
2385
2402
|
F: __dxlog_file9,
|
|
2386
|
-
L:
|
|
2403
|
+
L: 108,
|
|
2387
2404
|
S: this,
|
|
2388
2405
|
A: [
|
|
2389
2406
|
"response.space",
|
|
@@ -2394,7 +2411,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2394
2411
|
const assertion = getCredentialAssertion(credential);
|
|
2395
2412
|
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2396
2413
|
F: __dxlog_file9,
|
|
2397
|
-
L:
|
|
2414
|
+
L: 111,
|
|
2398
2415
|
S: this,
|
|
2399
2416
|
A: [
|
|
2400
2417
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2403,13 +2420,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2403
2420
|
});
|
|
2404
2421
|
invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2405
2422
|
F: __dxlog_file9,
|
|
2406
|
-
L:
|
|
2423
|
+
L: 112,
|
|
2407
2424
|
S: this,
|
|
2408
2425
|
A: [
|
|
2409
2426
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2410
2427
|
""
|
|
2411
2428
|
]
|
|
2412
2429
|
});
|
|
2430
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2431
|
+
throw new AlreadyJoinedError2("Already joined space.");
|
|
2432
|
+
}
|
|
2413
2433
|
await this._spaceManager.acceptSpace({
|
|
2414
2434
|
spaceKey: assertion.spaceKey,
|
|
2415
2435
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2515,27 +2535,29 @@ import { STORAGE_VERSION } from "@dxos/protocols";
|
|
|
2515
2535
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2516
2536
|
|
|
2517
2537
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2538
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
2518
2539
|
var getPlatform = () => {
|
|
2519
2540
|
if (process.browser) {
|
|
2520
2541
|
if (typeof window !== "undefined") {
|
|
2521
2542
|
const { userAgent } = window.navigator;
|
|
2522
2543
|
return {
|
|
2523
|
-
type:
|
|
2544
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
2524
2545
|
userAgent,
|
|
2525
2546
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2526
2547
|
};
|
|
2527
2548
|
} else {
|
|
2528
2549
|
return {
|
|
2529
|
-
type:
|
|
2550
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2530
2551
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2531
2552
|
};
|
|
2532
2553
|
}
|
|
2533
2554
|
} else {
|
|
2534
2555
|
const { platform: platform2, version, arch } = process;
|
|
2535
2556
|
return {
|
|
2536
|
-
type:
|
|
2537
|
-
platform:
|
|
2538
|
-
|
|
2557
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
2558
|
+
platform: platform2,
|
|
2559
|
+
arch,
|
|
2560
|
+
runtime: version,
|
|
2539
2561
|
uptime: Math.floor(process.uptime()),
|
|
2540
2562
|
memory: process.memoryUsage()
|
|
2541
2563
|
};
|
|
@@ -2543,7 +2565,7 @@ var getPlatform = () => {
|
|
|
2543
2565
|
};
|
|
2544
2566
|
|
|
2545
2567
|
// packages/sdk/client-services/src/version.ts
|
|
2546
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2568
|
+
var DXOS_VERSION = "0.3.11-main.800163e";
|
|
2547
2569
|
|
|
2548
2570
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2549
2571
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2562,7 +2584,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2562
2584
|
{
|
|
2563
2585
|
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2564
2586
|
F: __dxlog_file10,
|
|
2565
|
-
L:
|
|
2587
|
+
L: 94,
|
|
2566
2588
|
S: void 0,
|
|
2567
2589
|
A: [
|
|
2568
2590
|
"clientServices.LoggingService",
|
|
@@ -2573,6 +2595,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2573
2595
|
timeout: DEFAULT_TIMEOUT
|
|
2574
2596
|
}).catch(() => void 0);
|
|
2575
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
|
+
}
|
|
2576
2613
|
const identity = serviceContext.identityManager.identity;
|
|
2577
2614
|
if (identity) {
|
|
2578
2615
|
diagnostics.identity = {
|
|
@@ -2613,7 +2650,7 @@ var getProperties = (space) => {
|
|
|
2613
2650
|
} catch (err) {
|
|
2614
2651
|
log8.warn(err.message, void 0, {
|
|
2615
2652
|
F: __dxlog_file10,
|
|
2616
|
-
L:
|
|
2653
|
+
L: 179,
|
|
2617
2654
|
S: void 0,
|
|
2618
2655
|
C: (f, a) => f(...a)
|
|
2619
2656
|
});
|
|
@@ -2674,6 +2711,7 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
|
2674
2711
|
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2675
2712
|
import { timed } from "@dxos/debug";
|
|
2676
2713
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2714
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
2677
2715
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2678
2716
|
import { log as log10 } from "@dxos/log";
|
|
2679
2717
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2686,7 +2724,8 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
|
2686
2724
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2687
2725
|
import { checkCredentialType } from "@dxos/credentials";
|
|
2688
2726
|
var AutomergeSpaceState = class {
|
|
2689
|
-
constructor() {
|
|
2727
|
+
constructor(_onNewRoot) {
|
|
2728
|
+
this._onNewRoot = _onNewRoot;
|
|
2690
2729
|
this.rootUrl = void 0;
|
|
2691
2730
|
this.lastEpoch = void 0;
|
|
2692
2731
|
}
|
|
@@ -2697,6 +2736,7 @@ var AutomergeSpaceState = class {
|
|
|
2697
2736
|
this.lastEpoch = credential;
|
|
2698
2737
|
if (credential.subject.assertion.automergeRoot) {
|
|
2699
2738
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2739
|
+
this._onNewRoot(this.rootUrl);
|
|
2700
2740
|
}
|
|
2701
2741
|
}
|
|
2702
2742
|
};
|
|
@@ -2988,7 +3028,7 @@ var DataSpace = class {
|
|
|
2988
3028
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2989
3029
|
this._cache = void 0;
|
|
2990
3030
|
// TODO(dmaretskyi): Move into Space?
|
|
2991
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3031
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
2992
3032
|
this._state = SpaceState.CLOSED;
|
|
2993
3033
|
/**
|
|
2994
3034
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -3017,7 +3057,7 @@ var DataSpace = class {
|
|
|
3017
3057
|
state: SpaceState[this._state]
|
|
3018
3058
|
}, {
|
|
3019
3059
|
F: __dxlog_file12,
|
|
3020
|
-
L:
|
|
3060
|
+
L: 138,
|
|
3021
3061
|
S: this,
|
|
3022
3062
|
C: (f, a) => f(...a)
|
|
3023
3063
|
});
|
|
@@ -3064,7 +3104,7 @@ var DataSpace = class {
|
|
|
3064
3104
|
state: SpaceState[this._state]
|
|
3065
3105
|
}, {
|
|
3066
3106
|
F: __dxlog_file12,
|
|
3067
|
-
L:
|
|
3107
|
+
L: 190,
|
|
3068
3108
|
S: this,
|
|
3069
3109
|
C: (f, a) => f(...a)
|
|
3070
3110
|
});
|
|
@@ -3082,7 +3122,7 @@ var DataSpace = class {
|
|
|
3082
3122
|
state: SpaceState[this._state]
|
|
3083
3123
|
}, {
|
|
3084
3124
|
F: __dxlog_file12,
|
|
3085
|
-
L:
|
|
3125
|
+
L: 204,
|
|
3086
3126
|
S: this,
|
|
3087
3127
|
C: (f, a) => f(...a)
|
|
3088
3128
|
});
|
|
@@ -3114,7 +3154,7 @@ var DataSpace = class {
|
|
|
3114
3154
|
if (err instanceof CancelledError) {
|
|
3115
3155
|
log10("data pipeline initialization cancelled", err, {
|
|
3116
3156
|
F: __dxlog_file12,
|
|
3117
|
-
L:
|
|
3157
|
+
L: 237,
|
|
3118
3158
|
S: this,
|
|
3119
3159
|
C: (f, a) => f(...a)
|
|
3120
3160
|
});
|
|
@@ -3122,7 +3162,7 @@ var DataSpace = class {
|
|
|
3122
3162
|
}
|
|
3123
3163
|
log10.error("Error initializing data pipeline", err, {
|
|
3124
3164
|
F: __dxlog_file12,
|
|
3125
|
-
L:
|
|
3165
|
+
L: 241,
|
|
3126
3166
|
S: this,
|
|
3127
3167
|
C: (f, a) => f(...a)
|
|
3128
3168
|
});
|
|
@@ -3131,7 +3171,7 @@ var DataSpace = class {
|
|
|
3131
3171
|
state: SpaceState[this._state]
|
|
3132
3172
|
}, {
|
|
3133
3173
|
F: __dxlog_file12,
|
|
3134
|
-
L:
|
|
3174
|
+
L: 243,
|
|
3135
3175
|
S: this,
|
|
3136
3176
|
C: (f, a) => f(...a)
|
|
3137
3177
|
});
|
|
@@ -3151,7 +3191,7 @@ var DataSpace = class {
|
|
|
3151
3191
|
state: SpaceState[this._state]
|
|
3152
3192
|
}, {
|
|
3153
3193
|
F: __dxlog_file12,
|
|
3154
|
-
L:
|
|
3194
|
+
L: 259,
|
|
3155
3195
|
S: this,
|
|
3156
3196
|
C: (f, a) => f(...a)
|
|
3157
3197
|
});
|
|
@@ -3162,7 +3202,7 @@ var DataSpace = class {
|
|
|
3162
3202
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3163
3203
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3164
3204
|
F: __dxlog_file12,
|
|
3165
|
-
L:
|
|
3205
|
+
L: 273,
|
|
3166
3206
|
S: this,
|
|
3167
3207
|
C: (f, a) => f(...a)
|
|
3168
3208
|
});
|
|
@@ -3173,7 +3213,7 @@ var DataSpace = class {
|
|
|
3173
3213
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3174
3214
|
log10("data pipeline ready", void 0, {
|
|
3175
3215
|
F: __dxlog_file12,
|
|
3176
|
-
L:
|
|
3216
|
+
L: 282,
|
|
3177
3217
|
S: this,
|
|
3178
3218
|
C: (f, a) => f(...a)
|
|
3179
3219
|
});
|
|
@@ -3183,7 +3223,7 @@ var DataSpace = class {
|
|
|
3183
3223
|
state: SpaceState[this._state]
|
|
3184
3224
|
}, {
|
|
3185
3225
|
F: __dxlog_file12,
|
|
3186
|
-
L:
|
|
3226
|
+
L: 286,
|
|
3187
3227
|
S: this,
|
|
3188
3228
|
C: (f, a) => f(...a)
|
|
3189
3229
|
});
|
|
@@ -3199,7 +3239,7 @@ var DataSpace = class {
|
|
|
3199
3239
|
await this._createWritableFeeds();
|
|
3200
3240
|
log10("writable feeds created", void 0, {
|
|
3201
3241
|
F: __dxlog_file12,
|
|
3202
|
-
L:
|
|
3242
|
+
L: 302,
|
|
3203
3243
|
S: this,
|
|
3204
3244
|
C: (f, a) => f(...a)
|
|
3205
3245
|
});
|
|
@@ -3256,6 +3296,40 @@ var DataSpace = class {
|
|
|
3256
3296
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3257
3297
|
}
|
|
3258
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
|
+
}
|
|
3259
3333
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3260
3334
|
async updateOwnProfile(profile) {
|
|
3261
3335
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3339,7 +3413,7 @@ var DataSpace = class {
|
|
|
3339
3413
|
state: SpaceState[this._state]
|
|
3340
3414
|
}, {
|
|
3341
3415
|
F: __dxlog_file12,
|
|
3342
|
-
L:
|
|
3416
|
+
L: 470,
|
|
3343
3417
|
S: this,
|
|
3344
3418
|
C: (f, a) => f(...a)
|
|
3345
3419
|
});
|
|
@@ -3598,12 +3672,15 @@ var DataSpaceManager = class {
|
|
|
3598
3672
|
});
|
|
3599
3673
|
const space = await this._constructSpace(metadata);
|
|
3600
3674
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3675
|
+
automergeRoot.change((doc) => {
|
|
3676
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3677
|
+
});
|
|
3601
3678
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3602
3679
|
await this._metadataStore.addSpace(metadata);
|
|
3603
3680
|
const memberCredential = credentials[1];
|
|
3604
3681
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3605
3682
|
F: __dxlog_file13,
|
|
3606
|
-
L:
|
|
3683
|
+
L: 154,
|
|
3607
3684
|
S: this,
|
|
3608
3685
|
A: [
|
|
3609
3686
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3621,13 +3698,13 @@ var DataSpaceManager = class {
|
|
|
3621
3698
|
opts
|
|
3622
3699
|
}, {
|
|
3623
3700
|
F: __dxlog_file13,
|
|
3624
|
-
L:
|
|
3701
|
+
L: 166,
|
|
3625
3702
|
S: this,
|
|
3626
3703
|
C: (f, a) => f(...a)
|
|
3627
3704
|
});
|
|
3628
3705
|
invariant11(this._isOpen, "Not open.", {
|
|
3629
3706
|
F: __dxlog_file13,
|
|
3630
|
-
L:
|
|
3707
|
+
L: 167,
|
|
3631
3708
|
S: this,
|
|
3632
3709
|
A: [
|
|
3633
3710
|
"this._isOpen",
|
|
@@ -3636,7 +3713,7 @@ var DataSpaceManager = class {
|
|
|
3636
3713
|
});
|
|
3637
3714
|
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3638
3715
|
F: __dxlog_file13,
|
|
3639
|
-
L:
|
|
3716
|
+
L: 168,
|
|
3640
3717
|
S: this,
|
|
3641
3718
|
A: [
|
|
3642
3719
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3671,7 +3748,7 @@ var DataSpaceManager = class {
|
|
|
3671
3748
|
metadata
|
|
3672
3749
|
}, {
|
|
3673
3750
|
F: __dxlog_file13,
|
|
3674
|
-
L:
|
|
3751
|
+
L: 201,
|
|
3675
3752
|
S: this,
|
|
3676
3753
|
C: (f, a) => f(...a)
|
|
3677
3754
|
});
|
|
@@ -3698,17 +3775,18 @@ var DataSpaceManager = class {
|
|
|
3698
3775
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3699
3776
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
3700
3777
|
},
|
|
3701
|
-
|
|
3778
|
+
onAuthorizedConnection: (session) => {
|
|
3702
3779
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3703
3780
|
remotePeerId: session.remotePeerId
|
|
3704
3781
|
}));
|
|
3705
3782
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3783
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3706
3784
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3707
3785
|
},
|
|
3708
3786
|
onAuthFailure: () => {
|
|
3709
3787
|
log11.warn("auth failure", void 0, {
|
|
3710
3788
|
F: __dxlog_file13,
|
|
3711
|
-
L:
|
|
3789
|
+
L: 238,
|
|
3712
3790
|
S: this,
|
|
3713
3791
|
C: (f, a) => f(...a)
|
|
3714
3792
|
});
|
|
@@ -3732,7 +3810,7 @@ var DataSpaceManager = class {
|
|
|
3732
3810
|
space: space.key
|
|
3733
3811
|
}, {
|
|
3734
3812
|
F: __dxlog_file13,
|
|
3735
|
-
L:
|
|
3813
|
+
L: 256,
|
|
3736
3814
|
S: this,
|
|
3737
3815
|
C: (f, a) => f(...a)
|
|
3738
3816
|
});
|
|
@@ -3744,7 +3822,7 @@ var DataSpaceManager = class {
|
|
|
3744
3822
|
open: this._isOpen
|
|
3745
3823
|
}, {
|
|
3746
3824
|
F: __dxlog_file13,
|
|
3747
|
-
L:
|
|
3825
|
+
L: 263,
|
|
3748
3826
|
S: this,
|
|
3749
3827
|
C: (f, a) => f(...a)
|
|
3750
3828
|
});
|
|
@@ -3757,7 +3835,7 @@ var DataSpaceManager = class {
|
|
|
3757
3835
|
space: space.key
|
|
3758
3836
|
}, {
|
|
3759
3837
|
F: __dxlog_file13,
|
|
3760
|
-
L:
|
|
3838
|
+
L: 269,
|
|
3761
3839
|
S: this,
|
|
3762
3840
|
C: (f, a) => f(...a)
|
|
3763
3841
|
});
|
|
@@ -3814,7 +3892,7 @@ var SpacesServiceImpl = class {
|
|
|
3814
3892
|
}
|
|
3815
3893
|
async createSpace() {
|
|
3816
3894
|
if (!this._identityManager.identity) {
|
|
3817
|
-
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");
|
|
3818
3896
|
}
|
|
3819
3897
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3820
3898
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -4677,6 +4755,7 @@ var NetworkServiceImpl = class {
|
|
|
4677
4755
|
const update = () => {
|
|
4678
4756
|
next({
|
|
4679
4757
|
swarm: this.networkManager.connectionState,
|
|
4758
|
+
connectionInfo: this.networkManager.connectionLog?.swarms,
|
|
4680
4759
|
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
4681
4760
|
server: host,
|
|
4682
4761
|
state
|
|
@@ -4726,6 +4805,9 @@ var SystemServiceImpl = class {
|
|
|
4726
4805
|
})))
|
|
4727
4806
|
};
|
|
4728
4807
|
}
|
|
4808
|
+
async getPlatform() {
|
|
4809
|
+
return getPlatform();
|
|
4810
|
+
}
|
|
4729
4811
|
async updateStatus({ status }) {
|
|
4730
4812
|
await this._onUpdateStatus(status);
|
|
4731
4813
|
}
|
|
@@ -5187,4 +5269,4 @@ export {
|
|
|
5187
5269
|
createDefaultModelFactory,
|
|
5188
5270
|
ClientServicesHost
|
|
5189
5271
|
};
|
|
5190
|
-
//# sourceMappingURL=chunk-
|
|
5272
|
+
//# sourceMappingURL=chunk-GUFT4GX3.mjs.map
|