@dxos/client-services 0.4.10-main.93fda5f → 0.4.10-main.94f946a
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-ULO2U4N6.mjs → chunk-6CUDF3NG.mjs} +1505 -1131
- package/dist/lib/browser/chunk-6CUDF3NG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -6
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +141 -119
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-4TLGRMKO.cjs → chunk-NTBQPLBQ.cjs} +1388 -1098
- package/dist/lib/node/chunk-NTBQPLBQ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +55 -41
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +139 -120
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +12 -10
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +5 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- package/dist/types/src/packlets/system/system-service.d.ts +1 -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/packlets/testing/test-builder.d.ts +10 -4
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -34
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.test.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +75 -96
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/network/network-service.test.ts +1 -1
- package/src/packlets/services/automerge-host.test.ts +13 -7
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +9 -6
- package/src/packlets/services/service-context.ts +31 -26
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +47 -27
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +56 -13
- package/src/packlets/spaces/data-space.ts +54 -10
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +20 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +40 -9
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-ULO2U4N6.mjs.map +0 -7
- package/dist/lib/node/chunk-4TLGRMKO.cjs.map +0 -7
- package/dist/types/src/packlets/indexing/index.d.ts +0 -2
- package/dist/types/src/packlets/indexing/index.d.ts.map +0 -1
- package/dist/types/src/packlets/indexing/util.d.ts +0 -15
- package/dist/types/src/packlets/indexing/util.d.ts.map +0 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
- package/src/packlets/indexing/index.ts +0 -5
- package/src/packlets/indexing/util.ts +0 -89
|
@@ -1086,7 +1086,9 @@ var IdentityManager = class {
|
|
|
1086
1086
|
C: (f, a) => f(...a)
|
|
1087
1087
|
});
|
|
1088
1088
|
},
|
|
1089
|
-
memberKey: identityKey
|
|
1089
|
+
memberKey: identityKey,
|
|
1090
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1091
|
+
}
|
|
1090
1092
|
});
|
|
1091
1093
|
}
|
|
1092
1094
|
};
|
|
@@ -1194,10 +1196,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1194
1196
|
kind: Invitation.Kind.DEVICE
|
|
1195
1197
|
};
|
|
1196
1198
|
}
|
|
1197
|
-
async
|
|
1199
|
+
async delegate(invitation) {
|
|
1200
|
+
throw new Error("delegation not supported");
|
|
1201
|
+
}
|
|
1202
|
+
async admit(_, request) {
|
|
1198
1203
|
invariant4(request.device, void 0, {
|
|
1199
1204
|
F: __dxlog_file5,
|
|
1200
|
-
L:
|
|
1205
|
+
L: 42,
|
|
1201
1206
|
S: this,
|
|
1202
1207
|
A: [
|
|
1203
1208
|
"request.device",
|
|
@@ -1243,7 +1248,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1243
1248
|
async accept(response, request) {
|
|
1244
1249
|
invariant4(response.device, void 0, {
|
|
1245
1250
|
F: __dxlog_file5,
|
|
1246
|
-
L:
|
|
1251
|
+
L: 87,
|
|
1247
1252
|
S: this,
|
|
1248
1253
|
A: [
|
|
1249
1254
|
"response.device",
|
|
@@ -1253,7 +1258,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1253
1258
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1254
1259
|
invariant4(request.device, void 0, {
|
|
1255
1260
|
F: __dxlog_file5,
|
|
1256
|
-
L:
|
|
1261
|
+
L: 90,
|
|
1257
1262
|
S: this,
|
|
1258
1263
|
A: [
|
|
1259
1264
|
"request.device",
|
|
@@ -1279,9 +1284,9 @@ var DeviceInvitationProtocol = class {
|
|
|
1279
1284
|
|
|
1280
1285
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1281
1286
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
1282
|
-
import { AuthenticatingInvitation,
|
|
1287
|
+
import { AuthenticatingInvitation, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
1283
1288
|
import { Context as Context5 } from "@dxos/context";
|
|
1284
|
-
import {
|
|
1289
|
+
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1285
1290
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1286
1291
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1287
1292
|
import { log as log5 } from "@dxos/log";
|
|
@@ -1293,6 +1298,7 @@ import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protoco
|
|
|
1293
1298
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1294
1299
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1295
1300
|
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1301
|
+
import { randomBytes, verify } from "@dxos/crypto";
|
|
1296
1302
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1297
1303
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1298
1304
|
import { log as log4 } from "@dxos/log";
|
|
@@ -1316,6 +1322,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1316
1322
|
this._callbacks = _callbacks;
|
|
1317
1323
|
this._ctx = new Context4();
|
|
1318
1324
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1325
|
+
this._challenge = void 0;
|
|
1319
1326
|
this.invitation = void 0;
|
|
1320
1327
|
this.guestProfile = void 0;
|
|
1321
1328
|
this.authenticationPassed = false;
|
|
@@ -1330,7 +1337,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1330
1337
|
options: async (options) => {
|
|
1331
1338
|
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1332
1339
|
F: __dxlog_file6,
|
|
1333
|
-
L:
|
|
1340
|
+
L: 90,
|
|
1334
1341
|
S: this,
|
|
1335
1342
|
A: [
|
|
1336
1343
|
"!this._remoteOptions",
|
|
@@ -1347,7 +1354,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1347
1354
|
id: traceId
|
|
1348
1355
|
}), {
|
|
1349
1356
|
F: __dxlog_file6,
|
|
1350
|
-
L:
|
|
1357
|
+
L: 99,
|
|
1351
1358
|
S: this,
|
|
1352
1359
|
C: (f, a) => f(...a)
|
|
1353
1360
|
});
|
|
@@ -1357,7 +1364,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1357
1364
|
invitationId
|
|
1358
1365
|
}, {
|
|
1359
1366
|
F: __dxlog_file6,
|
|
1360
|
-
L:
|
|
1367
|
+
L: 103,
|
|
1361
1368
|
S: this,
|
|
1362
1369
|
C: (f, a) => f(...a)
|
|
1363
1370
|
});
|
|
@@ -1371,7 +1378,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1371
1378
|
guestProfile: profile
|
|
1372
1379
|
}, {
|
|
1373
1380
|
F: __dxlog_file6,
|
|
1374
|
-
L:
|
|
1381
|
+
L: 112,
|
|
1375
1382
|
S: this,
|
|
1376
1383
|
C: (f, a) => f(...a)
|
|
1377
1384
|
});
|
|
@@ -1380,25 +1387,27 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1380
1387
|
...this.invitation,
|
|
1381
1388
|
state: Invitation2.State.READY_FOR_AUTHENTICATION
|
|
1382
1389
|
});
|
|
1390
|
+
this._challenge = this.invitation.authMethod === Invitation2.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
1383
1391
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
|
|
1384
1392
|
id: traceId
|
|
1385
1393
|
}), {
|
|
1386
1394
|
F: __dxlog_file6,
|
|
1387
|
-
L:
|
|
1395
|
+
L: 122,
|
|
1388
1396
|
S: this,
|
|
1389
1397
|
C: (f, a) => f(...a)
|
|
1390
1398
|
});
|
|
1391
1399
|
return {
|
|
1392
|
-
authMethod: this.invitation.authMethod
|
|
1400
|
+
authMethod: this.invitation.authMethod,
|
|
1401
|
+
challenge: this._challenge
|
|
1393
1402
|
};
|
|
1394
1403
|
},
|
|
1395
|
-
authenticate: async ({ authCode: code }) => {
|
|
1404
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1396
1405
|
const traceId = PublicKey5.random().toHex();
|
|
1397
1406
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1398
1407
|
id: traceId
|
|
1399
1408
|
}), {
|
|
1400
1409
|
F: __dxlog_file6,
|
|
1401
|
-
L:
|
|
1410
|
+
L: 131,
|
|
1402
1411
|
S: this,
|
|
1403
1412
|
C: (f, a) => f(...a)
|
|
1404
1413
|
});
|
|
@@ -1406,14 +1415,14 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1406
1415
|
authCode: code
|
|
1407
1416
|
}, {
|
|
1408
1417
|
F: __dxlog_file6,
|
|
1409
|
-
L:
|
|
1418
|
+
L: 132,
|
|
1410
1419
|
S: this,
|
|
1411
1420
|
C: (f, a) => f(...a)
|
|
1412
1421
|
});
|
|
1413
1422
|
let status = AuthenticationResponse.Status.OK;
|
|
1414
1423
|
invariant5(this.invitation, "Invitation is not set.", {
|
|
1415
1424
|
F: __dxlog_file6,
|
|
1416
|
-
L:
|
|
1425
|
+
L: 135,
|
|
1417
1426
|
S: this,
|
|
1418
1427
|
A: [
|
|
1419
1428
|
"this.invitation",
|
|
@@ -1424,7 +1433,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1424
1433
|
case Invitation2.AuthMethod.NONE: {
|
|
1425
1434
|
log4("authentication not required", void 0, {
|
|
1426
1435
|
F: __dxlog_file6,
|
|
1427
|
-
L:
|
|
1436
|
+
L: 138,
|
|
1428
1437
|
S: this,
|
|
1429
1438
|
C: (f, a) => f(...a)
|
|
1430
1439
|
});
|
|
@@ -1444,12 +1453,25 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1444
1453
|
}
|
|
1445
1454
|
break;
|
|
1446
1455
|
}
|
|
1456
|
+
case Invitation2.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1457
|
+
if (!this.invitation.guestKeypair) {
|
|
1458
|
+
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
const isSignatureValid = this._challenge && verify(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1462
|
+
if (isSignatureValid) {
|
|
1463
|
+
this.authenticationPassed = true;
|
|
1464
|
+
} else {
|
|
1465
|
+
status = AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1466
|
+
}
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1447
1469
|
default: {
|
|
1448
1470
|
log4.error("invalid authentication method", {
|
|
1449
1471
|
authMethod: this.invitation.authMethod
|
|
1450
1472
|
}, {
|
|
1451
1473
|
F: __dxlog_file6,
|
|
1452
|
-
L:
|
|
1474
|
+
L: 176,
|
|
1453
1475
|
S: this,
|
|
1454
1476
|
C: (f, a) => f(...a)
|
|
1455
1477
|
});
|
|
@@ -1464,7 +1486,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1464
1486
|
}
|
|
1465
1487
|
}), {
|
|
1466
1488
|
F: __dxlog_file6,
|
|
1467
|
-
L:
|
|
1489
|
+
L: 182,
|
|
1468
1490
|
S: this,
|
|
1469
1491
|
C: (f, a) => f(...a)
|
|
1470
1492
|
});
|
|
@@ -1478,14 +1500,14 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1478
1500
|
id: traceId
|
|
1479
1501
|
}), {
|
|
1480
1502
|
F: __dxlog_file6,
|
|
1481
|
-
L:
|
|
1503
|
+
L: 188,
|
|
1482
1504
|
S: this,
|
|
1483
1505
|
C: (f, a) => f(...a)
|
|
1484
1506
|
});
|
|
1485
1507
|
try {
|
|
1486
1508
|
invariant5(this.invitation, "Invitation is not set.", {
|
|
1487
1509
|
F: __dxlog_file6,
|
|
1488
|
-
L:
|
|
1510
|
+
L: 191,
|
|
1489
1511
|
S: this,
|
|
1490
1512
|
A: [
|
|
1491
1513
|
"this.invitation",
|
|
@@ -1500,7 +1522,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1500
1522
|
id: traceId
|
|
1501
1523
|
}), {
|
|
1502
1524
|
F: __dxlog_file6,
|
|
1503
|
-
L:
|
|
1525
|
+
L: 199,
|
|
1504
1526
|
S: this,
|
|
1505
1527
|
C: (f, a) => f(...a)
|
|
1506
1528
|
});
|
|
@@ -1557,7 +1579,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1557
1579
|
options: async (options) => {
|
|
1558
1580
|
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1559
1581
|
F: __dxlog_file6,
|
|
1560
|
-
L:
|
|
1582
|
+
L: 266,
|
|
1561
1583
|
S: this,
|
|
1562
1584
|
A: [
|
|
1563
1585
|
"!this._remoteOptions",
|
|
@@ -1584,7 +1606,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1584
1606
|
try {
|
|
1585
1607
|
log4("begin options", void 0, {
|
|
1586
1608
|
F: __dxlog_file6,
|
|
1587
|
-
L:
|
|
1609
|
+
L: 287,
|
|
1588
1610
|
S: this,
|
|
1589
1611
|
C: (f, a) => f(...a)
|
|
1590
1612
|
});
|
|
@@ -1596,7 +1618,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1596
1618
|
}));
|
|
1597
1619
|
log4("end options", void 0, {
|
|
1598
1620
|
F: __dxlog_file6,
|
|
1599
|
-
L:
|
|
1621
|
+
L: 290,
|
|
1600
1622
|
S: this,
|
|
1601
1623
|
C: (f, a) => f(...a)
|
|
1602
1624
|
});
|
|
@@ -1610,7 +1632,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1610
1632
|
} catch (err) {
|
|
1611
1633
|
log4("openError", err, {
|
|
1612
1634
|
F: __dxlog_file6,
|
|
1613
|
-
L:
|
|
1635
|
+
L: 300,
|
|
1614
1636
|
S: this,
|
|
1615
1637
|
C: (f, a) => f(...a)
|
|
1616
1638
|
});
|
|
@@ -1620,7 +1642,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1620
1642
|
async onClose() {
|
|
1621
1643
|
log4("onClose", void 0, {
|
|
1622
1644
|
F: __dxlog_file6,
|
|
1623
|
-
L:
|
|
1645
|
+
L: 306,
|
|
1624
1646
|
S: this,
|
|
1625
1647
|
C: (f, a) => f(...a)
|
|
1626
1648
|
});
|
|
@@ -1638,49 +1660,7 @@ var InvitationsHandler = class {
|
|
|
1638
1660
|
constructor(_networkManager) {
|
|
1639
1661
|
this._networkManager = _networkManager;
|
|
1640
1662
|
}
|
|
1641
|
-
|
|
1642
|
-
const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
|
|
1643
|
-
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1644
|
-
invariant6(protocol, void 0, {
|
|
1645
|
-
F: __dxlog_file7,
|
|
1646
|
-
L: 84,
|
|
1647
|
-
S: this,
|
|
1648
|
-
A: [
|
|
1649
|
-
"protocol",
|
|
1650
|
-
""
|
|
1651
|
-
]
|
|
1652
|
-
});
|
|
1653
|
-
const invitation = {
|
|
1654
|
-
invitationId,
|
|
1655
|
-
type,
|
|
1656
|
-
authMethod,
|
|
1657
|
-
state,
|
|
1658
|
-
swarmKey,
|
|
1659
|
-
authCode,
|
|
1660
|
-
timeout,
|
|
1661
|
-
persistent,
|
|
1662
|
-
created,
|
|
1663
|
-
lifetime,
|
|
1664
|
-
...protocol.getInvitationContext()
|
|
1665
|
-
};
|
|
1666
|
-
const stream = new PushStream();
|
|
1667
|
-
const ctx = new Context5({
|
|
1668
|
-
onError: (err) => {
|
|
1669
|
-
stream.error(err);
|
|
1670
|
-
void ctx.dispose();
|
|
1671
|
-
}
|
|
1672
|
-
});
|
|
1673
|
-
ctx.onDispose(() => {
|
|
1674
|
-
log5("complete", {
|
|
1675
|
-
...protocol.toJSON()
|
|
1676
|
-
}, {
|
|
1677
|
-
F: __dxlog_file7,
|
|
1678
|
-
L: 109,
|
|
1679
|
-
S: this,
|
|
1680
|
-
C: (f, a) => f(...a)
|
|
1681
|
-
});
|
|
1682
|
-
stream.complete();
|
|
1683
|
-
});
|
|
1663
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1684
1664
|
const createExtension = () => {
|
|
1685
1665
|
const extension = new InvitationHostExtension({
|
|
1686
1666
|
onStateUpdate: (invitation2) => {
|
|
@@ -1689,8 +1669,8 @@ var InvitationsHandler = class {
|
|
|
1689
1669
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
1690
1670
|
});
|
|
1691
1671
|
},
|
|
1692
|
-
resolveInvitation: async ({ invitationId
|
|
1693
|
-
if (
|
|
1672
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1673
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1694
1674
|
return void 0;
|
|
1695
1675
|
}
|
|
1696
1676
|
return invitation;
|
|
@@ -1700,14 +1680,14 @@ var InvitationsHandler = class {
|
|
|
1700
1680
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1701
1681
|
invariant6(deviceKey, void 0, {
|
|
1702
1682
|
F: __dxlog_file7,
|
|
1703
|
-
L:
|
|
1683
|
+
L: 87,
|
|
1704
1684
|
S: this,
|
|
1705
1685
|
A: [
|
|
1706
1686
|
"deviceKey",
|
|
1707
1687
|
""
|
|
1708
1688
|
]
|
|
1709
1689
|
});
|
|
1710
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1690
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1711
1691
|
extension.completedTrigger.wake(deviceKey);
|
|
1712
1692
|
return admissionResponse;
|
|
1713
1693
|
} catch (err) {
|
|
@@ -1723,7 +1703,7 @@ var InvitationsHandler = class {
|
|
|
1723
1703
|
id: traceId
|
|
1724
1704
|
}), {
|
|
1725
1705
|
F: __dxlog_file7,
|
|
1726
|
-
L:
|
|
1706
|
+
L: 105,
|
|
1727
1707
|
S: this,
|
|
1728
1708
|
C: (f, a) => f(...a)
|
|
1729
1709
|
});
|
|
@@ -1731,7 +1711,7 @@ var InvitationsHandler = class {
|
|
|
1731
1711
|
...protocol.toJSON()
|
|
1732
1712
|
}, {
|
|
1733
1713
|
F: __dxlog_file7,
|
|
1734
|
-
L:
|
|
1714
|
+
L: 106,
|
|
1735
1715
|
S: this,
|
|
1736
1716
|
C: (f, a) => f(...a)
|
|
1737
1717
|
});
|
|
@@ -1740,14 +1720,14 @@ var InvitationsHandler = class {
|
|
|
1740
1720
|
state: Invitation3.State.CONNECTED
|
|
1741
1721
|
});
|
|
1742
1722
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1743
|
-
timeout
|
|
1723
|
+
timeout: invitation.timeout
|
|
1744
1724
|
});
|
|
1745
1725
|
log5("admitted guest", {
|
|
1746
1726
|
guest: deviceKey,
|
|
1747
1727
|
...protocol.toJSON()
|
|
1748
1728
|
}, {
|
|
1749
1729
|
F: __dxlog_file7,
|
|
1750
|
-
L:
|
|
1730
|
+
L: 109,
|
|
1751
1731
|
S: this,
|
|
1752
1732
|
C: (f, a) => f(...a)
|
|
1753
1733
|
});
|
|
@@ -1759,7 +1739,7 @@ var InvitationsHandler = class {
|
|
|
1759
1739
|
id: traceId
|
|
1760
1740
|
}), {
|
|
1761
1741
|
F: __dxlog_file7,
|
|
1762
|
-
L:
|
|
1742
|
+
L: 111,
|
|
1763
1743
|
S: this,
|
|
1764
1744
|
C: (f, a) => f(...a)
|
|
1765
1745
|
});
|
|
@@ -1769,7 +1749,7 @@ var InvitationsHandler = class {
|
|
|
1769
1749
|
...protocol.toJSON()
|
|
1770
1750
|
}, {
|
|
1771
1751
|
F: __dxlog_file7,
|
|
1772
|
-
L:
|
|
1752
|
+
L: 114,
|
|
1773
1753
|
S: this,
|
|
1774
1754
|
C: (f, a) => f(...a)
|
|
1775
1755
|
});
|
|
@@ -1780,7 +1760,7 @@ var InvitationsHandler = class {
|
|
|
1780
1760
|
} else {
|
|
1781
1761
|
log5.error("failed", err, {
|
|
1782
1762
|
F: __dxlog_file7,
|
|
1783
|
-
L:
|
|
1763
|
+
L: 117,
|
|
1784
1764
|
S: this,
|
|
1785
1765
|
C: (f, a) => f(...a)
|
|
1786
1766
|
});
|
|
@@ -1791,12 +1771,12 @@ var InvitationsHandler = class {
|
|
|
1791
1771
|
error: err
|
|
1792
1772
|
}), {
|
|
1793
1773
|
F: __dxlog_file7,
|
|
1794
|
-
L:
|
|
1774
|
+
L: 120,
|
|
1795
1775
|
S: this,
|
|
1796
1776
|
C: (f, a) => f(...a)
|
|
1797
1777
|
});
|
|
1798
1778
|
} finally {
|
|
1799
|
-
if (
|
|
1779
|
+
if (!invitation.multiUse) {
|
|
1800
1780
|
await swarmConnection.close();
|
|
1801
1781
|
await ctx.dispose();
|
|
1802
1782
|
}
|
|
@@ -1812,7 +1792,7 @@ var InvitationsHandler = class {
|
|
|
1812
1792
|
...protocol.toJSON()
|
|
1813
1793
|
}, {
|
|
1814
1794
|
F: __dxlog_file7,
|
|
1815
|
-
L:
|
|
1795
|
+
L: 135,
|
|
1816
1796
|
S: this,
|
|
1817
1797
|
C: (f, a) => f(...a)
|
|
1818
1798
|
});
|
|
@@ -1823,7 +1803,7 @@ var InvitationsHandler = class {
|
|
|
1823
1803
|
} else {
|
|
1824
1804
|
log5.error("failed", err, {
|
|
1825
1805
|
F: __dxlog_file7,
|
|
1826
|
-
L:
|
|
1806
|
+
L: 138,
|
|
1827
1807
|
S: this,
|
|
1828
1808
|
C: (f, a) => f(...a)
|
|
1829
1809
|
});
|
|
@@ -1833,11 +1813,11 @@ var InvitationsHandler = class {
|
|
|
1833
1813
|
});
|
|
1834
1814
|
return extension;
|
|
1835
1815
|
};
|
|
1836
|
-
if (invitation.lifetime && invitation.created
|
|
1816
|
+
if (invitation.lifetime && invitation.created) {
|
|
1837
1817
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1838
1818
|
log5.warn("invitation has already expired", void 0, {
|
|
1839
1819
|
F: __dxlog_file7,
|
|
1840
|
-
L:
|
|
1820
|
+
L: 149,
|
|
1841
1821
|
S: this,
|
|
1842
1822
|
C: (f, a) => f(...a)
|
|
1843
1823
|
});
|
|
@@ -1871,24 +1851,12 @@ var InvitationsHandler = class {
|
|
|
1871
1851
|
state: Invitation3.State.CONNECTING
|
|
1872
1852
|
});
|
|
1873
1853
|
});
|
|
1874
|
-
const observable = new CancellableInvitation({
|
|
1875
|
-
initialInvitation: invitation,
|
|
1876
|
-
subscriber: stream.observable,
|
|
1877
|
-
onCancel: async () => {
|
|
1878
|
-
stream.next({
|
|
1879
|
-
...invitation,
|
|
1880
|
-
state: Invitation3.State.CANCELLED
|
|
1881
|
-
});
|
|
1882
|
-
await ctx.dispose();
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
return observable;
|
|
1886
1854
|
}
|
|
1887
1855
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
1888
1856
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1889
1857
|
invariant6(protocol, void 0, {
|
|
1890
1858
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1859
|
+
L: 191,
|
|
1892
1860
|
S: this,
|
|
1893
1861
|
A: [
|
|
1894
1862
|
"protocol",
|
|
@@ -1898,7 +1866,7 @@ var InvitationsHandler = class {
|
|
|
1898
1866
|
if (deviceProfile) {
|
|
1899
1867
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1900
1868
|
F: __dxlog_file7,
|
|
1901
|
-
L:
|
|
1869
|
+
L: 194,
|
|
1902
1870
|
S: this,
|
|
1903
1871
|
A: [
|
|
1904
1872
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1913,7 +1881,7 @@ var InvitationsHandler = class {
|
|
|
1913
1881
|
const setState = (newData) => {
|
|
1914
1882
|
invariant6(newData.state !== void 0, void 0, {
|
|
1915
1883
|
F: __dxlog_file7,
|
|
1916
|
-
L:
|
|
1884
|
+
L: 205,
|
|
1917
1885
|
S: this,
|
|
1918
1886
|
A: [
|
|
1919
1887
|
"newData.state !== undefined",
|
|
@@ -1933,7 +1901,7 @@ var InvitationsHandler = class {
|
|
|
1933
1901
|
...protocol.toJSON()
|
|
1934
1902
|
}, {
|
|
1935
1903
|
F: __dxlog_file7,
|
|
1936
|
-
L:
|
|
1904
|
+
L: 213,
|
|
1937
1905
|
S: this,
|
|
1938
1906
|
C: (f, a) => f(...a)
|
|
1939
1907
|
});
|
|
@@ -1943,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1943
1911
|
} else {
|
|
1944
1912
|
log5.warn("auth failed", err, {
|
|
1945
1913
|
F: __dxlog_file7,
|
|
1946
|
-
L:
|
|
1914
|
+
L: 216,
|
|
1947
1915
|
S: this,
|
|
1948
1916
|
C: (f, a) => f(...a)
|
|
1949
1917
|
});
|
|
@@ -1957,7 +1925,7 @@ var InvitationsHandler = class {
|
|
|
1957
1925
|
...protocol.toJSON()
|
|
1958
1926
|
}, {
|
|
1959
1927
|
F: __dxlog_file7,
|
|
1960
|
-
L:
|
|
1928
|
+
L: 224,
|
|
1961
1929
|
S: this,
|
|
1962
1930
|
C: (f, a) => f(...a)
|
|
1963
1931
|
});
|
|
@@ -1972,7 +1940,7 @@ var InvitationsHandler = class {
|
|
|
1972
1940
|
currentState
|
|
1973
1941
|
}, {
|
|
1974
1942
|
F: __dxlog_file7,
|
|
1975
|
-
L:
|
|
1943
|
+
L: 234,
|
|
1976
1944
|
S: this,
|
|
1977
1945
|
C: (f, a) => f(...a)
|
|
1978
1946
|
});
|
|
@@ -1987,7 +1955,7 @@ var InvitationsHandler = class {
|
|
|
1987
1955
|
id: traceId
|
|
1988
1956
|
}), {
|
|
1989
1957
|
F: __dxlog_file7,
|
|
1990
|
-
L:
|
|
1958
|
+
L: 243,
|
|
1991
1959
|
S: this,
|
|
1992
1960
|
C: (f, a) => f(...a)
|
|
1993
1961
|
});
|
|
@@ -1999,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
1999
1967
|
...protocol.toJSON()
|
|
2000
1968
|
}, {
|
|
2001
1969
|
F: __dxlog_file7,
|
|
2002
|
-
L:
|
|
1970
|
+
L: 251,
|
|
2003
1971
|
S: this,
|
|
2004
1972
|
C: (f, a) => f(...a)
|
|
2005
1973
|
});
|
|
@@ -2010,7 +1978,7 @@ var InvitationsHandler = class {
|
|
|
2010
1978
|
...protocol.toJSON()
|
|
2011
1979
|
}, {
|
|
2012
1980
|
F: __dxlog_file7,
|
|
2013
|
-
L:
|
|
1981
|
+
L: 255,
|
|
2014
1982
|
S: this,
|
|
2015
1983
|
C: (f, a) => f(...a)
|
|
2016
1984
|
});
|
|
@@ -2020,62 +1988,28 @@ var InvitationsHandler = class {
|
|
|
2020
1988
|
response: introductionResponse
|
|
2021
1989
|
}, {
|
|
2022
1990
|
F: __dxlog_file7,
|
|
2023
|
-
L:
|
|
1991
|
+
L: 259,
|
|
2024
1992
|
S: this,
|
|
2025
1993
|
C: (f, a) => f(...a)
|
|
2026
1994
|
});
|
|
2027
1995
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2028
1996
|
if (isAuthenticationRequired(invitation)) {
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
2038
|
-
});
|
|
2039
|
-
const authCode = await authenticated.wait({
|
|
2040
|
-
timeout
|
|
2041
|
-
});
|
|
2042
|
-
log5("sending authentication request", void 0, {
|
|
2043
|
-
F: __dxlog_file7,
|
|
2044
|
-
L: 325,
|
|
2045
|
-
S: this,
|
|
2046
|
-
C: (f, a) => f(...a)
|
|
2047
|
-
});
|
|
2048
|
-
setState({
|
|
2049
|
-
state: Invitation3.State.AUTHENTICATING
|
|
2050
|
-
});
|
|
2051
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2052
|
-
authCode
|
|
2053
|
-
});
|
|
2054
|
-
if (response.status === void 0 || response.status === AuthenticationResponse2.Status.OK) {
|
|
1997
|
+
switch (invitation.authMethod) {
|
|
1998
|
+
case Invitation3.AuthMethod.SHARED_SECRET:
|
|
1999
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2000
|
+
timeout
|
|
2001
|
+
});
|
|
2002
|
+
break;
|
|
2003
|
+
case Invitation3.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2004
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2055
2005
|
break;
|
|
2056
|
-
}
|
|
2057
|
-
if (response.status === AuthenticationResponse2.Status.INVALID_OTP) {
|
|
2058
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2059
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2060
|
-
} else {
|
|
2061
|
-
log5("retrying invalid code", {
|
|
2062
|
-
attempt
|
|
2063
|
-
}, {
|
|
2064
|
-
F: __dxlog_file7,
|
|
2065
|
-
L: 336,
|
|
2066
|
-
S: this,
|
|
2067
|
-
C: (f, a) => f(...a)
|
|
2068
|
-
});
|
|
2069
|
-
authenticated.reset();
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
2006
|
}
|
|
2073
2007
|
}
|
|
2074
2008
|
log5("request admission", {
|
|
2075
2009
|
...protocol.toJSON()
|
|
2076
2010
|
}, {
|
|
2077
2011
|
F: __dxlog_file7,
|
|
2078
|
-
L:
|
|
2012
|
+
L: 275,
|
|
2079
2013
|
S: this,
|
|
2080
2014
|
C: (f, a) => f(...a)
|
|
2081
2015
|
});
|
|
@@ -2087,7 +2021,7 @@ var InvitationsHandler = class {
|
|
|
2087
2021
|
...protocol.toJSON()
|
|
2088
2022
|
}, {
|
|
2089
2023
|
F: __dxlog_file7,
|
|
2090
|
-
L:
|
|
2024
|
+
L: 286,
|
|
2091
2025
|
S: this,
|
|
2092
2026
|
C: (f, a) => f(...a)
|
|
2093
2027
|
});
|
|
@@ -2100,7 +2034,7 @@ var InvitationsHandler = class {
|
|
|
2100
2034
|
id: traceId
|
|
2101
2035
|
}), {
|
|
2102
2036
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2037
|
+
L: 288,
|
|
2104
2038
|
S: this,
|
|
2105
2039
|
C: (f, a) => f(...a)
|
|
2106
2040
|
});
|
|
@@ -2110,7 +2044,7 @@ var InvitationsHandler = class {
|
|
|
2110
2044
|
...protocol.toJSON()
|
|
2111
2045
|
}, {
|
|
2112
2046
|
F: __dxlog_file7,
|
|
2113
|
-
L:
|
|
2047
|
+
L: 291,
|
|
2114
2048
|
S: this,
|
|
2115
2049
|
C: (f, a) => f(...a)
|
|
2116
2050
|
});
|
|
@@ -2120,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2120
2054
|
} else {
|
|
2121
2055
|
log5("auth failed", err, {
|
|
2122
2056
|
F: __dxlog_file7,
|
|
2123
|
-
L:
|
|
2057
|
+
L: 294,
|
|
2124
2058
|
S: this,
|
|
2125
2059
|
C: (f, a) => f(...a)
|
|
2126
2060
|
});
|
|
@@ -2131,7 +2065,7 @@ var InvitationsHandler = class {
|
|
|
2131
2065
|
error: err
|
|
2132
2066
|
}), {
|
|
2133
2067
|
F: __dxlog_file7,
|
|
2134
|
-
L:
|
|
2068
|
+
L: 297,
|
|
2135
2069
|
S: this,
|
|
2136
2070
|
C: (f, a) => f(...a)
|
|
2137
2071
|
});
|
|
@@ -2149,7 +2083,7 @@ var InvitationsHandler = class {
|
|
|
2149
2083
|
...protocol.toJSON()
|
|
2150
2084
|
}, {
|
|
2151
2085
|
F: __dxlog_file7,
|
|
2152
|
-
L:
|
|
2086
|
+
L: 308,
|
|
2153
2087
|
S: this,
|
|
2154
2088
|
C: (f, a) => f(...a)
|
|
2155
2089
|
});
|
|
@@ -2159,7 +2093,7 @@ var InvitationsHandler = class {
|
|
|
2159
2093
|
} else {
|
|
2160
2094
|
log5("auth failed", err, {
|
|
2161
2095
|
F: __dxlog_file7,
|
|
2162
|
-
L:
|
|
2096
|
+
L: 311,
|
|
2163
2097
|
S: this,
|
|
2164
2098
|
C: (f, a) => f(...a)
|
|
2165
2099
|
});
|
|
@@ -2176,7 +2110,7 @@ var InvitationsHandler = class {
|
|
|
2176
2110
|
} else {
|
|
2177
2111
|
invariant6(invitation.swarmKey, void 0, {
|
|
2178
2112
|
F: __dxlog_file7,
|
|
2179
|
-
L:
|
|
2113
|
+
L: 325,
|
|
2180
2114
|
S: this,
|
|
2181
2115
|
A: [
|
|
2182
2116
|
"invitation.swarmKey",
|
|
@@ -2214,206 +2148,114 @@ var InvitationsHandler = class {
|
|
|
2214
2148
|
});
|
|
2215
2149
|
return observable;
|
|
2216
2150
|
}
|
|
2151
|
+
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2152
|
+
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2153
|
+
log5("guest waiting for authentication code...", void 0, {
|
|
2154
|
+
F: __dxlog_file7,
|
|
2155
|
+
L: 365,
|
|
2156
|
+
S: this,
|
|
2157
|
+
C: (f, a) => f(...a)
|
|
2158
|
+
});
|
|
2159
|
+
setState({
|
|
2160
|
+
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
2161
|
+
});
|
|
2162
|
+
const authCode = await authenticated.wait(options);
|
|
2163
|
+
log5("sending authentication request", void 0, {
|
|
2164
|
+
F: __dxlog_file7,
|
|
2165
|
+
L: 369,
|
|
2166
|
+
S: this,
|
|
2167
|
+
C: (f, a) => f(...a)
|
|
2168
|
+
});
|
|
2169
|
+
setState({
|
|
2170
|
+
state: Invitation3.State.AUTHENTICATING
|
|
2171
|
+
});
|
|
2172
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2173
|
+
authCode
|
|
2174
|
+
});
|
|
2175
|
+
if (response.status === void 0 || response.status === AuthenticationResponse2.Status.OK) {
|
|
2176
|
+
break;
|
|
2177
|
+
}
|
|
2178
|
+
if (response.status === AuthenticationResponse2.Status.INVALID_OTP) {
|
|
2179
|
+
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2180
|
+
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2181
|
+
} else {
|
|
2182
|
+
log5("retrying invalid code", {
|
|
2183
|
+
attempt
|
|
2184
|
+
}, {
|
|
2185
|
+
F: __dxlog_file7,
|
|
2186
|
+
L: 380,
|
|
2187
|
+
S: this,
|
|
2188
|
+
C: (f, a) => f(...a)
|
|
2189
|
+
});
|
|
2190
|
+
authenticated.reset();
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
|
|
2196
|
+
if (invitation.guestKeypair?.privateKey == null) {
|
|
2197
|
+
throw new Error("keypair missing in the invitation");
|
|
2198
|
+
}
|
|
2199
|
+
if (introductionResponse.challenge == null) {
|
|
2200
|
+
throw new Error("challenge missing in the introduction");
|
|
2201
|
+
}
|
|
2202
|
+
log5("sending authentication request", void 0, {
|
|
2203
|
+
F: __dxlog_file7,
|
|
2204
|
+
L: 399,
|
|
2205
|
+
S: this,
|
|
2206
|
+
C: (f, a) => f(...a)
|
|
2207
|
+
});
|
|
2208
|
+
setState({
|
|
2209
|
+
state: Invitation3.State.AUTHENTICATING
|
|
2210
|
+
});
|
|
2211
|
+
const signature = sign(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2212
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2213
|
+
signedChallenge: signature
|
|
2214
|
+
});
|
|
2215
|
+
if (response.status !== AuthenticationResponse2.Status.OK) {
|
|
2216
|
+
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2217
2219
|
};
|
|
2218
|
-
var
|
|
2219
|
-
|
|
2220
|
+
var createAdmissionKeypair = () => {
|
|
2221
|
+
const keypair = createKeyPair();
|
|
2222
|
+
return {
|
|
2223
|
+
publicKey: PublicKey6.from(keypair.publicKey),
|
|
2224
|
+
privateKey: keypair.secretKey
|
|
2225
|
+
};
|
|
2220
2226
|
};
|
|
2221
2227
|
|
|
2222
2228
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2223
|
-
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2224
2229
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2225
|
-
import {
|
|
2226
|
-
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2227
|
-
import { log as log6 } from "@dxos/log";
|
|
2228
|
-
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2229
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2230
|
+
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2230
2231
|
var InvitationsServiceImpl = class {
|
|
2231
|
-
constructor(
|
|
2232
|
-
this.
|
|
2233
|
-
this._getHandler = _getHandler;
|
|
2234
|
-
this._metadataStore = _metadataStore;
|
|
2235
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2236
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2237
|
-
this._invitationCreated = new Event3();
|
|
2238
|
-
this._invitationAccepted = new Event3();
|
|
2239
|
-
this._removedCreated = new Event3();
|
|
2240
|
-
this._removedAccepted = new Event3();
|
|
2241
|
-
this._saved = new Event3();
|
|
2242
|
-
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2243
|
-
this._persistentInvitationsLoaded = false;
|
|
2232
|
+
constructor(_invitationsManager) {
|
|
2233
|
+
this._invitationsManager = _invitationsManager;
|
|
2244
2234
|
}
|
|
2245
2235
|
// TODO(burdon): Guest/host label.
|
|
2246
2236
|
getLoggingContext() {
|
|
2247
2237
|
return {};
|
|
2248
2238
|
}
|
|
2249
2239
|
createInvitation(options) {
|
|
2250
|
-
let invitation;
|
|
2251
|
-
const savePersistentInvitationCtx = new Context6();
|
|
2252
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2253
|
-
if (existingInvitation) {
|
|
2254
|
-
invitation = existingInvitation;
|
|
2255
|
-
} else {
|
|
2256
|
-
const handler = this._getHandler(options);
|
|
2257
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2258
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2259
|
-
this._invitationCreated.emit(invitation.get());
|
|
2260
|
-
}
|
|
2261
2240
|
return new Stream8(({ next, close }) => {
|
|
2262
|
-
|
|
2263
|
-
scheduleTask3(savePersistentInvitationCtx, async () => {
|
|
2264
|
-
try {
|
|
2265
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2266
|
-
this._saved.emit(invitation.get());
|
|
2267
|
-
} catch (err) {
|
|
2268
|
-
close(err);
|
|
2269
|
-
}
|
|
2270
|
-
});
|
|
2271
|
-
}
|
|
2272
|
-
invitation.subscribe((invitation2) => {
|
|
2273
|
-
next(invitation2);
|
|
2274
|
-
}, async (err) => {
|
|
2275
|
-
await savePersistentInvitationCtx.dispose();
|
|
2276
|
-
close(err);
|
|
2277
|
-
}, async () => {
|
|
2278
|
-
close();
|
|
2279
|
-
if (invitation.get().persistent) {
|
|
2280
|
-
await savePersistentInvitationCtx.dispose();
|
|
2281
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2282
|
-
}
|
|
2283
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2284
|
-
if (invitation.get().type !== Invitation4.Type.MULTIUSE) {
|
|
2285
|
-
this._removedCreated.emit(invitation.get());
|
|
2286
|
-
}
|
|
2287
|
-
});
|
|
2241
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2288
2242
|
});
|
|
2289
2243
|
}
|
|
2290
|
-
|
|
2291
|
-
const
|
|
2292
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2293
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2294
|
-
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2295
|
-
F: __dxlog_file8,
|
|
2296
|
-
L: 109,
|
|
2297
|
-
S: this,
|
|
2298
|
-
A: [
|
|
2299
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2300
|
-
"'invitation already exists'"
|
|
2301
|
-
]
|
|
2302
|
-
});
|
|
2303
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2304
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2305
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2306
|
-
this._invitationCreated.emit(invitation.get());
|
|
2307
|
-
return persistentInvitation;
|
|
2308
|
-
});
|
|
2309
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2310
|
-
this._persistentInvitationsLoaded = true;
|
|
2311
|
-
return {
|
|
2312
|
-
invitations: cInvitations
|
|
2313
|
-
};
|
|
2314
|
-
}
|
|
2315
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2316
|
-
let invitation;
|
|
2317
|
-
if (deviceProfile) {
|
|
2318
|
-
invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2319
|
-
F: __dxlog_file8,
|
|
2320
|
-
L: 127,
|
|
2321
|
-
S: this,
|
|
2322
|
-
A: [
|
|
2323
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2324
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2325
|
-
]
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2329
|
-
if (existingInvitation) {
|
|
2330
|
-
invitation = existingInvitation;
|
|
2331
|
-
} else {
|
|
2332
|
-
const handler = this._getHandler(options);
|
|
2333
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2334
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2335
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2336
|
-
}
|
|
2244
|
+
acceptInvitation(request) {
|
|
2245
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2337
2246
|
return new Stream8(({ next, close }) => {
|
|
2338
|
-
invitation.subscribe(
|
|
2339
|
-
next(invitation2);
|
|
2340
|
-
}, (err) => {
|
|
2341
|
-
close(err);
|
|
2342
|
-
}, () => {
|
|
2343
|
-
close();
|
|
2344
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2345
|
-
if (invitation.get().type !== Invitation4.Type.MULTIUSE) {
|
|
2346
|
-
this._removedAccepted.emit(invitation.get());
|
|
2347
|
-
}
|
|
2348
|
-
});
|
|
2247
|
+
invitation.subscribe(next, close, close);
|
|
2349
2248
|
});
|
|
2350
2249
|
}
|
|
2351
|
-
async authenticate(
|
|
2352
|
-
|
|
2353
|
-
F: __dxlog_file8,
|
|
2354
|
-
L: 160,
|
|
2355
|
-
S: this,
|
|
2356
|
-
C: (f, a) => f(...a)
|
|
2357
|
-
});
|
|
2358
|
-
invariant7(invitationId, void 0, {
|
|
2359
|
-
F: __dxlog_file8,
|
|
2360
|
-
L: 161,
|
|
2361
|
-
S: this,
|
|
2362
|
-
A: [
|
|
2363
|
-
"invitationId",
|
|
2364
|
-
""
|
|
2365
|
-
]
|
|
2366
|
-
});
|
|
2367
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2368
|
-
if (!observable) {
|
|
2369
|
-
log6.warn("invalid invitation", {
|
|
2370
|
-
invitationId
|
|
2371
|
-
}, {
|
|
2372
|
-
F: __dxlog_file8,
|
|
2373
|
-
L: 164,
|
|
2374
|
-
S: this,
|
|
2375
|
-
C: (f, a) => f(...a)
|
|
2376
|
-
});
|
|
2377
|
-
} else {
|
|
2378
|
-
await observable.authenticate(authCode);
|
|
2379
|
-
}
|
|
2250
|
+
async authenticate(request) {
|
|
2251
|
+
return this._invitationsManager.authenticate(request);
|
|
2380
2252
|
}
|
|
2381
|
-
async cancelInvitation(
|
|
2382
|
-
|
|
2383
|
-
invitationId
|
|
2384
|
-
}, {
|
|
2385
|
-
F: __dxlog_file8,
|
|
2386
|
-
L: 171,
|
|
2387
|
-
S: this,
|
|
2388
|
-
C: (f, a) => f(...a)
|
|
2389
|
-
});
|
|
2390
|
-
invariant7(invitationId, void 0, {
|
|
2391
|
-
F: __dxlog_file8,
|
|
2392
|
-
L: 172,
|
|
2393
|
-
S: this,
|
|
2394
|
-
A: [
|
|
2395
|
-
"invitationId",
|
|
2396
|
-
""
|
|
2397
|
-
]
|
|
2398
|
-
});
|
|
2399
|
-
const created = this._createInvitations.get(invitationId);
|
|
2400
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2401
|
-
if (created) {
|
|
2402
|
-
await created.cancel();
|
|
2403
|
-
this._createInvitations.delete(invitationId);
|
|
2404
|
-
this._removedCreated.emit(created.get());
|
|
2405
|
-
if (created.get().persistent) {
|
|
2406
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2407
|
-
}
|
|
2408
|
-
} else if (accepted) {
|
|
2409
|
-
await accepted.cancel();
|
|
2410
|
-
this._acceptInvitations.delete(invitationId);
|
|
2411
|
-
this._removedAccepted.emit(accepted.get());
|
|
2412
|
-
}
|
|
2253
|
+
async cancelInvitation(request) {
|
|
2254
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2413
2255
|
}
|
|
2414
2256
|
queryInvitations() {
|
|
2415
2257
|
return new Stream8(({ next, ctx }) => {
|
|
2416
|
-
this.
|
|
2258
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2417
2259
|
next({
|
|
2418
2260
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2419
2261
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2422,7 +2264,7 @@ var InvitationsServiceImpl = class {
|
|
|
2422
2264
|
]
|
|
2423
2265
|
});
|
|
2424
2266
|
});
|
|
2425
|
-
this.
|
|
2267
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2426
2268
|
next({
|
|
2427
2269
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2428
2270
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2431,7 +2273,7 @@ var InvitationsServiceImpl = class {
|
|
|
2431
2273
|
]
|
|
2432
2274
|
});
|
|
2433
2275
|
});
|
|
2434
|
-
this.
|
|
2276
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2435
2277
|
next({
|
|
2436
2278
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2437
2279
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2440,7 +2282,7 @@ var InvitationsServiceImpl = class {
|
|
|
2440
2282
|
]
|
|
2441
2283
|
});
|
|
2442
2284
|
});
|
|
2443
|
-
this.
|
|
2285
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2444
2286
|
next({
|
|
2445
2287
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2446
2288
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2449,7 +2291,7 @@ var InvitationsServiceImpl = class {
|
|
|
2449
2291
|
]
|
|
2450
2292
|
});
|
|
2451
2293
|
});
|
|
2452
|
-
this.
|
|
2294
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2453
2295
|
next({
|
|
2454
2296
|
action: QueryInvitationsResponse.Action.SAVED,
|
|
2455
2297
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2461,40 +2303,34 @@ var InvitationsServiceImpl = class {
|
|
|
2461
2303
|
next({
|
|
2462
2304
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2463
2305
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2464
|
-
invitations:
|
|
2306
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2465
2307
|
existing: true
|
|
2466
2308
|
});
|
|
2467
2309
|
next({
|
|
2468
2310
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2469
2311
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2470
|
-
invitations:
|
|
2312
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2471
2313
|
existing: true
|
|
2472
2314
|
});
|
|
2473
|
-
|
|
2315
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2474
2316
|
next({
|
|
2475
2317
|
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2476
2318
|
type: QueryInvitationsResponse.Type.CREATED
|
|
2477
2319
|
});
|
|
2478
|
-
}
|
|
2479
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2480
|
-
next({
|
|
2481
|
-
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2482
|
-
type: QueryInvitationsResponse.Type.CREATED
|
|
2483
|
-
});
|
|
2484
|
-
});
|
|
2485
|
-
}
|
|
2320
|
+
});
|
|
2486
2321
|
});
|
|
2487
2322
|
}
|
|
2488
2323
|
};
|
|
2489
2324
|
|
|
2490
2325
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2491
|
-
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2326
|
+
import { createAdmissionCredentials, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
|
|
2492
2327
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2493
|
-
import { invariant as
|
|
2494
|
-
import { log as
|
|
2328
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2329
|
+
import { log as log6 } from "@dxos/log";
|
|
2495
2330
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2496
|
-
import { Invitation as
|
|
2497
|
-
|
|
2331
|
+
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2332
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2333
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2498
2334
|
var SpaceInvitationProtocol = class {
|
|
2499
2335
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2500
2336
|
this._spaceManager = _spaceManager;
|
|
@@ -2510,14 +2346,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2510
2346
|
}
|
|
2511
2347
|
getInvitationContext() {
|
|
2512
2348
|
return {
|
|
2513
|
-
kind:
|
|
2349
|
+
kind: Invitation4.Kind.SPACE,
|
|
2514
2350
|
spaceKey: this._spaceKey
|
|
2515
2351
|
};
|
|
2516
2352
|
}
|
|
2517
|
-
async admit(request, guestProfile) {
|
|
2518
|
-
|
|
2519
|
-
F:
|
|
2520
|
-
L:
|
|
2353
|
+
async admit(invitation, request, guestProfile) {
|
|
2354
|
+
invariant7(this._spaceKey, void 0, {
|
|
2355
|
+
F: __dxlog_file8,
|
|
2356
|
+
L: 55,
|
|
2521
2357
|
S: this,
|
|
2522
2358
|
A: [
|
|
2523
2359
|
"this._spaceKey",
|
|
@@ -2525,18 +2361,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2525
2361
|
]
|
|
2526
2362
|
});
|
|
2527
2363
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2528
|
-
|
|
2529
|
-
F:
|
|
2530
|
-
L:
|
|
2364
|
+
invariant7(space, void 0, {
|
|
2365
|
+
F: __dxlog_file8,
|
|
2366
|
+
L: 57,
|
|
2531
2367
|
S: this,
|
|
2532
2368
|
A: [
|
|
2533
2369
|
"space",
|
|
2534
2370
|
""
|
|
2535
2371
|
]
|
|
2536
2372
|
});
|
|
2537
|
-
|
|
2538
|
-
F:
|
|
2539
|
-
L:
|
|
2373
|
+
invariant7(request.space, void 0, {
|
|
2374
|
+
F: __dxlog_file8,
|
|
2375
|
+
L: 59,
|
|
2540
2376
|
S: this,
|
|
2541
2377
|
A: [
|
|
2542
2378
|
"request.space",
|
|
@@ -2544,19 +2380,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2544
2380
|
]
|
|
2545
2381
|
});
|
|
2546
2382
|
const { identityKey, deviceKey } = request.space;
|
|
2547
|
-
|
|
2383
|
+
log6("writing guest credentials", {
|
|
2548
2384
|
host: this._signingContext.deviceKey,
|
|
2549
2385
|
guest: deviceKey
|
|
2550
2386
|
}, {
|
|
2551
|
-
F:
|
|
2552
|
-
L:
|
|
2387
|
+
F: __dxlog_file8,
|
|
2388
|
+
L: 62,
|
|
2553
2389
|
S: this,
|
|
2554
2390
|
C: (f, a) => f(...a)
|
|
2555
2391
|
});
|
|
2556
|
-
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2557
|
-
|
|
2558
|
-
F:
|
|
2559
|
-
L:
|
|
2392
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2393
|
+
invariant7(credentials[0].credential, void 0, {
|
|
2394
|
+
F: __dxlog_file8,
|
|
2395
|
+
L: 74,
|
|
2560
2396
|
S: this,
|
|
2561
2397
|
A: [
|
|
2562
2398
|
"credentials[0].credential",
|
|
@@ -2564,9 +2400,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2564
2400
|
]
|
|
2565
2401
|
});
|
|
2566
2402
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2567
|
-
|
|
2568
|
-
F:
|
|
2569
|
-
L:
|
|
2403
|
+
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2404
|
+
F: __dxlog_file8,
|
|
2405
|
+
L: 76,
|
|
2570
2406
|
S: this,
|
|
2571
2407
|
A: [
|
|
2572
2408
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2581,6 +2417,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2581
2417
|
}
|
|
2582
2418
|
};
|
|
2583
2419
|
}
|
|
2420
|
+
async delegate(invitation) {
|
|
2421
|
+
invariant7(this._spaceKey, void 0, {
|
|
2422
|
+
F: __dxlog_file8,
|
|
2423
|
+
L: 89,
|
|
2424
|
+
S: this,
|
|
2425
|
+
A: [
|
|
2426
|
+
"this._spaceKey",
|
|
2427
|
+
""
|
|
2428
|
+
]
|
|
2429
|
+
});
|
|
2430
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2431
|
+
invariant7(space, void 0, {
|
|
2432
|
+
F: __dxlog_file8,
|
|
2433
|
+
L: 91,
|
|
2434
|
+
S: this,
|
|
2435
|
+
A: [
|
|
2436
|
+
"space",
|
|
2437
|
+
""
|
|
2438
|
+
]
|
|
2439
|
+
});
|
|
2440
|
+
if (invitation.authMethod === Invitation4.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2441
|
+
invariant7(invitation.guestKeypair?.publicKey, void 0, {
|
|
2442
|
+
F: __dxlog_file8,
|
|
2443
|
+
L: 93,
|
|
2444
|
+
S: this,
|
|
2445
|
+
A: [
|
|
2446
|
+
"invitation.guestKeypair?.publicKey",
|
|
2447
|
+
""
|
|
2448
|
+
]
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
log6("writing delegate space invitation", {
|
|
2452
|
+
host: this._signingContext.deviceKey,
|
|
2453
|
+
id: invitation.invitationId
|
|
2454
|
+
}, {
|
|
2455
|
+
F: __dxlog_file8,
|
|
2456
|
+
L: 96,
|
|
2457
|
+
S: this,
|
|
2458
|
+
C: (f, a) => f(...a)
|
|
2459
|
+
});
|
|
2460
|
+
const credential = await createDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, {
|
|
2461
|
+
invitationId: invitation.invitationId,
|
|
2462
|
+
authMethod: invitation.authMethod,
|
|
2463
|
+
swarmKey: invitation.swarmKey,
|
|
2464
|
+
role: SpaceMember.Role.ADMIN,
|
|
2465
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2466
|
+
multiUse: invitation.multiUse ?? false,
|
|
2467
|
+
guestKey: invitation.authMethod === Invitation4.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2468
|
+
});
|
|
2469
|
+
invariant7(credential.credential, void 0, {
|
|
2470
|
+
F: __dxlog_file8,
|
|
2471
|
+
L: 116,
|
|
2472
|
+
S: this,
|
|
2473
|
+
A: [
|
|
2474
|
+
"credential.credential",
|
|
2475
|
+
""
|
|
2476
|
+
]
|
|
2477
|
+
});
|
|
2478
|
+
await writeMessages2(space.inner.controlPipeline.writer, [
|
|
2479
|
+
credential
|
|
2480
|
+
]);
|
|
2481
|
+
return credential.credential.credential.id;
|
|
2482
|
+
}
|
|
2584
2483
|
checkInvitation(invitation) {
|
|
2585
2484
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2586
2485
|
return new AlreadyJoinedError2("Already joined space.");
|
|
@@ -2604,9 +2503,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2604
2503
|
};
|
|
2605
2504
|
}
|
|
2606
2505
|
async accept(response) {
|
|
2607
|
-
|
|
2608
|
-
F:
|
|
2609
|
-
L:
|
|
2506
|
+
invariant7(response.space, void 0, {
|
|
2507
|
+
F: __dxlog_file8,
|
|
2508
|
+
L: 149,
|
|
2610
2509
|
S: this,
|
|
2611
2510
|
A: [
|
|
2612
2511
|
"response.space",
|
|
@@ -2615,18 +2514,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2615
2514
|
});
|
|
2616
2515
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2617
2516
|
const assertion = getCredentialAssertion(credential);
|
|
2618
|
-
|
|
2619
|
-
F:
|
|
2620
|
-
L:
|
|
2517
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2518
|
+
F: __dxlog_file8,
|
|
2519
|
+
L: 152,
|
|
2621
2520
|
S: this,
|
|
2622
2521
|
A: [
|
|
2623
2522
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2624
2523
|
"'Invalid credential'"
|
|
2625
2524
|
]
|
|
2626
2525
|
});
|
|
2627
|
-
|
|
2628
|
-
F:
|
|
2629
|
-
L:
|
|
2526
|
+
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2527
|
+
F: __dxlog_file8,
|
|
2528
|
+
L: 153,
|
|
2630
2529
|
S: this,
|
|
2631
2530
|
A: [
|
|
2632
2531
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2649,6 +2548,295 @@ var SpaceInvitationProtocol = class {
|
|
|
2649
2548
|
}
|
|
2650
2549
|
};
|
|
2651
2550
|
|
|
2551
|
+
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
2552
|
+
import { Event as Event3, PushStream as PushStream2 } from "@dxos/async";
|
|
2553
|
+
import { AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2554
|
+
import { Context as Context6 } from "@dxos/context";
|
|
2555
|
+
import { generatePasscode } from "@dxos/credentials";
|
|
2556
|
+
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2557
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2558
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2559
|
+
import { log as log7 } from "@dxos/log";
|
|
2560
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2561
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2562
|
+
var InvitationsManager = class {
|
|
2563
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2564
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2565
|
+
this._getHandler = _getHandler;
|
|
2566
|
+
this._metadataStore = _metadataStore;
|
|
2567
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2568
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2569
|
+
this.invitationCreated = new Event3();
|
|
2570
|
+
this.invitationAccepted = new Event3();
|
|
2571
|
+
this.removedCreated = new Event3();
|
|
2572
|
+
this.removedAccepted = new Event3();
|
|
2573
|
+
this.saved = new Event3();
|
|
2574
|
+
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2575
|
+
this._persistentInvitationsLoaded = false;
|
|
2576
|
+
}
|
|
2577
|
+
async createInvitation(options) {
|
|
2578
|
+
if (options.invitationId) {
|
|
2579
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2580
|
+
if (existingInvitation) {
|
|
2581
|
+
return existingInvitation;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
const handler = this._getHandler(options);
|
|
2585
|
+
const invitation = this._createInvitation(handler, options);
|
|
2586
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2587
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2588
|
+
this.invitationCreated.emit(invitation);
|
|
2589
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2590
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2591
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2592
|
+
if (observableInvitation.get().persistent) {
|
|
2593
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
try {
|
|
2597
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2598
|
+
} catch (err) {
|
|
2599
|
+
log7.catch(err, void 0, {
|
|
2600
|
+
F: __dxlog_file9,
|
|
2601
|
+
L: 76,
|
|
2602
|
+
S: this,
|
|
2603
|
+
C: (f, a) => f(...a)
|
|
2604
|
+
});
|
|
2605
|
+
await observableInvitation.cancel();
|
|
2606
|
+
return observableInvitation;
|
|
2607
|
+
}
|
|
2608
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2609
|
+
return observableInvitation;
|
|
2610
|
+
}
|
|
2611
|
+
async loadPersistentInvitations() {
|
|
2612
|
+
if (this._persistentInvitationsLoaded) {
|
|
2613
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2614
|
+
return {
|
|
2615
|
+
invitations
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
try {
|
|
2619
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2620
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
2621
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2622
|
+
invariant8(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2623
|
+
F: __dxlog_file9,
|
|
2624
|
+
L: 97,
|
|
2625
|
+
S: this,
|
|
2626
|
+
A: [
|
|
2627
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2628
|
+
"'invitation already exists'"
|
|
2629
|
+
]
|
|
2630
|
+
});
|
|
2631
|
+
return this.createInvitation({
|
|
2632
|
+
...persistentInvitation,
|
|
2633
|
+
persistent: false
|
|
2634
|
+
});
|
|
2635
|
+
});
|
|
2636
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2637
|
+
return {
|
|
2638
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2639
|
+
};
|
|
2640
|
+
} catch (err) {
|
|
2641
|
+
log7.catch(err, void 0, {
|
|
2642
|
+
F: __dxlog_file9,
|
|
2643
|
+
L: 104,
|
|
2644
|
+
S: this,
|
|
2645
|
+
C: (f, a) => f(...a)
|
|
2646
|
+
});
|
|
2647
|
+
return {
|
|
2648
|
+
invitations: []
|
|
2649
|
+
};
|
|
2650
|
+
} finally {
|
|
2651
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2652
|
+
this._persistentInvitationsLoaded = true;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
acceptInvitation(request) {
|
|
2656
|
+
const options = request.invitation;
|
|
2657
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2658
|
+
if (existingInvitation) {
|
|
2659
|
+
return existingInvitation;
|
|
2660
|
+
}
|
|
2661
|
+
const handler = this._getHandler(options);
|
|
2662
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2663
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2664
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2665
|
+
this._onInvitationComplete(invitation, () => {
|
|
2666
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2667
|
+
this.removedAccepted.emit(invitation.get());
|
|
2668
|
+
});
|
|
2669
|
+
return invitation;
|
|
2670
|
+
}
|
|
2671
|
+
async authenticate({ invitationId, authCode }) {
|
|
2672
|
+
log7("authenticating...", void 0, {
|
|
2673
|
+
F: __dxlog_file9,
|
|
2674
|
+
L: 133,
|
|
2675
|
+
S: this,
|
|
2676
|
+
C: (f, a) => f(...a)
|
|
2677
|
+
});
|
|
2678
|
+
invariant8(invitationId, void 0, {
|
|
2679
|
+
F: __dxlog_file9,
|
|
2680
|
+
L: 134,
|
|
2681
|
+
S: this,
|
|
2682
|
+
A: [
|
|
2683
|
+
"invitationId",
|
|
2684
|
+
""
|
|
2685
|
+
]
|
|
2686
|
+
});
|
|
2687
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2688
|
+
if (!observable) {
|
|
2689
|
+
log7.warn("invalid invitation", {
|
|
2690
|
+
invitationId
|
|
2691
|
+
}, {
|
|
2692
|
+
F: __dxlog_file9,
|
|
2693
|
+
L: 137,
|
|
2694
|
+
S: this,
|
|
2695
|
+
C: (f, a) => f(...a)
|
|
2696
|
+
});
|
|
2697
|
+
} else {
|
|
2698
|
+
await observable.authenticate(authCode);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
async cancelInvitation({ invitationId }) {
|
|
2702
|
+
log7("cancelInvitation...", {
|
|
2703
|
+
invitationId
|
|
2704
|
+
}, {
|
|
2705
|
+
F: __dxlog_file9,
|
|
2706
|
+
L: 144,
|
|
2707
|
+
S: this,
|
|
2708
|
+
C: (f, a) => f(...a)
|
|
2709
|
+
});
|
|
2710
|
+
invariant8(invitationId, void 0, {
|
|
2711
|
+
F: __dxlog_file9,
|
|
2712
|
+
L: 145,
|
|
2713
|
+
S: this,
|
|
2714
|
+
A: [
|
|
2715
|
+
"invitationId",
|
|
2716
|
+
""
|
|
2717
|
+
]
|
|
2718
|
+
});
|
|
2719
|
+
const created = this._createInvitations.get(invitationId);
|
|
2720
|
+
if (created) {
|
|
2721
|
+
if (created.get().persistent) {
|
|
2722
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2723
|
+
}
|
|
2724
|
+
await created.cancel();
|
|
2725
|
+
this._createInvitations.delete(invitationId);
|
|
2726
|
+
this.removedCreated.emit(created.get());
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2730
|
+
if (accepted) {
|
|
2731
|
+
await accepted.cancel();
|
|
2732
|
+
this._acceptInvitations.delete(invitationId);
|
|
2733
|
+
this.removedAccepted.emit(accepted.get());
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
getCreatedInvitations() {
|
|
2737
|
+
return [
|
|
2738
|
+
...this._createInvitations.values()
|
|
2739
|
+
].map((i) => i.get());
|
|
2740
|
+
}
|
|
2741
|
+
getAcceptedInvitations() {
|
|
2742
|
+
return [
|
|
2743
|
+
...this._acceptInvitations.values()
|
|
2744
|
+
].map((i) => i.get());
|
|
2745
|
+
}
|
|
2746
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2747
|
+
if (this._persistentInvitationsLoaded) {
|
|
2748
|
+
callback();
|
|
2749
|
+
} else {
|
|
2750
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
_createInvitation(protocol, options) {
|
|
2754
|
+
const { invitationId = PublicKey7.random().toHex(), type = Invitation5.Type.INTERACTIVE, authMethod = Invitation5.AuthMethod.SHARED_SECRET, state = Invitation5.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey7.random(), persistent = options?.authMethod !== Invitation5.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2755
|
+
const authCode = options?.authCode ?? (authMethod === Invitation5.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2756
|
+
return {
|
|
2757
|
+
invitationId,
|
|
2758
|
+
type,
|
|
2759
|
+
authMethod,
|
|
2760
|
+
state,
|
|
2761
|
+
swarmKey,
|
|
2762
|
+
authCode,
|
|
2763
|
+
timeout,
|
|
2764
|
+
persistent: persistent && type !== Invitation5.Type.DELEGATED,
|
|
2765
|
+
guestKeypair: guestKeypair ?? (authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2766
|
+
created,
|
|
2767
|
+
lifetime,
|
|
2768
|
+
multiUse,
|
|
2769
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2770
|
+
...protocol.getInvitationContext()
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
_createObservableInvitation(handler, invitation) {
|
|
2774
|
+
const stream = new PushStream2();
|
|
2775
|
+
const ctx = new Context6({
|
|
2776
|
+
onError: (err) => {
|
|
2777
|
+
stream.error(err);
|
|
2778
|
+
void ctx.dispose();
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
ctx.onDispose(() => {
|
|
2782
|
+
log7("complete", {
|
|
2783
|
+
...handler.toJSON()
|
|
2784
|
+
}, {
|
|
2785
|
+
F: __dxlog_file9,
|
|
2786
|
+
L: 228,
|
|
2787
|
+
S: this,
|
|
2788
|
+
C: (f, a) => f(...a)
|
|
2789
|
+
});
|
|
2790
|
+
stream.complete();
|
|
2791
|
+
});
|
|
2792
|
+
const observableInvitation = new CancellableInvitation({
|
|
2793
|
+
initialInvitation: invitation,
|
|
2794
|
+
subscriber: stream.observable,
|
|
2795
|
+
onCancel: async () => {
|
|
2796
|
+
stream.next({
|
|
2797
|
+
...invitation,
|
|
2798
|
+
state: Invitation5.State.CANCELLED
|
|
2799
|
+
});
|
|
2800
|
+
await ctx.dispose();
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
return {
|
|
2804
|
+
ctx,
|
|
2805
|
+
stream,
|
|
2806
|
+
observableInvitation
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2810
|
+
if (invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2811
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2812
|
+
changeStream.next({
|
|
2813
|
+
...invitation,
|
|
2814
|
+
delegationCredentialId
|
|
2815
|
+
});
|
|
2816
|
+
} else if (invitation.persistent) {
|
|
2817
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2818
|
+
this.saved.emit(invitation);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
async _safeDeleteInvitation(invitation) {
|
|
2822
|
+
try {
|
|
2823
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2824
|
+
} catch (err) {
|
|
2825
|
+
log7.catch(err, void 0, {
|
|
2826
|
+
F: __dxlog_file9,
|
|
2827
|
+
L: 260,
|
|
2828
|
+
S: this,
|
|
2829
|
+
C: (f, a) => f(...a)
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
_onInvitationComplete(invitation, callback) {
|
|
2834
|
+
invitation.subscribe(() => {
|
|
2835
|
+
}, () => {
|
|
2836
|
+
}, callback);
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2652
2840
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2653
2841
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2654
2842
|
import { raise } from "@dxos/debug";
|
|
@@ -2730,220 +2918,72 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2730
2918
|
trace5.resource()
|
|
2731
2919
|
], ClientRpcServer);
|
|
2732
2920
|
|
|
2733
|
-
// packages/sdk/client-services/src/packlets/
|
|
2734
|
-
import {
|
|
2735
|
-
import {
|
|
2736
|
-
import {
|
|
2737
|
-
import {
|
|
2738
|
-
import {
|
|
2739
|
-
import {
|
|
2921
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2922
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2923
|
+
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2924
|
+
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2925
|
+
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2926
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2927
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2928
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
2929
|
+
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2930
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2931
|
+
import { log as log9 } from "@dxos/log";
|
|
2932
|
+
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2933
|
+
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
2934
|
+
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2935
|
+
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2936
|
+
import { trace as trace6 } from "@dxos/tracing";
|
|
2937
|
+
import { ComplexSet as ComplexSet3, assignDeep } from "@dxos/util";
|
|
2740
2938
|
|
|
2741
|
-
// packages/sdk/client-services/src/packlets/
|
|
2742
|
-
import {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2756
|
-
};
|
|
2939
|
+
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2940
|
+
import { Event as Event4 } from "@dxos/async";
|
|
2941
|
+
import { checkCredentialType } from "@dxos/credentials";
|
|
2942
|
+
var AutomergeSpaceState = class {
|
|
2943
|
+
constructor(_onNewRoot) {
|
|
2944
|
+
this._onNewRoot = _onNewRoot;
|
|
2945
|
+
this.rootUrl = void 0;
|
|
2946
|
+
this.lastEpoch = void 0;
|
|
2947
|
+
this.onNewEpoch = new Event4();
|
|
2948
|
+
this._isProcessingRootDocs = false;
|
|
2949
|
+
}
|
|
2950
|
+
async processCredential(credential) {
|
|
2951
|
+
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
2952
|
+
return;
|
|
2757
2953
|
}
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
const diagnostics = {
|
|
2779
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2780
|
-
platform: getPlatform(),
|
|
2781
|
-
client: {
|
|
2782
|
-
version: DXOS_VERSION,
|
|
2783
|
-
storage: {
|
|
2784
|
-
version: STORAGE_VERSION
|
|
2785
|
-
}
|
|
2786
|
-
},
|
|
2787
|
-
trace: TRACE_PROCESSOR.getDiagnostics()
|
|
2788
|
-
};
|
|
2789
|
-
{
|
|
2790
|
-
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2791
|
-
F: __dxlog_file10,
|
|
2792
|
-
L: 108,
|
|
2793
|
-
S: void 0,
|
|
2794
|
-
A: [
|
|
2795
|
-
"clientServices.LoggingService",
|
|
2796
|
-
"'SystemService is not available.'"
|
|
2797
|
-
]
|
|
2798
|
-
});
|
|
2799
|
-
diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
|
|
2800
|
-
timeout: DEFAULT_TIMEOUT
|
|
2801
|
-
}).catch(() => void 0);
|
|
2802
|
-
}
|
|
2803
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2804
|
-
const map = /* @__PURE__ */ new Map();
|
|
2805
|
-
const dir = await navigator.storage.getDirectory();
|
|
2806
|
-
for await (const filename of dir?.keys()) {
|
|
2807
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2808
|
-
if (idx === -1) {
|
|
2809
|
-
continue;
|
|
2810
|
-
}
|
|
2811
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2812
|
-
}
|
|
2813
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2814
|
-
file,
|
|
2815
|
-
count
|
|
2816
|
-
}));
|
|
2817
|
-
}
|
|
2818
|
-
const identity = serviceContext.identityManager.identity;
|
|
2819
|
-
if (identity) {
|
|
2820
|
-
diagnostics.identity = {
|
|
2821
|
-
identityKey: identity.identityKey,
|
|
2822
|
-
spaceKey: identity.space.key,
|
|
2823
|
-
profile: identity.profileDocument
|
|
2824
|
-
};
|
|
2825
|
-
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
2826
|
-
timeout: DEFAULT_TIMEOUT
|
|
2827
|
-
}).catch(() => void 0) ?? {};
|
|
2828
|
-
diagnostics.devices = devices;
|
|
2829
|
-
if (serviceContext.dataSpaceManager) {
|
|
2830
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2831
|
-
}
|
|
2832
|
-
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2833
|
-
timeout: DEFAULT_TIMEOUT
|
|
2834
|
-
}).catch(() => void 0) ?? {};
|
|
2835
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2836
|
-
feedKey,
|
|
2837
|
-
bytes,
|
|
2838
|
-
length
|
|
2839
|
-
}));
|
|
2840
|
-
const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
|
|
2841
|
-
timeout: DEFAULT_TIMEOUT
|
|
2842
|
-
}).catch(() => void 0);
|
|
2843
|
-
diagnostics.networkStatus = status;
|
|
2844
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2845
|
-
}
|
|
2846
|
-
diagnostics.config = config.values;
|
|
2847
|
-
return diagnostics;
|
|
2848
|
-
};
|
|
2849
|
-
var getSpaceStats = async (space) => {
|
|
2850
|
-
const stats = {
|
|
2851
|
-
key: space.key,
|
|
2852
|
-
metrics: space.metrics,
|
|
2853
|
-
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2854
|
-
...credential.subject.assertion,
|
|
2855
|
-
id: credential.id
|
|
2856
|
-
})),
|
|
2857
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2858
|
-
identity: {
|
|
2859
|
-
identityKey: member.key,
|
|
2860
|
-
profile: {
|
|
2861
|
-
displayName: member.assertion.profile?.displayName
|
|
2862
|
-
}
|
|
2863
|
-
},
|
|
2864
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2865
|
-
})),
|
|
2866
|
-
pipeline: {
|
|
2867
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2868
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2869
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2870
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2871
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2872
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2873
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2874
|
-
}
|
|
2875
|
-
};
|
|
2876
|
-
if (stats.metrics) {
|
|
2877
|
-
const { open, ready } = stats.metrics;
|
|
2878
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2879
|
-
}
|
|
2880
|
-
return stats;
|
|
2881
|
-
};
|
|
2882
|
-
|
|
2883
|
-
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2884
|
-
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2885
|
-
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2886
|
-
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2887
|
-
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2888
|
-
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2889
|
-
import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
|
|
2890
|
-
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2891
|
-
import { log as log9 } from "@dxos/log";
|
|
2892
|
-
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2893
|
-
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
2894
|
-
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2895
|
-
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2896
|
-
import { trace as trace6 } from "@dxos/tracing";
|
|
2897
|
-
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2898
|
-
|
|
2899
|
-
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2900
|
-
import { Event as Event4 } from "@dxos/async";
|
|
2901
|
-
import { checkCredentialType } from "@dxos/credentials";
|
|
2902
|
-
var AutomergeSpaceState = class {
|
|
2903
|
-
constructor(_onNewRoot) {
|
|
2904
|
-
this._onNewRoot = _onNewRoot;
|
|
2905
|
-
this.rootUrl = void 0;
|
|
2906
|
-
this.lastEpoch = void 0;
|
|
2907
|
-
this.onNewEpoch = new Event4();
|
|
2908
|
-
this._isProcessingRootDocs = false;
|
|
2909
|
-
}
|
|
2910
|
-
async processCredential(credential) {
|
|
2911
|
-
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
2912
|
-
return;
|
|
2913
|
-
}
|
|
2914
|
-
this.lastEpoch = credential;
|
|
2915
|
-
if (credential.subject.assertion.automergeRoot) {
|
|
2916
|
-
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2917
|
-
if (this._isProcessingRootDocs) {
|
|
2918
|
-
this._onNewRoot(this.rootUrl);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
this.onNewEpoch.emit(credential);
|
|
2922
|
-
}
|
|
2923
|
-
startProcessingRootDocs() {
|
|
2924
|
-
if (this._isProcessingRootDocs) {
|
|
2925
|
-
return;
|
|
2926
|
-
}
|
|
2927
|
-
if (this.rootUrl) {
|
|
2928
|
-
this._onNewRoot(this.rootUrl);
|
|
2929
|
-
}
|
|
2930
|
-
this._isProcessingRootDocs = true;
|
|
2931
|
-
}
|
|
2932
|
-
async ensureEpochInitialized() {
|
|
2933
|
-
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
2954
|
+
this.lastEpoch = credential;
|
|
2955
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
2956
|
+
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2957
|
+
if (this._isProcessingRootDocs) {
|
|
2958
|
+
this._onNewRoot(this.rootUrl);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
this.onNewEpoch.emit(credential);
|
|
2962
|
+
}
|
|
2963
|
+
startProcessingRootDocs() {
|
|
2964
|
+
if (this._isProcessingRootDocs) {
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
if (this.rootUrl) {
|
|
2968
|
+
this._onNewRoot(this.rootUrl);
|
|
2969
|
+
}
|
|
2970
|
+
this._isProcessingRootDocs = true;
|
|
2971
|
+
}
|
|
2972
|
+
async ensureEpochInitialized() {
|
|
2973
|
+
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
2934
2974
|
}
|
|
2935
2975
|
};
|
|
2936
2976
|
|
|
2937
2977
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2938
|
-
import { DeferredTask, Event as Event5, scheduleTask as
|
|
2978
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2939
2979
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2940
|
-
import { invariant as
|
|
2941
|
-
import { PublicKey as
|
|
2980
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2981
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2942
2982
|
import { log as log8 } from "@dxos/log";
|
|
2943
2983
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2944
2984
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2945
2985
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
2946
|
-
var
|
|
2986
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2947
2987
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2948
2988
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2949
2989
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2953,8 +2993,8 @@ var NotarizationPlugin = class {
|
|
|
2953
2993
|
this._ctx = new Context7();
|
|
2954
2994
|
this._extensionOpened = new Event5();
|
|
2955
2995
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2956
|
-
this._processedCredentials = new ComplexSet2(
|
|
2957
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2996
|
+
this._processedCredentials = new ComplexSet2(PublicKey8.hash);
|
|
2997
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey8.hash);
|
|
2958
2998
|
}
|
|
2959
2999
|
get hasWriter() {
|
|
2960
3000
|
return !!this._writer;
|
|
@@ -2971,13 +3011,13 @@ var NotarizationPlugin = class {
|
|
|
2971
3011
|
log8("notarize", {
|
|
2972
3012
|
credentials
|
|
2973
3013
|
}, {
|
|
2974
|
-
F:
|
|
3014
|
+
F: __dxlog_file10,
|
|
2975
3015
|
L: 90,
|
|
2976
3016
|
S: this,
|
|
2977
3017
|
C: (f, a) => f(...a)
|
|
2978
3018
|
});
|
|
2979
|
-
|
|
2980
|
-
F:
|
|
3019
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3020
|
+
F: __dxlog_file10,
|
|
2981
3021
|
L: 91,
|
|
2982
3022
|
S: this,
|
|
2983
3023
|
A: [
|
|
@@ -2991,7 +3031,7 @@ var NotarizationPlugin = class {
|
|
|
2991
3031
|
log8.warn("Notarization error", {
|
|
2992
3032
|
err
|
|
2993
3033
|
}, {
|
|
2994
|
-
F:
|
|
3034
|
+
F: __dxlog_file10,
|
|
2995
3035
|
L: 99,
|
|
2996
3036
|
S: this,
|
|
2997
3037
|
C: (f, a) => f(...a)
|
|
@@ -3002,12 +3042,12 @@ var NotarizationPlugin = class {
|
|
|
3002
3042
|
});
|
|
3003
3043
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3004
3044
|
if (timeout !== 0) {
|
|
3005
|
-
|
|
3045
|
+
scheduleTask3(ctx, () => {
|
|
3006
3046
|
log8.warn("Notarization timeout", {
|
|
3007
3047
|
timeout,
|
|
3008
3048
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3009
3049
|
}, {
|
|
3010
|
-
F:
|
|
3050
|
+
F: __dxlog_file10,
|
|
3011
3051
|
L: 111,
|
|
3012
3052
|
S: this,
|
|
3013
3053
|
C: (f, a) => f(...a)
|
|
@@ -3030,13 +3070,13 @@ var NotarizationPlugin = class {
|
|
|
3030
3070
|
log8.info("Exhausted all peers to notarize with", {
|
|
3031
3071
|
retryIn: retryTimeout
|
|
3032
3072
|
}, {
|
|
3033
|
-
F:
|
|
3073
|
+
F: __dxlog_file10,
|
|
3034
3074
|
L: 136,
|
|
3035
3075
|
S: this,
|
|
3036
3076
|
C: (f, a) => f(...a)
|
|
3037
3077
|
});
|
|
3038
3078
|
peersTried.clear();
|
|
3039
|
-
|
|
3079
|
+
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
3040
3080
|
return;
|
|
3041
3081
|
}
|
|
3042
3082
|
peersTried.add(peer);
|
|
@@ -3044,7 +3084,7 @@ var NotarizationPlugin = class {
|
|
|
3044
3084
|
peer: peer.localPeerId,
|
|
3045
3085
|
credentialId: credentials.map((credential) => credential.id)
|
|
3046
3086
|
}, {
|
|
3047
|
-
F:
|
|
3087
|
+
F: __dxlog_file10,
|
|
3048
3088
|
L: 143,
|
|
3049
3089
|
S: this,
|
|
3050
3090
|
C: (f, a) => f(...a)
|
|
@@ -3053,7 +3093,7 @@ var NotarizationPlugin = class {
|
|
|
3053
3093
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3054
3094
|
});
|
|
3055
3095
|
log8("success", void 0, {
|
|
3056
|
-
F:
|
|
3096
|
+
F: __dxlog_file10,
|
|
3057
3097
|
L: 147,
|
|
3058
3098
|
S: this,
|
|
3059
3099
|
C: (f, a) => f(...a)
|
|
@@ -3062,7 +3102,7 @@ var NotarizationPlugin = class {
|
|
|
3062
3102
|
} catch (err) {
|
|
3063
3103
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3064
3104
|
log8.info("error notarizing (recoverable)", err, {
|
|
3065
|
-
F:
|
|
3105
|
+
F: __dxlog_file10,
|
|
3066
3106
|
L: 151,
|
|
3067
3107
|
S: this,
|
|
3068
3108
|
C: (f, a) => f(...a)
|
|
@@ -3080,7 +3120,7 @@ var NotarizationPlugin = class {
|
|
|
3080
3120
|
errors.wait()
|
|
3081
3121
|
]);
|
|
3082
3122
|
log8("done", void 0, {
|
|
3083
|
-
F:
|
|
3123
|
+
F: __dxlog_file10,
|
|
3084
3124
|
L: 162,
|
|
3085
3125
|
S: this,
|
|
3086
3126
|
C: (f, a) => f(...a)
|
|
@@ -3101,8 +3141,8 @@ var NotarizationPlugin = class {
|
|
|
3101
3141
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3102
3142
|
}
|
|
3103
3143
|
setWriter(writer) {
|
|
3104
|
-
|
|
3105
|
-
F:
|
|
3144
|
+
invariant9(!this._writer, "Writer already set.", {
|
|
3145
|
+
F: __dxlog_file10,
|
|
3106
3146
|
L: 181,
|
|
3107
3147
|
S: this,
|
|
3108
3148
|
A: [
|
|
@@ -3126,8 +3166,8 @@ var NotarizationPlugin = class {
|
|
|
3126
3166
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3127
3167
|
}
|
|
3128
3168
|
for (const credential of request.credentials ?? []) {
|
|
3129
|
-
|
|
3130
|
-
F:
|
|
3169
|
+
invariant9(credential.id, "Credential must have an id", {
|
|
3170
|
+
F: __dxlog_file10,
|
|
3131
3171
|
L: 200,
|
|
3132
3172
|
S: this,
|
|
3133
3173
|
A: [
|
|
@@ -3147,7 +3187,7 @@ var NotarizationPlugin = class {
|
|
|
3147
3187
|
log8("extension opened", {
|
|
3148
3188
|
peer: extension.localPeerId
|
|
3149
3189
|
}, {
|
|
3150
|
-
F:
|
|
3190
|
+
F: __dxlog_file10,
|
|
3151
3191
|
L: 211,
|
|
3152
3192
|
S: this,
|
|
3153
3193
|
C: (f, a) => f(...a)
|
|
@@ -3159,7 +3199,7 @@ var NotarizationPlugin = class {
|
|
|
3159
3199
|
log8("extension closed", {
|
|
3160
3200
|
peer: extension.localPeerId
|
|
3161
3201
|
}, {
|
|
3162
|
-
F:
|
|
3202
|
+
F: __dxlog_file10,
|
|
3163
3203
|
L: 216,
|
|
3164
3204
|
S: this,
|
|
3165
3205
|
C: (f, a) => f(...a)
|
|
@@ -3213,7 +3253,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3213
3253
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3214
3254
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3215
3255
|
}
|
|
3216
|
-
var
|
|
3256
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3217
3257
|
var DataSpace = class {
|
|
3218
3258
|
constructor(params) {
|
|
3219
3259
|
this._ctx = new Context8();
|
|
@@ -3237,9 +3277,9 @@ var DataSpace = class {
|
|
|
3237
3277
|
this._metadataStore = params.metadataStore;
|
|
3238
3278
|
this._signingContext = params.signingContext;
|
|
3239
3279
|
this._callbacks = params.callbacks ?? {};
|
|
3240
|
-
this.
|
|
3280
|
+
this._echoHost = params.echoHost;
|
|
3241
3281
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3242
|
-
trustedKeysProvider: () => new ComplexSet3(
|
|
3282
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey9.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3243
3283
|
update: this._inner.stateUpdate,
|
|
3244
3284
|
authTimeout: AUTH_TIMEOUT2
|
|
3245
3285
|
});
|
|
@@ -3248,8 +3288,8 @@ var DataSpace = class {
|
|
|
3248
3288
|
log9("new state", {
|
|
3249
3289
|
state: SpaceState[this._state]
|
|
3250
3290
|
}, {
|
|
3251
|
-
F:
|
|
3252
|
-
L:
|
|
3291
|
+
F: __dxlog_file11,
|
|
3292
|
+
L: 135,
|
|
3253
3293
|
S: this,
|
|
3254
3294
|
C: (f, a) => f(...a)
|
|
3255
3295
|
});
|
|
@@ -3298,8 +3338,8 @@ var DataSpace = class {
|
|
|
3298
3338
|
log9("new state", {
|
|
3299
3339
|
state: SpaceState[this._state]
|
|
3300
3340
|
}, {
|
|
3301
|
-
F:
|
|
3302
|
-
L:
|
|
3341
|
+
F: __dxlog_file11,
|
|
3342
|
+
L: 193,
|
|
3303
3343
|
S: this,
|
|
3304
3344
|
C: (f, a) => f(...a)
|
|
3305
3345
|
});
|
|
@@ -3316,8 +3356,8 @@ var DataSpace = class {
|
|
|
3316
3356
|
log9("new state", {
|
|
3317
3357
|
state: SpaceState[this._state]
|
|
3318
3358
|
}, {
|
|
3319
|
-
F:
|
|
3320
|
-
L:
|
|
3359
|
+
F: __dxlog_file11,
|
|
3360
|
+
L: 207,
|
|
3321
3361
|
S: this,
|
|
3322
3362
|
C: (f, a) => f(...a)
|
|
3323
3363
|
});
|
|
@@ -3341,23 +3381,23 @@ var DataSpace = class {
|
|
|
3341
3381
|
* Initialize the data pipeline in a separate task.
|
|
3342
3382
|
*/
|
|
3343
3383
|
initializeDataPipelineAsync() {
|
|
3344
|
-
|
|
3384
|
+
scheduleTask4(this._ctx, async () => {
|
|
3345
3385
|
try {
|
|
3346
3386
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3347
3387
|
await this.initializeDataPipeline();
|
|
3348
3388
|
} catch (err) {
|
|
3349
3389
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3350
3390
|
log9("data pipeline initialization cancelled", err, {
|
|
3351
|
-
F:
|
|
3352
|
-
L:
|
|
3391
|
+
F: __dxlog_file11,
|
|
3392
|
+
L: 240,
|
|
3353
3393
|
S: this,
|
|
3354
3394
|
C: (f, a) => f(...a)
|
|
3355
3395
|
});
|
|
3356
3396
|
return;
|
|
3357
3397
|
}
|
|
3358
3398
|
log9.error("Error initializing data pipeline", err, {
|
|
3359
|
-
F:
|
|
3360
|
-
L:
|
|
3399
|
+
F: __dxlog_file11,
|
|
3400
|
+
L: 244,
|
|
3361
3401
|
S: this,
|
|
3362
3402
|
C: (f, a) => f(...a)
|
|
3363
3403
|
});
|
|
@@ -3365,8 +3405,8 @@ var DataSpace = class {
|
|
|
3365
3405
|
log9("new state", {
|
|
3366
3406
|
state: SpaceState[this._state]
|
|
3367
3407
|
}, {
|
|
3368
|
-
F:
|
|
3369
|
-
L:
|
|
3408
|
+
F: __dxlog_file11,
|
|
3409
|
+
L: 246,
|
|
3370
3410
|
S: this,
|
|
3371
3411
|
C: (f, a) => f(...a)
|
|
3372
3412
|
});
|
|
@@ -3385,8 +3425,8 @@ var DataSpace = class {
|
|
|
3385
3425
|
log9("new state", {
|
|
3386
3426
|
state: SpaceState[this._state]
|
|
3387
3427
|
}, {
|
|
3388
|
-
F:
|
|
3389
|
-
L:
|
|
3428
|
+
F: __dxlog_file11,
|
|
3429
|
+
L: 262,
|
|
3390
3430
|
S: this,
|
|
3391
3431
|
C: (f, a) => f(...a)
|
|
3392
3432
|
});
|
|
@@ -3395,8 +3435,8 @@ var DataSpace = class {
|
|
|
3395
3435
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3396
3436
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3397
3437
|
log9("data pipeline ready", void 0, {
|
|
3398
|
-
F:
|
|
3399
|
-
L:
|
|
3438
|
+
F: __dxlog_file11,
|
|
3439
|
+
L: 274,
|
|
3400
3440
|
S: this,
|
|
3401
3441
|
C: (f, a) => f(...a)
|
|
3402
3442
|
});
|
|
@@ -3405,8 +3445,8 @@ var DataSpace = class {
|
|
|
3405
3445
|
log9("new state", {
|
|
3406
3446
|
state: SpaceState[this._state]
|
|
3407
3447
|
}, {
|
|
3408
|
-
F:
|
|
3409
|
-
L:
|
|
3448
|
+
F: __dxlog_file11,
|
|
3449
|
+
L: 278,
|
|
3410
3450
|
S: this,
|
|
3411
3451
|
C: (f, a) => f(...a)
|
|
3412
3452
|
});
|
|
@@ -3421,8 +3461,8 @@ var DataSpace = class {
|
|
|
3421
3461
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3422
3462
|
await this._createWritableFeeds();
|
|
3423
3463
|
log9("writable feeds created", void 0, {
|
|
3424
|
-
F:
|
|
3425
|
-
L:
|
|
3464
|
+
F: __dxlog_file11,
|
|
3465
|
+
L: 294,
|
|
3426
3466
|
S: this,
|
|
3427
3467
|
C: (f, a) => f(...a)
|
|
3428
3468
|
});
|
|
@@ -3484,13 +3524,13 @@ var DataSpace = class {
|
|
|
3484
3524
|
space: this.key,
|
|
3485
3525
|
rootUrl
|
|
3486
3526
|
}, {
|
|
3487
|
-
F:
|
|
3488
|
-
L:
|
|
3527
|
+
F: __dxlog_file11,
|
|
3528
|
+
L: 360,
|
|
3489
3529
|
S: this,
|
|
3490
3530
|
C: (f, a) => f(...a)
|
|
3491
3531
|
});
|
|
3492
|
-
this.
|
|
3493
|
-
const handle = this.
|
|
3532
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3533
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3494
3534
|
queueMicrotask(async () => {
|
|
3495
3535
|
try {
|
|
3496
3536
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3516,8 +3556,8 @@ var DataSpace = class {
|
|
|
3516
3556
|
rootUrl,
|
|
3517
3557
|
err
|
|
3518
3558
|
}, {
|
|
3519
|
-
F:
|
|
3520
|
-
L:
|
|
3559
|
+
F: __dxlog_file11,
|
|
3560
|
+
L: 383,
|
|
3521
3561
|
S: this,
|
|
3522
3562
|
C: (f, a) => f(...a)
|
|
3523
3563
|
});
|
|
@@ -3555,7 +3595,7 @@ var DataSpace = class {
|
|
|
3555
3595
|
break;
|
|
3556
3596
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3557
3597
|
{
|
|
3558
|
-
const document = this.
|
|
3598
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3559
3599
|
epoch = {
|
|
3560
3600
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3561
3601
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3567,18 +3607,78 @@ var DataSpace = class {
|
|
|
3567
3607
|
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3568
3608
|
{
|
|
3569
3609
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3570
|
-
const rootHandle = this.
|
|
3610
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3571
3611
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3572
|
-
const newRoot = this.
|
|
3573
|
-
|
|
3574
|
-
F:
|
|
3575
|
-
L:
|
|
3612
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3613
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3614
|
+
F: __dxlog_file11,
|
|
3615
|
+
L: 433,
|
|
3616
|
+
S: this,
|
|
3617
|
+
A: [
|
|
3618
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3619
|
+
""
|
|
3620
|
+
]
|
|
3621
|
+
});
|
|
3622
|
+
epoch = {
|
|
3623
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3624
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3625
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3626
|
+
automergeRoot: newRoot.url
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
break;
|
|
3630
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3631
|
+
{
|
|
3632
|
+
log9.info("Fragmenting", void 0, {
|
|
3633
|
+
F: __dxlog_file11,
|
|
3634
|
+
L: 445,
|
|
3635
|
+
S: this,
|
|
3636
|
+
C: (f, a) => f(...a)
|
|
3637
|
+
});
|
|
3638
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3639
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3640
|
+
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3641
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3642
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3643
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3644
|
+
invariant10(properties, "Properties not found", {
|
|
3645
|
+
F: __dxlog_file11,
|
|
3646
|
+
L: 455,
|
|
3647
|
+
S: this,
|
|
3648
|
+
A: [
|
|
3649
|
+
"properties",
|
|
3650
|
+
"'Properties not found'"
|
|
3651
|
+
]
|
|
3652
|
+
});
|
|
3653
|
+
const newSpaceDoc = {
|
|
3654
|
+
...rootHandle.docSync(),
|
|
3655
|
+
objects: Object.fromEntries([
|
|
3656
|
+
properties
|
|
3657
|
+
])
|
|
3658
|
+
};
|
|
3659
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3660
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3661
|
+
F: __dxlog_file11,
|
|
3662
|
+
L: 460,
|
|
3576
3663
|
S: this,
|
|
3577
3664
|
A: [
|
|
3578
3665
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3579
3666
|
""
|
|
3580
3667
|
]
|
|
3581
3668
|
});
|
|
3669
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3670
|
+
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3671
|
+
rootUrl: newRoot.url
|
|
3672
|
+
});
|
|
3673
|
+
otherObjects.forEach(([key, value]) => {
|
|
3674
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3675
|
+
handle.change((doc) => {
|
|
3676
|
+
assignDeep(doc, [
|
|
3677
|
+
"objects",
|
|
3678
|
+
key
|
|
3679
|
+
], value);
|
|
3680
|
+
});
|
|
3681
|
+
});
|
|
3582
3682
|
epoch = {
|
|
3583
3683
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3584
3684
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3627,8 +3727,8 @@ var DataSpace = class {
|
|
|
3627
3727
|
log9("new state", {
|
|
3628
3728
|
state: SpaceState[this._state]
|
|
3629
3729
|
}, {
|
|
3630
|
-
F:
|
|
3631
|
-
L:
|
|
3730
|
+
F: __dxlog_file11,
|
|
3731
|
+
L: 526,
|
|
3632
3732
|
S: this,
|
|
3633
3733
|
C: (f, a) => f(...a)
|
|
3634
3734
|
});
|
|
@@ -3685,11 +3785,11 @@ DataSpace = _ts_decorate4([
|
|
|
3685
3785
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3686
3786
|
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3687
3787
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3688
|
-
import { invariant as
|
|
3689
|
-
import { PublicKey as
|
|
3788
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3789
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3690
3790
|
import { log as log10 } from "@dxos/log";
|
|
3691
3791
|
import { trace as trace7 } from "@dxos/protocols";
|
|
3692
|
-
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3792
|
+
import { Invitation as Invitation6, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3693
3793
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
3694
3794
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
3695
3795
|
|
|
@@ -3774,22 +3874,23 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3774
3874
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3775
3875
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3776
3876
|
}
|
|
3777
|
-
var
|
|
3877
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3778
3878
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3779
3879
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3780
3880
|
var DataSpaceManager = class {
|
|
3781
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3881
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3782
3882
|
this._spaceManager = _spaceManager;
|
|
3783
3883
|
this._metadataStore = _metadataStore;
|
|
3784
3884
|
this._keyring = _keyring;
|
|
3785
3885
|
this._signingContext = _signingContext;
|
|
3786
3886
|
this._feedStore = _feedStore;
|
|
3787
|
-
this.
|
|
3887
|
+
this._echoHost = _echoHost;
|
|
3888
|
+
this._invitationsManager = _invitationsManager;
|
|
3788
3889
|
this._ctx = new Context9();
|
|
3789
3890
|
this.updated = new Event7();
|
|
3790
|
-
this._spaces = new ComplexMap3(
|
|
3891
|
+
this._spaces = new ComplexMap3(PublicKey10.hash);
|
|
3791
3892
|
this._isOpen = false;
|
|
3792
|
-
this._instanceId =
|
|
3893
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3793
3894
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3794
3895
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3795
3896
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3800,24 +3901,24 @@ var DataSpaceManager = class {
|
|
|
3800
3901
|
}
|
|
3801
3902
|
async open() {
|
|
3802
3903
|
log10("open", void 0, {
|
|
3803
|
-
F:
|
|
3804
|
-
L:
|
|
3904
|
+
F: __dxlog_file12,
|
|
3905
|
+
L: 102,
|
|
3805
3906
|
S: this,
|
|
3806
3907
|
C: (f, a) => f(...a)
|
|
3807
3908
|
});
|
|
3808
3909
|
log10.trace("dxos.echo.data-space-manager.open", trace7.begin({
|
|
3809
3910
|
id: this._instanceId
|
|
3810
3911
|
}), {
|
|
3811
|
-
F:
|
|
3812
|
-
L:
|
|
3912
|
+
F: __dxlog_file12,
|
|
3913
|
+
L: 103,
|
|
3813
3914
|
S: this,
|
|
3814
3915
|
C: (f, a) => f(...a)
|
|
3815
3916
|
});
|
|
3816
3917
|
log10("metadata loaded", {
|
|
3817
3918
|
spaces: this._metadataStore.spaces.length
|
|
3818
3919
|
}, {
|
|
3819
|
-
F:
|
|
3820
|
-
L:
|
|
3920
|
+
F: __dxlog_file12,
|
|
3921
|
+
L: 104,
|
|
3821
3922
|
S: this,
|
|
3822
3923
|
C: (f, a) => f(...a)
|
|
3823
3924
|
});
|
|
@@ -3826,8 +3927,8 @@ var DataSpaceManager = class {
|
|
|
3826
3927
|
log10("load space", {
|
|
3827
3928
|
spaceMetadata
|
|
3828
3929
|
}, {
|
|
3829
|
-
F:
|
|
3830
|
-
L:
|
|
3930
|
+
F: __dxlog_file12,
|
|
3931
|
+
L: 108,
|
|
3831
3932
|
S: this,
|
|
3832
3933
|
C: (f, a) => f(...a)
|
|
3833
3934
|
});
|
|
@@ -3837,8 +3938,8 @@ var DataSpaceManager = class {
|
|
|
3837
3938
|
spaceMetadata,
|
|
3838
3939
|
err
|
|
3839
3940
|
}, {
|
|
3840
|
-
F:
|
|
3841
|
-
L:
|
|
3941
|
+
F: __dxlog_file12,
|
|
3942
|
+
L: 111,
|
|
3842
3943
|
S: this,
|
|
3843
3944
|
C: (f, a) => f(...a)
|
|
3844
3945
|
});
|
|
@@ -3854,16 +3955,16 @@ var DataSpaceManager = class {
|
|
|
3854
3955
|
log10.trace("dxos.echo.data-space-manager.open", trace7.end({
|
|
3855
3956
|
id: this._instanceId
|
|
3856
3957
|
}), {
|
|
3857
|
-
F:
|
|
3858
|
-
L:
|
|
3958
|
+
F: __dxlog_file12,
|
|
3959
|
+
L: 124,
|
|
3859
3960
|
S: this,
|
|
3860
3961
|
C: (f, a) => f(...a)
|
|
3861
3962
|
});
|
|
3862
3963
|
}
|
|
3863
3964
|
async close() {
|
|
3864
3965
|
log10("close", void 0, {
|
|
3865
|
-
F:
|
|
3866
|
-
L:
|
|
3966
|
+
F: __dxlog_file12,
|
|
3967
|
+
L: 129,
|
|
3867
3968
|
S: this,
|
|
3868
3969
|
C: (f, a) => f(...a)
|
|
3869
3970
|
});
|
|
@@ -3877,9 +3978,9 @@ var DataSpaceManager = class {
|
|
|
3877
3978
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3878
3979
|
*/
|
|
3879
3980
|
async createSpace() {
|
|
3880
|
-
|
|
3881
|
-
F:
|
|
3882
|
-
L:
|
|
3981
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3982
|
+
F: __dxlog_file12,
|
|
3983
|
+
L: 142,
|
|
3883
3984
|
S: this,
|
|
3884
3985
|
A: [
|
|
3885
3986
|
"this._isOpen",
|
|
@@ -3899,23 +4000,18 @@ var DataSpaceManager = class {
|
|
|
3899
4000
|
log10("creating space...", {
|
|
3900
4001
|
spaceKey
|
|
3901
4002
|
}, {
|
|
3902
|
-
F:
|
|
3903
|
-
L:
|
|
4003
|
+
F: __dxlog_file12,
|
|
4004
|
+
L: 154,
|
|
3904
4005
|
S: this,
|
|
3905
4006
|
C: (f, a) => f(...a)
|
|
3906
4007
|
});
|
|
3907
|
-
const
|
|
3908
|
-
automergeRoot.change((doc) => {
|
|
3909
|
-
doc.access = {
|
|
3910
|
-
spaceKey: spaceKey.toHex()
|
|
3911
|
-
};
|
|
3912
|
-
});
|
|
4008
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
3913
4009
|
const space = await this._constructSpace(metadata);
|
|
3914
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4010
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
3915
4011
|
await this._metadataStore.addSpace(metadata);
|
|
3916
4012
|
const memberCredential = credentials[1];
|
|
3917
|
-
|
|
3918
|
-
F:
|
|
4013
|
+
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4014
|
+
F: __dxlog_file12,
|
|
3919
4015
|
L: 163,
|
|
3920
4016
|
S: this,
|
|
3921
4017
|
A: [
|
|
@@ -3933,13 +4029,13 @@ var DataSpaceManager = class {
|
|
|
3933
4029
|
log10("accept space", {
|
|
3934
4030
|
opts
|
|
3935
4031
|
}, {
|
|
3936
|
-
F:
|
|
4032
|
+
F: __dxlog_file12,
|
|
3937
4033
|
L: 175,
|
|
3938
4034
|
S: this,
|
|
3939
4035
|
C: (f, a) => f(...a)
|
|
3940
4036
|
});
|
|
3941
|
-
|
|
3942
|
-
F:
|
|
4037
|
+
invariant11(this._isOpen, "Not open.", {
|
|
4038
|
+
F: __dxlog_file12,
|
|
3943
4039
|
L: 176,
|
|
3944
4040
|
S: this,
|
|
3945
4041
|
A: [
|
|
@@ -3947,8 +4043,8 @@ var DataSpaceManager = class {
|
|
|
3947
4043
|
"'Not open.'"
|
|
3948
4044
|
]
|
|
3949
4045
|
});
|
|
3950
|
-
|
|
3951
|
-
F:
|
|
4046
|
+
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4047
|
+
F: __dxlog_file12,
|
|
3952
4048
|
L: 177,
|
|
3953
4049
|
S: this,
|
|
3954
4050
|
A: [
|
|
@@ -3983,7 +4079,7 @@ var DataSpaceManager = class {
|
|
|
3983
4079
|
log10("construct space", {
|
|
3984
4080
|
metadata
|
|
3985
4081
|
}, {
|
|
3986
|
-
F:
|
|
4082
|
+
F: __dxlog_file12,
|
|
3987
4083
|
L: 210,
|
|
3988
4084
|
S: this,
|
|
3989
4085
|
C: (f, a) => f(...a)
|
|
@@ -4016,18 +4112,21 @@ var DataSpaceManager = class {
|
|
|
4016
4112
|
remotePeerId: session.remotePeerId
|
|
4017
4113
|
}));
|
|
4018
4114
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
4019
|
-
this.
|
|
4020
|
-
session.addExtension("dxos.mesh.teleport.automerge", this.
|
|
4115
|
+
this._echoHost.authorizeDevice(space.key, session.remotePeerId);
|
|
4116
|
+
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4021
4117
|
},
|
|
4022
4118
|
onAuthFailure: () => {
|
|
4023
4119
|
log10.warn("auth failure", void 0, {
|
|
4024
|
-
F:
|
|
4120
|
+
F: __dxlog_file12,
|
|
4025
4121
|
L: 247,
|
|
4026
4122
|
S: this,
|
|
4027
4123
|
C: (f, a) => f(...a)
|
|
4028
4124
|
});
|
|
4029
4125
|
},
|
|
4030
|
-
memberKey: this._signingContext.identityKey
|
|
4126
|
+
memberKey: this._signingContext.identityKey,
|
|
4127
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4128
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4129
|
+
}
|
|
4031
4130
|
});
|
|
4032
4131
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4033
4132
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
@@ -4039,14 +4138,15 @@ var DataSpaceManager = class {
|
|
|
4039
4138
|
presence,
|
|
4040
4139
|
keyring: this._keyring,
|
|
4041
4140
|
feedStore: this._feedStore,
|
|
4141
|
+
echoHost: this._echoHost,
|
|
4042
4142
|
signingContext: this._signingContext,
|
|
4043
4143
|
callbacks: {
|
|
4044
4144
|
beforeReady: async () => {
|
|
4045
4145
|
log10("before space ready", {
|
|
4046
4146
|
space: space.key
|
|
4047
4147
|
}, {
|
|
4048
|
-
F:
|
|
4049
|
-
L:
|
|
4148
|
+
F: __dxlog_file12,
|
|
4149
|
+
L: 269,
|
|
4050
4150
|
S: this,
|
|
4051
4151
|
C: (f, a) => f(...a)
|
|
4052
4152
|
});
|
|
@@ -4056,12 +4156,15 @@ var DataSpaceManager = class {
|
|
|
4056
4156
|
space: space.key,
|
|
4057
4157
|
open: this._isOpen
|
|
4058
4158
|
}, {
|
|
4059
|
-
F:
|
|
4060
|
-
L:
|
|
4159
|
+
F: __dxlog_file12,
|
|
4160
|
+
L: 272,
|
|
4061
4161
|
S: this,
|
|
4062
4162
|
C: (f, a) => f(...a)
|
|
4063
4163
|
});
|
|
4064
4164
|
if (this._isOpen) {
|
|
4165
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4166
|
+
...space.spaceState.invitations.entries()
|
|
4167
|
+
]);
|
|
4065
4168
|
this.updated.emit();
|
|
4066
4169
|
}
|
|
4067
4170
|
},
|
|
@@ -4069,15 +4172,14 @@ var DataSpaceManager = class {
|
|
|
4069
4172
|
log10("before space close", {
|
|
4070
4173
|
space: space.key
|
|
4071
4174
|
}, {
|
|
4072
|
-
F:
|
|
4073
|
-
L:
|
|
4175
|
+
F: __dxlog_file12,
|
|
4176
|
+
L: 279,
|
|
4074
4177
|
S: this,
|
|
4075
4178
|
C: (f, a) => f(...a)
|
|
4076
4179
|
});
|
|
4077
4180
|
}
|
|
4078
4181
|
},
|
|
4079
|
-
cache: metadata.cache
|
|
4080
|
-
automergeHost: this._automergeHost
|
|
4182
|
+
cache: metadata.cache
|
|
4081
4183
|
});
|
|
4082
4184
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4083
4185
|
await dataSpace.open();
|
|
@@ -4088,9 +4190,44 @@ var DataSpaceManager = class {
|
|
|
4088
4190
|
this._spaces.set(metadata.key, dataSpace);
|
|
4089
4191
|
return dataSpace;
|
|
4090
4192
|
}
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4193
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4194
|
+
if (dataSpace?.state !== SpaceState2.READY) {
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
4197
|
+
if (isActive) {
|
|
4198
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4199
|
+
[
|
|
4200
|
+
delegatedInvitation.credentialId,
|
|
4201
|
+
delegatedInvitation.invitation
|
|
4202
|
+
]
|
|
4203
|
+
]);
|
|
4204
|
+
} else {
|
|
4205
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4209
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4210
|
+
return this._invitationsManager.createInvitation({
|
|
4211
|
+
type: Invitation6.Type.DELEGATED,
|
|
4212
|
+
kind: Invitation6.Kind.SPACE,
|
|
4213
|
+
spaceKey: space.key,
|
|
4214
|
+
authMethod: invitation.authMethod,
|
|
4215
|
+
invitationId: invitation.invitationId,
|
|
4216
|
+
swarmKey: invitation.swarmKey,
|
|
4217
|
+
guestKeypair: invitation.guestKey ? {
|
|
4218
|
+
publicKey: invitation.guestKey
|
|
4219
|
+
} : void 0,
|
|
4220
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4221
|
+
multiUse: invitation.multiUse,
|
|
4222
|
+
delegationCredentialId: credentialId,
|
|
4223
|
+
persistent: false
|
|
4224
|
+
});
|
|
4225
|
+
});
|
|
4226
|
+
await Promise.all(tasks);
|
|
4227
|
+
}
|
|
4228
|
+
};
|
|
4229
|
+
_ts_decorate5([
|
|
4230
|
+
synchronized2
|
|
4094
4231
|
], DataSpaceManager.prototype, "open", null);
|
|
4095
4232
|
_ts_decorate5([
|
|
4096
4233
|
synchronized2
|
|
@@ -4106,14 +4243,14 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4106
4243
|
], DataSpaceManager);
|
|
4107
4244
|
|
|
4108
4245
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4109
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4246
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4110
4247
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4111
4248
|
import { raise as raise2 } from "@dxos/debug";
|
|
4112
|
-
import { invariant as
|
|
4249
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4113
4250
|
import { log as log11 } from "@dxos/log";
|
|
4114
4251
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4115
4252
|
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4116
|
-
var
|
|
4253
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4117
4254
|
var SpacesServiceImpl = class {
|
|
4118
4255
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4119
4256
|
this._identityManager = _identityManager;
|
|
@@ -4152,7 +4289,7 @@ var SpacesServiceImpl = class {
|
|
|
4152
4289
|
log11("update", {
|
|
4153
4290
|
spaces
|
|
4154
4291
|
}, {
|
|
4155
|
-
F:
|
|
4292
|
+
F: __dxlog_file13,
|
|
4156
4293
|
L: 77,
|
|
4157
4294
|
S: this,
|
|
4158
4295
|
C: (f, a) => f(...a)
|
|
@@ -4163,7 +4300,7 @@ var SpacesServiceImpl = class {
|
|
|
4163
4300
|
}, {
|
|
4164
4301
|
maxFrequency: false ? void 0 : 2
|
|
4165
4302
|
});
|
|
4166
|
-
|
|
4303
|
+
scheduleTask5(ctx, async () => {
|
|
4167
4304
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4168
4305
|
const subscriptions = new EventSubscriptions2();
|
|
4169
4306
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4197,7 +4334,7 @@ var SpacesServiceImpl = class {
|
|
|
4197
4334
|
}
|
|
4198
4335
|
subscribeMessages({ spaceKey, channel }) {
|
|
4199
4336
|
return new Stream10(({ ctx, next }) => {
|
|
4200
|
-
|
|
4337
|
+
scheduleTask5(ctx, async () => {
|
|
4201
4338
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4202
4339
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4203
4340
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4216,7 +4353,7 @@ var SpacesServiceImpl = class {
|
|
|
4216
4353
|
}
|
|
4217
4354
|
};
|
|
4218
4355
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4219
|
-
|
|
4356
|
+
scheduleTask5(ctx, async () => {
|
|
4220
4357
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4221
4358
|
if (noTail) {
|
|
4222
4359
|
close();
|
|
@@ -4234,8 +4371,8 @@ var SpacesServiceImpl = class {
|
|
|
4234
4371
|
}
|
|
4235
4372
|
});
|
|
4236
4373
|
} else {
|
|
4237
|
-
|
|
4238
|
-
F:
|
|
4374
|
+
invariant12(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4375
|
+
F: __dxlog_file13,
|
|
4239
4376
|
L: 164,
|
|
4240
4377
|
S: this,
|
|
4241
4378
|
A: [
|
|
@@ -4243,8 +4380,8 @@ var SpacesServiceImpl = class {
|
|
|
4243
4380
|
"'Id on unsigned credentials is not allowed'"
|
|
4244
4381
|
]
|
|
4245
4382
|
});
|
|
4246
|
-
|
|
4247
|
-
F:
|
|
4383
|
+
invariant12(this._identityManager.identity, "Identity is not available", {
|
|
4384
|
+
F: __dxlog_file13,
|
|
4248
4385
|
L: 165,
|
|
4249
4386
|
S: this,
|
|
4250
4387
|
A: [
|
|
@@ -4253,8 +4390,8 @@ var SpacesServiceImpl = class {
|
|
|
4253
4390
|
]
|
|
4254
4391
|
});
|
|
4255
4392
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4256
|
-
|
|
4257
|
-
F:
|
|
4393
|
+
invariant12(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4394
|
+
F: __dxlog_file13,
|
|
4258
4395
|
L: 167,
|
|
4259
4396
|
S: this,
|
|
4260
4397
|
A: [
|
|
@@ -4324,102 +4461,21 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4324
4461
|
|
|
4325
4462
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4326
4463
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4327
|
-
import { Context as Context10 } from "@dxos/context";
|
|
4464
|
+
import { Context as Context10, Resource } from "@dxos/context";
|
|
4328
4465
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4329
4466
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4330
|
-
import {
|
|
4467
|
+
import { EchoHost } from "@dxos/echo-db";
|
|
4468
|
+
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4331
4469
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4332
|
-
import {
|
|
4333
|
-
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4470
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4334
4471
|
import { Keyring } from "@dxos/keyring";
|
|
4335
|
-
import { PublicKey as
|
|
4472
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4336
4473
|
import { log as log12 } from "@dxos/log";
|
|
4337
|
-
import { InvalidStorageVersionError, STORAGE_VERSION
|
|
4338
|
-
import { Invitation as
|
|
4474
|
+
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4475
|
+
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4339
4476
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4340
4477
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4341
4478
|
import { safeInstanceof } from "@dxos/util";
|
|
4342
|
-
|
|
4343
|
-
// packages/sdk/client-services/src/packlets/indexing/util.ts
|
|
4344
|
-
import { getHeads } from "@dxos/automerge/automerge";
|
|
4345
|
-
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4346
|
-
import { idCodec } from "@dxos/protocols";
|
|
4347
|
-
var createLoadDocuments = (automergeHost) => (
|
|
4348
|
-
/**
|
|
4349
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4350
|
-
* @param ids
|
|
4351
|
-
*/
|
|
4352
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4353
|
-
async function* loadDocuments(ids) {
|
|
4354
|
-
for (const id of ids) {
|
|
4355
|
-
const { documentId, objectId } = idCodec.decode(id);
|
|
4356
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4357
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4358
|
-
const doc = handle.docSync();
|
|
4359
|
-
const hash = getHeads(doc).join("");
|
|
4360
|
-
yield [
|
|
4361
|
-
{
|
|
4362
|
-
id,
|
|
4363
|
-
object: doc.objects[objectId],
|
|
4364
|
-
currentHash: hash
|
|
4365
|
-
}
|
|
4366
|
-
];
|
|
4367
|
-
}
|
|
4368
|
-
}
|
|
4369
|
-
);
|
|
4370
|
-
var createGetAllDocuments = (automergeHost) => (
|
|
4371
|
-
/**
|
|
4372
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4373
|
-
* @param ids
|
|
4374
|
-
*/
|
|
4375
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4376
|
-
async function* getAllDocuments() {
|
|
4377
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4378
|
-
async function* getObjectsFromHandle(handle) {
|
|
4379
|
-
if (visited.has(handle.documentId)) {
|
|
4380
|
-
return;
|
|
4381
|
-
}
|
|
4382
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4383
|
-
const doc = handle.docSync();
|
|
4384
|
-
const heads = getHeads(doc);
|
|
4385
|
-
if (doc.objects) {
|
|
4386
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4387
|
-
return {
|
|
4388
|
-
id: idCodec.encode({
|
|
4389
|
-
documentId: handle.documentId,
|
|
4390
|
-
objectId
|
|
4391
|
-
}),
|
|
4392
|
-
object,
|
|
4393
|
-
currentHash: heads.at(-1)
|
|
4394
|
-
};
|
|
4395
|
-
});
|
|
4396
|
-
}
|
|
4397
|
-
if (doc.links) {
|
|
4398
|
-
for (const id of Object.values(doc.links)) {
|
|
4399
|
-
if (visited.has(id)) {
|
|
4400
|
-
continue;
|
|
4401
|
-
}
|
|
4402
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4403
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4404
|
-
yield result;
|
|
4405
|
-
}
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
visited.add(handle.documentId);
|
|
4409
|
-
}
|
|
4410
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4411
|
-
if (visited.has(handle.documentId)) {
|
|
4412
|
-
continue;
|
|
4413
|
-
}
|
|
4414
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4415
|
-
yield result;
|
|
4416
|
-
}
|
|
4417
|
-
visited.add(handle.documentId);
|
|
4418
|
-
}
|
|
4419
|
-
}
|
|
4420
|
-
);
|
|
4421
|
-
|
|
4422
|
-
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4423
4479
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4424
4480
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4425
4481
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4430,16 +4486,18 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4430
4486
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4431
4487
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4432
4488
|
}
|
|
4433
|
-
var
|
|
4434
|
-
var ServiceContext = class {
|
|
4435
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4489
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4490
|
+
var ServiceContext = class extends Resource {
|
|
4491
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4492
|
+
super();
|
|
4436
4493
|
this.storage = storage;
|
|
4494
|
+
this.level = level;
|
|
4437
4495
|
this.networkManager = networkManager;
|
|
4438
4496
|
this.signalManager = signalManager;
|
|
4439
4497
|
this._runtimeParams = _runtimeParams;
|
|
4440
4498
|
this.initialized = new Trigger5();
|
|
4441
4499
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4442
|
-
this._instanceId =
|
|
4500
|
+
this._instanceId = PublicKey11.random().toHex();
|
|
4443
4501
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4444
4502
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4445
4503
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4462,28 +4520,18 @@ var ServiceContext = class {
|
|
|
4462
4520
|
snapshotStore: this.snapshotStore
|
|
4463
4521
|
});
|
|
4464
4522
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4465
|
-
this.
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
this.automergeHost = new AutomergeHost({
|
|
4469
|
-
directory: storage.createDirectory("automerge"),
|
|
4470
|
-
metadata: this.indexMetadata
|
|
4471
|
-
});
|
|
4472
|
-
this.indexer = new Indexer({
|
|
4473
|
-
indexStore: new IndexStore({
|
|
4474
|
-
directory: storage.createDirectory("index-store")
|
|
4475
|
-
}),
|
|
4476
|
-
metadataStore: this.indexMetadata,
|
|
4477
|
-
loadDocuments: createLoadDocuments(this.automergeHost),
|
|
4478
|
-
getAllDocuments: createGetAllDocuments(this.automergeHost)
|
|
4523
|
+
this.echoHost = new EchoHost({
|
|
4524
|
+
kv: this.level,
|
|
4525
|
+
storage: this.storage
|
|
4479
4526
|
});
|
|
4480
4527
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4481
|
-
this.
|
|
4528
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4529
|
+
this._handlerFactories.set(Invitation7.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4482
4530
|
}
|
|
4483
|
-
async
|
|
4531
|
+
async _open(ctx) {
|
|
4484
4532
|
await this._checkStorageVersion();
|
|
4485
4533
|
log12("opening...", void 0, {
|
|
4486
|
-
F:
|
|
4534
|
+
F: __dxlog_file14,
|
|
4487
4535
|
L: 151,
|
|
4488
4536
|
S: this,
|
|
4489
4537
|
C: (f, a) => f(...a)
|
|
@@ -4491,56 +4539,65 @@ var ServiceContext = class {
|
|
|
4491
4539
|
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4492
4540
|
id: this._instanceId
|
|
4493
4541
|
}), {
|
|
4494
|
-
F:
|
|
4542
|
+
F: __dxlog_file14,
|
|
4495
4543
|
L: 152,
|
|
4496
4544
|
S: this,
|
|
4497
4545
|
C: (f, a) => f(...a)
|
|
4498
4546
|
});
|
|
4499
4547
|
await this.signalManager.open();
|
|
4500
4548
|
await this.networkManager.open();
|
|
4549
|
+
await this.echoHost.open(ctx);
|
|
4501
4550
|
await this.metadataStore.load();
|
|
4502
4551
|
await this.spaceManager.open();
|
|
4503
4552
|
await this.identityManager.open(ctx);
|
|
4504
4553
|
if (this.identityManager.identity) {
|
|
4505
4554
|
await this._initialize(ctx);
|
|
4506
4555
|
}
|
|
4556
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4557
|
+
log12("loaded persistent invitations", {
|
|
4558
|
+
count: loadedInvitations.invitations?.length
|
|
4559
|
+
}, {
|
|
4560
|
+
F: __dxlog_file14,
|
|
4561
|
+
L: 165,
|
|
4562
|
+
S: this,
|
|
4563
|
+
C: (f, a) => f(...a)
|
|
4564
|
+
});
|
|
4507
4565
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4508
4566
|
id: this._instanceId
|
|
4509
4567
|
}), {
|
|
4510
|
-
F:
|
|
4511
|
-
L:
|
|
4568
|
+
F: __dxlog_file14,
|
|
4569
|
+
L: 167,
|
|
4512
4570
|
S: this,
|
|
4513
4571
|
C: (f, a) => f(...a)
|
|
4514
4572
|
});
|
|
4515
4573
|
log12("opened", void 0, {
|
|
4516
|
-
F:
|
|
4517
|
-
L:
|
|
4574
|
+
F: __dxlog_file14,
|
|
4575
|
+
L: 168,
|
|
4518
4576
|
S: this,
|
|
4519
4577
|
C: (f, a) => f(...a)
|
|
4520
4578
|
});
|
|
4521
4579
|
}
|
|
4522
|
-
async
|
|
4580
|
+
async _close(ctx) {
|
|
4523
4581
|
log12("closing...", void 0, {
|
|
4524
|
-
F:
|
|
4525
|
-
L:
|
|
4582
|
+
F: __dxlog_file14,
|
|
4583
|
+
L: 172,
|
|
4526
4584
|
S: this,
|
|
4527
4585
|
C: (f, a) => f(...a)
|
|
4528
4586
|
});
|
|
4529
4587
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4530
4588
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4531
4589
|
}
|
|
4532
|
-
await this.automergeHost.close();
|
|
4533
4590
|
await this.dataSpaceManager?.close();
|
|
4534
4591
|
await this.identityManager.close();
|
|
4535
4592
|
await this.spaceManager.close();
|
|
4536
4593
|
await this.feedStore.close();
|
|
4594
|
+
await this.metadataStore.close();
|
|
4595
|
+
await this.echoHost.close(ctx);
|
|
4537
4596
|
await this.networkManager.close();
|
|
4538
4597
|
await this.signalManager.close();
|
|
4539
|
-
await this.metadataStore.close();
|
|
4540
|
-
await this.indexer.destroy();
|
|
4541
4598
|
log12("closed", void 0, {
|
|
4542
|
-
F:
|
|
4543
|
-
L:
|
|
4599
|
+
F: __dxlog_file14,
|
|
4600
|
+
L: 184,
|
|
4544
4601
|
S: this,
|
|
4545
4602
|
C: (f, a) => f(...a)
|
|
4546
4603
|
});
|
|
@@ -4552,9 +4609,9 @@ var ServiceContext = class {
|
|
|
4552
4609
|
}
|
|
4553
4610
|
getInvitationHandler(invitation) {
|
|
4554
4611
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4555
|
-
|
|
4556
|
-
F:
|
|
4557
|
-
L:
|
|
4612
|
+
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4613
|
+
F: __dxlog_file14,
|
|
4614
|
+
L: 195,
|
|
4558
4615
|
S: this,
|
|
4559
4616
|
A: [
|
|
4560
4617
|
"factory",
|
|
@@ -4578,15 +4635,15 @@ var ServiceContext = class {
|
|
|
4578
4635
|
}
|
|
4579
4636
|
async _checkStorageVersion() {
|
|
4580
4637
|
await this.metadataStore.load();
|
|
4581
|
-
if (this.metadataStore.version !==
|
|
4582
|
-
throw new InvalidStorageVersionError(
|
|
4638
|
+
if (this.metadataStore.version !== STORAGE_VERSION) {
|
|
4639
|
+
throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
|
|
4583
4640
|
}
|
|
4584
4641
|
}
|
|
4585
4642
|
// Called when identity is created.
|
|
4586
4643
|
async _initialize(ctx) {
|
|
4587
4644
|
log12("initializing spaces...", void 0, {
|
|
4588
|
-
F:
|
|
4589
|
-
L:
|
|
4645
|
+
F: __dxlog_file14,
|
|
4646
|
+
L: 226,
|
|
4590
4647
|
S: this,
|
|
4591
4648
|
C: (f, a) => f(...a)
|
|
4592
4649
|
});
|
|
@@ -4604,12 +4661,12 @@ var ServiceContext = class {
|
|
|
4604
4661
|
});
|
|
4605
4662
|
}
|
|
4606
4663
|
};
|
|
4607
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.
|
|
4664
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
4608
4665
|
await this.dataSpaceManager.open();
|
|
4609
|
-
this._handlerFactories.set(
|
|
4610
|
-
|
|
4611
|
-
F:
|
|
4612
|
-
L:
|
|
4666
|
+
this._handlerFactories.set(Invitation7.Kind.SPACE, (invitation) => {
|
|
4667
|
+
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4668
|
+
F: __dxlog_file14,
|
|
4669
|
+
L: 251,
|
|
4613
4670
|
S: this,
|
|
4614
4671
|
A: [
|
|
4615
4672
|
"this.dataSpaceManager",
|
|
@@ -4632,8 +4689,8 @@ var ServiceContext = class {
|
|
|
4632
4689
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4633
4690
|
details: assertion
|
|
4634
4691
|
}, {
|
|
4635
|
-
F:
|
|
4636
|
-
L:
|
|
4692
|
+
F: __dxlog_file14,
|
|
4693
|
+
L: 267,
|
|
4637
4694
|
S: this,
|
|
4638
4695
|
C: (f, a) => f(...a)
|
|
4639
4696
|
});
|
|
@@ -4643,8 +4700,8 @@ var ServiceContext = class {
|
|
|
4643
4700
|
log12("space already exists, ignoring space admission", {
|
|
4644
4701
|
details: assertion
|
|
4645
4702
|
}, {
|
|
4646
|
-
F:
|
|
4647
|
-
L:
|
|
4703
|
+
F: __dxlog_file14,
|
|
4704
|
+
L: 271,
|
|
4648
4705
|
S: this,
|
|
4649
4706
|
C: (f, a) => f(...a)
|
|
4650
4707
|
});
|
|
@@ -4654,8 +4711,8 @@ var ServiceContext = class {
|
|
|
4654
4711
|
log12("accepting space recorded in halo", {
|
|
4655
4712
|
details: assertion
|
|
4656
4713
|
}, {
|
|
4657
|
-
F:
|
|
4658
|
-
L:
|
|
4714
|
+
F: __dxlog_file14,
|
|
4715
|
+
L: 276,
|
|
4659
4716
|
S: this,
|
|
4660
4717
|
C: (f, a) => f(...a)
|
|
4661
4718
|
});
|
|
@@ -4665,8 +4722,8 @@ var ServiceContext = class {
|
|
|
4665
4722
|
});
|
|
4666
4723
|
} catch (err) {
|
|
4667
4724
|
log12.catch(err, void 0, {
|
|
4668
|
-
F:
|
|
4669
|
-
L:
|
|
4725
|
+
F: __dxlog_file14,
|
|
4726
|
+
L: 282,
|
|
4670
4727
|
S: this,
|
|
4671
4728
|
C: (f, a) => f(...a)
|
|
4672
4729
|
});
|
|
@@ -4678,7 +4735,7 @@ var ServiceContext = class {
|
|
|
4678
4735
|
};
|
|
4679
4736
|
_ts_decorate6([
|
|
4680
4737
|
Trace2.span()
|
|
4681
|
-
], ServiceContext.prototype, "
|
|
4738
|
+
], ServiceContext.prototype, "_open", null);
|
|
4682
4739
|
_ts_decorate6([
|
|
4683
4740
|
Trace2.span()
|
|
4684
4741
|
], ServiceContext.prototype, "_initialize", null);
|
|
@@ -4711,195 +4768,270 @@ var ServiceRegistry = class {
|
|
|
4711
4768
|
}
|
|
4712
4769
|
};
|
|
4713
4770
|
|
|
4714
|
-
// packages/sdk/client-services/src/packlets/
|
|
4715
|
-
import {
|
|
4716
|
-
import {
|
|
4717
|
-
import {
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
}
|
|
4742
|
-
get lockKey() {
|
|
4743
|
-
return this._lockKey;
|
|
4744
|
-
}
|
|
4745
|
-
async acquire() {
|
|
4746
|
-
this._broadcastChannel.postMessage({
|
|
4747
|
-
message: "acquiring"
|
|
4748
|
-
});
|
|
4749
|
-
try {
|
|
4750
|
-
log13("aquiring lock...", void 0, {
|
|
4751
|
-
F: __dxlog_file16,
|
|
4752
|
-
L: 42,
|
|
4753
|
-
S: this,
|
|
4754
|
-
C: (f, a) => f(...a)
|
|
4755
|
-
});
|
|
4756
|
-
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4757
|
-
log13("acquired lock", void 0, {
|
|
4758
|
-
F: __dxlog_file16,
|
|
4759
|
-
L: 44,
|
|
4760
|
-
S: this,
|
|
4761
|
-
C: (f, a) => f(...a)
|
|
4762
|
-
});
|
|
4763
|
-
} catch {
|
|
4764
|
-
log13("stealing lock...", void 0, {
|
|
4765
|
-
F: __dxlog_file16,
|
|
4766
|
-
L: 46,
|
|
4767
|
-
S: this,
|
|
4768
|
-
C: (f, a) => f(...a)
|
|
4769
|
-
});
|
|
4770
|
-
await this._requestLock(true);
|
|
4771
|
-
log13("stolen lock", void 0, {
|
|
4772
|
-
F: __dxlog_file16,
|
|
4773
|
-
L: 48,
|
|
4774
|
-
S: this,
|
|
4775
|
-
C: (f, a) => f(...a)
|
|
4776
|
-
});
|
|
4771
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
4772
|
+
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
4773
|
+
import { credentialTypeFilter } from "@dxos/credentials";
|
|
4774
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4775
|
+
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
4776
|
+
import { SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4777
|
+
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4778
|
+
|
|
4779
|
+
// packages/sdk/client-services/src/version.ts
|
|
4780
|
+
var DXOS_VERSION = "0.4.10-main.94f946a";
|
|
4781
|
+
|
|
4782
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4783
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
4784
|
+
var getPlatform = () => {
|
|
4785
|
+
if (process.browser) {
|
|
4786
|
+
if (typeof window !== "undefined") {
|
|
4787
|
+
const { userAgent } = window.navigator;
|
|
4788
|
+
return {
|
|
4789
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
4790
|
+
userAgent,
|
|
4791
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4792
|
+
};
|
|
4793
|
+
} else {
|
|
4794
|
+
return {
|
|
4795
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4796
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4797
|
+
};
|
|
4777
4798
|
}
|
|
4799
|
+
} else {
|
|
4800
|
+
const { platform: platform2, version, arch } = process;
|
|
4801
|
+
return {
|
|
4802
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
4803
|
+
platform: platform2,
|
|
4804
|
+
arch,
|
|
4805
|
+
runtime: version,
|
|
4806
|
+
uptime: Math.floor(process.uptime()),
|
|
4807
|
+
memory: process.memoryUsage()
|
|
4808
|
+
};
|
|
4778
4809
|
}
|
|
4779
|
-
|
|
4780
|
-
|
|
4810
|
+
};
|
|
4811
|
+
|
|
4812
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
4813
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4814
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4815
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4816
|
+
const diagnostics = {
|
|
4817
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4818
|
+
platform: getPlatform(),
|
|
4819
|
+
client: {
|
|
4820
|
+
version: DXOS_VERSION,
|
|
4821
|
+
storage: {
|
|
4822
|
+
version: STORAGE_VERSION2
|
|
4823
|
+
}
|
|
4824
|
+
},
|
|
4825
|
+
trace: TRACE_PROCESSOR.getDiagnostics()
|
|
4826
|
+
};
|
|
4827
|
+
{
|
|
4828
|
+
invariant14(clientServices.LoggingService, "SystemService is not available.", {
|
|
4829
|
+
F: __dxlog_file15,
|
|
4830
|
+
L: 108,
|
|
4831
|
+
S: void 0,
|
|
4832
|
+
A: [
|
|
4833
|
+
"clientServices.LoggingService",
|
|
4834
|
+
"'SystemService is not available.'"
|
|
4835
|
+
]
|
|
4836
|
+
});
|
|
4837
|
+
diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
|
|
4838
|
+
timeout: DEFAULT_TIMEOUT
|
|
4839
|
+
}).catch(() => void 0);
|
|
4781
4840
|
}
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4841
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4842
|
+
const map = /* @__PURE__ */ new Map();
|
|
4843
|
+
const dir = await navigator.storage.getDirectory();
|
|
4844
|
+
for await (const filename of dir?.keys()) {
|
|
4845
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4846
|
+
if (idx === -1) {
|
|
4847
|
+
continue;
|
|
4848
|
+
}
|
|
4849
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4785
4850
|
}
|
|
4851
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4852
|
+
file,
|
|
4853
|
+
count
|
|
4854
|
+
}));
|
|
4786
4855
|
}
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
S: this,
|
|
4815
|
-
C: (f, a) => f(...a)
|
|
4816
|
-
});
|
|
4817
|
-
}).catch(async () => {
|
|
4818
|
-
await this._onRelease?.();
|
|
4819
|
-
});
|
|
4820
|
-
await acquired.wait();
|
|
4821
|
-
log13("recieved lock", {
|
|
4822
|
-
steal
|
|
4823
|
-
}, {
|
|
4824
|
-
F: __dxlog_file16,
|
|
4825
|
-
L: 81,
|
|
4826
|
-
S: this,
|
|
4827
|
-
C: (f, a) => f(...a)
|
|
4828
|
-
});
|
|
4856
|
+
const identity = serviceContext.identityManager.identity;
|
|
4857
|
+
if (identity) {
|
|
4858
|
+
diagnostics.identity = {
|
|
4859
|
+
identityKey: identity.identityKey,
|
|
4860
|
+
spaceKey: identity.space.key,
|
|
4861
|
+
profile: identity.profileDocument
|
|
4862
|
+
};
|
|
4863
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
4864
|
+
timeout: DEFAULT_TIMEOUT
|
|
4865
|
+
}).catch(() => void 0) ?? {};
|
|
4866
|
+
diagnostics.devices = devices;
|
|
4867
|
+
if (serviceContext.dataSpaceManager) {
|
|
4868
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4869
|
+
}
|
|
4870
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4871
|
+
timeout: DEFAULT_TIMEOUT
|
|
4872
|
+
}).catch(() => void 0) ?? {};
|
|
4873
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4874
|
+
feedKey,
|
|
4875
|
+
bytes,
|
|
4876
|
+
length
|
|
4877
|
+
}));
|
|
4878
|
+
const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
|
|
4879
|
+
timeout: DEFAULT_TIMEOUT
|
|
4880
|
+
}).catch(() => void 0);
|
|
4881
|
+
diagnostics.networkStatus = status;
|
|
4882
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4829
4883
|
}
|
|
4884
|
+
diagnostics.config = config.values;
|
|
4885
|
+
return diagnostics;
|
|
4830
4886
|
};
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4887
|
+
var getSpaceStats = async (space) => {
|
|
4888
|
+
const stats = {
|
|
4889
|
+
key: space.key,
|
|
4890
|
+
metrics: space.metrics,
|
|
4891
|
+
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4892
|
+
...credential.subject.assertion,
|
|
4893
|
+
id: credential.id
|
|
4894
|
+
})),
|
|
4895
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4896
|
+
identity: {
|
|
4897
|
+
identityKey: member.key,
|
|
4898
|
+
profile: {
|
|
4899
|
+
displayName: member.assertion.profile?.displayName
|
|
4900
|
+
}
|
|
4901
|
+
},
|
|
4902
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE
|
|
4903
|
+
})),
|
|
4904
|
+
pipeline: {
|
|
4905
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4906
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4907
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4908
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4909
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4910
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4911
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4912
|
+
}
|
|
4913
|
+
};
|
|
4914
|
+
if (stats.metrics) {
|
|
4915
|
+
const { open, ready } = stats.metrics;
|
|
4916
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4917
|
+
}
|
|
4918
|
+
return stats;
|
|
4836
4919
|
};
|
|
4837
4920
|
|
|
4838
|
-
// packages/sdk/client-services/src/packlets/
|
|
4839
|
-
import {
|
|
4840
|
-
import {
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4921
|
+
// packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
|
|
4922
|
+
import { Trigger as Trigger6 } from "@dxos/async";
|
|
4923
|
+
import { log as log13 } from "@dxos/log";
|
|
4924
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
|
|
4925
|
+
var CHANNEL_NAME = "dxos.diagnostics.broadcast";
|
|
4926
|
+
var MessageType;
|
|
4927
|
+
(function(MessageType2) {
|
|
4928
|
+
MessageType2["PROBE"] = "probe";
|
|
4929
|
+
MessageType2["PROBE_ACK"] = "probe-ack";
|
|
4930
|
+
MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
|
|
4931
|
+
MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
|
|
4932
|
+
})(MessageType || (MessageType = {}));
|
|
4933
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4934
|
+
return {
|
|
4935
|
+
broadcastDiagnosticsRequest: async () => {
|
|
4936
|
+
let expectedResponse = "probe-ack";
|
|
4937
|
+
let channel;
|
|
4938
|
+
try {
|
|
4939
|
+
const trigger = new Trigger6();
|
|
4940
|
+
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
4941
|
+
channel.onmessage = (msg) => {
|
|
4942
|
+
if (expectedResponse === msg.data.type) {
|
|
4943
|
+
trigger.wake(msg.data);
|
|
4944
|
+
}
|
|
4945
|
+
};
|
|
4946
|
+
channel.postMessage({
|
|
4947
|
+
type: "probe"
|
|
4948
|
+
});
|
|
4949
|
+
await trigger.wait({
|
|
4950
|
+
timeout: 200
|
|
4951
|
+
});
|
|
4952
|
+
expectedResponse = "receive-diagnostics";
|
|
4953
|
+
trigger.reset();
|
|
4954
|
+
channel.postMessage({
|
|
4955
|
+
type: "request-diagnostics"
|
|
4956
|
+
});
|
|
4957
|
+
const diagnostics = await trigger.wait({
|
|
4958
|
+
timeout: 5e3
|
|
4959
|
+
});
|
|
4960
|
+
return diagnostics.payload;
|
|
4961
|
+
} catch (e) {
|
|
4962
|
+
const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
|
|
4963
|
+
return {
|
|
4964
|
+
expectedResponse,
|
|
4965
|
+
errorDescription
|
|
4966
|
+
};
|
|
4967
|
+
} finally {
|
|
4968
|
+
safeClose(channel);
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
};
|
|
4972
|
+
};
|
|
4973
|
+
var createCollectDiagnosticsBroadcastHandler = (systemService) => {
|
|
4974
|
+
let channel;
|
|
4859
4975
|
return {
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4976
|
+
start: () => {
|
|
4977
|
+
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
4978
|
+
channel.onmessage = async (message) => {
|
|
4979
|
+
try {
|
|
4980
|
+
if (message.data.type === "probe") {
|
|
4981
|
+
channel?.postMessage({
|
|
4982
|
+
type: "probe-ack"
|
|
4983
|
+
});
|
|
4984
|
+
} else if (message.data.type === "request-diagnostics") {
|
|
4985
|
+
const diagnostics = await systemService.getDiagnostics({});
|
|
4986
|
+
channel?.postMessage({
|
|
4987
|
+
type: "receive-diagnostics",
|
|
4988
|
+
payload: diagnostics
|
|
4989
|
+
});
|
|
4990
|
+
}
|
|
4991
|
+
} catch (error) {
|
|
4992
|
+
log13.catch(error, void 0, {
|
|
4993
|
+
F: __dxlog_file16,
|
|
4994
|
+
L: 77,
|
|
4995
|
+
S: void 0,
|
|
4996
|
+
C: (f, a) => f(...a)
|
|
4997
|
+
});
|
|
4998
|
+
}
|
|
4999
|
+
};
|
|
5000
|
+
},
|
|
5001
|
+
stop: () => {
|
|
5002
|
+
safeClose(channel);
|
|
5003
|
+
channel = void 0;
|
|
5004
|
+
}
|
|
4864
5005
|
};
|
|
4865
5006
|
};
|
|
4866
|
-
var
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
case StorageDriver.RAM:
|
|
4871
|
-
return StorageType.RAM;
|
|
4872
|
-
case StorageDriver.CHROME:
|
|
4873
|
-
return StorageType.CHROME;
|
|
4874
|
-
case StorageDriver.FIREFOX:
|
|
4875
|
-
return StorageType.FIREFOX;
|
|
4876
|
-
case StorageDriver.IDB:
|
|
4877
|
-
return StorageType.IDB;
|
|
4878
|
-
case StorageDriver.NODE:
|
|
4879
|
-
return StorageType.NODE;
|
|
4880
|
-
case StorageDriver.WEBFS:
|
|
4881
|
-
return StorageType.WEBFS;
|
|
4882
|
-
default:
|
|
4883
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5007
|
+
var safeClose = (channel) => {
|
|
5008
|
+
try {
|
|
5009
|
+
channel?.close();
|
|
5010
|
+
} catch (e) {
|
|
4884
5011
|
}
|
|
4885
5012
|
};
|
|
4886
5013
|
|
|
5014
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
5015
|
+
import { ConfigResource } from "@dxos/config";
|
|
5016
|
+
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5017
|
+
import { TRACE_PROCESSOR as TRACE_PROCESSOR3 } from "@dxos/tracing";
|
|
5018
|
+
import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
5019
|
+
|
|
4887
5020
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4888
5021
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4889
|
-
import {
|
|
5022
|
+
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4890
5023
|
import { Context as Context11 } from "@dxos/context";
|
|
4891
|
-
import {
|
|
4892
|
-
import {
|
|
4893
|
-
import { IndexServiceImpl } from "@dxos/indexing";
|
|
5024
|
+
import { encodeReference } from "@dxos/echo-pipeline";
|
|
5025
|
+
import { getTypeReference } from "@dxos/echo-schema";
|
|
4894
5026
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4895
|
-
import { PublicKey as
|
|
4896
|
-
import { log as
|
|
5027
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
5028
|
+
import { log as log16 } from "@dxos/log";
|
|
4897
5029
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4898
5030
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4899
5031
|
import { trace as trace9 } from "@dxos/protocols";
|
|
4900
5032
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4901
5033
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
|
|
4902
|
-
import { assignDeep } from "@dxos/util";
|
|
5034
|
+
import { assignDeep as assignDeep2 } from "@dxos/util";
|
|
4903
5035
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
4904
5036
|
|
|
4905
5037
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
@@ -4984,28 +5116,152 @@ var DevicesServiceImpl = class {
|
|
|
4984
5116
|
}
|
|
4985
5117
|
};
|
|
4986
5118
|
|
|
5119
|
+
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5120
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
|
|
5121
|
+
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5122
|
+
import { log as log14, logInfo } from "@dxos/log";
|
|
5123
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5124
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5125
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5126
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5127
|
+
else
|
|
5128
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
5129
|
+
if (d = decorators[i])
|
|
5130
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5131
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5132
|
+
}
|
|
5133
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5134
|
+
var Message;
|
|
5135
|
+
(function(Message2) {
|
|
5136
|
+
Message2["ACQUIRING"] = "acquiring";
|
|
5137
|
+
})(Message || (Message = {}));
|
|
5138
|
+
var Lock = class {
|
|
5139
|
+
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5140
|
+
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5141
|
+
this._releaseTrigger = new Trigger7();
|
|
5142
|
+
this._lockKey = lockKey;
|
|
5143
|
+
this._onAcquire = onAcquire;
|
|
5144
|
+
this._onRelease = onRelease;
|
|
5145
|
+
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
5146
|
+
}
|
|
5147
|
+
get lockKey() {
|
|
5148
|
+
return this._lockKey;
|
|
5149
|
+
}
|
|
5150
|
+
async acquire() {
|
|
5151
|
+
this._broadcastChannel.postMessage({
|
|
5152
|
+
message: "acquiring"
|
|
5153
|
+
});
|
|
5154
|
+
try {
|
|
5155
|
+
log14("aquiring lock...", void 0, {
|
|
5156
|
+
F: __dxlog_file18,
|
|
5157
|
+
L: 42,
|
|
5158
|
+
S: this,
|
|
5159
|
+
C: (f, a) => f(...a)
|
|
5160
|
+
});
|
|
5161
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5162
|
+
log14("acquired lock", void 0, {
|
|
5163
|
+
F: __dxlog_file18,
|
|
5164
|
+
L: 44,
|
|
5165
|
+
S: this,
|
|
5166
|
+
C: (f, a) => f(...a)
|
|
5167
|
+
});
|
|
5168
|
+
} catch {
|
|
5169
|
+
log14("stealing lock...", void 0, {
|
|
5170
|
+
F: __dxlog_file18,
|
|
5171
|
+
L: 46,
|
|
5172
|
+
S: this,
|
|
5173
|
+
C: (f, a) => f(...a)
|
|
5174
|
+
});
|
|
5175
|
+
await this._requestLock(true);
|
|
5176
|
+
log14("stolen lock", void 0, {
|
|
5177
|
+
F: __dxlog_file18,
|
|
5178
|
+
L: 48,
|
|
5179
|
+
S: this,
|
|
5180
|
+
C: (f, a) => f(...a)
|
|
5181
|
+
});
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
async release() {
|
|
5185
|
+
this._releaseTrigger.wake();
|
|
5186
|
+
}
|
|
5187
|
+
_onMessage(event) {
|
|
5188
|
+
if (event.data.message === "acquiring") {
|
|
5189
|
+
this._releaseTrigger.wake();
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
async _requestLock(steal = false) {
|
|
5193
|
+
log14("requesting lock...", {
|
|
5194
|
+
steal
|
|
5195
|
+
}, {
|
|
5196
|
+
F: __dxlog_file18,
|
|
5197
|
+
L: 63,
|
|
5198
|
+
S: this,
|
|
5199
|
+
C: (f, a) => f(...a)
|
|
5200
|
+
});
|
|
5201
|
+
const acquired = new Trigger7();
|
|
5202
|
+
void navigator.locks.request(this._lockKey, {
|
|
5203
|
+
steal
|
|
5204
|
+
}, async () => {
|
|
5205
|
+
await this._onAcquire?.();
|
|
5206
|
+
acquired.wake();
|
|
5207
|
+
this._releaseTrigger = new Trigger7();
|
|
5208
|
+
await this._releaseTrigger.wait();
|
|
5209
|
+
log14("releasing lock...", void 0, {
|
|
5210
|
+
F: __dxlog_file18,
|
|
5211
|
+
L: 72,
|
|
5212
|
+
S: this,
|
|
5213
|
+
C: (f, a) => f(...a)
|
|
5214
|
+
});
|
|
5215
|
+
await this._onRelease?.();
|
|
5216
|
+
log14("released lock", void 0, {
|
|
5217
|
+
F: __dxlog_file18,
|
|
5218
|
+
L: 74,
|
|
5219
|
+
S: this,
|
|
5220
|
+
C: (f, a) => f(...a)
|
|
5221
|
+
});
|
|
5222
|
+
}).catch(async () => {
|
|
5223
|
+
await this._onRelease?.();
|
|
5224
|
+
});
|
|
5225
|
+
await acquired.wait();
|
|
5226
|
+
log14("recieved lock", {
|
|
5227
|
+
steal
|
|
5228
|
+
}, {
|
|
5229
|
+
F: __dxlog_file18,
|
|
5230
|
+
L: 81,
|
|
5231
|
+
S: this,
|
|
5232
|
+
C: (f, a) => f(...a)
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
};
|
|
5236
|
+
_ts_decorate7([
|
|
5237
|
+
logInfo
|
|
5238
|
+
], Lock.prototype, "lockKey", null);
|
|
5239
|
+
var isLocked = (lockPath) => {
|
|
5240
|
+
throw new Error("Not implemented");
|
|
5241
|
+
};
|
|
5242
|
+
|
|
4987
5243
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
4988
5244
|
import { Event as Event8 } from "@dxos/async";
|
|
4989
5245
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
4990
|
-
import { PublicKey as
|
|
4991
|
-
import { getContextFromEntry, log as
|
|
5246
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5247
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
4992
5248
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4993
5249
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
4994
5250
|
var LoggingServiceImpl = class {
|
|
4995
5251
|
constructor() {
|
|
4996
5252
|
this._logs = new Event8();
|
|
4997
5253
|
this._started = Date.now();
|
|
4998
|
-
this._sessionId =
|
|
5254
|
+
this._sessionId = PublicKey12.random().toHex();
|
|
4999
5255
|
this._logProcessor = (_config, entry2) => {
|
|
5000
5256
|
this._logs.emit(entry2);
|
|
5001
5257
|
};
|
|
5002
5258
|
}
|
|
5003
5259
|
async open() {
|
|
5004
|
-
|
|
5260
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
5005
5261
|
}
|
|
5006
5262
|
async close() {
|
|
5007
|
-
const index =
|
|
5008
|
-
|
|
5263
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5264
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
5009
5265
|
}
|
|
5010
5266
|
async controlMetrics({ reset, record }) {
|
|
5011
5267
|
if (reset) {
|
|
@@ -5090,12 +5346,12 @@ var LoggingServiceImpl = class {
|
|
|
5090
5346
|
});
|
|
5091
5347
|
}
|
|
5092
5348
|
};
|
|
5093
|
-
var matchFilter = (filter, level,
|
|
5349
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5094
5350
|
switch (options) {
|
|
5095
5351
|
case QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5096
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5352
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5097
5353
|
case QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5098
|
-
return level === filter.level && (!filter.pattern ||
|
|
5354
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5099
5355
|
}
|
|
5100
5356
|
};
|
|
5101
5357
|
var shouldLog = (entry2, request) => {
|
|
@@ -5141,6 +5397,80 @@ var NetworkServiceImpl = class {
|
|
|
5141
5397
|
}
|
|
5142
5398
|
};
|
|
5143
5399
|
|
|
5400
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
5401
|
+
import { InvalidConfigError } from "@dxos/protocols";
|
|
5402
|
+
import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
|
|
5403
|
+
import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
5404
|
+
|
|
5405
|
+
// packages/sdk/client-services/src/packlets/storage/util.ts
|
|
5406
|
+
import { DX_DATA } from "@dxos/client-protocol";
|
|
5407
|
+
import { Runtime } from "@dxos/protocols/proto/dxos/config";
|
|
5408
|
+
import { isNode as isNode2 } from "@dxos/util";
|
|
5409
|
+
var getRootPath = (config) => {
|
|
5410
|
+
const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
|
|
5411
|
+
return `${dataRoot}/`;
|
|
5412
|
+
};
|
|
5413
|
+
var isPersistent = (config) => {
|
|
5414
|
+
const { persistent = false } = config ?? {};
|
|
5415
|
+
return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5416
|
+
};
|
|
5417
|
+
|
|
5418
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
5419
|
+
var StorageDriver = Runtime2.Client.Storage.StorageDriver;
|
|
5420
|
+
var createStorageObjects = (config) => {
|
|
5421
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5422
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5423
|
+
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5424
|
+
}
|
|
5425
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5426
|
+
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5427
|
+
}
|
|
5428
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5429
|
+
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5430
|
+
}
|
|
5431
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5432
|
+
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5433
|
+
}
|
|
5434
|
+
return {
|
|
5435
|
+
storage: createStorage({
|
|
5436
|
+
type: persistent ? toStorageType(dataStore) : StorageType.RAM,
|
|
5437
|
+
root: getRootPath(config)
|
|
5438
|
+
})
|
|
5439
|
+
};
|
|
5440
|
+
};
|
|
5441
|
+
var toStorageType = (type) => {
|
|
5442
|
+
switch (type) {
|
|
5443
|
+
case void 0:
|
|
5444
|
+
return void 0;
|
|
5445
|
+
case StorageDriver.RAM:
|
|
5446
|
+
return StorageType.RAM;
|
|
5447
|
+
case StorageDriver.CHROME:
|
|
5448
|
+
return StorageType.CHROME;
|
|
5449
|
+
case StorageDriver.FIREFOX:
|
|
5450
|
+
return StorageType.FIREFOX;
|
|
5451
|
+
case StorageDriver.IDB:
|
|
5452
|
+
return StorageType.IDB;
|
|
5453
|
+
case StorageDriver.NODE:
|
|
5454
|
+
return StorageType.NODE;
|
|
5455
|
+
case StorageDriver.WEBFS:
|
|
5456
|
+
return StorageType.WEBFS;
|
|
5457
|
+
default:
|
|
5458
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5459
|
+
}
|
|
5460
|
+
};
|
|
5461
|
+
|
|
5462
|
+
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
5463
|
+
import { Level } from "level";
|
|
5464
|
+
import path from "@dxos/node-std/path";
|
|
5465
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
5466
|
+
var createLevel = async (config) => {
|
|
5467
|
+
const persistent = isPersistent(config);
|
|
5468
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey13.random().toHex()}`;
|
|
5469
|
+
const level = new Level(storagePath);
|
|
5470
|
+
await level.open();
|
|
5471
|
+
return level;
|
|
5472
|
+
};
|
|
5473
|
+
|
|
5144
5474
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
5145
5475
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
5146
5476
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5209,13 +5539,14 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5209
5539
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5210
5540
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5211
5541
|
}
|
|
5212
|
-
var
|
|
5542
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5213
5543
|
var ClientServicesHost = class {
|
|
5214
5544
|
constructor({
|
|
5215
5545
|
config,
|
|
5216
5546
|
transportFactory,
|
|
5217
5547
|
signalManager,
|
|
5218
5548
|
storage,
|
|
5549
|
+
level,
|
|
5219
5550
|
// TODO(wittjosiah): Turn this on by default.
|
|
5220
5551
|
lockKey,
|
|
5221
5552
|
callbacks,
|
|
@@ -5226,6 +5557,7 @@ var ClientServicesHost = class {
|
|
|
5226
5557
|
this._opening = false;
|
|
5227
5558
|
this._open = false;
|
|
5228
5559
|
this._storage = storage;
|
|
5560
|
+
this._level = level;
|
|
5229
5561
|
this._callbacks = callbacks;
|
|
5230
5562
|
this._runtimeParams = runtimeParams;
|
|
5231
5563
|
if (config) {
|
|
@@ -5264,6 +5596,7 @@ var ClientServicesHost = class {
|
|
|
5264
5596
|
await this.reset();
|
|
5265
5597
|
}
|
|
5266
5598
|
});
|
|
5599
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5267
5600
|
this._loggingService = new LoggingServiceImpl();
|
|
5268
5601
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
5269
5602
|
SystemService: this._systemService,
|
|
@@ -5295,24 +5628,24 @@ var ClientServicesHost = class {
|
|
|
5295
5628
|
*/
|
|
5296
5629
|
initialize({ config, ...options }) {
|
|
5297
5630
|
invariant16(!this._open, "service host is open", {
|
|
5298
|
-
F:
|
|
5299
|
-
L:
|
|
5631
|
+
F: __dxlog_file19,
|
|
5632
|
+
L: 190,
|
|
5300
5633
|
S: this,
|
|
5301
5634
|
A: [
|
|
5302
5635
|
"!this._open",
|
|
5303
5636
|
"'service host is open'"
|
|
5304
5637
|
]
|
|
5305
5638
|
});
|
|
5306
|
-
|
|
5307
|
-
F:
|
|
5308
|
-
L:
|
|
5639
|
+
log16("initializing...", void 0, {
|
|
5640
|
+
F: __dxlog_file19,
|
|
5641
|
+
L: 191,
|
|
5309
5642
|
S: this,
|
|
5310
5643
|
C: (f, a) => f(...a)
|
|
5311
5644
|
});
|
|
5312
5645
|
if (config) {
|
|
5313
5646
|
invariant16(!this._config, "config already set", {
|
|
5314
|
-
F:
|
|
5315
|
-
L:
|
|
5647
|
+
F: __dxlog_file19,
|
|
5648
|
+
L: 194,
|
|
5316
5649
|
S: this,
|
|
5317
5650
|
A: [
|
|
5318
5651
|
"!this._config",
|
|
@@ -5325,9 +5658,9 @@ var ClientServicesHost = class {
|
|
|
5325
5658
|
}
|
|
5326
5659
|
}
|
|
5327
5660
|
if (!options.signalManager) {
|
|
5328
|
-
|
|
5329
|
-
F:
|
|
5330
|
-
L:
|
|
5661
|
+
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5662
|
+
F: __dxlog_file19,
|
|
5663
|
+
L: 202,
|
|
5331
5664
|
S: this,
|
|
5332
5665
|
C: (f, a) => f(...a)
|
|
5333
5666
|
});
|
|
@@ -5337,8 +5670,8 @@ var ClientServicesHost = class {
|
|
|
5337
5670
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5338
5671
|
this._signalManager = signalManager;
|
|
5339
5672
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5340
|
-
F:
|
|
5341
|
-
L:
|
|
5673
|
+
F: __dxlog_file19,
|
|
5674
|
+
L: 213,
|
|
5342
5675
|
S: this,
|
|
5343
5676
|
A: [
|
|
5344
5677
|
"!this._networkManager",
|
|
@@ -5350,9 +5683,9 @@ var ClientServicesHost = class {
|
|
|
5350
5683
|
transportFactory,
|
|
5351
5684
|
signalManager
|
|
5352
5685
|
});
|
|
5353
|
-
|
|
5354
|
-
F:
|
|
5355
|
-
L:
|
|
5686
|
+
log16("initialized", void 0, {
|
|
5687
|
+
F: __dxlog_file19,
|
|
5688
|
+
L: 220,
|
|
5356
5689
|
S: this,
|
|
5357
5690
|
C: (f, a) => f(...a)
|
|
5358
5691
|
});
|
|
@@ -5361,18 +5694,18 @@ var ClientServicesHost = class {
|
|
|
5361
5694
|
if (this._open) {
|
|
5362
5695
|
return;
|
|
5363
5696
|
}
|
|
5364
|
-
const traceId =
|
|
5365
|
-
|
|
5697
|
+
const traceId = PublicKey14.random().toHex();
|
|
5698
|
+
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5366
5699
|
id: traceId
|
|
5367
5700
|
}), {
|
|
5368
|
-
F:
|
|
5369
|
-
L:
|
|
5701
|
+
F: __dxlog_file19,
|
|
5702
|
+
L: 231,
|
|
5370
5703
|
S: this,
|
|
5371
5704
|
C: (f, a) => f(...a)
|
|
5372
5705
|
});
|
|
5373
5706
|
invariant16(this._config, "config not set", {
|
|
5374
|
-
F:
|
|
5375
|
-
L:
|
|
5707
|
+
F: __dxlog_file19,
|
|
5708
|
+
L: 233,
|
|
5376
5709
|
S: this,
|
|
5377
5710
|
A: [
|
|
5378
5711
|
"this._config",
|
|
@@ -5380,8 +5713,8 @@ var ClientServicesHost = class {
|
|
|
5380
5713
|
]
|
|
5381
5714
|
});
|
|
5382
5715
|
invariant16(this._storage, "storage not set", {
|
|
5383
|
-
F:
|
|
5384
|
-
L:
|
|
5716
|
+
F: __dxlog_file19,
|
|
5717
|
+
L: 234,
|
|
5385
5718
|
S: this,
|
|
5386
5719
|
A: [
|
|
5387
5720
|
"this._storage",
|
|
@@ -5389,8 +5722,8 @@ var ClientServicesHost = class {
|
|
|
5389
5722
|
]
|
|
5390
5723
|
});
|
|
5391
5724
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5392
|
-
F:
|
|
5393
|
-
L:
|
|
5725
|
+
F: __dxlog_file19,
|
|
5726
|
+
L: 235,
|
|
5394
5727
|
S: this,
|
|
5395
5728
|
A: [
|
|
5396
5729
|
"this._signalManager",
|
|
@@ -5398,8 +5731,8 @@ var ClientServicesHost = class {
|
|
|
5398
5731
|
]
|
|
5399
5732
|
});
|
|
5400
5733
|
invariant16(this._networkManager, "network manager not set", {
|
|
5401
|
-
F:
|
|
5402
|
-
L:
|
|
5734
|
+
F: __dxlog_file19,
|
|
5735
|
+
L: 236,
|
|
5403
5736
|
S: this,
|
|
5404
5737
|
A: [
|
|
5405
5738
|
"this._networkManager",
|
|
@@ -5407,31 +5740,32 @@ var ClientServicesHost = class {
|
|
|
5407
5740
|
]
|
|
5408
5741
|
});
|
|
5409
5742
|
this._opening = true;
|
|
5410
|
-
|
|
5743
|
+
log16("opening...", {
|
|
5411
5744
|
lockKey: this._resourceLock?.lockKey
|
|
5412
5745
|
}, {
|
|
5413
|
-
F:
|
|
5414
|
-
L:
|
|
5746
|
+
F: __dxlog_file19,
|
|
5747
|
+
L: 239,
|
|
5415
5748
|
S: this,
|
|
5416
5749
|
C: (f, a) => f(...a)
|
|
5417
5750
|
});
|
|
5751
|
+
if (!this._level) {
|
|
5752
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5753
|
+
}
|
|
5754
|
+
await this._level.open();
|
|
5418
5755
|
await this._resourceLock?.acquire();
|
|
5419
5756
|
await this._loggingService.open();
|
|
5420
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5757
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5421
5758
|
this._serviceRegistry.setServices({
|
|
5422
5759
|
SystemService: this._systemService,
|
|
5423
5760
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5424
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5761
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5425
5762
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5426
5763
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5427
5764
|
await this._serviceContext.initialized.wait();
|
|
5428
5765
|
return this._serviceContext.dataSpaceManager;
|
|
5429
5766
|
}),
|
|
5430
|
-
DataService:
|
|
5431
|
-
|
|
5432
|
-
indexer: this._serviceContext.indexer,
|
|
5433
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5434
|
-
}),
|
|
5767
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5768
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5435
5769
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5436
5770
|
LoggingService: this._loggingService,
|
|
5437
5771
|
TracingService: this._tracingService,
|
|
@@ -5443,24 +5777,6 @@ var ClientServicesHost = class {
|
|
|
5443
5777
|
})
|
|
5444
5778
|
});
|
|
5445
5779
|
await this._serviceContext.open(ctx);
|
|
5446
|
-
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5447
|
-
F: __dxlog_file18,
|
|
5448
|
-
L: 289,
|
|
5449
|
-
S: this,
|
|
5450
|
-
A: [
|
|
5451
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5452
|
-
""
|
|
5453
|
-
]
|
|
5454
|
-
});
|
|
5455
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5456
|
-
log15("loaded persistent invitations", {
|
|
5457
|
-
count: loadedInvitations.invitations?.length
|
|
5458
|
-
}, {
|
|
5459
|
-
F: __dxlog_file18,
|
|
5460
|
-
L: 292,
|
|
5461
|
-
S: this,
|
|
5462
|
-
C: (f, a) => f(...a)
|
|
5463
|
-
});
|
|
5464
5780
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5465
5781
|
if (devtoolsProxy) {
|
|
5466
5782
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5471,23 +5787,24 @@ var ClientServicesHost = class {
|
|
|
5471
5787
|
});
|
|
5472
5788
|
void this._devtoolsProxy.open();
|
|
5473
5789
|
}
|
|
5790
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5474
5791
|
this._opening = false;
|
|
5475
5792
|
this._open = true;
|
|
5476
5793
|
this._statusUpdate.emit();
|
|
5477
5794
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5478
|
-
|
|
5795
|
+
log16("opened", {
|
|
5479
5796
|
deviceKey
|
|
5480
5797
|
}, {
|
|
5481
|
-
F:
|
|
5482
|
-
L:
|
|
5798
|
+
F: __dxlog_file19,
|
|
5799
|
+
L: 315,
|
|
5483
5800
|
S: this,
|
|
5484
5801
|
C: (f, a) => f(...a)
|
|
5485
5802
|
});
|
|
5486
|
-
|
|
5803
|
+
log16.trace("dxos.client-services.host.open", trace9.end({
|
|
5487
5804
|
id: traceId
|
|
5488
5805
|
}), {
|
|
5489
|
-
F:
|
|
5490
|
-
L:
|
|
5806
|
+
F: __dxlog_file19,
|
|
5807
|
+
L: 316,
|
|
5491
5808
|
S: this,
|
|
5492
5809
|
C: (f, a) => f(...a)
|
|
5493
5810
|
});
|
|
@@ -5497,60 +5814,62 @@ var ClientServicesHost = class {
|
|
|
5497
5814
|
return;
|
|
5498
5815
|
}
|
|
5499
5816
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5500
|
-
|
|
5817
|
+
log16("closing...", {
|
|
5501
5818
|
deviceKey
|
|
5502
5819
|
}, {
|
|
5503
|
-
F:
|
|
5504
|
-
L:
|
|
5820
|
+
F: __dxlog_file19,
|
|
5821
|
+
L: 327,
|
|
5505
5822
|
S: this,
|
|
5506
5823
|
C: (f, a) => f(...a)
|
|
5507
5824
|
});
|
|
5825
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5508
5826
|
await this._devtoolsProxy?.close();
|
|
5509
5827
|
this._serviceRegistry.setServices({
|
|
5510
5828
|
SystemService: this._systemService
|
|
5511
5829
|
});
|
|
5512
5830
|
await this._loggingService.close();
|
|
5513
5831
|
await this._serviceContext.close();
|
|
5832
|
+
await this._level?.close();
|
|
5514
5833
|
this._open = false;
|
|
5515
5834
|
this._statusUpdate.emit();
|
|
5516
|
-
|
|
5835
|
+
log16("closed", {
|
|
5517
5836
|
deviceKey
|
|
5518
5837
|
}, {
|
|
5519
|
-
F:
|
|
5520
|
-
L:
|
|
5838
|
+
F: __dxlog_file19,
|
|
5839
|
+
L: 336,
|
|
5521
5840
|
S: this,
|
|
5522
5841
|
C: (f, a) => f(...a)
|
|
5523
5842
|
});
|
|
5524
5843
|
}
|
|
5525
5844
|
async reset() {
|
|
5526
|
-
const traceId =
|
|
5527
|
-
|
|
5845
|
+
const traceId = PublicKey14.random().toHex();
|
|
5846
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5528
5847
|
id: traceId
|
|
5529
5848
|
}), {
|
|
5530
|
-
F:
|
|
5531
|
-
L:
|
|
5849
|
+
F: __dxlog_file19,
|
|
5850
|
+
L: 341,
|
|
5532
5851
|
S: this,
|
|
5533
5852
|
C: (f, a) => f(...a)
|
|
5534
5853
|
});
|
|
5535
|
-
|
|
5536
|
-
F:
|
|
5537
|
-
L:
|
|
5854
|
+
log16("resetting...", void 0, {
|
|
5855
|
+
F: __dxlog_file19,
|
|
5856
|
+
L: 343,
|
|
5538
5857
|
S: this,
|
|
5539
5858
|
C: (f, a) => f(...a)
|
|
5540
5859
|
});
|
|
5541
5860
|
await this._serviceContext?.close();
|
|
5542
5861
|
await this._storage.reset();
|
|
5543
|
-
|
|
5544
|
-
F:
|
|
5545
|
-
L:
|
|
5862
|
+
log16("reset", void 0, {
|
|
5863
|
+
F: __dxlog_file19,
|
|
5864
|
+
L: 346,
|
|
5546
5865
|
S: this,
|
|
5547
5866
|
C: (f, a) => f(...a)
|
|
5548
5867
|
});
|
|
5549
|
-
|
|
5868
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5550
5869
|
id: traceId
|
|
5551
5870
|
}), {
|
|
5552
|
-
F:
|
|
5553
|
-
L:
|
|
5871
|
+
F: __dxlog_file19,
|
|
5872
|
+
L: 347,
|
|
5554
5873
|
S: this,
|
|
5555
5874
|
C: (f, a) => f(...a)
|
|
5556
5875
|
});
|
|
@@ -5560,26 +5879,37 @@ var ClientServicesHost = class {
|
|
|
5560
5879
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5561
5880
|
await this._serviceContext.initialized.wait();
|
|
5562
5881
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5563
|
-
const obj = new Properties(void 0);
|
|
5564
|
-
obj[defaultKey] = identity.identityKey.toHex();
|
|
5565
5882
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5566
5883
|
invariant16(automergeIndex, void 0, {
|
|
5567
|
-
F:
|
|
5568
|
-
L:
|
|
5884
|
+
F: __dxlog_file19,
|
|
5885
|
+
L: 359,
|
|
5569
5886
|
S: this,
|
|
5570
5887
|
A: [
|
|
5571
5888
|
"automergeIndex",
|
|
5572
5889
|
""
|
|
5573
5890
|
]
|
|
5574
5891
|
});
|
|
5575
|
-
const document = await this._serviceContext.
|
|
5892
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5576
5893
|
await document.whenReady();
|
|
5894
|
+
const properties = {
|
|
5895
|
+
system: {
|
|
5896
|
+
type: encodeReference(getTypeReference(Properties))
|
|
5897
|
+
},
|
|
5898
|
+
data: {
|
|
5899
|
+
[defaultKey]: identity.identityKey.toHex()
|
|
5900
|
+
},
|
|
5901
|
+
meta: {
|
|
5902
|
+
keys: []
|
|
5903
|
+
}
|
|
5904
|
+
};
|
|
5905
|
+
const propertiesId = PublicKey14.random().toHex();
|
|
5577
5906
|
document.change((doc) => {
|
|
5578
|
-
|
|
5907
|
+
assignDeep2(doc, [
|
|
5579
5908
|
"objects",
|
|
5580
|
-
|
|
5581
|
-
],
|
|
5909
|
+
propertiesId
|
|
5910
|
+
], properties);
|
|
5582
5911
|
});
|
|
5912
|
+
await this._serviceContext.echoHost.flush();
|
|
5583
5913
|
return identity;
|
|
5584
5914
|
}
|
|
5585
5915
|
};
|
|
@@ -5601,6 +5931,44 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5601
5931
|
Trace3.resource()
|
|
5602
5932
|
], ClientServicesHost);
|
|
5603
5933
|
|
|
5934
|
+
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
5935
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5936
|
+
import { humanize } from "@dxos/util";
|
|
5937
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5938
|
+
|
|
5939
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
5940
|
+
var DiagnosticsCollector = class {
|
|
5941
|
+
static {
|
|
5942
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5943
|
+
}
|
|
5944
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5945
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5946
|
+
keys: options.humanize ? GetDiagnosticsRequest2.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest2.KEY_OPTION.TRUNCATE : void 0
|
|
5947
|
+
});
|
|
5948
|
+
const clientDiagnostics = {
|
|
5949
|
+
config,
|
|
5950
|
+
trace: TRACE_PROCESSOR3.getDiagnostics()
|
|
5951
|
+
};
|
|
5952
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5953
|
+
client: clientDiagnostics,
|
|
5954
|
+
services: serviceDiagnostics
|
|
5955
|
+
} : {
|
|
5956
|
+
client: clientDiagnostics,
|
|
5957
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5958
|
+
};
|
|
5959
|
+
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer2(options)));
|
|
5960
|
+
}
|
|
5961
|
+
};
|
|
5962
|
+
var findSystemServiceProvider = () => {
|
|
5963
|
+
const serviceProviders = TRACE_PROCESSOR3.findByAnnotation(ClientServicesProviderResource);
|
|
5964
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5965
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5966
|
+
};
|
|
5967
|
+
var findConfigs = () => {
|
|
5968
|
+
const configs = TRACE_PROCESSOR3.findByAnnotation(ConfigResource);
|
|
5969
|
+
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
5970
|
+
};
|
|
5971
|
+
|
|
5604
5972
|
export {
|
|
5605
5973
|
Buffer,
|
|
5606
5974
|
subscribeToFeeds,
|
|
@@ -5620,19 +5988,25 @@ export {
|
|
|
5620
5988
|
IdentityServiceImpl,
|
|
5621
5989
|
DeviceInvitationProtocol,
|
|
5622
5990
|
InvitationsHandler,
|
|
5623
|
-
|
|
5991
|
+
createAdmissionKeypair,
|
|
5624
5992
|
InvitationsServiceImpl,
|
|
5625
5993
|
SpaceInvitationProtocol,
|
|
5994
|
+
InvitationsManager,
|
|
5626
5995
|
ClientRpcServer,
|
|
5627
|
-
createDiagnostics,
|
|
5628
5996
|
DataSpace,
|
|
5629
5997
|
DataSpaceManager,
|
|
5630
5998
|
SpacesServiceImpl,
|
|
5631
5999
|
ServiceContext,
|
|
5632
6000
|
ServiceRegistry,
|
|
6001
|
+
createDiagnostics,
|
|
6002
|
+
createCollectDiagnosticsBroadcastSender,
|
|
6003
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
6004
|
+
DiagnosticsCollector,
|
|
5633
6005
|
Lock,
|
|
5634
6006
|
isLocked,
|
|
5635
6007
|
createStorageObjects,
|
|
5636
|
-
|
|
6008
|
+
createLevel,
|
|
6009
|
+
ClientServicesHost,
|
|
6010
|
+
ClientServicesProviderResource
|
|
5637
6011
|
};
|
|
5638
|
-
//# sourceMappingURL=chunk-
|
|
6012
|
+
//# sourceMappingURL=chunk-6CUDF3NG.mjs.map
|