@dxos/client-services 0.4.10-main.3e35a2f → 0.4.10-main.3f5e2d2
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-S3G2RM7S.mjs → chunk-HIQTBJPW.mjs} +837 -715
- package/dist/lib/browser/chunk-HIQTBJPW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +10 -4
- 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 +132 -116
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-3T6D6GIB.cjs → chunk-JGUWA36I.cjs} +859 -733
- package/dist/lib/node/chunk-JGUWA36I.cjs.map +7 -0
- package/dist/lib/node/index.cjs +50 -44
- 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 +131 -118
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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 -3
- 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/service-context.d.ts +6 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +2 -2
- package/dist/types/src/packlets/services/service-host.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/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +9 -6
- 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 +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- 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 +77 -91
- 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/services/automerge-host.test.ts +4 -4
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +23 -25
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +9 -29
- 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 +14 -19
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +29 -16
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-S3G2RM7S.mjs.map +0 -7
- package/dist/lib/node/chunk-3T6D6GIB.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/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,50 +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, multiUse = false } = 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: 85,
|
|
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: persistent && type !== Invitation3.Type.OFFLINE,
|
|
1662
|
-
created,
|
|
1663
|
-
lifetime,
|
|
1664
|
-
multiUse,
|
|
1665
|
-
...protocol.getInvitationContext()
|
|
1666
|
-
};
|
|
1667
|
-
const stream = new PushStream();
|
|
1668
|
-
const ctx = new Context5({
|
|
1669
|
-
onError: (err) => {
|
|
1670
|
-
stream.error(err);
|
|
1671
|
-
void ctx.dispose();
|
|
1672
|
-
}
|
|
1673
|
-
});
|
|
1674
|
-
ctx.onDispose(() => {
|
|
1675
|
-
log5("complete", {
|
|
1676
|
-
...protocol.toJSON()
|
|
1677
|
-
}, {
|
|
1678
|
-
F: __dxlog_file7,
|
|
1679
|
-
L: 111,
|
|
1680
|
-
S: this,
|
|
1681
|
-
C: (f, a) => f(...a)
|
|
1682
|
-
});
|
|
1683
|
-
stream.complete();
|
|
1684
|
-
});
|
|
1663
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1685
1664
|
const createExtension = () => {
|
|
1686
1665
|
const extension = new InvitationHostExtension({
|
|
1687
1666
|
onStateUpdate: (invitation2) => {
|
|
@@ -1690,8 +1669,8 @@ var InvitationsHandler = class {
|
|
|
1690
1669
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
1691
1670
|
});
|
|
1692
1671
|
},
|
|
1693
|
-
resolveInvitation: async ({ invitationId
|
|
1694
|
-
if (
|
|
1672
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1673
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1695
1674
|
return void 0;
|
|
1696
1675
|
}
|
|
1697
1676
|
return invitation;
|
|
@@ -1701,14 +1680,14 @@ var InvitationsHandler = class {
|
|
|
1701
1680
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1702
1681
|
invariant6(deviceKey, void 0, {
|
|
1703
1682
|
F: __dxlog_file7,
|
|
1704
|
-
L:
|
|
1683
|
+
L: 87,
|
|
1705
1684
|
S: this,
|
|
1706
1685
|
A: [
|
|
1707
1686
|
"deviceKey",
|
|
1708
1687
|
""
|
|
1709
1688
|
]
|
|
1710
1689
|
});
|
|
1711
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1690
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1712
1691
|
extension.completedTrigger.wake(deviceKey);
|
|
1713
1692
|
return admissionResponse;
|
|
1714
1693
|
} catch (err) {
|
|
@@ -1724,7 +1703,7 @@ var InvitationsHandler = class {
|
|
|
1724
1703
|
id: traceId
|
|
1725
1704
|
}), {
|
|
1726
1705
|
F: __dxlog_file7,
|
|
1727
|
-
L:
|
|
1706
|
+
L: 105,
|
|
1728
1707
|
S: this,
|
|
1729
1708
|
C: (f, a) => f(...a)
|
|
1730
1709
|
});
|
|
@@ -1732,7 +1711,7 @@ var InvitationsHandler = class {
|
|
|
1732
1711
|
...protocol.toJSON()
|
|
1733
1712
|
}, {
|
|
1734
1713
|
F: __dxlog_file7,
|
|
1735
|
-
L:
|
|
1714
|
+
L: 106,
|
|
1736
1715
|
S: this,
|
|
1737
1716
|
C: (f, a) => f(...a)
|
|
1738
1717
|
});
|
|
@@ -1741,14 +1720,14 @@ var InvitationsHandler = class {
|
|
|
1741
1720
|
state: Invitation3.State.CONNECTED
|
|
1742
1721
|
});
|
|
1743
1722
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1744
|
-
timeout
|
|
1723
|
+
timeout: invitation.timeout
|
|
1745
1724
|
});
|
|
1746
1725
|
log5("admitted guest", {
|
|
1747
1726
|
guest: deviceKey,
|
|
1748
1727
|
...protocol.toJSON()
|
|
1749
1728
|
}, {
|
|
1750
1729
|
F: __dxlog_file7,
|
|
1751
|
-
L:
|
|
1730
|
+
L: 109,
|
|
1752
1731
|
S: this,
|
|
1753
1732
|
C: (f, a) => f(...a)
|
|
1754
1733
|
});
|
|
@@ -1760,7 +1739,7 @@ var InvitationsHandler = class {
|
|
|
1760
1739
|
id: traceId
|
|
1761
1740
|
}), {
|
|
1762
1741
|
F: __dxlog_file7,
|
|
1763
|
-
L:
|
|
1742
|
+
L: 111,
|
|
1764
1743
|
S: this,
|
|
1765
1744
|
C: (f, a) => f(...a)
|
|
1766
1745
|
});
|
|
@@ -1770,7 +1749,7 @@ var InvitationsHandler = class {
|
|
|
1770
1749
|
...protocol.toJSON()
|
|
1771
1750
|
}, {
|
|
1772
1751
|
F: __dxlog_file7,
|
|
1773
|
-
L:
|
|
1752
|
+
L: 114,
|
|
1774
1753
|
S: this,
|
|
1775
1754
|
C: (f, a) => f(...a)
|
|
1776
1755
|
});
|
|
@@ -1781,7 +1760,7 @@ var InvitationsHandler = class {
|
|
|
1781
1760
|
} else {
|
|
1782
1761
|
log5.error("failed", err, {
|
|
1783
1762
|
F: __dxlog_file7,
|
|
1784
|
-
L:
|
|
1763
|
+
L: 117,
|
|
1785
1764
|
S: this,
|
|
1786
1765
|
C: (f, a) => f(...a)
|
|
1787
1766
|
});
|
|
@@ -1792,12 +1771,12 @@ var InvitationsHandler = class {
|
|
|
1792
1771
|
error: err
|
|
1793
1772
|
}), {
|
|
1794
1773
|
F: __dxlog_file7,
|
|
1795
|
-
L:
|
|
1774
|
+
L: 120,
|
|
1796
1775
|
S: this,
|
|
1797
1776
|
C: (f, a) => f(...a)
|
|
1798
1777
|
});
|
|
1799
1778
|
} finally {
|
|
1800
|
-
if (!multiUse) {
|
|
1779
|
+
if (!invitation.multiUse) {
|
|
1801
1780
|
await swarmConnection.close();
|
|
1802
1781
|
await ctx.dispose();
|
|
1803
1782
|
}
|
|
@@ -1813,7 +1792,7 @@ var InvitationsHandler = class {
|
|
|
1813
1792
|
...protocol.toJSON()
|
|
1814
1793
|
}, {
|
|
1815
1794
|
F: __dxlog_file7,
|
|
1816
|
-
L:
|
|
1795
|
+
L: 135,
|
|
1817
1796
|
S: this,
|
|
1818
1797
|
C: (f, a) => f(...a)
|
|
1819
1798
|
});
|
|
@@ -1824,7 +1803,7 @@ var InvitationsHandler = class {
|
|
|
1824
1803
|
} else {
|
|
1825
1804
|
log5.error("failed", err, {
|
|
1826
1805
|
F: __dxlog_file7,
|
|
1827
|
-
L:
|
|
1806
|
+
L: 138,
|
|
1828
1807
|
S: this,
|
|
1829
1808
|
C: (f, a) => f(...a)
|
|
1830
1809
|
});
|
|
@@ -1834,11 +1813,11 @@ var InvitationsHandler = class {
|
|
|
1834
1813
|
});
|
|
1835
1814
|
return extension;
|
|
1836
1815
|
};
|
|
1837
|
-
if (invitation.lifetime && invitation.created
|
|
1816
|
+
if (invitation.lifetime && invitation.created) {
|
|
1838
1817
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1839
1818
|
log5.warn("invitation has already expired", void 0, {
|
|
1840
1819
|
F: __dxlog_file7,
|
|
1841
|
-
L:
|
|
1820
|
+
L: 149,
|
|
1842
1821
|
S: this,
|
|
1843
1822
|
C: (f, a) => f(...a)
|
|
1844
1823
|
});
|
|
@@ -1872,24 +1851,12 @@ var InvitationsHandler = class {
|
|
|
1872
1851
|
state: Invitation3.State.CONNECTING
|
|
1873
1852
|
});
|
|
1874
1853
|
});
|
|
1875
|
-
const observable = new CancellableInvitation({
|
|
1876
|
-
initialInvitation: invitation,
|
|
1877
|
-
subscriber: stream.observable,
|
|
1878
|
-
onCancel: async () => {
|
|
1879
|
-
stream.next({
|
|
1880
|
-
...invitation,
|
|
1881
|
-
state: Invitation3.State.CANCELLED
|
|
1882
|
-
});
|
|
1883
|
-
await ctx.dispose();
|
|
1884
|
-
}
|
|
1885
|
-
});
|
|
1886
|
-
return observable;
|
|
1887
1854
|
}
|
|
1888
1855
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
1889
1856
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1890
1857
|
invariant6(protocol, void 0, {
|
|
1891
1858
|
F: __dxlog_file7,
|
|
1892
|
-
L:
|
|
1859
|
+
L: 191,
|
|
1893
1860
|
S: this,
|
|
1894
1861
|
A: [
|
|
1895
1862
|
"protocol",
|
|
@@ -1899,7 +1866,7 @@ var InvitationsHandler = class {
|
|
|
1899
1866
|
if (deviceProfile) {
|
|
1900
1867
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1901
1868
|
F: __dxlog_file7,
|
|
1902
|
-
L:
|
|
1869
|
+
L: 194,
|
|
1903
1870
|
S: this,
|
|
1904
1871
|
A: [
|
|
1905
1872
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1914,7 +1881,7 @@ var InvitationsHandler = class {
|
|
|
1914
1881
|
const setState = (newData) => {
|
|
1915
1882
|
invariant6(newData.state !== void 0, void 0, {
|
|
1916
1883
|
F: __dxlog_file7,
|
|
1917
|
-
L:
|
|
1884
|
+
L: 205,
|
|
1918
1885
|
S: this,
|
|
1919
1886
|
A: [
|
|
1920
1887
|
"newData.state !== undefined",
|
|
@@ -1934,7 +1901,7 @@ var InvitationsHandler = class {
|
|
|
1934
1901
|
...protocol.toJSON()
|
|
1935
1902
|
}, {
|
|
1936
1903
|
F: __dxlog_file7,
|
|
1937
|
-
L:
|
|
1904
|
+
L: 213,
|
|
1938
1905
|
S: this,
|
|
1939
1906
|
C: (f, a) => f(...a)
|
|
1940
1907
|
});
|
|
@@ -1944,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1944
1911
|
} else {
|
|
1945
1912
|
log5.warn("auth failed", err, {
|
|
1946
1913
|
F: __dxlog_file7,
|
|
1947
|
-
L:
|
|
1914
|
+
L: 216,
|
|
1948
1915
|
S: this,
|
|
1949
1916
|
C: (f, a) => f(...a)
|
|
1950
1917
|
});
|
|
@@ -1958,7 +1925,7 @@ var InvitationsHandler = class {
|
|
|
1958
1925
|
...protocol.toJSON()
|
|
1959
1926
|
}, {
|
|
1960
1927
|
F: __dxlog_file7,
|
|
1961
|
-
L:
|
|
1928
|
+
L: 224,
|
|
1962
1929
|
S: this,
|
|
1963
1930
|
C: (f, a) => f(...a)
|
|
1964
1931
|
});
|
|
@@ -1973,7 +1940,7 @@ var InvitationsHandler = class {
|
|
|
1973
1940
|
currentState
|
|
1974
1941
|
}, {
|
|
1975
1942
|
F: __dxlog_file7,
|
|
1976
|
-
L:
|
|
1943
|
+
L: 234,
|
|
1977
1944
|
S: this,
|
|
1978
1945
|
C: (f, a) => f(...a)
|
|
1979
1946
|
});
|
|
@@ -1988,7 +1955,7 @@ var InvitationsHandler = class {
|
|
|
1988
1955
|
id: traceId
|
|
1989
1956
|
}), {
|
|
1990
1957
|
F: __dxlog_file7,
|
|
1991
|
-
L:
|
|
1958
|
+
L: 243,
|
|
1992
1959
|
S: this,
|
|
1993
1960
|
C: (f, a) => f(...a)
|
|
1994
1961
|
});
|
|
@@ -2000,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
2000
1967
|
...protocol.toJSON()
|
|
2001
1968
|
}, {
|
|
2002
1969
|
F: __dxlog_file7,
|
|
2003
|
-
L:
|
|
1970
|
+
L: 251,
|
|
2004
1971
|
S: this,
|
|
2005
1972
|
C: (f, a) => f(...a)
|
|
2006
1973
|
});
|
|
@@ -2011,7 +1978,7 @@ var InvitationsHandler = class {
|
|
|
2011
1978
|
...protocol.toJSON()
|
|
2012
1979
|
}, {
|
|
2013
1980
|
F: __dxlog_file7,
|
|
2014
|
-
L:
|
|
1981
|
+
L: 255,
|
|
2015
1982
|
S: this,
|
|
2016
1983
|
C: (f, a) => f(...a)
|
|
2017
1984
|
});
|
|
@@ -2021,62 +1988,28 @@ var InvitationsHandler = class {
|
|
|
2021
1988
|
response: introductionResponse
|
|
2022
1989
|
}, {
|
|
2023
1990
|
F: __dxlog_file7,
|
|
2024
|
-
L:
|
|
1991
|
+
L: 259,
|
|
2025
1992
|
S: this,
|
|
2026
1993
|
C: (f, a) => f(...a)
|
|
2027
1994
|
});
|
|
2028
1995
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2029
1996
|
if (isAuthenticationRequired(invitation)) {
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
2039
|
-
});
|
|
2040
|
-
const authCode = await authenticated.wait({
|
|
2041
|
-
timeout
|
|
2042
|
-
});
|
|
2043
|
-
log5("sending authentication request", void 0, {
|
|
2044
|
-
F: __dxlog_file7,
|
|
2045
|
-
L: 327,
|
|
2046
|
-
S: this,
|
|
2047
|
-
C: (f, a) => f(...a)
|
|
2048
|
-
});
|
|
2049
|
-
setState({
|
|
2050
|
-
state: Invitation3.State.AUTHENTICATING
|
|
2051
|
-
});
|
|
2052
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2053
|
-
authCode
|
|
2054
|
-
});
|
|
2055
|
-
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);
|
|
2056
2005
|
break;
|
|
2057
|
-
}
|
|
2058
|
-
if (response.status === AuthenticationResponse2.Status.INVALID_OTP) {
|
|
2059
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2060
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2061
|
-
} else {
|
|
2062
|
-
log5("retrying invalid code", {
|
|
2063
|
-
attempt
|
|
2064
|
-
}, {
|
|
2065
|
-
F: __dxlog_file7,
|
|
2066
|
-
L: 338,
|
|
2067
|
-
S: this,
|
|
2068
|
-
C: (f, a) => f(...a)
|
|
2069
|
-
});
|
|
2070
|
-
authenticated.reset();
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
2006
|
}
|
|
2074
2007
|
}
|
|
2075
2008
|
log5("request admission", {
|
|
2076
2009
|
...protocol.toJSON()
|
|
2077
2010
|
}, {
|
|
2078
2011
|
F: __dxlog_file7,
|
|
2079
|
-
L:
|
|
2012
|
+
L: 275,
|
|
2080
2013
|
S: this,
|
|
2081
2014
|
C: (f, a) => f(...a)
|
|
2082
2015
|
});
|
|
@@ -2088,7 +2021,7 @@ var InvitationsHandler = class {
|
|
|
2088
2021
|
...protocol.toJSON()
|
|
2089
2022
|
}, {
|
|
2090
2023
|
F: __dxlog_file7,
|
|
2091
|
-
L:
|
|
2024
|
+
L: 286,
|
|
2092
2025
|
S: this,
|
|
2093
2026
|
C: (f, a) => f(...a)
|
|
2094
2027
|
});
|
|
@@ -2101,7 +2034,7 @@ var InvitationsHandler = class {
|
|
|
2101
2034
|
id: traceId
|
|
2102
2035
|
}), {
|
|
2103
2036
|
F: __dxlog_file7,
|
|
2104
|
-
L:
|
|
2037
|
+
L: 288,
|
|
2105
2038
|
S: this,
|
|
2106
2039
|
C: (f, a) => f(...a)
|
|
2107
2040
|
});
|
|
@@ -2111,7 +2044,7 @@ var InvitationsHandler = class {
|
|
|
2111
2044
|
...protocol.toJSON()
|
|
2112
2045
|
}, {
|
|
2113
2046
|
F: __dxlog_file7,
|
|
2114
|
-
L:
|
|
2047
|
+
L: 291,
|
|
2115
2048
|
S: this,
|
|
2116
2049
|
C: (f, a) => f(...a)
|
|
2117
2050
|
});
|
|
@@ -2121,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2121
2054
|
} else {
|
|
2122
2055
|
log5("auth failed", err, {
|
|
2123
2056
|
F: __dxlog_file7,
|
|
2124
|
-
L:
|
|
2057
|
+
L: 294,
|
|
2125
2058
|
S: this,
|
|
2126
2059
|
C: (f, a) => f(...a)
|
|
2127
2060
|
});
|
|
@@ -2132,7 +2065,7 @@ var InvitationsHandler = class {
|
|
|
2132
2065
|
error: err
|
|
2133
2066
|
}), {
|
|
2134
2067
|
F: __dxlog_file7,
|
|
2135
|
-
L:
|
|
2068
|
+
L: 297,
|
|
2136
2069
|
S: this,
|
|
2137
2070
|
C: (f, a) => f(...a)
|
|
2138
2071
|
});
|
|
@@ -2150,7 +2083,7 @@ var InvitationsHandler = class {
|
|
|
2150
2083
|
...protocol.toJSON()
|
|
2151
2084
|
}, {
|
|
2152
2085
|
F: __dxlog_file7,
|
|
2153
|
-
L:
|
|
2086
|
+
L: 308,
|
|
2154
2087
|
S: this,
|
|
2155
2088
|
C: (f, a) => f(...a)
|
|
2156
2089
|
});
|
|
@@ -2160,7 +2093,7 @@ var InvitationsHandler = class {
|
|
|
2160
2093
|
} else {
|
|
2161
2094
|
log5("auth failed", err, {
|
|
2162
2095
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2096
|
+
L: 311,
|
|
2164
2097
|
S: this,
|
|
2165
2098
|
C: (f, a) => f(...a)
|
|
2166
2099
|
});
|
|
@@ -2177,7 +2110,7 @@ var InvitationsHandler = class {
|
|
|
2177
2110
|
} else {
|
|
2178
2111
|
invariant6(invitation.swarmKey, void 0, {
|
|
2179
2112
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2113
|
+
L: 325,
|
|
2181
2114
|
S: this,
|
|
2182
2115
|
A: [
|
|
2183
2116
|
"invitation.swarmKey",
|
|
@@ -2215,204 +2148,114 @@ var InvitationsHandler = class {
|
|
|
2215
2148
|
});
|
|
2216
2149
|
return observable;
|
|
2217
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
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
var createAdmissionKeypair = () => {
|
|
2221
|
+
const keypair = createKeyPair();
|
|
2222
|
+
return {
|
|
2223
|
+
publicKey: PublicKey6.from(keypair.publicKey),
|
|
2224
|
+
privateKey: keypair.secretKey
|
|
2225
|
+
};
|
|
2218
2226
|
};
|
|
2219
2227
|
|
|
2220
2228
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2221
|
-
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2222
2229
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2223
|
-
import {
|
|
2224
|
-
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2225
|
-
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2226
|
-
import { log as log6 } from "@dxos/log";
|
|
2227
|
-
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2228
|
-
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";
|
|
2229
2231
|
var InvitationsServiceImpl = class {
|
|
2230
|
-
constructor(
|
|
2231
|
-
this.
|
|
2232
|
-
this._getHandler = _getHandler;
|
|
2233
|
-
this._metadataStore = _metadataStore;
|
|
2234
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2235
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2236
|
-
this._invitationCreated = new Event3();
|
|
2237
|
-
this._invitationAccepted = new Event3();
|
|
2238
|
-
this._removedCreated = new Event3();
|
|
2239
|
-
this._removedAccepted = new Event3();
|
|
2240
|
-
this._saved = new Event3();
|
|
2241
|
-
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2242
|
-
this._persistentInvitationsLoaded = false;
|
|
2232
|
+
constructor(_invitationsManager) {
|
|
2233
|
+
this._invitationsManager = _invitationsManager;
|
|
2243
2234
|
}
|
|
2244
2235
|
// TODO(burdon): Guest/host label.
|
|
2245
2236
|
getLoggingContext() {
|
|
2246
2237
|
return {};
|
|
2247
2238
|
}
|
|
2248
2239
|
createInvitation(options) {
|
|
2249
|
-
let invitation;
|
|
2250
|
-
const savePersistentInvitationCtx = new Context6();
|
|
2251
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2252
|
-
if (existingInvitation) {
|
|
2253
|
-
invitation = existingInvitation;
|
|
2254
|
-
} else {
|
|
2255
|
-
const handler = this._getHandler(options);
|
|
2256
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2257
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2258
|
-
this._invitationCreated.emit(invitation.get());
|
|
2259
|
-
}
|
|
2260
2240
|
return new Stream8(({ next, close }) => {
|
|
2261
|
-
|
|
2262
|
-
scheduleTask3(savePersistentInvitationCtx, async () => {
|
|
2263
|
-
try {
|
|
2264
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2265
|
-
this._saved.emit(invitation.get());
|
|
2266
|
-
} catch (err) {
|
|
2267
|
-
close(err);
|
|
2268
|
-
}
|
|
2269
|
-
});
|
|
2270
|
-
}
|
|
2271
|
-
invitation.subscribe((invitation2) => {
|
|
2272
|
-
next(invitation2);
|
|
2273
|
-
}, async (err) => {
|
|
2274
|
-
await savePersistentInvitationCtx.dispose();
|
|
2275
|
-
close(err);
|
|
2276
|
-
}, async () => {
|
|
2277
|
-
close();
|
|
2278
|
-
if (invitation.get().persistent) {
|
|
2279
|
-
await savePersistentInvitationCtx.dispose();
|
|
2280
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2281
|
-
}
|
|
2282
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2283
|
-
if (!invitation.get().multiUse) {
|
|
2284
|
-
this._removedCreated.emit(invitation.get());
|
|
2285
|
-
}
|
|
2286
|
-
});
|
|
2241
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2287
2242
|
});
|
|
2288
2243
|
}
|
|
2289
|
-
|
|
2290
|
-
const
|
|
2291
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !hasInvitationExpired(invitation));
|
|
2292
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2293
|
-
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2294
|
-
F: __dxlog_file8,
|
|
2295
|
-
L: 109,
|
|
2296
|
-
S: this,
|
|
2297
|
-
A: [
|
|
2298
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2299
|
-
"'invitation already exists'"
|
|
2300
|
-
]
|
|
2301
|
-
});
|
|
2302
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2303
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2304
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2305
|
-
this._invitationCreated.emit(invitation.get());
|
|
2306
|
-
return persistentInvitation;
|
|
2307
|
-
});
|
|
2308
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2309
|
-
this._persistentInvitationsLoaded = true;
|
|
2310
|
-
return {
|
|
2311
|
-
invitations: cInvitations
|
|
2312
|
-
};
|
|
2313
|
-
}
|
|
2314
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2315
|
-
let invitation;
|
|
2316
|
-
if (deviceProfile) {
|
|
2317
|
-
invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2318
|
-
F: __dxlog_file8,
|
|
2319
|
-
L: 127,
|
|
2320
|
-
S: this,
|
|
2321
|
-
A: [
|
|
2322
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2323
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2324
|
-
]
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2328
|
-
if (existingInvitation) {
|
|
2329
|
-
invitation = existingInvitation;
|
|
2330
|
-
} else {
|
|
2331
|
-
const handler = this._getHandler(options);
|
|
2332
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2333
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2334
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2335
|
-
}
|
|
2244
|
+
acceptInvitation(request) {
|
|
2245
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2336
2246
|
return new Stream8(({ next, close }) => {
|
|
2337
|
-
invitation.subscribe(
|
|
2338
|
-
next(invitation2);
|
|
2339
|
-
}, (err) => {
|
|
2340
|
-
close(err);
|
|
2341
|
-
}, () => {
|
|
2342
|
-
close();
|
|
2343
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2344
|
-
if (!invitation.get().multiUse) {
|
|
2345
|
-
this._removedAccepted.emit(invitation.get());
|
|
2346
|
-
}
|
|
2347
|
-
});
|
|
2247
|
+
invitation.subscribe(next, close, close);
|
|
2348
2248
|
});
|
|
2349
2249
|
}
|
|
2350
|
-
async authenticate(
|
|
2351
|
-
|
|
2352
|
-
F: __dxlog_file8,
|
|
2353
|
-
L: 160,
|
|
2354
|
-
S: this,
|
|
2355
|
-
C: (f, a) => f(...a)
|
|
2356
|
-
});
|
|
2357
|
-
invariant7(invitationId, void 0, {
|
|
2358
|
-
F: __dxlog_file8,
|
|
2359
|
-
L: 161,
|
|
2360
|
-
S: this,
|
|
2361
|
-
A: [
|
|
2362
|
-
"invitationId",
|
|
2363
|
-
""
|
|
2364
|
-
]
|
|
2365
|
-
});
|
|
2366
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2367
|
-
if (!observable) {
|
|
2368
|
-
log6.warn("invalid invitation", {
|
|
2369
|
-
invitationId
|
|
2370
|
-
}, {
|
|
2371
|
-
F: __dxlog_file8,
|
|
2372
|
-
L: 164,
|
|
2373
|
-
S: this,
|
|
2374
|
-
C: (f, a) => f(...a)
|
|
2375
|
-
});
|
|
2376
|
-
} else {
|
|
2377
|
-
await observable.authenticate(authCode);
|
|
2378
|
-
}
|
|
2250
|
+
async authenticate(request) {
|
|
2251
|
+
return this._invitationsManager.authenticate(request);
|
|
2379
2252
|
}
|
|
2380
|
-
async cancelInvitation(
|
|
2381
|
-
|
|
2382
|
-
invitationId
|
|
2383
|
-
}, {
|
|
2384
|
-
F: __dxlog_file8,
|
|
2385
|
-
L: 171,
|
|
2386
|
-
S: this,
|
|
2387
|
-
C: (f, a) => f(...a)
|
|
2388
|
-
});
|
|
2389
|
-
invariant7(invitationId, void 0, {
|
|
2390
|
-
F: __dxlog_file8,
|
|
2391
|
-
L: 172,
|
|
2392
|
-
S: this,
|
|
2393
|
-
A: [
|
|
2394
|
-
"invitationId",
|
|
2395
|
-
""
|
|
2396
|
-
]
|
|
2397
|
-
});
|
|
2398
|
-
const created = this._createInvitations.get(invitationId);
|
|
2399
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2400
|
-
if (created) {
|
|
2401
|
-
await created.cancel();
|
|
2402
|
-
this._createInvitations.delete(invitationId);
|
|
2403
|
-
this._removedCreated.emit(created.get());
|
|
2404
|
-
if (created.get().persistent) {
|
|
2405
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2406
|
-
}
|
|
2407
|
-
} else if (accepted) {
|
|
2408
|
-
await accepted.cancel();
|
|
2409
|
-
this._acceptInvitations.delete(invitationId);
|
|
2410
|
-
this._removedAccepted.emit(accepted.get());
|
|
2411
|
-
}
|
|
2253
|
+
async cancelInvitation(request) {
|
|
2254
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2412
2255
|
}
|
|
2413
2256
|
queryInvitations() {
|
|
2414
2257
|
return new Stream8(({ next, ctx }) => {
|
|
2415
|
-
this.
|
|
2258
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2416
2259
|
next({
|
|
2417
2260
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2418
2261
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2421,7 +2264,7 @@ var InvitationsServiceImpl = class {
|
|
|
2421
2264
|
]
|
|
2422
2265
|
});
|
|
2423
2266
|
});
|
|
2424
|
-
this.
|
|
2267
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2425
2268
|
next({
|
|
2426
2269
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2427
2270
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2430,7 +2273,7 @@ var InvitationsServiceImpl = class {
|
|
|
2430
2273
|
]
|
|
2431
2274
|
});
|
|
2432
2275
|
});
|
|
2433
|
-
this.
|
|
2276
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2434
2277
|
next({
|
|
2435
2278
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2436
2279
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2439,7 +2282,7 @@ var InvitationsServiceImpl = class {
|
|
|
2439
2282
|
]
|
|
2440
2283
|
});
|
|
2441
2284
|
});
|
|
2442
|
-
this.
|
|
2285
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2443
2286
|
next({
|
|
2444
2287
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2445
2288
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2448,7 +2291,7 @@ var InvitationsServiceImpl = class {
|
|
|
2448
2291
|
]
|
|
2449
2292
|
});
|
|
2450
2293
|
});
|
|
2451
|
-
this.
|
|
2294
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2452
2295
|
next({
|
|
2453
2296
|
action: QueryInvitationsResponse.Action.SAVED,
|
|
2454
2297
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2460,40 +2303,34 @@ var InvitationsServiceImpl = class {
|
|
|
2460
2303
|
next({
|
|
2461
2304
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2462
2305
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2463
|
-
invitations:
|
|
2306
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2464
2307
|
existing: true
|
|
2465
2308
|
});
|
|
2466
2309
|
next({
|
|
2467
2310
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2468
2311
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2469
|
-
invitations:
|
|
2312
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2470
2313
|
existing: true
|
|
2471
2314
|
});
|
|
2472
|
-
|
|
2315
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2473
2316
|
next({
|
|
2474
2317
|
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2475
2318
|
type: QueryInvitationsResponse.Type.CREATED
|
|
2476
2319
|
});
|
|
2477
|
-
}
|
|
2478
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2479
|
-
next({
|
|
2480
|
-
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2481
|
-
type: QueryInvitationsResponse.Type.CREATED
|
|
2482
|
-
});
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2320
|
+
});
|
|
2485
2321
|
});
|
|
2486
2322
|
}
|
|
2487
2323
|
};
|
|
2488
2324
|
|
|
2489
2325
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2490
|
-
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2326
|
+
import { createAdmissionCredentials, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
|
|
2491
2327
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2492
|
-
import { invariant as
|
|
2493
|
-
import { log as
|
|
2328
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2329
|
+
import { log as log6 } from "@dxos/log";
|
|
2494
2330
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2495
|
-
import { Invitation as
|
|
2496
|
-
|
|
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";
|
|
2497
2334
|
var SpaceInvitationProtocol = class {
|
|
2498
2335
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2499
2336
|
this._spaceManager = _spaceManager;
|
|
@@ -2509,143 +2346,495 @@ var SpaceInvitationProtocol = class {
|
|
|
2509
2346
|
}
|
|
2510
2347
|
getInvitationContext() {
|
|
2511
2348
|
return {
|
|
2512
|
-
kind:
|
|
2349
|
+
kind: Invitation4.Kind.SPACE,
|
|
2513
2350
|
spaceKey: this._spaceKey
|
|
2514
2351
|
};
|
|
2515
2352
|
}
|
|
2516
|
-
async admit(request, guestProfile) {
|
|
2517
|
-
|
|
2518
|
-
F:
|
|
2519
|
-
L:
|
|
2353
|
+
async admit(invitation, request, guestProfile) {
|
|
2354
|
+
invariant7(this._spaceKey, void 0, {
|
|
2355
|
+
F: __dxlog_file8,
|
|
2356
|
+
L: 55,
|
|
2357
|
+
S: this,
|
|
2358
|
+
A: [
|
|
2359
|
+
"this._spaceKey",
|
|
2360
|
+
""
|
|
2361
|
+
]
|
|
2362
|
+
});
|
|
2363
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2364
|
+
invariant7(space, void 0, {
|
|
2365
|
+
F: __dxlog_file8,
|
|
2366
|
+
L: 57,
|
|
2367
|
+
S: this,
|
|
2368
|
+
A: [
|
|
2369
|
+
"space",
|
|
2370
|
+
""
|
|
2371
|
+
]
|
|
2372
|
+
});
|
|
2373
|
+
invariant7(request.space, void 0, {
|
|
2374
|
+
F: __dxlog_file8,
|
|
2375
|
+
L: 59,
|
|
2376
|
+
S: this,
|
|
2377
|
+
A: [
|
|
2378
|
+
"request.space",
|
|
2379
|
+
""
|
|
2380
|
+
]
|
|
2381
|
+
});
|
|
2382
|
+
const { identityKey, deviceKey } = request.space;
|
|
2383
|
+
log6("writing guest credentials", {
|
|
2384
|
+
host: this._signingContext.deviceKey,
|
|
2385
|
+
guest: deviceKey
|
|
2386
|
+
}, {
|
|
2387
|
+
F: __dxlog_file8,
|
|
2388
|
+
L: 62,
|
|
2389
|
+
S: this,
|
|
2390
|
+
C: (f, a) => f(...a)
|
|
2391
|
+
});
|
|
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,
|
|
2396
|
+
S: this,
|
|
2397
|
+
A: [
|
|
2398
|
+
"credentials[0].credential",
|
|
2399
|
+
""
|
|
2400
|
+
]
|
|
2401
|
+
});
|
|
2402
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2403
|
+
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2404
|
+
F: __dxlog_file8,
|
|
2405
|
+
L: 76,
|
|
2406
|
+
S: this,
|
|
2407
|
+
A: [
|
|
2408
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2409
|
+
""
|
|
2410
|
+
]
|
|
2411
|
+
});
|
|
2412
|
+
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2413
|
+
return {
|
|
2414
|
+
space: {
|
|
2415
|
+
credential: spaceMemberCredential,
|
|
2416
|
+
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
async delegate(invitation) {
|
|
2421
|
+
invariant7(this._spaceKey, void 0, {
|
|
2422
|
+
F: __dxlog_file8,
|
|
2423
|
+
L: 89,
|
|
2520
2424
|
S: this,
|
|
2521
2425
|
A: [
|
|
2522
2426
|
"this._spaceKey",
|
|
2523
2427
|
""
|
|
2524
2428
|
]
|
|
2525
2429
|
});
|
|
2526
|
-
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2527
|
-
|
|
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
|
+
}
|
|
2483
|
+
checkInvitation(invitation) {
|
|
2484
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2485
|
+
return new AlreadyJoinedError2("Already joined space.");
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
createIntroduction() {
|
|
2489
|
+
return {
|
|
2490
|
+
profile: this._signingContext.getProfile()
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
async createAdmissionRequest() {
|
|
2494
|
+
const controlFeedKey = await this._keyring.createKey();
|
|
2495
|
+
const dataFeedKey = await this._keyring.createKey();
|
|
2496
|
+
return {
|
|
2497
|
+
space: {
|
|
2498
|
+
identityKey: this._signingContext.identityKey,
|
|
2499
|
+
deviceKey: this._signingContext.deviceKey,
|
|
2500
|
+
controlFeedKey,
|
|
2501
|
+
dataFeedKey
|
|
2502
|
+
}
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
async accept(response) {
|
|
2506
|
+
invariant7(response.space, void 0, {
|
|
2507
|
+
F: __dxlog_file8,
|
|
2508
|
+
L: 149,
|
|
2509
|
+
S: this,
|
|
2510
|
+
A: [
|
|
2511
|
+
"response.space",
|
|
2512
|
+
""
|
|
2513
|
+
]
|
|
2514
|
+
});
|
|
2515
|
+
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2516
|
+
const assertion = getCredentialAssertion(credential);
|
|
2517
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2518
|
+
F: __dxlog_file8,
|
|
2519
|
+
L: 152,
|
|
2520
|
+
S: this,
|
|
2521
|
+
A: [
|
|
2522
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2523
|
+
"'Invalid credential'"
|
|
2524
|
+
]
|
|
2525
|
+
});
|
|
2526
|
+
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2527
|
+
F: __dxlog_file8,
|
|
2528
|
+
L: 153,
|
|
2529
|
+
S: this,
|
|
2530
|
+
A: [
|
|
2531
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2532
|
+
""
|
|
2533
|
+
]
|
|
2534
|
+
});
|
|
2535
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2536
|
+
throw new AlreadyJoinedError2("Already joined space.");
|
|
2537
|
+
}
|
|
2538
|
+
await this._spaceManager.acceptSpace({
|
|
2539
|
+
spaceKey: assertion.spaceKey,
|
|
2540
|
+
genesisFeedKey: assertion.genesisFeedKey,
|
|
2541
|
+
controlTimeframe,
|
|
2542
|
+
dataTimeframe
|
|
2543
|
+
});
|
|
2544
|
+
await this._signingContext.recordCredential(credential);
|
|
2545
|
+
return {
|
|
2546
|
+
spaceKey: assertion.spaceKey
|
|
2547
|
+
};
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
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, {
|
|
2528
2673
|
F: __dxlog_file9,
|
|
2529
|
-
L:
|
|
2674
|
+
L: 133,
|
|
2530
2675
|
S: this,
|
|
2531
|
-
|
|
2532
|
-
"space",
|
|
2533
|
-
""
|
|
2534
|
-
]
|
|
2676
|
+
C: (f, a) => f(...a)
|
|
2535
2677
|
});
|
|
2536
|
-
invariant8(
|
|
2678
|
+
invariant8(invitationId, void 0, {
|
|
2537
2679
|
F: __dxlog_file9,
|
|
2538
|
-
L:
|
|
2680
|
+
L: 134,
|
|
2539
2681
|
S: this,
|
|
2540
2682
|
A: [
|
|
2541
|
-
"
|
|
2683
|
+
"invitationId",
|
|
2542
2684
|
""
|
|
2543
2685
|
]
|
|
2544
2686
|
});
|
|
2545
|
-
const
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
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
|
|
2549
2704
|
}, {
|
|
2550
2705
|
F: __dxlog_file9,
|
|
2551
|
-
L:
|
|
2706
|
+
L: 144,
|
|
2552
2707
|
S: this,
|
|
2553
2708
|
C: (f, a) => f(...a)
|
|
2554
2709
|
});
|
|
2555
|
-
|
|
2556
|
-
invariant8(credentials[0].credential, void 0, {
|
|
2557
|
-
F: __dxlog_file9,
|
|
2558
|
-
L: 65,
|
|
2559
|
-
S: this,
|
|
2560
|
-
A: [
|
|
2561
|
-
"credentials[0].credential",
|
|
2562
|
-
""
|
|
2563
|
-
]
|
|
2564
|
-
});
|
|
2565
|
-
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2566
|
-
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2710
|
+
invariant8(invitationId, void 0, {
|
|
2567
2711
|
F: __dxlog_file9,
|
|
2568
|
-
L:
|
|
2712
|
+
L: 145,
|
|
2569
2713
|
S: this,
|
|
2570
2714
|
A: [
|
|
2571
|
-
"
|
|
2715
|
+
"invitationId",
|
|
2572
2716
|
""
|
|
2573
2717
|
]
|
|
2574
2718
|
});
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2719
|
+
const created = this._createInvitations.get(invitationId);
|
|
2720
|
+
if (created) {
|
|
2721
|
+
if (created.get().persistent) {
|
|
2722
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2580
2723
|
}
|
|
2581
|
-
|
|
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
|
+
}
|
|
2582
2735
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
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());
|
|
2586
2751
|
}
|
|
2587
2752
|
}
|
|
2588
|
-
|
|
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);
|
|
2589
2756
|
return {
|
|
2590
|
-
|
|
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()
|
|
2591
2771
|
};
|
|
2592
2772
|
}
|
|
2593
|
-
|
|
2594
|
-
const
|
|
2595
|
-
const
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
deviceKey: this._signingContext.deviceKey,
|
|
2600
|
-
controlFeedKey,
|
|
2601
|
-
dataFeedKey
|
|
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();
|
|
2602
2779
|
}
|
|
2603
|
-
};
|
|
2604
|
-
}
|
|
2605
|
-
async accept(response) {
|
|
2606
|
-
invariant8(response.space, void 0, {
|
|
2607
|
-
F: __dxlog_file9,
|
|
2608
|
-
L: 107,
|
|
2609
|
-
S: this,
|
|
2610
|
-
A: [
|
|
2611
|
-
"response.space",
|
|
2612
|
-
""
|
|
2613
|
-
]
|
|
2614
|
-
});
|
|
2615
|
-
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2616
|
-
const assertion = getCredentialAssertion(credential);
|
|
2617
|
-
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2618
|
-
F: __dxlog_file9,
|
|
2619
|
-
L: 110,
|
|
2620
|
-
S: this,
|
|
2621
|
-
A: [
|
|
2622
|
-
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2623
|
-
"'Invalid credential'"
|
|
2624
|
-
]
|
|
2625
2780
|
});
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
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();
|
|
2634
2791
|
});
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
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
|
+
}
|
|
2643
2802
|
});
|
|
2644
|
-
await this._signingContext.recordCredential(credential);
|
|
2645
2803
|
return {
|
|
2646
|
-
|
|
2804
|
+
ctx,
|
|
2805
|
+
stream,
|
|
2806
|
+
observableInvitation
|
|
2647
2807
|
};
|
|
2648
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
|
+
}
|
|
2649
2838
|
};
|
|
2650
2839
|
|
|
2651
2840
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
@@ -2730,15 +2919,15 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2730
2919
|
], ClientRpcServer);
|
|
2731
2920
|
|
|
2732
2921
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2733
|
-
import { Event as Event6, asyncTimeout, scheduleTask as
|
|
2922
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2734
2923
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2735
2924
|
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2736
2925
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2737
|
-
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2738
2926
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2739
2927
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2928
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
2740
2929
|
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2741
|
-
import { PublicKey as
|
|
2930
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2742
2931
|
import { log as log9 } from "@dxos/log";
|
|
2743
2932
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2744
2933
|
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2786,10 +2975,10 @@ var AutomergeSpaceState = class {
|
|
|
2786
2975
|
};
|
|
2787
2976
|
|
|
2788
2977
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2789
|
-
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";
|
|
2790
2979
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2791
2980
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2792
|
-
import { PublicKey as
|
|
2981
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2793
2982
|
import { log as log8 } from "@dxos/log";
|
|
2794
2983
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2795
2984
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
@@ -2804,8 +2993,8 @@ var NotarizationPlugin = class {
|
|
|
2804
2993
|
this._ctx = new Context7();
|
|
2805
2994
|
this._extensionOpened = new Event5();
|
|
2806
2995
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2807
|
-
this._processedCredentials = new ComplexSet2(
|
|
2808
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2996
|
+
this._processedCredentials = new ComplexSet2(PublicKey8.hash);
|
|
2997
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey8.hash);
|
|
2809
2998
|
}
|
|
2810
2999
|
get hasWriter() {
|
|
2811
3000
|
return !!this._writer;
|
|
@@ -2853,7 +3042,7 @@ var NotarizationPlugin = class {
|
|
|
2853
3042
|
});
|
|
2854
3043
|
opCtx?.onDispose(() => ctx.dispose());
|
|
2855
3044
|
if (timeout !== 0) {
|
|
2856
|
-
|
|
3045
|
+
scheduleTask3(ctx, () => {
|
|
2857
3046
|
log8.warn("Notarization timeout", {
|
|
2858
3047
|
timeout,
|
|
2859
3048
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2887,7 +3076,7 @@ var NotarizationPlugin = class {
|
|
|
2887
3076
|
C: (f, a) => f(...a)
|
|
2888
3077
|
});
|
|
2889
3078
|
peersTried.clear();
|
|
2890
|
-
|
|
3079
|
+
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2891
3080
|
return;
|
|
2892
3081
|
}
|
|
2893
3082
|
peersTried.add(peer);
|
|
@@ -3088,9 +3277,9 @@ var DataSpace = class {
|
|
|
3088
3277
|
this._metadataStore = params.metadataStore;
|
|
3089
3278
|
this._signingContext = params.signingContext;
|
|
3090
3279
|
this._callbacks = params.callbacks ?? {};
|
|
3091
|
-
this.
|
|
3280
|
+
this._echoHost = params.echoHost;
|
|
3092
3281
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3093
|
-
trustedKeysProvider: () => new ComplexSet3(
|
|
3282
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey9.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3094
3283
|
update: this._inner.stateUpdate,
|
|
3095
3284
|
authTimeout: AUTH_TIMEOUT2
|
|
3096
3285
|
});
|
|
@@ -3100,7 +3289,7 @@ var DataSpace = class {
|
|
|
3100
3289
|
state: SpaceState[this._state]
|
|
3101
3290
|
}, {
|
|
3102
3291
|
F: __dxlog_file11,
|
|
3103
|
-
L:
|
|
3292
|
+
L: 135,
|
|
3104
3293
|
S: this,
|
|
3105
3294
|
C: (f, a) => f(...a)
|
|
3106
3295
|
});
|
|
@@ -3150,7 +3339,7 @@ var DataSpace = class {
|
|
|
3150
3339
|
state: SpaceState[this._state]
|
|
3151
3340
|
}, {
|
|
3152
3341
|
F: __dxlog_file11,
|
|
3153
|
-
L:
|
|
3342
|
+
L: 193,
|
|
3154
3343
|
S: this,
|
|
3155
3344
|
C: (f, a) => f(...a)
|
|
3156
3345
|
});
|
|
@@ -3168,7 +3357,7 @@ var DataSpace = class {
|
|
|
3168
3357
|
state: SpaceState[this._state]
|
|
3169
3358
|
}, {
|
|
3170
3359
|
F: __dxlog_file11,
|
|
3171
|
-
L:
|
|
3360
|
+
L: 207,
|
|
3172
3361
|
S: this,
|
|
3173
3362
|
C: (f, a) => f(...a)
|
|
3174
3363
|
});
|
|
@@ -3192,7 +3381,7 @@ var DataSpace = class {
|
|
|
3192
3381
|
* Initialize the data pipeline in a separate task.
|
|
3193
3382
|
*/
|
|
3194
3383
|
initializeDataPipelineAsync() {
|
|
3195
|
-
|
|
3384
|
+
scheduleTask4(this._ctx, async () => {
|
|
3196
3385
|
try {
|
|
3197
3386
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3198
3387
|
await this.initializeDataPipeline();
|
|
@@ -3200,7 +3389,7 @@ var DataSpace = class {
|
|
|
3200
3389
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3201
3390
|
log9("data pipeline initialization cancelled", err, {
|
|
3202
3391
|
F: __dxlog_file11,
|
|
3203
|
-
L:
|
|
3392
|
+
L: 240,
|
|
3204
3393
|
S: this,
|
|
3205
3394
|
C: (f, a) => f(...a)
|
|
3206
3395
|
});
|
|
@@ -3208,7 +3397,7 @@ var DataSpace = class {
|
|
|
3208
3397
|
}
|
|
3209
3398
|
log9.error("Error initializing data pipeline", err, {
|
|
3210
3399
|
F: __dxlog_file11,
|
|
3211
|
-
L:
|
|
3400
|
+
L: 244,
|
|
3212
3401
|
S: this,
|
|
3213
3402
|
C: (f, a) => f(...a)
|
|
3214
3403
|
});
|
|
@@ -3217,7 +3406,7 @@ var DataSpace = class {
|
|
|
3217
3406
|
state: SpaceState[this._state]
|
|
3218
3407
|
}, {
|
|
3219
3408
|
F: __dxlog_file11,
|
|
3220
|
-
L:
|
|
3409
|
+
L: 246,
|
|
3221
3410
|
S: this,
|
|
3222
3411
|
C: (f, a) => f(...a)
|
|
3223
3412
|
});
|
|
@@ -3237,7 +3426,7 @@ var DataSpace = class {
|
|
|
3237
3426
|
state: SpaceState[this._state]
|
|
3238
3427
|
}, {
|
|
3239
3428
|
F: __dxlog_file11,
|
|
3240
|
-
L:
|
|
3429
|
+
L: 262,
|
|
3241
3430
|
S: this,
|
|
3242
3431
|
C: (f, a) => f(...a)
|
|
3243
3432
|
});
|
|
@@ -3247,7 +3436,7 @@ var DataSpace = class {
|
|
|
3247
3436
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3248
3437
|
log9("data pipeline ready", void 0, {
|
|
3249
3438
|
F: __dxlog_file11,
|
|
3250
|
-
L:
|
|
3439
|
+
L: 274,
|
|
3251
3440
|
S: this,
|
|
3252
3441
|
C: (f, a) => f(...a)
|
|
3253
3442
|
});
|
|
@@ -3257,7 +3446,7 @@ var DataSpace = class {
|
|
|
3257
3446
|
state: SpaceState[this._state]
|
|
3258
3447
|
}, {
|
|
3259
3448
|
F: __dxlog_file11,
|
|
3260
|
-
L:
|
|
3449
|
+
L: 278,
|
|
3261
3450
|
S: this,
|
|
3262
3451
|
C: (f, a) => f(...a)
|
|
3263
3452
|
});
|
|
@@ -3273,7 +3462,7 @@ var DataSpace = class {
|
|
|
3273
3462
|
await this._createWritableFeeds();
|
|
3274
3463
|
log9("writable feeds created", void 0, {
|
|
3275
3464
|
F: __dxlog_file11,
|
|
3276
|
-
L:
|
|
3465
|
+
L: 294,
|
|
3277
3466
|
S: this,
|
|
3278
3467
|
C: (f, a) => f(...a)
|
|
3279
3468
|
});
|
|
@@ -3336,12 +3525,12 @@ var DataSpace = class {
|
|
|
3336
3525
|
rootUrl
|
|
3337
3526
|
}, {
|
|
3338
3527
|
F: __dxlog_file11,
|
|
3339
|
-
L:
|
|
3528
|
+
L: 360,
|
|
3340
3529
|
S: this,
|
|
3341
3530
|
C: (f, a) => f(...a)
|
|
3342
3531
|
});
|
|
3343
|
-
this.
|
|
3344
|
-
const handle = this.
|
|
3532
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3533
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3345
3534
|
queueMicrotask(async () => {
|
|
3346
3535
|
try {
|
|
3347
3536
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3368,7 +3557,7 @@ var DataSpace = class {
|
|
|
3368
3557
|
err
|
|
3369
3558
|
}, {
|
|
3370
3559
|
F: __dxlog_file11,
|
|
3371
|
-
L:
|
|
3560
|
+
L: 383,
|
|
3372
3561
|
S: this,
|
|
3373
3562
|
C: (f, a) => f(...a)
|
|
3374
3563
|
});
|
|
@@ -3406,7 +3595,7 @@ var DataSpace = class {
|
|
|
3406
3595
|
break;
|
|
3407
3596
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3408
3597
|
{
|
|
3409
|
-
const document = this.
|
|
3598
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3410
3599
|
epoch = {
|
|
3411
3600
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3412
3601
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3418,12 +3607,12 @@ var DataSpace = class {
|
|
|
3418
3607
|
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3419
3608
|
{
|
|
3420
3609
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3421
|
-
const rootHandle = this.
|
|
3610
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3422
3611
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3423
|
-
const newRoot = this.
|
|
3612
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3424
3613
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3425
3614
|
F: __dxlog_file11,
|
|
3426
|
-
L:
|
|
3615
|
+
L: 433,
|
|
3427
3616
|
S: this,
|
|
3428
3617
|
A: [
|
|
3429
3618
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3442,19 +3631,19 @@ var DataSpace = class {
|
|
|
3442
3631
|
{
|
|
3443
3632
|
log9.info("Fragmenting", void 0, {
|
|
3444
3633
|
F: __dxlog_file11,
|
|
3445
|
-
L:
|
|
3634
|
+
L: 445,
|
|
3446
3635
|
S: this,
|
|
3447
3636
|
C: (f, a) => f(...a)
|
|
3448
3637
|
});
|
|
3449
3638
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3450
|
-
const rootHandle = this.
|
|
3639
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3451
3640
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3452
3641
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3453
3642
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3454
3643
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3455
3644
|
invariant10(properties, "Properties not found", {
|
|
3456
3645
|
F: __dxlog_file11,
|
|
3457
|
-
L:
|
|
3646
|
+
L: 455,
|
|
3458
3647
|
S: this,
|
|
3459
3648
|
A: [
|
|
3460
3649
|
"properties",
|
|
@@ -3467,17 +3656,17 @@ var DataSpace = class {
|
|
|
3467
3656
|
properties
|
|
3468
3657
|
])
|
|
3469
3658
|
};
|
|
3470
|
-
const newRoot = this.
|
|
3659
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3471
3660
|
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3472
3661
|
F: __dxlog_file11,
|
|
3473
|
-
L:
|
|
3662
|
+
L: 460,
|
|
3474
3663
|
S: this,
|
|
3475
3664
|
A: [
|
|
3476
3665
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3477
3666
|
""
|
|
3478
3667
|
]
|
|
3479
3668
|
});
|
|
3480
|
-
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this.
|
|
3669
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3481
3670
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3482
3671
|
rootUrl: newRoot.url
|
|
3483
3672
|
});
|
|
@@ -3539,7 +3728,7 @@ var DataSpace = class {
|
|
|
3539
3728
|
state: SpaceState[this._state]
|
|
3540
3729
|
}, {
|
|
3541
3730
|
F: __dxlog_file11,
|
|
3542
|
-
L:
|
|
3731
|
+
L: 526,
|
|
3543
3732
|
S: this,
|
|
3544
3733
|
C: (f, a) => f(...a)
|
|
3545
3734
|
});
|
|
@@ -3597,17 +3786,17 @@ import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeak
|
|
|
3597
3786
|
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3598
3787
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3599
3788
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3600
|
-
import { PublicKey as
|
|
3789
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3601
3790
|
import { log as log10 } from "@dxos/log";
|
|
3602
3791
|
import { trace as trace7 } from "@dxos/protocols";
|
|
3603
|
-
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";
|
|
3604
3793
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
3605
3794
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
3606
3795
|
|
|
3607
3796
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3608
3797
|
import { createCredential } from "@dxos/credentials";
|
|
3609
3798
|
import { failUndefined } from "@dxos/debug";
|
|
3610
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3799
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3611
3800
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3612
3801
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3613
3802
|
const credentials = [
|
|
@@ -3627,7 +3816,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3627
3816
|
assertion: {
|
|
3628
3817
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3629
3818
|
spaceKey: space.key,
|
|
3630
|
-
role:
|
|
3819
|
+
role: SpaceMember2.Role.ADMIN,
|
|
3631
3820
|
profile: signingContext.getProfile(),
|
|
3632
3821
|
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
3633
3822
|
}
|
|
@@ -3689,18 +3878,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3689
3878
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3690
3879
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3691
3880
|
var DataSpaceManager = class {
|
|
3692
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3881
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3693
3882
|
this._spaceManager = _spaceManager;
|
|
3694
3883
|
this._metadataStore = _metadataStore;
|
|
3695
3884
|
this._keyring = _keyring;
|
|
3696
3885
|
this._signingContext = _signingContext;
|
|
3697
3886
|
this._feedStore = _feedStore;
|
|
3698
|
-
this.
|
|
3887
|
+
this._echoHost = _echoHost;
|
|
3888
|
+
this._invitationsManager = _invitationsManager;
|
|
3699
3889
|
this._ctx = new Context9();
|
|
3700
3890
|
this.updated = new Event7();
|
|
3701
|
-
this._spaces = new ComplexMap3(
|
|
3891
|
+
this._spaces = new ComplexMap3(PublicKey10.hash);
|
|
3702
3892
|
this._isOpen = false;
|
|
3703
|
-
this._instanceId =
|
|
3893
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3704
3894
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3705
3895
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3706
3896
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3712,7 +3902,7 @@ var DataSpaceManager = class {
|
|
|
3712
3902
|
async open() {
|
|
3713
3903
|
log10("open", void 0, {
|
|
3714
3904
|
F: __dxlog_file12,
|
|
3715
|
-
L:
|
|
3905
|
+
L: 102,
|
|
3716
3906
|
S: this,
|
|
3717
3907
|
C: (f, a) => f(...a)
|
|
3718
3908
|
});
|
|
@@ -3720,7 +3910,7 @@ var DataSpaceManager = class {
|
|
|
3720
3910
|
id: this._instanceId
|
|
3721
3911
|
}), {
|
|
3722
3912
|
F: __dxlog_file12,
|
|
3723
|
-
L:
|
|
3913
|
+
L: 103,
|
|
3724
3914
|
S: this,
|
|
3725
3915
|
C: (f, a) => f(...a)
|
|
3726
3916
|
});
|
|
@@ -3728,7 +3918,7 @@ var DataSpaceManager = class {
|
|
|
3728
3918
|
spaces: this._metadataStore.spaces.length
|
|
3729
3919
|
}, {
|
|
3730
3920
|
F: __dxlog_file12,
|
|
3731
|
-
L:
|
|
3921
|
+
L: 104,
|
|
3732
3922
|
S: this,
|
|
3733
3923
|
C: (f, a) => f(...a)
|
|
3734
3924
|
});
|
|
@@ -3738,7 +3928,7 @@ var DataSpaceManager = class {
|
|
|
3738
3928
|
spaceMetadata
|
|
3739
3929
|
}, {
|
|
3740
3930
|
F: __dxlog_file12,
|
|
3741
|
-
L:
|
|
3931
|
+
L: 108,
|
|
3742
3932
|
S: this,
|
|
3743
3933
|
C: (f, a) => f(...a)
|
|
3744
3934
|
});
|
|
@@ -3749,7 +3939,7 @@ var DataSpaceManager = class {
|
|
|
3749
3939
|
err
|
|
3750
3940
|
}, {
|
|
3751
3941
|
F: __dxlog_file12,
|
|
3752
|
-
L:
|
|
3942
|
+
L: 111,
|
|
3753
3943
|
S: this,
|
|
3754
3944
|
C: (f, a) => f(...a)
|
|
3755
3945
|
});
|
|
@@ -3766,7 +3956,7 @@ var DataSpaceManager = class {
|
|
|
3766
3956
|
id: this._instanceId
|
|
3767
3957
|
}), {
|
|
3768
3958
|
F: __dxlog_file12,
|
|
3769
|
-
L:
|
|
3959
|
+
L: 124,
|
|
3770
3960
|
S: this,
|
|
3771
3961
|
C: (f, a) => f(...a)
|
|
3772
3962
|
});
|
|
@@ -3774,7 +3964,7 @@ var DataSpaceManager = class {
|
|
|
3774
3964
|
async close() {
|
|
3775
3965
|
log10("close", void 0, {
|
|
3776
3966
|
F: __dxlog_file12,
|
|
3777
|
-
L:
|
|
3967
|
+
L: 129,
|
|
3778
3968
|
S: this,
|
|
3779
3969
|
C: (f, a) => f(...a)
|
|
3780
3970
|
});
|
|
@@ -3790,7 +3980,7 @@ var DataSpaceManager = class {
|
|
|
3790
3980
|
async createSpace() {
|
|
3791
3981
|
invariant11(this._isOpen, "Not open.", {
|
|
3792
3982
|
F: __dxlog_file12,
|
|
3793
|
-
L:
|
|
3983
|
+
L: 142,
|
|
3794
3984
|
S: this,
|
|
3795
3985
|
A: [
|
|
3796
3986
|
"this._isOpen",
|
|
@@ -3811,18 +4001,13 @@ var DataSpaceManager = class {
|
|
|
3811
4001
|
spaceKey
|
|
3812
4002
|
}, {
|
|
3813
4003
|
F: __dxlog_file12,
|
|
3814
|
-
L:
|
|
4004
|
+
L: 154,
|
|
3815
4005
|
S: this,
|
|
3816
4006
|
C: (f, a) => f(...a)
|
|
3817
4007
|
});
|
|
3818
|
-
const
|
|
3819
|
-
automergeRoot.change((doc) => {
|
|
3820
|
-
doc.access = {
|
|
3821
|
-
spaceKey: spaceKey.toHex()
|
|
3822
|
-
};
|
|
3823
|
-
});
|
|
4008
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
3824
4009
|
const space = await this._constructSpace(metadata);
|
|
3825
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4010
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
3826
4011
|
await this._metadataStore.addSpace(metadata);
|
|
3827
4012
|
const memberCredential = credentials[1];
|
|
3828
4013
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
@@ -3927,8 +4112,8 @@ var DataSpaceManager = class {
|
|
|
3927
4112
|
remotePeerId: session.remotePeerId
|
|
3928
4113
|
}));
|
|
3929
4114
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3930
|
-
this.
|
|
3931
|
-
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());
|
|
3932
4117
|
},
|
|
3933
4118
|
onAuthFailure: () => {
|
|
3934
4119
|
log10.warn("auth failure", void 0, {
|
|
@@ -3938,7 +4123,10 @@ var DataSpaceManager = class {
|
|
|
3938
4123
|
C: (f, a) => f(...a)
|
|
3939
4124
|
});
|
|
3940
4125
|
},
|
|
3941
|
-
memberKey: this._signingContext.identityKey
|
|
4126
|
+
memberKey: this._signingContext.identityKey,
|
|
4127
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4128
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4129
|
+
}
|
|
3942
4130
|
});
|
|
3943
4131
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
3944
4132
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
@@ -3950,6 +4138,7 @@ var DataSpaceManager = class {
|
|
|
3950
4138
|
presence,
|
|
3951
4139
|
keyring: this._keyring,
|
|
3952
4140
|
feedStore: this._feedStore,
|
|
4141
|
+
echoHost: this._echoHost,
|
|
3953
4142
|
signingContext: this._signingContext,
|
|
3954
4143
|
callbacks: {
|
|
3955
4144
|
beforeReady: async () => {
|
|
@@ -3957,7 +4146,7 @@ var DataSpaceManager = class {
|
|
|
3957
4146
|
space: space.key
|
|
3958
4147
|
}, {
|
|
3959
4148
|
F: __dxlog_file12,
|
|
3960
|
-
L:
|
|
4149
|
+
L: 269,
|
|
3961
4150
|
S: this,
|
|
3962
4151
|
C: (f, a) => f(...a)
|
|
3963
4152
|
});
|
|
@@ -3968,11 +4157,14 @@ var DataSpaceManager = class {
|
|
|
3968
4157
|
open: this._isOpen
|
|
3969
4158
|
}, {
|
|
3970
4159
|
F: __dxlog_file12,
|
|
3971
|
-
L:
|
|
4160
|
+
L: 272,
|
|
3972
4161
|
S: this,
|
|
3973
4162
|
C: (f, a) => f(...a)
|
|
3974
4163
|
});
|
|
3975
4164
|
if (this._isOpen) {
|
|
4165
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4166
|
+
...space.spaceState.invitations.entries()
|
|
4167
|
+
]);
|
|
3976
4168
|
this.updated.emit();
|
|
3977
4169
|
}
|
|
3978
4170
|
},
|
|
@@ -3981,14 +4173,13 @@ var DataSpaceManager = class {
|
|
|
3981
4173
|
space: space.key
|
|
3982
4174
|
}, {
|
|
3983
4175
|
F: __dxlog_file12,
|
|
3984
|
-
L:
|
|
4176
|
+
L: 279,
|
|
3985
4177
|
S: this,
|
|
3986
4178
|
C: (f, a) => f(...a)
|
|
3987
4179
|
});
|
|
3988
4180
|
}
|
|
3989
4181
|
},
|
|
3990
|
-
cache: metadata.cache
|
|
3991
|
-
automergeHost: this._automergeHost
|
|
4182
|
+
cache: metadata.cache
|
|
3992
4183
|
});
|
|
3993
4184
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
3994
4185
|
await dataSpace.open();
|
|
@@ -3999,6 +4190,41 @@ var DataSpaceManager = class {
|
|
|
3999
4190
|
this._spaces.set(metadata.key, dataSpace);
|
|
4000
4191
|
return dataSpace;
|
|
4001
4192
|
}
|
|
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
|
+
}
|
|
4002
4228
|
};
|
|
4003
4229
|
_ts_decorate5([
|
|
4004
4230
|
synchronized2
|
|
@@ -4017,13 +4243,13 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4017
4243
|
], DataSpaceManager);
|
|
4018
4244
|
|
|
4019
4245
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4020
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4246
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4021
4247
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4022
4248
|
import { raise as raise2 } from "@dxos/debug";
|
|
4023
4249
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4024
4250
|
import { log as log11 } from "@dxos/log";
|
|
4025
4251
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4026
|
-
import { SpaceMember as
|
|
4252
|
+
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4027
4253
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4028
4254
|
var SpacesServiceImpl = class {
|
|
4029
4255
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
@@ -4074,7 +4300,7 @@ var SpacesServiceImpl = class {
|
|
|
4074
4300
|
}, {
|
|
4075
4301
|
maxFrequency: false ? void 0 : 2
|
|
4076
4302
|
});
|
|
4077
|
-
|
|
4303
|
+
scheduleTask5(ctx, async () => {
|
|
4078
4304
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4079
4305
|
const subscriptions = new EventSubscriptions2();
|
|
4080
4306
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4108,7 +4334,7 @@ var SpacesServiceImpl = class {
|
|
|
4108
4334
|
}
|
|
4109
4335
|
subscribeMessages({ spaceKey, channel }) {
|
|
4110
4336
|
return new Stream10(({ ctx, next }) => {
|
|
4111
|
-
|
|
4337
|
+
scheduleTask5(ctx, async () => {
|
|
4112
4338
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4113
4339
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4114
4340
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4127,7 +4353,7 @@ var SpacesServiceImpl = class {
|
|
|
4127
4353
|
}
|
|
4128
4354
|
};
|
|
4129
4355
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4130
|
-
|
|
4356
|
+
scheduleTask5(ctx, async () => {
|
|
4131
4357
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4132
4358
|
if (noTail) {
|
|
4133
4359
|
close();
|
|
@@ -4221,7 +4447,7 @@ var SpacesServiceImpl = class {
|
|
|
4221
4447
|
identityKey: member.key,
|
|
4222
4448
|
profile: member.profile ?? {}
|
|
4223
4449
|
},
|
|
4224
|
-
presence: member.removed ?
|
|
4450
|
+
presence: member.removed ? SpaceMember3.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
4225
4451
|
peerStates: peers
|
|
4226
4452
|
};
|
|
4227
4453
|
}),
|
|
@@ -4238,99 +4464,18 @@ import { Trigger as Trigger5 } from "@dxos/async";
|
|
|
4238
4464
|
import { Context as Context10, Resource } from "@dxos/context";
|
|
4239
4465
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4240
4466
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4241
|
-
import {
|
|
4467
|
+
import { EchoHost } from "@dxos/echo-db";
|
|
4468
|
+
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4242
4469
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4243
|
-
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4244
4470
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4245
4471
|
import { Keyring } from "@dxos/keyring";
|
|
4246
|
-
import { PublicKey as
|
|
4472
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4247
4473
|
import { log as log12 } from "@dxos/log";
|
|
4248
4474
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4249
|
-
import { Invitation as
|
|
4475
|
+
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4250
4476
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4251
4477
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4252
4478
|
import { safeInstanceof } from "@dxos/util";
|
|
4253
|
-
|
|
4254
|
-
// packages/sdk/client-services/src/packlets/indexing/util.ts
|
|
4255
|
-
import { getHeads } from "@dxos/automerge/automerge";
|
|
4256
|
-
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4257
|
-
import { idCodec } from "@dxos/protocols";
|
|
4258
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4259
|
-
/**
|
|
4260
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4261
|
-
* @param ids
|
|
4262
|
-
*/
|
|
4263
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4264
|
-
async function* loadDocuments(ids) {
|
|
4265
|
-
for (const id of ids) {
|
|
4266
|
-
const { documentId, objectId } = idCodec.decode(id);
|
|
4267
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4268
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4269
|
-
const doc = handle.docSync();
|
|
4270
|
-
const hash = getHeads(doc).join("");
|
|
4271
|
-
yield doc.objects?.[objectId] ? [
|
|
4272
|
-
{
|
|
4273
|
-
id,
|
|
4274
|
-
object: doc.objects[objectId],
|
|
4275
|
-
currentHash: hash
|
|
4276
|
-
}
|
|
4277
|
-
] : [];
|
|
4278
|
-
}
|
|
4279
|
-
}
|
|
4280
|
-
);
|
|
4281
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4282
|
-
/**
|
|
4283
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4284
|
-
* @param ids
|
|
4285
|
-
*/
|
|
4286
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4287
|
-
async function* getAllDocuments() {
|
|
4288
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4289
|
-
async function* getObjectsFromHandle(handle) {
|
|
4290
|
-
if (visited.has(handle.documentId)) {
|
|
4291
|
-
return;
|
|
4292
|
-
}
|
|
4293
|
-
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4294
|
-
const doc = handle.docSync();
|
|
4295
|
-
const heads = getHeads(doc);
|
|
4296
|
-
if (doc.objects) {
|
|
4297
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4298
|
-
return {
|
|
4299
|
-
id: idCodec.encode({
|
|
4300
|
-
documentId: handle.documentId,
|
|
4301
|
-
objectId
|
|
4302
|
-
}),
|
|
4303
|
-
object,
|
|
4304
|
-
currentHash: heads.join("")
|
|
4305
|
-
};
|
|
4306
|
-
});
|
|
4307
|
-
}
|
|
4308
|
-
if (doc.links) {
|
|
4309
|
-
for (const id of Object.values(doc.links)) {
|
|
4310
|
-
if (visited.has(id)) {
|
|
4311
|
-
continue;
|
|
4312
|
-
}
|
|
4313
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4314
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4315
|
-
yield result;
|
|
4316
|
-
}
|
|
4317
|
-
}
|
|
4318
|
-
}
|
|
4319
|
-
visited.add(handle.documentId);
|
|
4320
|
-
}
|
|
4321
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4322
|
-
if (visited.has(handle.documentId)) {
|
|
4323
|
-
continue;
|
|
4324
|
-
}
|
|
4325
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4326
|
-
yield result;
|
|
4327
|
-
}
|
|
4328
|
-
visited.add(handle.documentId);
|
|
4329
|
-
}
|
|
4330
|
-
}
|
|
4331
|
-
);
|
|
4332
|
-
|
|
4333
|
-
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4334
4479
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4335
4480
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4336
4481
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4352,7 +4497,7 @@ var ServiceContext = class extends Resource {
|
|
|
4352
4497
|
this._runtimeParams = _runtimeParams;
|
|
4353
4498
|
this.initialized = new Trigger5();
|
|
4354
4499
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4355
|
-
this._instanceId =
|
|
4500
|
+
this._instanceId = PublicKey11.random().toHex();
|
|
4356
4501
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4357
4502
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4358
4503
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4375,30 +4520,19 @@ var ServiceContext = class extends Resource {
|
|
|
4375
4520
|
snapshotStore: this.snapshotStore
|
|
4376
4521
|
});
|
|
4377
4522
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4378
|
-
this.
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
this.automergeHost = new AutomergeHost({
|
|
4382
|
-
directory: storage.createDirectory("automerge"),
|
|
4383
|
-
db: level.sublevel("automerge"),
|
|
4384
|
-
metadata: this.indexMetadata
|
|
4385
|
-
});
|
|
4386
|
-
this.indexer = new Indexer({
|
|
4387
|
-
indexStore: new IndexStore({
|
|
4388
|
-
directory: storage.createDirectory("index-store")
|
|
4389
|
-
}),
|
|
4390
|
-
metadataStore: this.indexMetadata,
|
|
4391
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4392
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4523
|
+
this.echoHost = new EchoHost({
|
|
4524
|
+
kv: this.level,
|
|
4525
|
+
storage: this.storage
|
|
4393
4526
|
});
|
|
4394
4527
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4395
|
-
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)));
|
|
4396
4530
|
}
|
|
4397
4531
|
async _open(ctx) {
|
|
4398
4532
|
await this._checkStorageVersion();
|
|
4399
4533
|
log12("opening...", void 0, {
|
|
4400
4534
|
F: __dxlog_file14,
|
|
4401
|
-
L:
|
|
4535
|
+
L: 151,
|
|
4402
4536
|
S: this,
|
|
4403
4537
|
C: (f, a) => f(...a)
|
|
4404
4538
|
});
|
|
@@ -4406,56 +4540,64 @@ var ServiceContext = class extends Resource {
|
|
|
4406
4540
|
id: this._instanceId
|
|
4407
4541
|
}), {
|
|
4408
4542
|
F: __dxlog_file14,
|
|
4409
|
-
L:
|
|
4543
|
+
L: 152,
|
|
4410
4544
|
S: this,
|
|
4411
4545
|
C: (f, a) => f(...a)
|
|
4412
4546
|
});
|
|
4413
4547
|
await this.signalManager.open();
|
|
4414
4548
|
await this.networkManager.open();
|
|
4415
|
-
await this.
|
|
4549
|
+
await this.echoHost.open(ctx);
|
|
4416
4550
|
await this.metadataStore.load();
|
|
4417
4551
|
await this.spaceManager.open();
|
|
4418
4552
|
await this.identityManager.open(ctx);
|
|
4419
4553
|
if (this.identityManager.identity) {
|
|
4420
4554
|
await this._initialize(ctx);
|
|
4421
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
|
+
});
|
|
4422
4565
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4423
4566
|
id: this._instanceId
|
|
4424
4567
|
}), {
|
|
4425
4568
|
F: __dxlog_file14,
|
|
4426
|
-
L:
|
|
4569
|
+
L: 167,
|
|
4427
4570
|
S: this,
|
|
4428
4571
|
C: (f, a) => f(...a)
|
|
4429
4572
|
});
|
|
4430
4573
|
log12("opened", void 0, {
|
|
4431
4574
|
F: __dxlog_file14,
|
|
4432
|
-
L:
|
|
4575
|
+
L: 168,
|
|
4433
4576
|
S: this,
|
|
4434
4577
|
C: (f, a) => f(...a)
|
|
4435
4578
|
});
|
|
4436
4579
|
}
|
|
4437
|
-
async _close() {
|
|
4580
|
+
async _close(ctx) {
|
|
4438
4581
|
log12("closing...", void 0, {
|
|
4439
4582
|
F: __dxlog_file14,
|
|
4440
|
-
L:
|
|
4583
|
+
L: 172,
|
|
4441
4584
|
S: this,
|
|
4442
4585
|
C: (f, a) => f(...a)
|
|
4443
4586
|
});
|
|
4444
4587
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4445
4588
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4446
4589
|
}
|
|
4447
|
-
await this.automergeHost.close();
|
|
4448
4590
|
await this.dataSpaceManager?.close();
|
|
4449
4591
|
await this.identityManager.close();
|
|
4450
4592
|
await this.spaceManager.close();
|
|
4451
4593
|
await this.feedStore.close();
|
|
4594
|
+
await this.metadataStore.close();
|
|
4595
|
+
await this.echoHost.close(ctx);
|
|
4452
4596
|
await this.networkManager.close();
|
|
4453
4597
|
await this.signalManager.close();
|
|
4454
|
-
await this.metadataStore.close();
|
|
4455
|
-
await this.indexer.destroy();
|
|
4456
4598
|
log12("closed", void 0, {
|
|
4457
4599
|
F: __dxlog_file14,
|
|
4458
|
-
L:
|
|
4600
|
+
L: 184,
|
|
4459
4601
|
S: this,
|
|
4460
4602
|
C: (f, a) => f(...a)
|
|
4461
4603
|
});
|
|
@@ -4469,7 +4611,7 @@ var ServiceContext = class extends Resource {
|
|
|
4469
4611
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4470
4612
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4471
4613
|
F: __dxlog_file14,
|
|
4472
|
-
L:
|
|
4614
|
+
L: 195,
|
|
4473
4615
|
S: this,
|
|
4474
4616
|
A: [
|
|
4475
4617
|
"factory",
|
|
@@ -4501,7 +4643,7 @@ var ServiceContext = class extends Resource {
|
|
|
4501
4643
|
async _initialize(ctx) {
|
|
4502
4644
|
log12("initializing spaces...", void 0, {
|
|
4503
4645
|
F: __dxlog_file14,
|
|
4504
|
-
L:
|
|
4646
|
+
L: 226,
|
|
4505
4647
|
S: this,
|
|
4506
4648
|
C: (f, a) => f(...a)
|
|
4507
4649
|
});
|
|
@@ -4519,12 +4661,12 @@ var ServiceContext = class extends Resource {
|
|
|
4519
4661
|
});
|
|
4520
4662
|
}
|
|
4521
4663
|
};
|
|
4522
|
-
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);
|
|
4523
4665
|
await this.dataSpaceManager.open();
|
|
4524
|
-
this._handlerFactories.set(
|
|
4666
|
+
this._handlerFactories.set(Invitation7.Kind.SPACE, (invitation) => {
|
|
4525
4667
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4526
4668
|
F: __dxlog_file14,
|
|
4527
|
-
L:
|
|
4669
|
+
L: 251,
|
|
4528
4670
|
S: this,
|
|
4529
4671
|
A: [
|
|
4530
4672
|
"this.dataSpaceManager",
|
|
@@ -4548,7 +4690,7 @@ var ServiceContext = class extends Resource {
|
|
|
4548
4690
|
details: assertion
|
|
4549
4691
|
}, {
|
|
4550
4692
|
F: __dxlog_file14,
|
|
4551
|
-
L:
|
|
4693
|
+
L: 267,
|
|
4552
4694
|
S: this,
|
|
4553
4695
|
C: (f, a) => f(...a)
|
|
4554
4696
|
});
|
|
@@ -4559,7 +4701,7 @@ var ServiceContext = class extends Resource {
|
|
|
4559
4701
|
details: assertion
|
|
4560
4702
|
}, {
|
|
4561
4703
|
F: __dxlog_file14,
|
|
4562
|
-
L:
|
|
4704
|
+
L: 271,
|
|
4563
4705
|
S: this,
|
|
4564
4706
|
C: (f, a) => f(...a)
|
|
4565
4707
|
});
|
|
@@ -4570,7 +4712,7 @@ var ServiceContext = class extends Resource {
|
|
|
4570
4712
|
details: assertion
|
|
4571
4713
|
}, {
|
|
4572
4714
|
F: __dxlog_file14,
|
|
4573
|
-
L:
|
|
4715
|
+
L: 276,
|
|
4574
4716
|
S: this,
|
|
4575
4717
|
C: (f, a) => f(...a)
|
|
4576
4718
|
});
|
|
@@ -4581,7 +4723,7 @@ var ServiceContext = class extends Resource {
|
|
|
4581
4723
|
} catch (err) {
|
|
4582
4724
|
log12.catch(err, void 0, {
|
|
4583
4725
|
F: __dxlog_file14,
|
|
4584
|
-
L:
|
|
4726
|
+
L: 282,
|
|
4585
4727
|
S: this,
|
|
4586
4728
|
C: (f, a) => f(...a)
|
|
4587
4729
|
});
|
|
@@ -4631,11 +4773,11 @@ import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
|
4631
4773
|
import { credentialTypeFilter } from "@dxos/credentials";
|
|
4632
4774
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4633
4775
|
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
4634
|
-
import { SpaceMember as
|
|
4776
|
+
import { SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4635
4777
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4636
4778
|
|
|
4637
4779
|
// packages/sdk/client-services/src/version.ts
|
|
4638
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4780
|
+
var DXOS_VERSION = "0.4.10-main.3f5e2d2";
|
|
4639
4781
|
|
|
4640
4782
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4641
4783
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4757,7 +4899,7 @@ var getSpaceStats = async (space) => {
|
|
|
4757
4899
|
displayName: member.assertion.profile?.displayName
|
|
4758
4900
|
}
|
|
4759
4901
|
},
|
|
4760
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4902
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE
|
|
4761
4903
|
})),
|
|
4762
4904
|
pipeline: {
|
|
4763
4905
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4879,11 +5021,10 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
4879
5021
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4880
5022
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4881
5023
|
import { Context as Context11 } from "@dxos/context";
|
|
4882
|
-
import {
|
|
4883
|
-
import
|
|
4884
|
-
import { IndexServiceImpl } from "@dxos/indexing";
|
|
5024
|
+
import { encodeReference } from "@dxos/echo-pipeline";
|
|
5025
|
+
import { getTypeReference } from "@dxos/echo-schema";
|
|
4885
5026
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4886
|
-
import { PublicKey as
|
|
5027
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
4887
5028
|
import { log as log16 } from "@dxos/log";
|
|
4888
5029
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4889
5030
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
@@ -5102,7 +5243,7 @@ var isLocked = (lockPath) => {
|
|
|
5102
5243
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5103
5244
|
import { Event as Event8 } from "@dxos/async";
|
|
5104
5245
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5105
|
-
import { PublicKey as
|
|
5246
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5106
5247
|
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
5107
5248
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5108
5249
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
@@ -5110,7 +5251,7 @@ var LoggingServiceImpl = class {
|
|
|
5110
5251
|
constructor() {
|
|
5111
5252
|
this._logs = new Event8();
|
|
5112
5253
|
this._started = Date.now();
|
|
5113
|
-
this._sessionId =
|
|
5254
|
+
this._sessionId = PublicKey12.random().toHex();
|
|
5114
5255
|
this._logProcessor = (_config, entry2) => {
|
|
5115
5256
|
this._logs.emit(entry2);
|
|
5116
5257
|
};
|
|
@@ -5321,10 +5462,10 @@ var toStorageType = (type) => {
|
|
|
5321
5462
|
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
5322
5463
|
import { Level } from "level";
|
|
5323
5464
|
import path from "@dxos/node-std/path";
|
|
5324
|
-
import { PublicKey as
|
|
5465
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
5325
5466
|
var createLevel = async (config) => {
|
|
5326
5467
|
const persistent = isPersistent(config);
|
|
5327
|
-
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5468
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey13.random().toHex()}`;
|
|
5328
5469
|
const level = new Level(storagePath);
|
|
5329
5470
|
await level.open();
|
|
5330
5471
|
return level;
|
|
@@ -5488,7 +5629,7 @@ var ClientServicesHost = class {
|
|
|
5488
5629
|
initialize({ config, ...options }) {
|
|
5489
5630
|
invariant16(!this._open, "service host is open", {
|
|
5490
5631
|
F: __dxlog_file19,
|
|
5491
|
-
L:
|
|
5632
|
+
L: 190,
|
|
5492
5633
|
S: this,
|
|
5493
5634
|
A: [
|
|
5494
5635
|
"!this._open",
|
|
@@ -5497,14 +5638,14 @@ var ClientServicesHost = class {
|
|
|
5497
5638
|
});
|
|
5498
5639
|
log16("initializing...", void 0, {
|
|
5499
5640
|
F: __dxlog_file19,
|
|
5500
|
-
L:
|
|
5641
|
+
L: 191,
|
|
5501
5642
|
S: this,
|
|
5502
5643
|
C: (f, a) => f(...a)
|
|
5503
5644
|
});
|
|
5504
5645
|
if (config) {
|
|
5505
5646
|
invariant16(!this._config, "config already set", {
|
|
5506
5647
|
F: __dxlog_file19,
|
|
5507
|
-
L:
|
|
5648
|
+
L: 194,
|
|
5508
5649
|
S: this,
|
|
5509
5650
|
A: [
|
|
5510
5651
|
"!this._config",
|
|
@@ -5519,7 +5660,7 @@ var ClientServicesHost = class {
|
|
|
5519
5660
|
if (!options.signalManager) {
|
|
5520
5661
|
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5521
5662
|
F: __dxlog_file19,
|
|
5522
|
-
L:
|
|
5663
|
+
L: 202,
|
|
5523
5664
|
S: this,
|
|
5524
5665
|
C: (f, a) => f(...a)
|
|
5525
5666
|
});
|
|
@@ -5530,7 +5671,7 @@ var ClientServicesHost = class {
|
|
|
5530
5671
|
this._signalManager = signalManager;
|
|
5531
5672
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5532
5673
|
F: __dxlog_file19,
|
|
5533
|
-
L:
|
|
5674
|
+
L: 213,
|
|
5534
5675
|
S: this,
|
|
5535
5676
|
A: [
|
|
5536
5677
|
"!this._networkManager",
|
|
@@ -5544,7 +5685,7 @@ var ClientServicesHost = class {
|
|
|
5544
5685
|
});
|
|
5545
5686
|
log16("initialized", void 0, {
|
|
5546
5687
|
F: __dxlog_file19,
|
|
5547
|
-
L:
|
|
5688
|
+
L: 220,
|
|
5548
5689
|
S: this,
|
|
5549
5690
|
C: (f, a) => f(...a)
|
|
5550
5691
|
});
|
|
@@ -5553,18 +5694,18 @@ var ClientServicesHost = class {
|
|
|
5553
5694
|
if (this._open) {
|
|
5554
5695
|
return;
|
|
5555
5696
|
}
|
|
5556
|
-
const traceId =
|
|
5697
|
+
const traceId = PublicKey14.random().toHex();
|
|
5557
5698
|
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5558
5699
|
id: traceId
|
|
5559
5700
|
}), {
|
|
5560
5701
|
F: __dxlog_file19,
|
|
5561
|
-
L:
|
|
5702
|
+
L: 231,
|
|
5562
5703
|
S: this,
|
|
5563
5704
|
C: (f, a) => f(...a)
|
|
5564
5705
|
});
|
|
5565
5706
|
invariant16(this._config, "config not set", {
|
|
5566
5707
|
F: __dxlog_file19,
|
|
5567
|
-
L:
|
|
5708
|
+
L: 233,
|
|
5568
5709
|
S: this,
|
|
5569
5710
|
A: [
|
|
5570
5711
|
"this._config",
|
|
@@ -5573,7 +5714,7 @@ var ClientServicesHost = class {
|
|
|
5573
5714
|
});
|
|
5574
5715
|
invariant16(this._storage, "storage not set", {
|
|
5575
5716
|
F: __dxlog_file19,
|
|
5576
|
-
L:
|
|
5717
|
+
L: 234,
|
|
5577
5718
|
S: this,
|
|
5578
5719
|
A: [
|
|
5579
5720
|
"this._storage",
|
|
@@ -5582,7 +5723,7 @@ var ClientServicesHost = class {
|
|
|
5582
5723
|
});
|
|
5583
5724
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5584
5725
|
F: __dxlog_file19,
|
|
5585
|
-
L:
|
|
5726
|
+
L: 235,
|
|
5586
5727
|
S: this,
|
|
5587
5728
|
A: [
|
|
5588
5729
|
"this._signalManager",
|
|
@@ -5591,7 +5732,7 @@ var ClientServicesHost = class {
|
|
|
5591
5732
|
});
|
|
5592
5733
|
invariant16(this._networkManager, "network manager not set", {
|
|
5593
5734
|
F: __dxlog_file19,
|
|
5594
|
-
L:
|
|
5735
|
+
L: 236,
|
|
5595
5736
|
S: this,
|
|
5596
5737
|
A: [
|
|
5597
5738
|
"this._networkManager",
|
|
@@ -5603,7 +5744,7 @@ var ClientServicesHost = class {
|
|
|
5603
5744
|
lockKey: this._resourceLock?.lockKey
|
|
5604
5745
|
}, {
|
|
5605
5746
|
F: __dxlog_file19,
|
|
5606
|
-
L:
|
|
5747
|
+
L: 239,
|
|
5607
5748
|
S: this,
|
|
5608
5749
|
C: (f, a) => f(...a)
|
|
5609
5750
|
});
|
|
@@ -5617,17 +5758,14 @@ var ClientServicesHost = class {
|
|
|
5617
5758
|
this._serviceRegistry.setServices({
|
|
5618
5759
|
SystemService: this._systemService,
|
|
5619
5760
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5620
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5761
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5621
5762
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5622
5763
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5623
5764
|
await this._serviceContext.initialized.wait();
|
|
5624
5765
|
return this._serviceContext.dataSpaceManager;
|
|
5625
5766
|
}),
|
|
5626
|
-
DataService:
|
|
5627
|
-
|
|
5628
|
-
indexer: this._serviceContext.indexer,
|
|
5629
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5630
|
-
}),
|
|
5767
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5768
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5631
5769
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5632
5770
|
LoggingService: this._loggingService,
|
|
5633
5771
|
TracingService: this._tracingService,
|
|
@@ -5639,24 +5777,6 @@ var ClientServicesHost = class {
|
|
|
5639
5777
|
})
|
|
5640
5778
|
});
|
|
5641
5779
|
await this._serviceContext.open(ctx);
|
|
5642
|
-
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5643
|
-
F: __dxlog_file19,
|
|
5644
|
-
L: 314,
|
|
5645
|
-
S: this,
|
|
5646
|
-
A: [
|
|
5647
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5648
|
-
""
|
|
5649
|
-
]
|
|
5650
|
-
});
|
|
5651
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5652
|
-
log16("loaded persistent invitations", {
|
|
5653
|
-
count: loadedInvitations.invitations?.length
|
|
5654
|
-
}, {
|
|
5655
|
-
F: __dxlog_file19,
|
|
5656
|
-
L: 317,
|
|
5657
|
-
S: this,
|
|
5658
|
-
C: (f, a) => f(...a)
|
|
5659
|
-
});
|
|
5660
5780
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5661
5781
|
if (devtoolsProxy) {
|
|
5662
5782
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5676,7 +5796,7 @@ var ClientServicesHost = class {
|
|
|
5676
5796
|
deviceKey
|
|
5677
5797
|
}, {
|
|
5678
5798
|
F: __dxlog_file19,
|
|
5679
|
-
L:
|
|
5799
|
+
L: 315,
|
|
5680
5800
|
S: this,
|
|
5681
5801
|
C: (f, a) => f(...a)
|
|
5682
5802
|
});
|
|
@@ -5684,7 +5804,7 @@ var ClientServicesHost = class {
|
|
|
5684
5804
|
id: traceId
|
|
5685
5805
|
}), {
|
|
5686
5806
|
F: __dxlog_file19,
|
|
5687
|
-
L:
|
|
5807
|
+
L: 316,
|
|
5688
5808
|
S: this,
|
|
5689
5809
|
C: (f, a) => f(...a)
|
|
5690
5810
|
});
|
|
@@ -5698,7 +5818,7 @@ var ClientServicesHost = class {
|
|
|
5698
5818
|
deviceKey
|
|
5699
5819
|
}, {
|
|
5700
5820
|
F: __dxlog_file19,
|
|
5701
|
-
L:
|
|
5821
|
+
L: 327,
|
|
5702
5822
|
S: this,
|
|
5703
5823
|
C: (f, a) => f(...a)
|
|
5704
5824
|
});
|
|
@@ -5716,24 +5836,24 @@ var ClientServicesHost = class {
|
|
|
5716
5836
|
deviceKey
|
|
5717
5837
|
}, {
|
|
5718
5838
|
F: __dxlog_file19,
|
|
5719
|
-
L:
|
|
5839
|
+
L: 336,
|
|
5720
5840
|
S: this,
|
|
5721
5841
|
C: (f, a) => f(...a)
|
|
5722
5842
|
});
|
|
5723
5843
|
}
|
|
5724
5844
|
async reset() {
|
|
5725
|
-
const traceId =
|
|
5845
|
+
const traceId = PublicKey14.random().toHex();
|
|
5726
5846
|
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5727
5847
|
id: traceId
|
|
5728
5848
|
}), {
|
|
5729
5849
|
F: __dxlog_file19,
|
|
5730
|
-
L:
|
|
5850
|
+
L: 341,
|
|
5731
5851
|
S: this,
|
|
5732
5852
|
C: (f, a) => f(...a)
|
|
5733
5853
|
});
|
|
5734
5854
|
log16("resetting...", void 0, {
|
|
5735
5855
|
F: __dxlog_file19,
|
|
5736
|
-
L:
|
|
5856
|
+
L: 343,
|
|
5737
5857
|
S: this,
|
|
5738
5858
|
C: (f, a) => f(...a)
|
|
5739
5859
|
});
|
|
@@ -5741,7 +5861,7 @@ var ClientServicesHost = class {
|
|
|
5741
5861
|
await this._storage.reset();
|
|
5742
5862
|
log16("reset", void 0, {
|
|
5743
5863
|
F: __dxlog_file19,
|
|
5744
|
-
L:
|
|
5864
|
+
L: 346,
|
|
5745
5865
|
S: this,
|
|
5746
5866
|
C: (f, a) => f(...a)
|
|
5747
5867
|
});
|
|
@@ -5749,7 +5869,7 @@ var ClientServicesHost = class {
|
|
|
5749
5869
|
id: traceId
|
|
5750
5870
|
}), {
|
|
5751
5871
|
F: __dxlog_file19,
|
|
5752
|
-
L:
|
|
5872
|
+
L: 347,
|
|
5753
5873
|
S: this,
|
|
5754
5874
|
C: (f, a) => f(...a)
|
|
5755
5875
|
});
|
|
@@ -5762,18 +5882,18 @@ var ClientServicesHost = class {
|
|
|
5762
5882
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5763
5883
|
invariant16(automergeIndex, void 0, {
|
|
5764
5884
|
F: __dxlog_file19,
|
|
5765
|
-
L:
|
|
5885
|
+
L: 359,
|
|
5766
5886
|
S: this,
|
|
5767
5887
|
A: [
|
|
5768
5888
|
"automergeIndex",
|
|
5769
5889
|
""
|
|
5770
5890
|
]
|
|
5771
5891
|
});
|
|
5772
|
-
const document = await this._serviceContext.
|
|
5892
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5773
5893
|
await document.whenReady();
|
|
5774
5894
|
const properties = {
|
|
5775
5895
|
system: {
|
|
5776
|
-
type: encodeReference(
|
|
5896
|
+
type: encodeReference(getTypeReference(Properties))
|
|
5777
5897
|
},
|
|
5778
5898
|
data: {
|
|
5779
5899
|
[defaultKey]: identity.identityKey.toHex()
|
|
@@ -5782,14 +5902,14 @@ var ClientServicesHost = class {
|
|
|
5782
5902
|
keys: []
|
|
5783
5903
|
}
|
|
5784
5904
|
};
|
|
5785
|
-
const propertiesId =
|
|
5905
|
+
const propertiesId = PublicKey14.random().toHex();
|
|
5786
5906
|
document.change((doc) => {
|
|
5787
5907
|
assignDeep2(doc, [
|
|
5788
5908
|
"objects",
|
|
5789
5909
|
propertiesId
|
|
5790
5910
|
], properties);
|
|
5791
5911
|
});
|
|
5792
|
-
await this._serviceContext.
|
|
5912
|
+
await this._serviceContext.echoHost.flush();
|
|
5793
5913
|
return identity;
|
|
5794
5914
|
}
|
|
5795
5915
|
};
|
|
@@ -5812,7 +5932,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5812
5932
|
], ClientServicesHost);
|
|
5813
5933
|
|
|
5814
5934
|
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
5815
|
-
import { PublicKey as
|
|
5935
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5816
5936
|
import { humanize } from "@dxos/util";
|
|
5817
5937
|
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5818
5938
|
|
|
@@ -5868,8 +5988,10 @@ export {
|
|
|
5868
5988
|
IdentityServiceImpl,
|
|
5869
5989
|
DeviceInvitationProtocol,
|
|
5870
5990
|
InvitationsHandler,
|
|
5991
|
+
createAdmissionKeypair,
|
|
5871
5992
|
InvitationsServiceImpl,
|
|
5872
5993
|
SpaceInvitationProtocol,
|
|
5994
|
+
InvitationsManager,
|
|
5873
5995
|
ClientRpcServer,
|
|
5874
5996
|
DataSpace,
|
|
5875
5997
|
DataSpaceManager,
|
|
@@ -5887,4 +6009,4 @@ export {
|
|
|
5887
6009
|
ClientServicesHost,
|
|
5888
6010
|
ClientServicesProviderResource
|
|
5889
6011
|
};
|
|
5890
|
-
//# sourceMappingURL=chunk-
|
|
6012
|
+
//# sourceMappingURL=chunk-HIQTBJPW.mjs.map
|