@dxos/client-services 0.4.10-main.8583d5a → 0.4.10-main.85f8e19
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-ZBQ4LQQX.mjs → chunk-GVJIB6RK.mjs} +494 -387
- package/dist/lib/browser/chunk-GVJIB6RK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +3 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-HMAV5VTX.cjs → chunk-GY5U4XLI.cjs} +490 -383
- package/dist/lib/node/chunk-GY5U4XLI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +45 -41
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -7
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/indexing/util.d.ts +2 -1
- package/dist/types/src/packlets/indexing/util.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/invitations-handler.d.ts +4 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +42 -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/services/service-context.d.ts +2 -0
- 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/testing/test-builder.d.ts +3 -4
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/indexing/util.ts +2 -2
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitations-handler.ts +72 -25
- package/src/packlets/invitations/invitations-manager.ts +197 -0
- package/src/packlets/invitations/invitations-service.ts +21 -168
- package/src/packlets/services/service-context.ts +14 -3
- package/src/packlets/services/service-host.ts +5 -14
- package/src/packlets/testing/test-builder.ts +4 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-ZBQ4LQQX.mjs.map +0 -7
- package/dist/lib/node/chunk-HMAV5VTX.cjs.map +0 -7
|
@@ -1282,6 +1282,7 @@ import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Tri
|
|
|
1282
1282
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
1283
1283
|
import { Context as Context5 } from "@dxos/context";
|
|
1284
1284
|
import { generatePasscode } from "@dxos/credentials";
|
|
1285
|
+
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1285
1286
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1286
1287
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1287
1288
|
import { log as log5 } from "@dxos/log";
|
|
@@ -1293,6 +1294,7 @@ import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protoco
|
|
|
1293
1294
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1294
1295
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1295
1296
|
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1297
|
+
import { randomBytes, verify } from "@dxos/crypto";
|
|
1296
1298
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1297
1299
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1298
1300
|
import { log as log4 } from "@dxos/log";
|
|
@@ -1316,6 +1318,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1316
1318
|
this._callbacks = _callbacks;
|
|
1317
1319
|
this._ctx = new Context4();
|
|
1318
1320
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1321
|
+
this._challenge = void 0;
|
|
1319
1322
|
this.invitation = void 0;
|
|
1320
1323
|
this.guestProfile = void 0;
|
|
1321
1324
|
this.authenticationPassed = false;
|
|
@@ -1330,7 +1333,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1330
1333
|
options: async (options) => {
|
|
1331
1334
|
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1332
1335
|
F: __dxlog_file6,
|
|
1333
|
-
L:
|
|
1336
|
+
L: 90,
|
|
1334
1337
|
S: this,
|
|
1335
1338
|
A: [
|
|
1336
1339
|
"!this._remoteOptions",
|
|
@@ -1347,7 +1350,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1347
1350
|
id: traceId
|
|
1348
1351
|
}), {
|
|
1349
1352
|
F: __dxlog_file6,
|
|
1350
|
-
L:
|
|
1353
|
+
L: 99,
|
|
1351
1354
|
S: this,
|
|
1352
1355
|
C: (f, a) => f(...a)
|
|
1353
1356
|
});
|
|
@@ -1357,7 +1360,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1357
1360
|
invitationId
|
|
1358
1361
|
}, {
|
|
1359
1362
|
F: __dxlog_file6,
|
|
1360
|
-
L:
|
|
1363
|
+
L: 103,
|
|
1361
1364
|
S: this,
|
|
1362
1365
|
C: (f, a) => f(...a)
|
|
1363
1366
|
});
|
|
@@ -1371,7 +1374,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1371
1374
|
guestProfile: profile
|
|
1372
1375
|
}, {
|
|
1373
1376
|
F: __dxlog_file6,
|
|
1374
|
-
L:
|
|
1377
|
+
L: 112,
|
|
1375
1378
|
S: this,
|
|
1376
1379
|
C: (f, a) => f(...a)
|
|
1377
1380
|
});
|
|
@@ -1380,25 +1383,27 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1380
1383
|
...this.invitation,
|
|
1381
1384
|
state: Invitation2.State.READY_FOR_AUTHENTICATION
|
|
1382
1385
|
});
|
|
1386
|
+
this._challenge = this.invitation.authMethod === Invitation2.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
1383
1387
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
|
|
1384
1388
|
id: traceId
|
|
1385
1389
|
}), {
|
|
1386
1390
|
F: __dxlog_file6,
|
|
1387
|
-
L:
|
|
1391
|
+
L: 122,
|
|
1388
1392
|
S: this,
|
|
1389
1393
|
C: (f, a) => f(...a)
|
|
1390
1394
|
});
|
|
1391
1395
|
return {
|
|
1392
|
-
authMethod: this.invitation.authMethod
|
|
1396
|
+
authMethod: this.invitation.authMethod,
|
|
1397
|
+
challenge: this._challenge
|
|
1393
1398
|
};
|
|
1394
1399
|
},
|
|
1395
|
-
authenticate: async ({ authCode: code }) => {
|
|
1400
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1396
1401
|
const traceId = PublicKey5.random().toHex();
|
|
1397
1402
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1398
1403
|
id: traceId
|
|
1399
1404
|
}), {
|
|
1400
1405
|
F: __dxlog_file6,
|
|
1401
|
-
L:
|
|
1406
|
+
L: 131,
|
|
1402
1407
|
S: this,
|
|
1403
1408
|
C: (f, a) => f(...a)
|
|
1404
1409
|
});
|
|
@@ -1406,14 +1411,14 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1406
1411
|
authCode: code
|
|
1407
1412
|
}, {
|
|
1408
1413
|
F: __dxlog_file6,
|
|
1409
|
-
L:
|
|
1414
|
+
L: 132,
|
|
1410
1415
|
S: this,
|
|
1411
1416
|
C: (f, a) => f(...a)
|
|
1412
1417
|
});
|
|
1413
1418
|
let status = AuthenticationResponse.Status.OK;
|
|
1414
1419
|
invariant5(this.invitation, "Invitation is not set.", {
|
|
1415
1420
|
F: __dxlog_file6,
|
|
1416
|
-
L:
|
|
1421
|
+
L: 135,
|
|
1417
1422
|
S: this,
|
|
1418
1423
|
A: [
|
|
1419
1424
|
"this.invitation",
|
|
@@ -1424,7 +1429,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1424
1429
|
case Invitation2.AuthMethod.NONE: {
|
|
1425
1430
|
log4("authentication not required", void 0, {
|
|
1426
1431
|
F: __dxlog_file6,
|
|
1427
|
-
L:
|
|
1432
|
+
L: 138,
|
|
1428
1433
|
S: this,
|
|
1429
1434
|
C: (f, a) => f(...a)
|
|
1430
1435
|
});
|
|
@@ -1444,12 +1449,25 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1444
1449
|
}
|
|
1445
1450
|
break;
|
|
1446
1451
|
}
|
|
1452
|
+
case Invitation2.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1453
|
+
if (!this.invitation.guestKeypair) {
|
|
1454
|
+
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
const isSignatureValid = this._challenge && verify(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1458
|
+
if (isSignatureValid) {
|
|
1459
|
+
this.authenticationPassed = true;
|
|
1460
|
+
} else {
|
|
1461
|
+
status = AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1462
|
+
}
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1447
1465
|
default: {
|
|
1448
1466
|
log4.error("invalid authentication method", {
|
|
1449
1467
|
authMethod: this.invitation.authMethod
|
|
1450
1468
|
}, {
|
|
1451
1469
|
F: __dxlog_file6,
|
|
1452
|
-
L:
|
|
1470
|
+
L: 176,
|
|
1453
1471
|
S: this,
|
|
1454
1472
|
C: (f, a) => f(...a)
|
|
1455
1473
|
});
|
|
@@ -1464,7 +1482,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1464
1482
|
}
|
|
1465
1483
|
}), {
|
|
1466
1484
|
F: __dxlog_file6,
|
|
1467
|
-
L:
|
|
1485
|
+
L: 182,
|
|
1468
1486
|
S: this,
|
|
1469
1487
|
C: (f, a) => f(...a)
|
|
1470
1488
|
});
|
|
@@ -1478,14 +1496,14 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1478
1496
|
id: traceId
|
|
1479
1497
|
}), {
|
|
1480
1498
|
F: __dxlog_file6,
|
|
1481
|
-
L:
|
|
1499
|
+
L: 188,
|
|
1482
1500
|
S: this,
|
|
1483
1501
|
C: (f, a) => f(...a)
|
|
1484
1502
|
});
|
|
1485
1503
|
try {
|
|
1486
1504
|
invariant5(this.invitation, "Invitation is not set.", {
|
|
1487
1505
|
F: __dxlog_file6,
|
|
1488
|
-
L:
|
|
1506
|
+
L: 191,
|
|
1489
1507
|
S: this,
|
|
1490
1508
|
A: [
|
|
1491
1509
|
"this.invitation",
|
|
@@ -1500,7 +1518,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1500
1518
|
id: traceId
|
|
1501
1519
|
}), {
|
|
1502
1520
|
F: __dxlog_file6,
|
|
1503
|
-
L:
|
|
1521
|
+
L: 199,
|
|
1504
1522
|
S: this,
|
|
1505
1523
|
C: (f, a) => f(...a)
|
|
1506
1524
|
});
|
|
@@ -1557,7 +1575,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1557
1575
|
options: async (options) => {
|
|
1558
1576
|
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1559
1577
|
F: __dxlog_file6,
|
|
1560
|
-
L:
|
|
1578
|
+
L: 266,
|
|
1561
1579
|
S: this,
|
|
1562
1580
|
A: [
|
|
1563
1581
|
"!this._remoteOptions",
|
|
@@ -1584,7 +1602,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1584
1602
|
try {
|
|
1585
1603
|
log4("begin options", void 0, {
|
|
1586
1604
|
F: __dxlog_file6,
|
|
1587
|
-
L:
|
|
1605
|
+
L: 287,
|
|
1588
1606
|
S: this,
|
|
1589
1607
|
C: (f, a) => f(...a)
|
|
1590
1608
|
});
|
|
@@ -1596,7 +1614,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1596
1614
|
}));
|
|
1597
1615
|
log4("end options", void 0, {
|
|
1598
1616
|
F: __dxlog_file6,
|
|
1599
|
-
L:
|
|
1617
|
+
L: 290,
|
|
1600
1618
|
S: this,
|
|
1601
1619
|
C: (f, a) => f(...a)
|
|
1602
1620
|
});
|
|
@@ -1610,7 +1628,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1610
1628
|
} catch (err) {
|
|
1611
1629
|
log4("openError", err, {
|
|
1612
1630
|
F: __dxlog_file6,
|
|
1613
|
-
L:
|
|
1631
|
+
L: 300,
|
|
1614
1632
|
S: this,
|
|
1615
1633
|
C: (f, a) => f(...a)
|
|
1616
1634
|
});
|
|
@@ -1620,7 +1638,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1620
1638
|
async onClose() {
|
|
1621
1639
|
log4("onClose", void 0, {
|
|
1622
1640
|
F: __dxlog_file6,
|
|
1623
|
-
L:
|
|
1641
|
+
L: 306,
|
|
1624
1642
|
S: this,
|
|
1625
1643
|
C: (f, a) => f(...a)
|
|
1626
1644
|
});
|
|
@@ -1639,11 +1657,11 @@ var InvitationsHandler = class {
|
|
|
1639
1657
|
this._networkManager = _networkManager;
|
|
1640
1658
|
}
|
|
1641
1659
|
createInvitation(protocol, options) {
|
|
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 =
|
|
1660
|
+
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 = options?.authMethod !== Invitation3.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
1643
1661
|
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1644
1662
|
invariant6(protocol, void 0, {
|
|
1645
1663
|
F: __dxlog_file7,
|
|
1646
|
-
L:
|
|
1664
|
+
L: 87,
|
|
1647
1665
|
S: this,
|
|
1648
1666
|
A: [
|
|
1649
1667
|
"protocol",
|
|
@@ -1658,7 +1676,8 @@ var InvitationsHandler = class {
|
|
|
1658
1676
|
swarmKey,
|
|
1659
1677
|
authCode,
|
|
1660
1678
|
timeout,
|
|
1661
|
-
persistent: persistent && type !== Invitation3.Type.
|
|
1679
|
+
persistent: persistent && type !== Invitation3.Type.DELEGATED,
|
|
1680
|
+
guestKeypair: guestKeypair ?? (authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1662
1681
|
created,
|
|
1663
1682
|
lifetime,
|
|
1664
1683
|
multiUse,
|
|
@@ -1676,7 +1695,7 @@ var InvitationsHandler = class {
|
|
|
1676
1695
|
...protocol.toJSON()
|
|
1677
1696
|
}, {
|
|
1678
1697
|
F: __dxlog_file7,
|
|
1679
|
-
L:
|
|
1698
|
+
L: 115,
|
|
1680
1699
|
S: this,
|
|
1681
1700
|
C: (f, a) => f(...a)
|
|
1682
1701
|
});
|
|
@@ -1701,7 +1720,7 @@ var InvitationsHandler = class {
|
|
|
1701
1720
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1702
1721
|
invariant6(deviceKey, void 0, {
|
|
1703
1722
|
F: __dxlog_file7,
|
|
1704
|
-
L:
|
|
1723
|
+
L: 136,
|
|
1705
1724
|
S: this,
|
|
1706
1725
|
A: [
|
|
1707
1726
|
"deviceKey",
|
|
@@ -1724,7 +1743,7 @@ var InvitationsHandler = class {
|
|
|
1724
1743
|
id: traceId
|
|
1725
1744
|
}), {
|
|
1726
1745
|
F: __dxlog_file7,
|
|
1727
|
-
L:
|
|
1746
|
+
L: 154,
|
|
1728
1747
|
S: this,
|
|
1729
1748
|
C: (f, a) => f(...a)
|
|
1730
1749
|
});
|
|
@@ -1732,7 +1751,7 @@ var InvitationsHandler = class {
|
|
|
1732
1751
|
...protocol.toJSON()
|
|
1733
1752
|
}, {
|
|
1734
1753
|
F: __dxlog_file7,
|
|
1735
|
-
L:
|
|
1754
|
+
L: 155,
|
|
1736
1755
|
S: this,
|
|
1737
1756
|
C: (f, a) => f(...a)
|
|
1738
1757
|
});
|
|
@@ -1748,7 +1767,7 @@ var InvitationsHandler = class {
|
|
|
1748
1767
|
...protocol.toJSON()
|
|
1749
1768
|
}, {
|
|
1750
1769
|
F: __dxlog_file7,
|
|
1751
|
-
L:
|
|
1770
|
+
L: 158,
|
|
1752
1771
|
S: this,
|
|
1753
1772
|
C: (f, a) => f(...a)
|
|
1754
1773
|
});
|
|
@@ -1760,7 +1779,7 @@ var InvitationsHandler = class {
|
|
|
1760
1779
|
id: traceId
|
|
1761
1780
|
}), {
|
|
1762
1781
|
F: __dxlog_file7,
|
|
1763
|
-
L:
|
|
1782
|
+
L: 160,
|
|
1764
1783
|
S: this,
|
|
1765
1784
|
C: (f, a) => f(...a)
|
|
1766
1785
|
});
|
|
@@ -1770,7 +1789,7 @@ var InvitationsHandler = class {
|
|
|
1770
1789
|
...protocol.toJSON()
|
|
1771
1790
|
}, {
|
|
1772
1791
|
F: __dxlog_file7,
|
|
1773
|
-
L:
|
|
1792
|
+
L: 163,
|
|
1774
1793
|
S: this,
|
|
1775
1794
|
C: (f, a) => f(...a)
|
|
1776
1795
|
});
|
|
@@ -1781,7 +1800,7 @@ var InvitationsHandler = class {
|
|
|
1781
1800
|
} else {
|
|
1782
1801
|
log5.error("failed", err, {
|
|
1783
1802
|
F: __dxlog_file7,
|
|
1784
|
-
L:
|
|
1803
|
+
L: 166,
|
|
1785
1804
|
S: this,
|
|
1786
1805
|
C: (f, a) => f(...a)
|
|
1787
1806
|
});
|
|
@@ -1792,7 +1811,7 @@ var InvitationsHandler = class {
|
|
|
1792
1811
|
error: err
|
|
1793
1812
|
}), {
|
|
1794
1813
|
F: __dxlog_file7,
|
|
1795
|
-
L:
|
|
1814
|
+
L: 169,
|
|
1796
1815
|
S: this,
|
|
1797
1816
|
C: (f, a) => f(...a)
|
|
1798
1817
|
});
|
|
@@ -1813,7 +1832,7 @@ var InvitationsHandler = class {
|
|
|
1813
1832
|
...protocol.toJSON()
|
|
1814
1833
|
}, {
|
|
1815
1834
|
F: __dxlog_file7,
|
|
1816
|
-
L:
|
|
1835
|
+
L: 184,
|
|
1817
1836
|
S: this,
|
|
1818
1837
|
C: (f, a) => f(...a)
|
|
1819
1838
|
});
|
|
@@ -1824,7 +1843,7 @@ var InvitationsHandler = class {
|
|
|
1824
1843
|
} else {
|
|
1825
1844
|
log5.error("failed", err, {
|
|
1826
1845
|
F: __dxlog_file7,
|
|
1827
|
-
L:
|
|
1846
|
+
L: 187,
|
|
1828
1847
|
S: this,
|
|
1829
1848
|
C: (f, a) => f(...a)
|
|
1830
1849
|
});
|
|
@@ -1834,11 +1853,11 @@ var InvitationsHandler = class {
|
|
|
1834
1853
|
});
|
|
1835
1854
|
return extension;
|
|
1836
1855
|
};
|
|
1837
|
-
if (invitation.lifetime && invitation.created
|
|
1856
|
+
if (invitation.lifetime && invitation.created) {
|
|
1838
1857
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1839
1858
|
log5.warn("invitation has already expired", void 0, {
|
|
1840
1859
|
F: __dxlog_file7,
|
|
1841
|
-
L:
|
|
1860
|
+
L: 198,
|
|
1842
1861
|
S: this,
|
|
1843
1862
|
C: (f, a) => f(...a)
|
|
1844
1863
|
});
|
|
@@ -1889,7 +1908,7 @@ var InvitationsHandler = class {
|
|
|
1889
1908
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1890
1909
|
invariant6(protocol, void 0, {
|
|
1891
1910
|
F: __dxlog_file7,
|
|
1892
|
-
L:
|
|
1911
|
+
L: 252,
|
|
1893
1912
|
S: this,
|
|
1894
1913
|
A: [
|
|
1895
1914
|
"protocol",
|
|
@@ -1899,7 +1918,7 @@ var InvitationsHandler = class {
|
|
|
1899
1918
|
if (deviceProfile) {
|
|
1900
1919
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1901
1920
|
F: __dxlog_file7,
|
|
1902
|
-
L:
|
|
1921
|
+
L: 255,
|
|
1903
1922
|
S: this,
|
|
1904
1923
|
A: [
|
|
1905
1924
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1914,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1914
1933
|
const setState = (newData) => {
|
|
1915
1934
|
invariant6(newData.state !== void 0, void 0, {
|
|
1916
1935
|
F: __dxlog_file7,
|
|
1917
|
-
L:
|
|
1936
|
+
L: 266,
|
|
1918
1937
|
S: this,
|
|
1919
1938
|
A: [
|
|
1920
1939
|
"newData.state !== undefined",
|
|
@@ -1934,7 +1953,7 @@ var InvitationsHandler = class {
|
|
|
1934
1953
|
...protocol.toJSON()
|
|
1935
1954
|
}, {
|
|
1936
1955
|
F: __dxlog_file7,
|
|
1937
|
-
L:
|
|
1956
|
+
L: 274,
|
|
1938
1957
|
S: this,
|
|
1939
1958
|
C: (f, a) => f(...a)
|
|
1940
1959
|
});
|
|
@@ -1944,7 +1963,7 @@ var InvitationsHandler = class {
|
|
|
1944
1963
|
} else {
|
|
1945
1964
|
log5.warn("auth failed", err, {
|
|
1946
1965
|
F: __dxlog_file7,
|
|
1947
|
-
L:
|
|
1966
|
+
L: 277,
|
|
1948
1967
|
S: this,
|
|
1949
1968
|
C: (f, a) => f(...a)
|
|
1950
1969
|
});
|
|
@@ -1958,7 +1977,7 @@ var InvitationsHandler = class {
|
|
|
1958
1977
|
...protocol.toJSON()
|
|
1959
1978
|
}, {
|
|
1960
1979
|
F: __dxlog_file7,
|
|
1961
|
-
L:
|
|
1980
|
+
L: 285,
|
|
1962
1981
|
S: this,
|
|
1963
1982
|
C: (f, a) => f(...a)
|
|
1964
1983
|
});
|
|
@@ -1973,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1973
1992
|
currentState
|
|
1974
1993
|
}, {
|
|
1975
1994
|
F: __dxlog_file7,
|
|
1976
|
-
L:
|
|
1995
|
+
L: 295,
|
|
1977
1996
|
S: this,
|
|
1978
1997
|
C: (f, a) => f(...a)
|
|
1979
1998
|
});
|
|
@@ -1988,7 +2007,7 @@ var InvitationsHandler = class {
|
|
|
1988
2007
|
id: traceId
|
|
1989
2008
|
}), {
|
|
1990
2009
|
F: __dxlog_file7,
|
|
1991
|
-
L:
|
|
2010
|
+
L: 304,
|
|
1992
2011
|
S: this,
|
|
1993
2012
|
C: (f, a) => f(...a)
|
|
1994
2013
|
});
|
|
@@ -2000,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
2000
2019
|
...protocol.toJSON()
|
|
2001
2020
|
}, {
|
|
2002
2021
|
F: __dxlog_file7,
|
|
2003
|
-
L:
|
|
2022
|
+
L: 312,
|
|
2004
2023
|
S: this,
|
|
2005
2024
|
C: (f, a) => f(...a)
|
|
2006
2025
|
});
|
|
@@ -2011,7 +2030,7 @@ var InvitationsHandler = class {
|
|
|
2011
2030
|
...protocol.toJSON()
|
|
2012
2031
|
}, {
|
|
2013
2032
|
F: __dxlog_file7,
|
|
2014
|
-
L:
|
|
2033
|
+
L: 316,
|
|
2015
2034
|
S: this,
|
|
2016
2035
|
C: (f, a) => f(...a)
|
|
2017
2036
|
});
|
|
@@ -2021,62 +2040,28 @@ var InvitationsHandler = class {
|
|
|
2021
2040
|
response: introductionResponse
|
|
2022
2041
|
}, {
|
|
2023
2042
|
F: __dxlog_file7,
|
|
2024
|
-
L:
|
|
2043
|
+
L: 320,
|
|
2025
2044
|
S: this,
|
|
2026
2045
|
C: (f, a) => f(...a)
|
|
2027
2046
|
});
|
|
2028
2047
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2029
2048
|
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) {
|
|
2049
|
+
switch (invitation.authMethod) {
|
|
2050
|
+
case Invitation3.AuthMethod.SHARED_SECRET:
|
|
2051
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2052
|
+
timeout
|
|
2053
|
+
});
|
|
2054
|
+
break;
|
|
2055
|
+
case Invitation3.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2056
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2056
2057
|
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
2058
|
}
|
|
2074
2059
|
}
|
|
2075
2060
|
log5("request admission", {
|
|
2076
2061
|
...protocol.toJSON()
|
|
2077
2062
|
}, {
|
|
2078
2063
|
F: __dxlog_file7,
|
|
2079
|
-
L:
|
|
2064
|
+
L: 336,
|
|
2080
2065
|
S: this,
|
|
2081
2066
|
C: (f, a) => f(...a)
|
|
2082
2067
|
});
|
|
@@ -2088,7 +2073,7 @@ var InvitationsHandler = class {
|
|
|
2088
2073
|
...protocol.toJSON()
|
|
2089
2074
|
}, {
|
|
2090
2075
|
F: __dxlog_file7,
|
|
2091
|
-
L:
|
|
2076
|
+
L: 347,
|
|
2092
2077
|
S: this,
|
|
2093
2078
|
C: (f, a) => f(...a)
|
|
2094
2079
|
});
|
|
@@ -2101,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2101
2086
|
id: traceId
|
|
2102
2087
|
}), {
|
|
2103
2088
|
F: __dxlog_file7,
|
|
2104
|
-
L:
|
|
2089
|
+
L: 349,
|
|
2105
2090
|
S: this,
|
|
2106
2091
|
C: (f, a) => f(...a)
|
|
2107
2092
|
});
|
|
@@ -2111,7 +2096,7 @@ var InvitationsHandler = class {
|
|
|
2111
2096
|
...protocol.toJSON()
|
|
2112
2097
|
}, {
|
|
2113
2098
|
F: __dxlog_file7,
|
|
2114
|
-
L:
|
|
2099
|
+
L: 352,
|
|
2115
2100
|
S: this,
|
|
2116
2101
|
C: (f, a) => f(...a)
|
|
2117
2102
|
});
|
|
@@ -2121,7 +2106,7 @@ var InvitationsHandler = class {
|
|
|
2121
2106
|
} else {
|
|
2122
2107
|
log5("auth failed", err, {
|
|
2123
2108
|
F: __dxlog_file7,
|
|
2124
|
-
L:
|
|
2109
|
+
L: 355,
|
|
2125
2110
|
S: this,
|
|
2126
2111
|
C: (f, a) => f(...a)
|
|
2127
2112
|
});
|
|
@@ -2132,7 +2117,7 @@ var InvitationsHandler = class {
|
|
|
2132
2117
|
error: err
|
|
2133
2118
|
}), {
|
|
2134
2119
|
F: __dxlog_file7,
|
|
2135
|
-
L:
|
|
2120
|
+
L: 358,
|
|
2136
2121
|
S: this,
|
|
2137
2122
|
C: (f, a) => f(...a)
|
|
2138
2123
|
});
|
|
@@ -2150,7 +2135,7 @@ var InvitationsHandler = class {
|
|
|
2150
2135
|
...protocol.toJSON()
|
|
2151
2136
|
}, {
|
|
2152
2137
|
F: __dxlog_file7,
|
|
2153
|
-
L:
|
|
2138
|
+
L: 369,
|
|
2154
2139
|
S: this,
|
|
2155
2140
|
C: (f, a) => f(...a)
|
|
2156
2141
|
});
|
|
@@ -2160,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2160
2145
|
} else {
|
|
2161
2146
|
log5("auth failed", err, {
|
|
2162
2147
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2148
|
+
L: 372,
|
|
2164
2149
|
S: this,
|
|
2165
2150
|
C: (f, a) => f(...a)
|
|
2166
2151
|
});
|
|
@@ -2177,7 +2162,7 @@ var InvitationsHandler = class {
|
|
|
2177
2162
|
} else {
|
|
2178
2163
|
invariant6(invitation.swarmKey, void 0, {
|
|
2179
2164
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2165
|
+
L: 386,
|
|
2181
2166
|
S: this,
|
|
2182
2167
|
A: [
|
|
2183
2168
|
"invitation.swarmKey",
|
|
@@ -2215,204 +2200,115 @@ var InvitationsHandler = class {
|
|
|
2215
2200
|
});
|
|
2216
2201
|
return observable;
|
|
2217
2202
|
}
|
|
2203
|
+
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2204
|
+
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2205
|
+
log5("guest waiting for authentication code...", void 0, {
|
|
2206
|
+
F: __dxlog_file7,
|
|
2207
|
+
L: 426,
|
|
2208
|
+
S: this,
|
|
2209
|
+
C: (f, a) => f(...a)
|
|
2210
|
+
});
|
|
2211
|
+
setState({
|
|
2212
|
+
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
2213
|
+
});
|
|
2214
|
+
const authCode = await authenticated.wait(options);
|
|
2215
|
+
log5("sending authentication request", void 0, {
|
|
2216
|
+
F: __dxlog_file7,
|
|
2217
|
+
L: 430,
|
|
2218
|
+
S: this,
|
|
2219
|
+
C: (f, a) => f(...a)
|
|
2220
|
+
});
|
|
2221
|
+
setState({
|
|
2222
|
+
state: Invitation3.State.AUTHENTICATING
|
|
2223
|
+
});
|
|
2224
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2225
|
+
authCode
|
|
2226
|
+
});
|
|
2227
|
+
if (response.status === void 0 || response.status === AuthenticationResponse2.Status.OK) {
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
if (response.status === AuthenticationResponse2.Status.INVALID_OTP) {
|
|
2231
|
+
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2232
|
+
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2233
|
+
} else {
|
|
2234
|
+
log5("retrying invalid code", {
|
|
2235
|
+
attempt
|
|
2236
|
+
}, {
|
|
2237
|
+
F: __dxlog_file7,
|
|
2238
|
+
L: 441,
|
|
2239
|
+
S: this,
|
|
2240
|
+
C: (f, a) => f(...a)
|
|
2241
|
+
});
|
|
2242
|
+
authenticated.reset();
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
|
|
2248
|
+
if (invitation.guestKeypair?.privateKey == null) {
|
|
2249
|
+
throw new Error("keypair missing in the invitation");
|
|
2250
|
+
}
|
|
2251
|
+
if (introductionResponse.challenge == null) {
|
|
2252
|
+
throw new Error("challenge missing in the introduction");
|
|
2253
|
+
}
|
|
2254
|
+
log5("sending authentication request", void 0, {
|
|
2255
|
+
F: __dxlog_file7,
|
|
2256
|
+
L: 460,
|
|
2257
|
+
S: this,
|
|
2258
|
+
C: (f, a) => f(...a)
|
|
2259
|
+
});
|
|
2260
|
+
setState({
|
|
2261
|
+
state: Invitation3.State.AUTHENTICATING
|
|
2262
|
+
});
|
|
2263
|
+
const signature = sign(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2264
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2265
|
+
signedChallenge: signature
|
|
2266
|
+
});
|
|
2267
|
+
if (response.status !== AuthenticationResponse2.Status.OK) {
|
|
2268
|
+
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
var createAdmissionKeypair = () => {
|
|
2273
|
+
const keypair = createKeyPair();
|
|
2274
|
+
return {
|
|
2275
|
+
publicKey: PublicKey6.from(keypair.publicKey),
|
|
2276
|
+
privateKey: keypair.secretKey
|
|
2277
|
+
};
|
|
2218
2278
|
};
|
|
2219
2279
|
|
|
2220
2280
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2221
|
-
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2222
2281
|
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";
|
|
2282
|
+
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2229
2283
|
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;
|
|
2284
|
+
constructor(_invitationsManager) {
|
|
2285
|
+
this._invitationsManager = _invitationsManager;
|
|
2243
2286
|
}
|
|
2244
2287
|
// TODO(burdon): Guest/host label.
|
|
2245
2288
|
getLoggingContext() {
|
|
2246
2289
|
return {};
|
|
2247
2290
|
}
|
|
2248
2291
|
createInvitation(options) {
|
|
2249
|
-
|
|
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
|
-
}
|
|
2292
|
+
const invitation = this._invitationsManager.createInvitation(options);
|
|
2260
2293
|
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
|
-
});
|
|
2294
|
+
invitation.subscribe(next, close, close);
|
|
2287
2295
|
});
|
|
2288
2296
|
}
|
|
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
|
-
}
|
|
2297
|
+
acceptInvitation(request) {
|
|
2298
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2336
2299
|
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
|
-
});
|
|
2300
|
+
invitation.subscribe(next, close, close);
|
|
2348
2301
|
});
|
|
2349
2302
|
}
|
|
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
|
-
}
|
|
2303
|
+
async authenticate(request) {
|
|
2304
|
+
return this._invitationsManager.authenticate(request);
|
|
2379
2305
|
}
|
|
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
|
-
}
|
|
2306
|
+
async cancelInvitation(request) {
|
|
2307
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2412
2308
|
}
|
|
2413
2309
|
queryInvitations() {
|
|
2414
2310
|
return new Stream8(({ next, ctx }) => {
|
|
2415
|
-
this.
|
|
2311
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2416
2312
|
next({
|
|
2417
2313
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2418
2314
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2421,7 +2317,7 @@ var InvitationsServiceImpl = class {
|
|
|
2421
2317
|
]
|
|
2422
2318
|
});
|
|
2423
2319
|
});
|
|
2424
|
-
this.
|
|
2320
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2425
2321
|
next({
|
|
2426
2322
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2427
2323
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2430,7 +2326,7 @@ var InvitationsServiceImpl = class {
|
|
|
2430
2326
|
]
|
|
2431
2327
|
});
|
|
2432
2328
|
});
|
|
2433
|
-
this.
|
|
2329
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2434
2330
|
next({
|
|
2435
2331
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2436
2332
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2439,7 +2335,7 @@ var InvitationsServiceImpl = class {
|
|
|
2439
2335
|
]
|
|
2440
2336
|
});
|
|
2441
2337
|
});
|
|
2442
|
-
this.
|
|
2338
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2443
2339
|
next({
|
|
2444
2340
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2445
2341
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2448,7 +2344,7 @@ var InvitationsServiceImpl = class {
|
|
|
2448
2344
|
]
|
|
2449
2345
|
});
|
|
2450
2346
|
});
|
|
2451
|
-
this.
|
|
2347
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2452
2348
|
next({
|
|
2453
2349
|
action: QueryInvitationsResponse.Action.SAVED,
|
|
2454
2350
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2460,28 +2356,21 @@ var InvitationsServiceImpl = class {
|
|
|
2460
2356
|
next({
|
|
2461
2357
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2462
2358
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2463
|
-
invitations:
|
|
2359
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2464
2360
|
existing: true
|
|
2465
2361
|
});
|
|
2466
2362
|
next({
|
|
2467
2363
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2468
2364
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2469
|
-
invitations:
|
|
2365
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2470
2366
|
existing: true
|
|
2471
2367
|
});
|
|
2472
|
-
|
|
2368
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2473
2369
|
next({
|
|
2474
2370
|
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2475
2371
|
type: QueryInvitationsResponse.Type.CREATED
|
|
2476
2372
|
});
|
|
2477
|
-
}
|
|
2478
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2479
|
-
next({
|
|
2480
|
-
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2481
|
-
type: QueryInvitationsResponse.Type.CREATED
|
|
2482
|
-
});
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2373
|
+
});
|
|
2485
2374
|
});
|
|
2486
2375
|
}
|
|
2487
2376
|
};
|
|
@@ -2489,11 +2378,11 @@ var InvitationsServiceImpl = class {
|
|
|
2489
2378
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2490
2379
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2491
2380
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2492
|
-
import { invariant as
|
|
2493
|
-
import { log as
|
|
2381
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2382
|
+
import { log as log6 } from "@dxos/log";
|
|
2494
2383
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2495
|
-
import { Invitation as
|
|
2496
|
-
var
|
|
2384
|
+
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2385
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2497
2386
|
var SpaceInvitationProtocol = class {
|
|
2498
2387
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2499
2388
|
this._spaceManager = _spaceManager;
|
|
@@ -2509,13 +2398,13 @@ var SpaceInvitationProtocol = class {
|
|
|
2509
2398
|
}
|
|
2510
2399
|
getInvitationContext() {
|
|
2511
2400
|
return {
|
|
2512
|
-
kind:
|
|
2401
|
+
kind: Invitation4.Kind.SPACE,
|
|
2513
2402
|
spaceKey: this._spaceKey
|
|
2514
2403
|
};
|
|
2515
2404
|
}
|
|
2516
2405
|
async admit(request, guestProfile) {
|
|
2517
|
-
|
|
2518
|
-
F:
|
|
2406
|
+
invariant7(this._spaceKey, void 0, {
|
|
2407
|
+
F: __dxlog_file8,
|
|
2519
2408
|
L: 47,
|
|
2520
2409
|
S: this,
|
|
2521
2410
|
A: [
|
|
@@ -2524,8 +2413,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2524
2413
|
]
|
|
2525
2414
|
});
|
|
2526
2415
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2527
|
-
|
|
2528
|
-
F:
|
|
2416
|
+
invariant7(space, void 0, {
|
|
2417
|
+
F: __dxlog_file8,
|
|
2529
2418
|
L: 49,
|
|
2530
2419
|
S: this,
|
|
2531
2420
|
A: [
|
|
@@ -2533,8 +2422,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2533
2422
|
""
|
|
2534
2423
|
]
|
|
2535
2424
|
});
|
|
2536
|
-
|
|
2537
|
-
F:
|
|
2425
|
+
invariant7(request.space, void 0, {
|
|
2426
|
+
F: __dxlog_file8,
|
|
2538
2427
|
L: 51,
|
|
2539
2428
|
S: this,
|
|
2540
2429
|
A: [
|
|
@@ -2543,18 +2432,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2543
2432
|
]
|
|
2544
2433
|
});
|
|
2545
2434
|
const { identityKey, deviceKey } = request.space;
|
|
2546
|
-
|
|
2435
|
+
log6("writing guest credentials", {
|
|
2547
2436
|
host: this._signingContext.deviceKey,
|
|
2548
2437
|
guest: deviceKey
|
|
2549
2438
|
}, {
|
|
2550
|
-
F:
|
|
2439
|
+
F: __dxlog_file8,
|
|
2551
2440
|
L: 54,
|
|
2552
2441
|
S: this,
|
|
2553
2442
|
C: (f, a) => f(...a)
|
|
2554
2443
|
});
|
|
2555
2444
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2556
|
-
|
|
2557
|
-
F:
|
|
2445
|
+
invariant7(credentials[0].credential, void 0, {
|
|
2446
|
+
F: __dxlog_file8,
|
|
2558
2447
|
L: 65,
|
|
2559
2448
|
S: this,
|
|
2560
2449
|
A: [
|
|
@@ -2563,8 +2452,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2563
2452
|
]
|
|
2564
2453
|
});
|
|
2565
2454
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2566
|
-
|
|
2567
|
-
F:
|
|
2455
|
+
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2456
|
+
F: __dxlog_file8,
|
|
2568
2457
|
L: 67,
|
|
2569
2458
|
S: this,
|
|
2570
2459
|
A: [
|
|
@@ -2603,8 +2492,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2603
2492
|
};
|
|
2604
2493
|
}
|
|
2605
2494
|
async accept(response) {
|
|
2606
|
-
|
|
2607
|
-
F:
|
|
2495
|
+
invariant7(response.space, void 0, {
|
|
2496
|
+
F: __dxlog_file8,
|
|
2608
2497
|
L: 107,
|
|
2609
2498
|
S: this,
|
|
2610
2499
|
A: [
|
|
@@ -2614,8 +2503,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2614
2503
|
});
|
|
2615
2504
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2616
2505
|
const assertion = getCredentialAssertion(credential);
|
|
2617
|
-
|
|
2618
|
-
F:
|
|
2506
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2507
|
+
F: __dxlog_file8,
|
|
2619
2508
|
L: 110,
|
|
2620
2509
|
S: this,
|
|
2621
2510
|
A: [
|
|
@@ -2623,8 +2512,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2623
2512
|
"'Invalid credential'"
|
|
2624
2513
|
]
|
|
2625
2514
|
});
|
|
2626
|
-
|
|
2627
|
-
F:
|
|
2515
|
+
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2516
|
+
F: __dxlog_file8,
|
|
2628
2517
|
L: 111,
|
|
2629
2518
|
S: this,
|
|
2630
2519
|
A: [
|
|
@@ -2648,6 +2537,227 @@ var SpaceInvitationProtocol = class {
|
|
|
2648
2537
|
}
|
|
2649
2538
|
};
|
|
2650
2539
|
|
|
2540
|
+
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
2541
|
+
import { Event as Event3 } from "@dxos/async";
|
|
2542
|
+
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2543
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2544
|
+
import { log as log7 } from "@dxos/log";
|
|
2545
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2546
|
+
var InvitationsManager = class {
|
|
2547
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2548
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2549
|
+
this._getHandler = _getHandler;
|
|
2550
|
+
this._metadataStore = _metadataStore;
|
|
2551
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2552
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2553
|
+
this.invitationCreated = new Event3();
|
|
2554
|
+
this.invitationAccepted = new Event3();
|
|
2555
|
+
this.removedCreated = new Event3();
|
|
2556
|
+
this.removedAccepted = new Event3();
|
|
2557
|
+
this.saved = new Event3();
|
|
2558
|
+
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2559
|
+
this._persistentInvitationsLoaded = false;
|
|
2560
|
+
}
|
|
2561
|
+
createInvitation(options) {
|
|
2562
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2563
|
+
if (existingInvitation) {
|
|
2564
|
+
return existingInvitation;
|
|
2565
|
+
}
|
|
2566
|
+
const handler = this._getHandler(options);
|
|
2567
|
+
const invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2568
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2569
|
+
this.invitationCreated.emit(invitation.get());
|
|
2570
|
+
const saveInvitationTask = invitation.get().persistent ? this._safePersistInBackground(invitation) : Promise.resolve();
|
|
2571
|
+
this._onInvitationComplete(invitation, async () => {
|
|
2572
|
+
this._createInvitations.delete(invitation.get().invitationId);
|
|
2573
|
+
this.removedCreated.emit(invitation.get());
|
|
2574
|
+
if (invitation.get().persistent) {
|
|
2575
|
+
await saveInvitationTask;
|
|
2576
|
+
await this._safeDeleteInvitation(invitation.get());
|
|
2577
|
+
}
|
|
2578
|
+
});
|
|
2579
|
+
return invitation;
|
|
2580
|
+
}
|
|
2581
|
+
async loadPersistentInvitations() {
|
|
2582
|
+
if (this._persistentInvitationsLoaded) {
|
|
2583
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2584
|
+
return {
|
|
2585
|
+
invitations
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
try {
|
|
2589
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2590
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
2591
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2592
|
+
invariant8(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2593
|
+
F: __dxlog_file9,
|
|
2594
|
+
L: 82,
|
|
2595
|
+
S: this,
|
|
2596
|
+
A: [
|
|
2597
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2598
|
+
"'invitation already exists'"
|
|
2599
|
+
]
|
|
2600
|
+
});
|
|
2601
|
+
return this.createInvitation({
|
|
2602
|
+
...persistentInvitation,
|
|
2603
|
+
persistent: false
|
|
2604
|
+
}).get();
|
|
2605
|
+
});
|
|
2606
|
+
return {
|
|
2607
|
+
invitations: cInvitations
|
|
2608
|
+
};
|
|
2609
|
+
} catch (err) {
|
|
2610
|
+
log7.catch(err, void 0, {
|
|
2611
|
+
F: __dxlog_file9,
|
|
2612
|
+
L: 88,
|
|
2613
|
+
S: this,
|
|
2614
|
+
C: (f, a) => f(...a)
|
|
2615
|
+
});
|
|
2616
|
+
return {
|
|
2617
|
+
invitations: []
|
|
2618
|
+
};
|
|
2619
|
+
} finally {
|
|
2620
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2621
|
+
this._persistentInvitationsLoaded = true;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
acceptInvitation(request) {
|
|
2625
|
+
const options = request.invitation;
|
|
2626
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2627
|
+
if (existingInvitation) {
|
|
2628
|
+
return existingInvitation;
|
|
2629
|
+
}
|
|
2630
|
+
const handler = this._getHandler(options);
|
|
2631
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2632
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2633
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2634
|
+
this._onInvitationComplete(invitation, () => {
|
|
2635
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2636
|
+
this.removedAccepted.emit(invitation.get());
|
|
2637
|
+
});
|
|
2638
|
+
return invitation;
|
|
2639
|
+
}
|
|
2640
|
+
async authenticate({ invitationId, authCode }) {
|
|
2641
|
+
log7("authenticating...", void 0, {
|
|
2642
|
+
F: __dxlog_file9,
|
|
2643
|
+
L: 117,
|
|
2644
|
+
S: this,
|
|
2645
|
+
C: (f, a) => f(...a)
|
|
2646
|
+
});
|
|
2647
|
+
invariant8(invitationId, void 0, {
|
|
2648
|
+
F: __dxlog_file9,
|
|
2649
|
+
L: 118,
|
|
2650
|
+
S: this,
|
|
2651
|
+
A: [
|
|
2652
|
+
"invitationId",
|
|
2653
|
+
""
|
|
2654
|
+
]
|
|
2655
|
+
});
|
|
2656
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2657
|
+
if (!observable) {
|
|
2658
|
+
log7.warn("invalid invitation", {
|
|
2659
|
+
invitationId
|
|
2660
|
+
}, {
|
|
2661
|
+
F: __dxlog_file9,
|
|
2662
|
+
L: 121,
|
|
2663
|
+
S: this,
|
|
2664
|
+
C: (f, a) => f(...a)
|
|
2665
|
+
});
|
|
2666
|
+
} else {
|
|
2667
|
+
await observable.authenticate(authCode);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
async cancelInvitation({ invitationId }) {
|
|
2671
|
+
log7("cancelInvitation...", {
|
|
2672
|
+
invitationId
|
|
2673
|
+
}, {
|
|
2674
|
+
F: __dxlog_file9,
|
|
2675
|
+
L: 128,
|
|
2676
|
+
S: this,
|
|
2677
|
+
C: (f, a) => f(...a)
|
|
2678
|
+
});
|
|
2679
|
+
invariant8(invitationId, void 0, {
|
|
2680
|
+
F: __dxlog_file9,
|
|
2681
|
+
L: 129,
|
|
2682
|
+
S: this,
|
|
2683
|
+
A: [
|
|
2684
|
+
"invitationId",
|
|
2685
|
+
""
|
|
2686
|
+
]
|
|
2687
|
+
});
|
|
2688
|
+
const created = this._createInvitations.get(invitationId);
|
|
2689
|
+
if (created) {
|
|
2690
|
+
if (created.get().persistent) {
|
|
2691
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2692
|
+
}
|
|
2693
|
+
await created.cancel();
|
|
2694
|
+
this._createInvitations.delete(invitationId);
|
|
2695
|
+
this.removedCreated.emit(created.get());
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2699
|
+
if (accepted) {
|
|
2700
|
+
await accepted.cancel();
|
|
2701
|
+
this._acceptInvitations.delete(invitationId);
|
|
2702
|
+
this.removedAccepted.emit(accepted.get());
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
getCreatedInvitations() {
|
|
2706
|
+
return [
|
|
2707
|
+
...this._createInvitations.values()
|
|
2708
|
+
].map((i) => i.get());
|
|
2709
|
+
}
|
|
2710
|
+
getAcceptedInvitations() {
|
|
2711
|
+
return [
|
|
2712
|
+
...this._acceptInvitations.values()
|
|
2713
|
+
].map((i) => i.get());
|
|
2714
|
+
}
|
|
2715
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2716
|
+
if (this._persistentInvitationsLoaded) {
|
|
2717
|
+
callback();
|
|
2718
|
+
} else {
|
|
2719
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
_safePersistInBackground(invitation) {
|
|
2723
|
+
return new Promise((resolve) => {
|
|
2724
|
+
setTimeout(async () => {
|
|
2725
|
+
try {
|
|
2726
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2727
|
+
this.saved.emit(invitation.get());
|
|
2728
|
+
} catch (err) {
|
|
2729
|
+
log7.catch(err, void 0, {
|
|
2730
|
+
F: __dxlog_file9,
|
|
2731
|
+
L: 173,
|
|
2732
|
+
S: this,
|
|
2733
|
+
C: (f, a) => f(...a)
|
|
2734
|
+
});
|
|
2735
|
+
await invitation.cancel();
|
|
2736
|
+
} finally {
|
|
2737
|
+
resolve();
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
async _safeDeleteInvitation(invitation) {
|
|
2743
|
+
try {
|
|
2744
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2745
|
+
} catch (err) {
|
|
2746
|
+
log7.catch(err, void 0, {
|
|
2747
|
+
F: __dxlog_file9,
|
|
2748
|
+
L: 186,
|
|
2749
|
+
S: this,
|
|
2750
|
+
C: (f, a) => f(...a)
|
|
2751
|
+
});
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
_onInvitationComplete(invitation, callback) {
|
|
2755
|
+
invitation.subscribe(() => {
|
|
2756
|
+
}, () => {
|
|
2757
|
+
}, callback);
|
|
2758
|
+
}
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2651
2761
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2652
2762
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2653
2763
|
import { raise } from "@dxos/debug";
|
|
@@ -2730,9 +2840,9 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2730
2840
|
], ClientRpcServer);
|
|
2731
2841
|
|
|
2732
2842
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2733
|
-
import { Event as Event6, asyncTimeout, scheduleTask as
|
|
2843
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2734
2844
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2735
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2845
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7, ContextDisposedError } from "@dxos/context";
|
|
2736
2846
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2737
2847
|
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2738
2848
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
@@ -2786,8 +2896,8 @@ var AutomergeSpaceState = class {
|
|
|
2786
2896
|
};
|
|
2787
2897
|
|
|
2788
2898
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2789
|
-
import { DeferredTask, Event as Event5, scheduleTask as
|
|
2790
|
-
import { Context as
|
|
2899
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2900
|
+
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2791
2901
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2792
2902
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2793
2903
|
import { log as log8 } from "@dxos/log";
|
|
@@ -2801,7 +2911,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2801
2911
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2802
2912
|
var NotarizationPlugin = class {
|
|
2803
2913
|
constructor() {
|
|
2804
|
-
this._ctx = new
|
|
2914
|
+
this._ctx = new Context6();
|
|
2805
2915
|
this._extensionOpened = new Event5();
|
|
2806
2916
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2807
2917
|
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
@@ -2853,7 +2963,7 @@ var NotarizationPlugin = class {
|
|
|
2853
2963
|
});
|
|
2854
2964
|
opCtx?.onDispose(() => ctx.dispose());
|
|
2855
2965
|
if (timeout !== 0) {
|
|
2856
|
-
|
|
2966
|
+
scheduleTask3(ctx, () => {
|
|
2857
2967
|
log8.warn("Notarization timeout", {
|
|
2858
2968
|
timeout,
|
|
2859
2969
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2887,7 +2997,7 @@ var NotarizationPlugin = class {
|
|
|
2887
2997
|
C: (f, a) => f(...a)
|
|
2888
2998
|
});
|
|
2889
2999
|
peersTried.clear();
|
|
2890
|
-
|
|
3000
|
+
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2891
3001
|
return;
|
|
2892
3002
|
}
|
|
2893
3003
|
peersTried.add(peer);
|
|
@@ -3067,7 +3177,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3067
3177
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3068
3178
|
var DataSpace = class {
|
|
3069
3179
|
constructor(params) {
|
|
3070
|
-
this._ctx = new
|
|
3180
|
+
this._ctx = new Context7();
|
|
3071
3181
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3072
3182
|
this._cache = void 0;
|
|
3073
3183
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -3144,7 +3254,7 @@ var DataSpace = class {
|
|
|
3144
3254
|
await this._notarizationPlugin.open();
|
|
3145
3255
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3146
3256
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3147
|
-
await this._inner.open(new
|
|
3257
|
+
await this._inner.open(new Context7());
|
|
3148
3258
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3149
3259
|
log9("new state", {
|
|
3150
3260
|
state: SpaceState[this._state]
|
|
@@ -3173,7 +3283,7 @@ var DataSpace = class {
|
|
|
3173
3283
|
C: (f, a) => f(...a)
|
|
3174
3284
|
});
|
|
3175
3285
|
await this._ctx.dispose();
|
|
3176
|
-
this._ctx = new
|
|
3286
|
+
this._ctx = new Context7();
|
|
3177
3287
|
await this.authVerifier.close();
|
|
3178
3288
|
await this._inner.close();
|
|
3179
3289
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3192,7 +3302,7 @@ var DataSpace = class {
|
|
|
3192
3302
|
* Initialize the data pipeline in a separate task.
|
|
3193
3303
|
*/
|
|
3194
3304
|
initializeDataPipelineAsync() {
|
|
3195
|
-
|
|
3305
|
+
scheduleTask4(this._ctx, async () => {
|
|
3196
3306
|
try {
|
|
3197
3307
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3198
3308
|
await this.initializeDataPipeline();
|
|
@@ -3594,7 +3704,7 @@ DataSpace = _ts_decorate4([
|
|
|
3594
3704
|
|
|
3595
3705
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3596
3706
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3597
|
-
import { Context as
|
|
3707
|
+
import { Context as Context8, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3598
3708
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3599
3709
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3600
3710
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
@@ -3696,7 +3806,7 @@ var DataSpaceManager = class {
|
|
|
3696
3806
|
this._signingContext = _signingContext;
|
|
3697
3807
|
this._feedStore = _feedStore;
|
|
3698
3808
|
this._automergeHost = _automergeHost;
|
|
3699
|
-
this._ctx = new
|
|
3809
|
+
this._ctx = new Context8();
|
|
3700
3810
|
this.updated = new Event7();
|
|
3701
3811
|
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3702
3812
|
this._isOpen = false;
|
|
@@ -4017,7 +4127,7 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4017
4127
|
], DataSpaceManager);
|
|
4018
4128
|
|
|
4019
4129
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4020
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4130
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4021
4131
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4022
4132
|
import { raise as raise2 } from "@dxos/debug";
|
|
4023
4133
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
@@ -4074,7 +4184,7 @@ var SpacesServiceImpl = class {
|
|
|
4074
4184
|
}, {
|
|
4075
4185
|
maxFrequency: false ? void 0 : 2
|
|
4076
4186
|
});
|
|
4077
|
-
|
|
4187
|
+
scheduleTask5(ctx, async () => {
|
|
4078
4188
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4079
4189
|
const subscriptions = new EventSubscriptions2();
|
|
4080
4190
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4108,7 +4218,7 @@ var SpacesServiceImpl = class {
|
|
|
4108
4218
|
}
|
|
4109
4219
|
subscribeMessages({ spaceKey, channel }) {
|
|
4110
4220
|
return new Stream10(({ ctx, next }) => {
|
|
4111
|
-
|
|
4221
|
+
scheduleTask5(ctx, async () => {
|
|
4112
4222
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4113
4223
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4114
4224
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4127,7 +4237,7 @@ var SpacesServiceImpl = class {
|
|
|
4127
4237
|
}
|
|
4128
4238
|
};
|
|
4129
4239
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4130
|
-
|
|
4240
|
+
scheduleTask5(ctx, async () => {
|
|
4131
4241
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4132
4242
|
if (noTail) {
|
|
4133
4243
|
close();
|
|
@@ -4235,18 +4345,18 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4235
4345
|
|
|
4236
4346
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4237
4347
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4238
|
-
import { Context as
|
|
4348
|
+
import { Context as Context9, Resource } from "@dxos/context";
|
|
4239
4349
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4240
4350
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4241
4351
|
import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4242
4352
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4243
|
-
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4353
|
+
import { IndexMetadataStore, IndexStore, Indexer, createStorageCallbacks } from "@dxos/indexing";
|
|
4244
4354
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4245
4355
|
import { Keyring } from "@dxos/keyring";
|
|
4246
4356
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4247
4357
|
import { log as log12 } from "@dxos/log";
|
|
4248
4358
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4249
|
-
import { Invitation as
|
|
4359
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4250
4360
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4251
4361
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4252
4362
|
import { safeInstanceof } from "@dxos/util";
|
|
@@ -4381,24 +4491,28 @@ var ServiceContext = class extends Resource {
|
|
|
4381
4491
|
this.automergeHost = new AutomergeHost({
|
|
4382
4492
|
directory: storage.createDirectory("automerge"),
|
|
4383
4493
|
db: level.sublevel("automerge"),
|
|
4384
|
-
|
|
4494
|
+
storageCallbacks: createStorageCallbacks({
|
|
4495
|
+
host: () => this.automergeHost,
|
|
4496
|
+
metadata: this.indexMetadata
|
|
4497
|
+
})
|
|
4385
4498
|
});
|
|
4386
4499
|
this.indexer = new Indexer({
|
|
4387
4500
|
indexStore: new IndexStore({
|
|
4388
|
-
|
|
4501
|
+
db: level.sublevel("index-storage")
|
|
4389
4502
|
}),
|
|
4390
4503
|
metadataStore: this.indexMetadata,
|
|
4391
4504
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4392
4505
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4393
4506
|
});
|
|
4394
4507
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4395
|
-
this.
|
|
4508
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4509
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4396
4510
|
}
|
|
4397
4511
|
async _open(ctx) {
|
|
4398
4512
|
await this._checkStorageVersion();
|
|
4399
4513
|
log12("opening...", void 0, {
|
|
4400
4514
|
F: __dxlog_file14,
|
|
4401
|
-
L:
|
|
4515
|
+
L: 164,
|
|
4402
4516
|
S: this,
|
|
4403
4517
|
C: (f, a) => f(...a)
|
|
4404
4518
|
});
|
|
@@ -4406,7 +4520,7 @@ var ServiceContext = class extends Resource {
|
|
|
4406
4520
|
id: this._instanceId
|
|
4407
4521
|
}), {
|
|
4408
4522
|
F: __dxlog_file14,
|
|
4409
|
-
L:
|
|
4523
|
+
L: 165,
|
|
4410
4524
|
S: this,
|
|
4411
4525
|
C: (f, a) => f(...a)
|
|
4412
4526
|
});
|
|
@@ -4419,17 +4533,26 @@ var ServiceContext = class extends Resource {
|
|
|
4419
4533
|
if (this.identityManager.identity) {
|
|
4420
4534
|
await this._initialize(ctx);
|
|
4421
4535
|
}
|
|
4536
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4537
|
+
log12("loaded persistent invitations", {
|
|
4538
|
+
count: loadedInvitations.invitations?.length
|
|
4539
|
+
}, {
|
|
4540
|
+
F: __dxlog_file14,
|
|
4541
|
+
L: 178,
|
|
4542
|
+
S: this,
|
|
4543
|
+
C: (f, a) => f(...a)
|
|
4544
|
+
});
|
|
4422
4545
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4423
4546
|
id: this._instanceId
|
|
4424
4547
|
}), {
|
|
4425
4548
|
F: __dxlog_file14,
|
|
4426
|
-
L:
|
|
4549
|
+
L: 180,
|
|
4427
4550
|
S: this,
|
|
4428
4551
|
C: (f, a) => f(...a)
|
|
4429
4552
|
});
|
|
4430
4553
|
log12("opened", void 0, {
|
|
4431
4554
|
F: __dxlog_file14,
|
|
4432
|
-
L:
|
|
4555
|
+
L: 181,
|
|
4433
4556
|
S: this,
|
|
4434
4557
|
C: (f, a) => f(...a)
|
|
4435
4558
|
});
|
|
@@ -4437,7 +4560,7 @@ var ServiceContext = class extends Resource {
|
|
|
4437
4560
|
async _close() {
|
|
4438
4561
|
log12("closing...", void 0, {
|
|
4439
4562
|
F: __dxlog_file14,
|
|
4440
|
-
L:
|
|
4563
|
+
L: 185,
|
|
4441
4564
|
S: this,
|
|
4442
4565
|
C: (f, a) => f(...a)
|
|
4443
4566
|
});
|
|
@@ -4455,21 +4578,21 @@ var ServiceContext = class extends Resource {
|
|
|
4455
4578
|
await this.indexer.destroy();
|
|
4456
4579
|
log12("closed", void 0, {
|
|
4457
4580
|
F: __dxlog_file14,
|
|
4458
|
-
L:
|
|
4581
|
+
L: 198,
|
|
4459
4582
|
S: this,
|
|
4460
4583
|
C: (f, a) => f(...a)
|
|
4461
4584
|
});
|
|
4462
4585
|
}
|
|
4463
4586
|
async createIdentity(params = {}) {
|
|
4464
4587
|
const identity = await this.identityManager.createIdentity(params);
|
|
4465
|
-
await this._initialize(new
|
|
4588
|
+
await this._initialize(new Context9());
|
|
4466
4589
|
return identity;
|
|
4467
4590
|
}
|
|
4468
4591
|
getInvitationHandler(invitation) {
|
|
4469
4592
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4470
4593
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4471
4594
|
F: __dxlog_file14,
|
|
4472
|
-
L:
|
|
4595
|
+
L: 209,
|
|
4473
4596
|
S: this,
|
|
4474
4597
|
A: [
|
|
4475
4598
|
"factory",
|
|
@@ -4488,7 +4611,7 @@ var ServiceContext = class extends Resource {
|
|
|
4488
4611
|
}
|
|
4489
4612
|
async _acceptIdentity(params) {
|
|
4490
4613
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4491
|
-
await this._initialize(new
|
|
4614
|
+
await this._initialize(new Context9());
|
|
4492
4615
|
return identity;
|
|
4493
4616
|
}
|
|
4494
4617
|
async _checkStorageVersion() {
|
|
@@ -4501,7 +4624,7 @@ var ServiceContext = class extends Resource {
|
|
|
4501
4624
|
async _initialize(ctx) {
|
|
4502
4625
|
log12("initializing spaces...", void 0, {
|
|
4503
4626
|
F: __dxlog_file14,
|
|
4504
|
-
L:
|
|
4627
|
+
L: 240,
|
|
4505
4628
|
S: this,
|
|
4506
4629
|
C: (f, a) => f(...a)
|
|
4507
4630
|
});
|
|
@@ -4521,10 +4644,10 @@ var ServiceContext = class extends Resource {
|
|
|
4521
4644
|
};
|
|
4522
4645
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4523
4646
|
await this.dataSpaceManager.open();
|
|
4524
|
-
this._handlerFactories.set(
|
|
4647
|
+
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
4525
4648
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4526
4649
|
F: __dxlog_file14,
|
|
4527
|
-
L:
|
|
4650
|
+
L: 264,
|
|
4528
4651
|
S: this,
|
|
4529
4652
|
A: [
|
|
4530
4653
|
"this.dataSpaceManager",
|
|
@@ -4548,7 +4671,7 @@ var ServiceContext = class extends Resource {
|
|
|
4548
4671
|
details: assertion
|
|
4549
4672
|
}, {
|
|
4550
4673
|
F: __dxlog_file14,
|
|
4551
|
-
L:
|
|
4674
|
+
L: 280,
|
|
4552
4675
|
S: this,
|
|
4553
4676
|
C: (f, a) => f(...a)
|
|
4554
4677
|
});
|
|
@@ -4559,7 +4682,7 @@ var ServiceContext = class extends Resource {
|
|
|
4559
4682
|
details: assertion
|
|
4560
4683
|
}, {
|
|
4561
4684
|
F: __dxlog_file14,
|
|
4562
|
-
L:
|
|
4685
|
+
L: 284,
|
|
4563
4686
|
S: this,
|
|
4564
4687
|
C: (f, a) => f(...a)
|
|
4565
4688
|
});
|
|
@@ -4570,7 +4693,7 @@ var ServiceContext = class extends Resource {
|
|
|
4570
4693
|
details: assertion
|
|
4571
4694
|
}, {
|
|
4572
4695
|
F: __dxlog_file14,
|
|
4573
|
-
L:
|
|
4696
|
+
L: 289,
|
|
4574
4697
|
S: this,
|
|
4575
4698
|
C: (f, a) => f(...a)
|
|
4576
4699
|
});
|
|
@@ -4581,7 +4704,7 @@ var ServiceContext = class extends Resource {
|
|
|
4581
4704
|
} catch (err) {
|
|
4582
4705
|
log12.catch(err, void 0, {
|
|
4583
4706
|
F: __dxlog_file14,
|
|
4584
|
-
L:
|
|
4707
|
+
L: 295,
|
|
4585
4708
|
S: this,
|
|
4586
4709
|
C: (f, a) => f(...a)
|
|
4587
4710
|
});
|
|
@@ -4635,7 +4758,7 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/s
|
|
|
4635
4758
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4636
4759
|
|
|
4637
4760
|
// packages/sdk/client-services/src/version.ts
|
|
4638
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4761
|
+
var DXOS_VERSION = "0.4.10-main.85f8e19";
|
|
4639
4762
|
|
|
4640
4763
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4641
4764
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4878,9 +5001,9 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
4878
5001
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4879
5002
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4880
5003
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4881
|
-
import { Context as
|
|
5004
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4882
5005
|
import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
|
|
4883
|
-
import
|
|
5006
|
+
import { getTypeReference } from "@dxos/echo-schema";
|
|
4884
5007
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4885
5008
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4886
5009
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
@@ -5431,7 +5554,7 @@ var ClientServicesHost = class {
|
|
|
5431
5554
|
lockKey,
|
|
5432
5555
|
onAcquire: () => {
|
|
5433
5556
|
if (!this._opening) {
|
|
5434
|
-
void this.open(new
|
|
5557
|
+
void this.open(new Context10());
|
|
5435
5558
|
}
|
|
5436
5559
|
},
|
|
5437
5560
|
onRelease: () => this.close()
|
|
@@ -5617,7 +5740,7 @@ var ClientServicesHost = class {
|
|
|
5617
5740
|
this._serviceRegistry.setServices({
|
|
5618
5741
|
SystemService: this._systemService,
|
|
5619
5742
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5620
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5743
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5621
5744
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5622
5745
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5623
5746
|
await this._serviceContext.initialized.wait();
|
|
@@ -5639,24 +5762,6 @@ var ClientServicesHost = class {
|
|
|
5639
5762
|
})
|
|
5640
5763
|
});
|
|
5641
5764
|
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
5765
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5661
5766
|
if (devtoolsProxy) {
|
|
5662
5767
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5676,7 +5781,7 @@ var ClientServicesHost = class {
|
|
|
5676
5781
|
deviceKey
|
|
5677
5782
|
}, {
|
|
5678
5783
|
F: __dxlog_file19,
|
|
5679
|
-
L:
|
|
5784
|
+
L: 326,
|
|
5680
5785
|
S: this,
|
|
5681
5786
|
C: (f, a) => f(...a)
|
|
5682
5787
|
});
|
|
@@ -5684,7 +5789,7 @@ var ClientServicesHost = class {
|
|
|
5684
5789
|
id: traceId
|
|
5685
5790
|
}), {
|
|
5686
5791
|
F: __dxlog_file19,
|
|
5687
|
-
L:
|
|
5792
|
+
L: 327,
|
|
5688
5793
|
S: this,
|
|
5689
5794
|
C: (f, a) => f(...a)
|
|
5690
5795
|
});
|
|
@@ -5698,7 +5803,7 @@ var ClientServicesHost = class {
|
|
|
5698
5803
|
deviceKey
|
|
5699
5804
|
}, {
|
|
5700
5805
|
F: __dxlog_file19,
|
|
5701
|
-
L:
|
|
5806
|
+
L: 338,
|
|
5702
5807
|
S: this,
|
|
5703
5808
|
C: (f, a) => f(...a)
|
|
5704
5809
|
});
|
|
@@ -5716,7 +5821,7 @@ var ClientServicesHost = class {
|
|
|
5716
5821
|
deviceKey
|
|
5717
5822
|
}, {
|
|
5718
5823
|
F: __dxlog_file19,
|
|
5719
|
-
L:
|
|
5824
|
+
L: 347,
|
|
5720
5825
|
S: this,
|
|
5721
5826
|
C: (f, a) => f(...a)
|
|
5722
5827
|
});
|
|
@@ -5727,13 +5832,13 @@ var ClientServicesHost = class {
|
|
|
5727
5832
|
id: traceId
|
|
5728
5833
|
}), {
|
|
5729
5834
|
F: __dxlog_file19,
|
|
5730
|
-
L:
|
|
5835
|
+
L: 352,
|
|
5731
5836
|
S: this,
|
|
5732
5837
|
C: (f, a) => f(...a)
|
|
5733
5838
|
});
|
|
5734
5839
|
log16("resetting...", void 0, {
|
|
5735
5840
|
F: __dxlog_file19,
|
|
5736
|
-
L:
|
|
5841
|
+
L: 354,
|
|
5737
5842
|
S: this,
|
|
5738
5843
|
C: (f, a) => f(...a)
|
|
5739
5844
|
});
|
|
@@ -5741,7 +5846,7 @@ var ClientServicesHost = class {
|
|
|
5741
5846
|
await this._storage.reset();
|
|
5742
5847
|
log16("reset", void 0, {
|
|
5743
5848
|
F: __dxlog_file19,
|
|
5744
|
-
L:
|
|
5849
|
+
L: 357,
|
|
5745
5850
|
S: this,
|
|
5746
5851
|
C: (f, a) => f(...a)
|
|
5747
5852
|
});
|
|
@@ -5749,7 +5854,7 @@ var ClientServicesHost = class {
|
|
|
5749
5854
|
id: traceId
|
|
5750
5855
|
}), {
|
|
5751
5856
|
F: __dxlog_file19,
|
|
5752
|
-
L:
|
|
5857
|
+
L: 358,
|
|
5753
5858
|
S: this,
|
|
5754
5859
|
C: (f, a) => f(...a)
|
|
5755
5860
|
});
|
|
@@ -5762,7 +5867,7 @@ var ClientServicesHost = class {
|
|
|
5762
5867
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5763
5868
|
invariant16(automergeIndex, void 0, {
|
|
5764
5869
|
F: __dxlog_file19,
|
|
5765
|
-
L:
|
|
5870
|
+
L: 370,
|
|
5766
5871
|
S: this,
|
|
5767
5872
|
A: [
|
|
5768
5873
|
"automergeIndex",
|
|
@@ -5773,7 +5878,7 @@ var ClientServicesHost = class {
|
|
|
5773
5878
|
await document.whenReady();
|
|
5774
5879
|
const properties = {
|
|
5775
5880
|
system: {
|
|
5776
|
-
type: encodeReference(
|
|
5881
|
+
type: encodeReference(getTypeReference(Properties))
|
|
5777
5882
|
},
|
|
5778
5883
|
data: {
|
|
5779
5884
|
[defaultKey]: identity.identityKey.toHex()
|
|
@@ -5868,8 +5973,10 @@ export {
|
|
|
5868
5973
|
IdentityServiceImpl,
|
|
5869
5974
|
DeviceInvitationProtocol,
|
|
5870
5975
|
InvitationsHandler,
|
|
5976
|
+
createAdmissionKeypair,
|
|
5871
5977
|
InvitationsServiceImpl,
|
|
5872
5978
|
SpaceInvitationProtocol,
|
|
5979
|
+
InvitationsManager,
|
|
5873
5980
|
ClientRpcServer,
|
|
5874
5981
|
DataSpace,
|
|
5875
5982
|
DataSpaceManager,
|
|
@@ -5887,4 +5994,4 @@ export {
|
|
|
5887
5994
|
ClientServicesHost,
|
|
5888
5995
|
ClientServicesProviderResource
|
|
5889
5996
|
};
|
|
5890
|
-
//# sourceMappingURL=chunk-
|
|
5997
|
+
//# sourceMappingURL=chunk-GVJIB6RK.mjs.map
|