@dxos/client-services 0.4.10-main.b9b4602 → 0.4.10-main.bf8d896
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-TPPBOJTA.mjs → chunk-3Z5ZPB7G.mjs} +208 -144
- package/dist/lib/browser/chunk-3Z5ZPB7G.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +8 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-33Q7F4MM.cjs → chunk-A2VEEQ4M.cjs} +224 -160
- package/dist/lib/node/chunk-A2VEEQ4M.cjs.map +7 -0
- package/dist/lib/node/index.cjs +43 -43
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +13 -9
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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 -2
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +4 -1
- 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/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitations-handler.ts +73 -32
- package/src/packlets/invitations/invitations-service.ts +5 -5
- package/src/packlets/services/automerge-host.test.ts +9 -3
- package/src/packlets/services/service-context.test.ts +4 -1
- package/src/packlets/services/service-context.ts +2 -0
- package/src/packlets/services/service-host.ts +12 -1
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/storage/level.ts +1 -1
- package/src/packlets/testing/test-builder.ts +20 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-TPPBOJTA.mjs.map +0 -7
- package/dist/lib/node/chunk-33Q7F4MM.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,9 +1676,11 @@ var InvitationsHandler = class {
|
|
|
1658
1676
|
swarmKey,
|
|
1659
1677
|
authCode,
|
|
1660
1678
|
timeout,
|
|
1661
|
-
persistent,
|
|
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,
|
|
1683
|
+
multiUse,
|
|
1664
1684
|
...protocol.getInvitationContext()
|
|
1665
1685
|
};
|
|
1666
1686
|
const stream = new PushStream();
|
|
@@ -1675,7 +1695,7 @@ var InvitationsHandler = class {
|
|
|
1675
1695
|
...protocol.toJSON()
|
|
1676
1696
|
}, {
|
|
1677
1697
|
F: __dxlog_file7,
|
|
1678
|
-
L:
|
|
1698
|
+
L: 115,
|
|
1679
1699
|
S: this,
|
|
1680
1700
|
C: (f, a) => f(...a)
|
|
1681
1701
|
});
|
|
@@ -1700,7 +1720,7 @@ var InvitationsHandler = class {
|
|
|
1700
1720
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1701
1721
|
invariant6(deviceKey, void 0, {
|
|
1702
1722
|
F: __dxlog_file7,
|
|
1703
|
-
L:
|
|
1723
|
+
L: 136,
|
|
1704
1724
|
S: this,
|
|
1705
1725
|
A: [
|
|
1706
1726
|
"deviceKey",
|
|
@@ -1723,7 +1743,7 @@ var InvitationsHandler = class {
|
|
|
1723
1743
|
id: traceId
|
|
1724
1744
|
}), {
|
|
1725
1745
|
F: __dxlog_file7,
|
|
1726
|
-
L:
|
|
1746
|
+
L: 154,
|
|
1727
1747
|
S: this,
|
|
1728
1748
|
C: (f, a) => f(...a)
|
|
1729
1749
|
});
|
|
@@ -1731,7 +1751,7 @@ var InvitationsHandler = class {
|
|
|
1731
1751
|
...protocol.toJSON()
|
|
1732
1752
|
}, {
|
|
1733
1753
|
F: __dxlog_file7,
|
|
1734
|
-
L:
|
|
1754
|
+
L: 155,
|
|
1735
1755
|
S: this,
|
|
1736
1756
|
C: (f, a) => f(...a)
|
|
1737
1757
|
});
|
|
@@ -1747,7 +1767,7 @@ var InvitationsHandler = class {
|
|
|
1747
1767
|
...protocol.toJSON()
|
|
1748
1768
|
}, {
|
|
1749
1769
|
F: __dxlog_file7,
|
|
1750
|
-
L:
|
|
1770
|
+
L: 158,
|
|
1751
1771
|
S: this,
|
|
1752
1772
|
C: (f, a) => f(...a)
|
|
1753
1773
|
});
|
|
@@ -1759,7 +1779,7 @@ var InvitationsHandler = class {
|
|
|
1759
1779
|
id: traceId
|
|
1760
1780
|
}), {
|
|
1761
1781
|
F: __dxlog_file7,
|
|
1762
|
-
L:
|
|
1782
|
+
L: 160,
|
|
1763
1783
|
S: this,
|
|
1764
1784
|
C: (f, a) => f(...a)
|
|
1765
1785
|
});
|
|
@@ -1769,7 +1789,7 @@ var InvitationsHandler = class {
|
|
|
1769
1789
|
...protocol.toJSON()
|
|
1770
1790
|
}, {
|
|
1771
1791
|
F: __dxlog_file7,
|
|
1772
|
-
L:
|
|
1792
|
+
L: 163,
|
|
1773
1793
|
S: this,
|
|
1774
1794
|
C: (f, a) => f(...a)
|
|
1775
1795
|
});
|
|
@@ -1780,7 +1800,7 @@ var InvitationsHandler = class {
|
|
|
1780
1800
|
} else {
|
|
1781
1801
|
log5.error("failed", err, {
|
|
1782
1802
|
F: __dxlog_file7,
|
|
1783
|
-
L:
|
|
1803
|
+
L: 166,
|
|
1784
1804
|
S: this,
|
|
1785
1805
|
C: (f, a) => f(...a)
|
|
1786
1806
|
});
|
|
@@ -1791,12 +1811,12 @@ var InvitationsHandler = class {
|
|
|
1791
1811
|
error: err
|
|
1792
1812
|
}), {
|
|
1793
1813
|
F: __dxlog_file7,
|
|
1794
|
-
L:
|
|
1814
|
+
L: 169,
|
|
1795
1815
|
S: this,
|
|
1796
1816
|
C: (f, a) => f(...a)
|
|
1797
1817
|
});
|
|
1798
1818
|
} finally {
|
|
1799
|
-
if (
|
|
1819
|
+
if (!multiUse) {
|
|
1800
1820
|
await swarmConnection.close();
|
|
1801
1821
|
await ctx.dispose();
|
|
1802
1822
|
}
|
|
@@ -1812,7 +1832,7 @@ var InvitationsHandler = class {
|
|
|
1812
1832
|
...protocol.toJSON()
|
|
1813
1833
|
}, {
|
|
1814
1834
|
F: __dxlog_file7,
|
|
1815
|
-
L:
|
|
1835
|
+
L: 184,
|
|
1816
1836
|
S: this,
|
|
1817
1837
|
C: (f, a) => f(...a)
|
|
1818
1838
|
});
|
|
@@ -1823,7 +1843,7 @@ var InvitationsHandler = class {
|
|
|
1823
1843
|
} else {
|
|
1824
1844
|
log5.error("failed", err, {
|
|
1825
1845
|
F: __dxlog_file7,
|
|
1826
|
-
L:
|
|
1846
|
+
L: 187,
|
|
1827
1847
|
S: this,
|
|
1828
1848
|
C: (f, a) => f(...a)
|
|
1829
1849
|
});
|
|
@@ -1837,7 +1857,7 @@ var InvitationsHandler = class {
|
|
|
1837
1857
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1838
1858
|
log5.warn("invitation has already expired", void 0, {
|
|
1839
1859
|
F: __dxlog_file7,
|
|
1840
|
-
L:
|
|
1860
|
+
L: 198,
|
|
1841
1861
|
S: this,
|
|
1842
1862
|
C: (f, a) => f(...a)
|
|
1843
1863
|
});
|
|
@@ -1888,7 +1908,7 @@ var InvitationsHandler = class {
|
|
|
1888
1908
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1889
1909
|
invariant6(protocol, void 0, {
|
|
1890
1910
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1911
|
+
L: 252,
|
|
1892
1912
|
S: this,
|
|
1893
1913
|
A: [
|
|
1894
1914
|
"protocol",
|
|
@@ -1898,7 +1918,7 @@ var InvitationsHandler = class {
|
|
|
1898
1918
|
if (deviceProfile) {
|
|
1899
1919
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1900
1920
|
F: __dxlog_file7,
|
|
1901
|
-
L:
|
|
1921
|
+
L: 256,
|
|
1902
1922
|
S: this,
|
|
1903
1923
|
A: [
|
|
1904
1924
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1913,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1913
1933
|
const setState = (newData) => {
|
|
1914
1934
|
invariant6(newData.state !== void 0, void 0, {
|
|
1915
1935
|
F: __dxlog_file7,
|
|
1916
|
-
L:
|
|
1936
|
+
L: 267,
|
|
1917
1937
|
S: this,
|
|
1918
1938
|
A: [
|
|
1919
1939
|
"newData.state !== undefined",
|
|
@@ -1933,7 +1953,7 @@ var InvitationsHandler = class {
|
|
|
1933
1953
|
...protocol.toJSON()
|
|
1934
1954
|
}, {
|
|
1935
1955
|
F: __dxlog_file7,
|
|
1936
|
-
L:
|
|
1956
|
+
L: 275,
|
|
1937
1957
|
S: this,
|
|
1938
1958
|
C: (f, a) => f(...a)
|
|
1939
1959
|
});
|
|
@@ -1943,7 +1963,7 @@ var InvitationsHandler = class {
|
|
|
1943
1963
|
} else {
|
|
1944
1964
|
log5.warn("auth failed", err, {
|
|
1945
1965
|
F: __dxlog_file7,
|
|
1946
|
-
L:
|
|
1966
|
+
L: 278,
|
|
1947
1967
|
S: this,
|
|
1948
1968
|
C: (f, a) => f(...a)
|
|
1949
1969
|
});
|
|
@@ -1957,7 +1977,7 @@ var InvitationsHandler = class {
|
|
|
1957
1977
|
...protocol.toJSON()
|
|
1958
1978
|
}, {
|
|
1959
1979
|
F: __dxlog_file7,
|
|
1960
|
-
L:
|
|
1980
|
+
L: 286,
|
|
1961
1981
|
S: this,
|
|
1962
1982
|
C: (f, a) => f(...a)
|
|
1963
1983
|
});
|
|
@@ -1972,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1972
1992
|
currentState
|
|
1973
1993
|
}, {
|
|
1974
1994
|
F: __dxlog_file7,
|
|
1975
|
-
L:
|
|
1995
|
+
L: 296,
|
|
1976
1996
|
S: this,
|
|
1977
1997
|
C: (f, a) => f(...a)
|
|
1978
1998
|
});
|
|
@@ -1987,7 +2007,7 @@ var InvitationsHandler = class {
|
|
|
1987
2007
|
id: traceId
|
|
1988
2008
|
}), {
|
|
1989
2009
|
F: __dxlog_file7,
|
|
1990
|
-
L:
|
|
2010
|
+
L: 305,
|
|
1991
2011
|
S: this,
|
|
1992
2012
|
C: (f, a) => f(...a)
|
|
1993
2013
|
});
|
|
@@ -1999,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
1999
2019
|
...protocol.toJSON()
|
|
2000
2020
|
}, {
|
|
2001
2021
|
F: __dxlog_file7,
|
|
2002
|
-
L:
|
|
2022
|
+
L: 313,
|
|
2003
2023
|
S: this,
|
|
2004
2024
|
C: (f, a) => f(...a)
|
|
2005
2025
|
});
|
|
@@ -2010,7 +2030,7 @@ var InvitationsHandler = class {
|
|
|
2010
2030
|
...protocol.toJSON()
|
|
2011
2031
|
}, {
|
|
2012
2032
|
F: __dxlog_file7,
|
|
2013
|
-
L:
|
|
2033
|
+
L: 317,
|
|
2014
2034
|
S: this,
|
|
2015
2035
|
C: (f, a) => f(...a)
|
|
2016
2036
|
});
|
|
@@ -2020,62 +2040,28 @@ var InvitationsHandler = class {
|
|
|
2020
2040
|
response: introductionResponse
|
|
2021
2041
|
}, {
|
|
2022
2042
|
F: __dxlog_file7,
|
|
2023
|
-
L:
|
|
2043
|
+
L: 321,
|
|
2024
2044
|
S: this,
|
|
2025
2045
|
C: (f, a) => f(...a)
|
|
2026
2046
|
});
|
|
2027
2047
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2028
2048
|
if (isAuthenticationRequired(invitation)) {
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
2038
|
-
});
|
|
2039
|
-
const authCode = await authenticated.wait({
|
|
2040
|
-
timeout
|
|
2041
|
-
});
|
|
2042
|
-
log5("sending authentication request", void 0, {
|
|
2043
|
-
F: __dxlog_file7,
|
|
2044
|
-
L: 325,
|
|
2045
|
-
S: this,
|
|
2046
|
-
C: (f, a) => f(...a)
|
|
2047
|
-
});
|
|
2048
|
-
setState({
|
|
2049
|
-
state: Invitation3.State.AUTHENTICATING
|
|
2050
|
-
});
|
|
2051
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2052
|
-
authCode
|
|
2053
|
-
});
|
|
2054
|
-
if (response.status === void 0 || response.status === AuthenticationResponse2.Status.OK) {
|
|
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);
|
|
2055
2057
|
break;
|
|
2056
|
-
}
|
|
2057
|
-
if (response.status === AuthenticationResponse2.Status.INVALID_OTP) {
|
|
2058
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2059
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2060
|
-
} else {
|
|
2061
|
-
log5("retrying invalid code", {
|
|
2062
|
-
attempt
|
|
2063
|
-
}, {
|
|
2064
|
-
F: __dxlog_file7,
|
|
2065
|
-
L: 336,
|
|
2066
|
-
S: this,
|
|
2067
|
-
C: (f, a) => f(...a)
|
|
2068
|
-
});
|
|
2069
|
-
authenticated.reset();
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
2058
|
}
|
|
2073
2059
|
}
|
|
2074
2060
|
log5("request admission", {
|
|
2075
2061
|
...protocol.toJSON()
|
|
2076
2062
|
}, {
|
|
2077
2063
|
F: __dxlog_file7,
|
|
2078
|
-
L:
|
|
2064
|
+
L: 337,
|
|
2079
2065
|
S: this,
|
|
2080
2066
|
C: (f, a) => f(...a)
|
|
2081
2067
|
});
|
|
@@ -2087,7 +2073,7 @@ var InvitationsHandler = class {
|
|
|
2087
2073
|
...protocol.toJSON()
|
|
2088
2074
|
}, {
|
|
2089
2075
|
F: __dxlog_file7,
|
|
2090
|
-
L:
|
|
2076
|
+
L: 348,
|
|
2091
2077
|
S: this,
|
|
2092
2078
|
C: (f, a) => f(...a)
|
|
2093
2079
|
});
|
|
@@ -2100,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2100
2086
|
id: traceId
|
|
2101
2087
|
}), {
|
|
2102
2088
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2089
|
+
L: 350,
|
|
2104
2090
|
S: this,
|
|
2105
2091
|
C: (f, a) => f(...a)
|
|
2106
2092
|
});
|
|
@@ -2110,7 +2096,7 @@ var InvitationsHandler = class {
|
|
|
2110
2096
|
...protocol.toJSON()
|
|
2111
2097
|
}, {
|
|
2112
2098
|
F: __dxlog_file7,
|
|
2113
|
-
L:
|
|
2099
|
+
L: 353,
|
|
2114
2100
|
S: this,
|
|
2115
2101
|
C: (f, a) => f(...a)
|
|
2116
2102
|
});
|
|
@@ -2120,7 +2106,7 @@ var InvitationsHandler = class {
|
|
|
2120
2106
|
} else {
|
|
2121
2107
|
log5("auth failed", err, {
|
|
2122
2108
|
F: __dxlog_file7,
|
|
2123
|
-
L:
|
|
2109
|
+
L: 356,
|
|
2124
2110
|
S: this,
|
|
2125
2111
|
C: (f, a) => f(...a)
|
|
2126
2112
|
});
|
|
@@ -2131,7 +2117,7 @@ var InvitationsHandler = class {
|
|
|
2131
2117
|
error: err
|
|
2132
2118
|
}), {
|
|
2133
2119
|
F: __dxlog_file7,
|
|
2134
|
-
L:
|
|
2120
|
+
L: 359,
|
|
2135
2121
|
S: this,
|
|
2136
2122
|
C: (f, a) => f(...a)
|
|
2137
2123
|
});
|
|
@@ -2149,7 +2135,7 @@ var InvitationsHandler = class {
|
|
|
2149
2135
|
...protocol.toJSON()
|
|
2150
2136
|
}, {
|
|
2151
2137
|
F: __dxlog_file7,
|
|
2152
|
-
L:
|
|
2138
|
+
L: 370,
|
|
2153
2139
|
S: this,
|
|
2154
2140
|
C: (f, a) => f(...a)
|
|
2155
2141
|
});
|
|
@@ -2159,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2159
2145
|
} else {
|
|
2160
2146
|
log5("auth failed", err, {
|
|
2161
2147
|
F: __dxlog_file7,
|
|
2162
|
-
L:
|
|
2148
|
+
L: 373,
|
|
2163
2149
|
S: this,
|
|
2164
2150
|
C: (f, a) => f(...a)
|
|
2165
2151
|
});
|
|
@@ -2176,7 +2162,7 @@ var InvitationsHandler = class {
|
|
|
2176
2162
|
} else {
|
|
2177
2163
|
invariant6(invitation.swarmKey, void 0, {
|
|
2178
2164
|
F: __dxlog_file7,
|
|
2179
|
-
L:
|
|
2165
|
+
L: 387,
|
|
2180
2166
|
S: this,
|
|
2181
2167
|
A: [
|
|
2182
2168
|
"invitation.swarmKey",
|
|
@@ -2214,15 +2200,88 @@ var InvitationsHandler = class {
|
|
|
2214
2200
|
});
|
|
2215
2201
|
return observable;
|
|
2216
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: 427,
|
|
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: 431,
|
|
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: 442,
|
|
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: 461,
|
|
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
|
+
}
|
|
2217
2271
|
};
|
|
2218
|
-
var
|
|
2219
|
-
|
|
2272
|
+
var createAdmissionKeypair = () => {
|
|
2273
|
+
const keypair = createKeyPair();
|
|
2274
|
+
return {
|
|
2275
|
+
publicKey: PublicKey6.from(keypair.publicKey),
|
|
2276
|
+
privateKey: keypair.secretKey
|
|
2277
|
+
};
|
|
2220
2278
|
};
|
|
2221
2279
|
|
|
2222
2280
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2223
2281
|
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2224
2282
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2225
2283
|
import { Context as Context6 } from "@dxos/context";
|
|
2284
|
+
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2226
2285
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2227
2286
|
import { log as log6 } from "@dxos/log";
|
|
2228
2287
|
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2281,7 +2340,7 @@ var InvitationsServiceImpl = class {
|
|
|
2281
2340
|
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2282
2341
|
}
|
|
2283
2342
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2284
|
-
if (invitation.get().
|
|
2343
|
+
if (!invitation.get().multiUse) {
|
|
2285
2344
|
this._removedCreated.emit(invitation.get());
|
|
2286
2345
|
}
|
|
2287
2346
|
});
|
|
@@ -2289,7 +2348,7 @@ var InvitationsServiceImpl = class {
|
|
|
2289
2348
|
}
|
|
2290
2349
|
async loadPersistentInvitations() {
|
|
2291
2350
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2292
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !
|
|
2351
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !hasInvitationExpired(invitation));
|
|
2293
2352
|
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2294
2353
|
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2295
2354
|
F: __dxlog_file8,
|
|
@@ -2342,7 +2401,7 @@ var InvitationsServiceImpl = class {
|
|
|
2342
2401
|
}, () => {
|
|
2343
2402
|
close();
|
|
2344
2403
|
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2345
|
-
if (invitation.get().
|
|
2404
|
+
if (!invitation.get().multiUse) {
|
|
2346
2405
|
this._removedAccepted.emit(invitation.get());
|
|
2347
2406
|
}
|
|
2348
2407
|
});
|
|
@@ -4381,6 +4440,7 @@ var ServiceContext = class extends Resource {
|
|
|
4381
4440
|
});
|
|
4382
4441
|
this.automergeHost = new AutomergeHost({
|
|
4383
4442
|
directory: storage.createDirectory("automerge"),
|
|
4443
|
+
db: level.sublevel("automerge"),
|
|
4384
4444
|
metadata: this.indexMetadata
|
|
4385
4445
|
});
|
|
4386
4446
|
this.indexer = new Indexer({
|
|
@@ -4398,7 +4458,7 @@ var ServiceContext = class extends Resource {
|
|
|
4398
4458
|
await this._checkStorageVersion();
|
|
4399
4459
|
log12("opening...", void 0, {
|
|
4400
4460
|
F: __dxlog_file14,
|
|
4401
|
-
L:
|
|
4461
|
+
L: 157,
|
|
4402
4462
|
S: this,
|
|
4403
4463
|
C: (f, a) => f(...a)
|
|
4404
4464
|
});
|
|
@@ -4406,12 +4466,13 @@ var ServiceContext = class extends Resource {
|
|
|
4406
4466
|
id: this._instanceId
|
|
4407
4467
|
}), {
|
|
4408
4468
|
F: __dxlog_file14,
|
|
4409
|
-
L:
|
|
4469
|
+
L: 158,
|
|
4410
4470
|
S: this,
|
|
4411
4471
|
C: (f, a) => f(...a)
|
|
4412
4472
|
});
|
|
4413
4473
|
await this.signalManager.open();
|
|
4414
4474
|
await this.networkManager.open();
|
|
4475
|
+
await this.automergeHost.open();
|
|
4415
4476
|
await this.metadataStore.load();
|
|
4416
4477
|
await this.spaceManager.open();
|
|
4417
4478
|
await this.identityManager.open(ctx);
|
|
@@ -4422,13 +4483,13 @@ var ServiceContext = class extends Resource {
|
|
|
4422
4483
|
id: this._instanceId
|
|
4423
4484
|
}), {
|
|
4424
4485
|
F: __dxlog_file14,
|
|
4425
|
-
L:
|
|
4486
|
+
L: 169,
|
|
4426
4487
|
S: this,
|
|
4427
4488
|
C: (f, a) => f(...a)
|
|
4428
4489
|
});
|
|
4429
4490
|
log12("opened", void 0, {
|
|
4430
4491
|
F: __dxlog_file14,
|
|
4431
|
-
L:
|
|
4492
|
+
L: 170,
|
|
4432
4493
|
S: this,
|
|
4433
4494
|
C: (f, a) => f(...a)
|
|
4434
4495
|
});
|
|
@@ -4436,7 +4497,7 @@ var ServiceContext = class extends Resource {
|
|
|
4436
4497
|
async _close() {
|
|
4437
4498
|
log12("closing...", void 0, {
|
|
4438
4499
|
F: __dxlog_file14,
|
|
4439
|
-
L:
|
|
4500
|
+
L: 174,
|
|
4440
4501
|
S: this,
|
|
4441
4502
|
C: (f, a) => f(...a)
|
|
4442
4503
|
});
|
|
@@ -4454,7 +4515,7 @@ var ServiceContext = class extends Resource {
|
|
|
4454
4515
|
await this.indexer.destroy();
|
|
4455
4516
|
log12("closed", void 0, {
|
|
4456
4517
|
F: __dxlog_file14,
|
|
4457
|
-
L:
|
|
4518
|
+
L: 187,
|
|
4458
4519
|
S: this,
|
|
4459
4520
|
C: (f, a) => f(...a)
|
|
4460
4521
|
});
|
|
@@ -4468,7 +4529,7 @@ var ServiceContext = class extends Resource {
|
|
|
4468
4529
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4469
4530
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4470
4531
|
F: __dxlog_file14,
|
|
4471
|
-
L:
|
|
4532
|
+
L: 198,
|
|
4472
4533
|
S: this,
|
|
4473
4534
|
A: [
|
|
4474
4535
|
"factory",
|
|
@@ -4500,7 +4561,7 @@ var ServiceContext = class extends Resource {
|
|
|
4500
4561
|
async _initialize(ctx) {
|
|
4501
4562
|
log12("initializing spaces...", void 0, {
|
|
4502
4563
|
F: __dxlog_file14,
|
|
4503
|
-
L:
|
|
4564
|
+
L: 229,
|
|
4504
4565
|
S: this,
|
|
4505
4566
|
C: (f, a) => f(...a)
|
|
4506
4567
|
});
|
|
@@ -4523,7 +4584,7 @@ var ServiceContext = class extends Resource {
|
|
|
4523
4584
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4524
4585
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4525
4586
|
F: __dxlog_file14,
|
|
4526
|
-
L:
|
|
4587
|
+
L: 253,
|
|
4527
4588
|
S: this,
|
|
4528
4589
|
A: [
|
|
4529
4590
|
"this.dataSpaceManager",
|
|
@@ -4547,7 +4608,7 @@ var ServiceContext = class extends Resource {
|
|
|
4547
4608
|
details: assertion
|
|
4548
4609
|
}, {
|
|
4549
4610
|
F: __dxlog_file14,
|
|
4550
|
-
L:
|
|
4611
|
+
L: 269,
|
|
4551
4612
|
S: this,
|
|
4552
4613
|
C: (f, a) => f(...a)
|
|
4553
4614
|
});
|
|
@@ -4558,7 +4619,7 @@ var ServiceContext = class extends Resource {
|
|
|
4558
4619
|
details: assertion
|
|
4559
4620
|
}, {
|
|
4560
4621
|
F: __dxlog_file14,
|
|
4561
|
-
L:
|
|
4622
|
+
L: 273,
|
|
4562
4623
|
S: this,
|
|
4563
4624
|
C: (f, a) => f(...a)
|
|
4564
4625
|
});
|
|
@@ -4569,7 +4630,7 @@ var ServiceContext = class extends Resource {
|
|
|
4569
4630
|
details: assertion
|
|
4570
4631
|
}, {
|
|
4571
4632
|
F: __dxlog_file14,
|
|
4572
|
-
L:
|
|
4633
|
+
L: 278,
|
|
4573
4634
|
S: this,
|
|
4574
4635
|
C: (f, a) => f(...a)
|
|
4575
4636
|
});
|
|
@@ -4580,7 +4641,7 @@ var ServiceContext = class extends Resource {
|
|
|
4580
4641
|
} catch (err) {
|
|
4581
4642
|
log12.catch(err, void 0, {
|
|
4582
4643
|
F: __dxlog_file14,
|
|
4583
|
-
L:
|
|
4644
|
+
L: 284,
|
|
4584
4645
|
S: this,
|
|
4585
4646
|
C: (f, a) => f(...a)
|
|
4586
4647
|
});
|
|
@@ -4634,7 +4695,7 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/s
|
|
|
4634
4695
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4635
4696
|
|
|
4636
4697
|
// packages/sdk/client-services/src/version.ts
|
|
4637
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4698
|
+
var DXOS_VERSION = "0.4.10-main.bf8d896";
|
|
4638
4699
|
|
|
4639
4700
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4640
4701
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5323,7 +5384,7 @@ import path from "@dxos/node-std/path";
|
|
|
5323
5384
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5324
5385
|
var createLevel = async (config) => {
|
|
5325
5386
|
const persistent = isPersistent(config);
|
|
5326
|
-
const storagePath = persistent ? getRootPath(config)
|
|
5387
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey12.random().toHex()}`;
|
|
5327
5388
|
const level = new Level(storagePath);
|
|
5328
5389
|
await level.open();
|
|
5329
5390
|
return level;
|
|
@@ -5404,6 +5465,7 @@ var ClientServicesHost = class {
|
|
|
5404
5465
|
transportFactory,
|
|
5405
5466
|
signalManager,
|
|
5406
5467
|
storage,
|
|
5468
|
+
level,
|
|
5407
5469
|
// TODO(wittjosiah): Turn this on by default.
|
|
5408
5470
|
lockKey,
|
|
5409
5471
|
callbacks,
|
|
@@ -5414,6 +5476,7 @@ var ClientServicesHost = class {
|
|
|
5414
5476
|
this._opening = false;
|
|
5415
5477
|
this._open = false;
|
|
5416
5478
|
this._storage = storage;
|
|
5479
|
+
this._level = level;
|
|
5417
5480
|
this._callbacks = callbacks;
|
|
5418
5481
|
this._runtimeParams = runtimeParams;
|
|
5419
5482
|
if (config) {
|
|
@@ -5485,7 +5548,7 @@ var ClientServicesHost = class {
|
|
|
5485
5548
|
initialize({ config, ...options }) {
|
|
5486
5549
|
invariant16(!this._open, "service host is open", {
|
|
5487
5550
|
F: __dxlog_file19,
|
|
5488
|
-
L:
|
|
5551
|
+
L: 197,
|
|
5489
5552
|
S: this,
|
|
5490
5553
|
A: [
|
|
5491
5554
|
"!this._open",
|
|
@@ -5494,14 +5557,14 @@ var ClientServicesHost = class {
|
|
|
5494
5557
|
});
|
|
5495
5558
|
log16("initializing...", void 0, {
|
|
5496
5559
|
F: __dxlog_file19,
|
|
5497
|
-
L:
|
|
5560
|
+
L: 198,
|
|
5498
5561
|
S: this,
|
|
5499
5562
|
C: (f, a) => f(...a)
|
|
5500
5563
|
});
|
|
5501
5564
|
if (config) {
|
|
5502
5565
|
invariant16(!this._config, "config already set", {
|
|
5503
5566
|
F: __dxlog_file19,
|
|
5504
|
-
L:
|
|
5567
|
+
L: 201,
|
|
5505
5568
|
S: this,
|
|
5506
5569
|
A: [
|
|
5507
5570
|
"!this._config",
|
|
@@ -5516,7 +5579,7 @@ var ClientServicesHost = class {
|
|
|
5516
5579
|
if (!options.signalManager) {
|
|
5517
5580
|
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5518
5581
|
F: __dxlog_file19,
|
|
5519
|
-
L:
|
|
5582
|
+
L: 209,
|
|
5520
5583
|
S: this,
|
|
5521
5584
|
C: (f, a) => f(...a)
|
|
5522
5585
|
});
|
|
@@ -5527,7 +5590,7 @@ var ClientServicesHost = class {
|
|
|
5527
5590
|
this._signalManager = signalManager;
|
|
5528
5591
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5529
5592
|
F: __dxlog_file19,
|
|
5530
|
-
L:
|
|
5593
|
+
L: 220,
|
|
5531
5594
|
S: this,
|
|
5532
5595
|
A: [
|
|
5533
5596
|
"!this._networkManager",
|
|
@@ -5541,7 +5604,7 @@ var ClientServicesHost = class {
|
|
|
5541
5604
|
});
|
|
5542
5605
|
log16("initialized", void 0, {
|
|
5543
5606
|
F: __dxlog_file19,
|
|
5544
|
-
L:
|
|
5607
|
+
L: 227,
|
|
5545
5608
|
S: this,
|
|
5546
5609
|
C: (f, a) => f(...a)
|
|
5547
5610
|
});
|
|
@@ -5555,13 +5618,13 @@ var ClientServicesHost = class {
|
|
|
5555
5618
|
id: traceId
|
|
5556
5619
|
}), {
|
|
5557
5620
|
F: __dxlog_file19,
|
|
5558
|
-
L:
|
|
5621
|
+
L: 238,
|
|
5559
5622
|
S: this,
|
|
5560
5623
|
C: (f, a) => f(...a)
|
|
5561
5624
|
});
|
|
5562
5625
|
invariant16(this._config, "config not set", {
|
|
5563
5626
|
F: __dxlog_file19,
|
|
5564
|
-
L:
|
|
5627
|
+
L: 240,
|
|
5565
5628
|
S: this,
|
|
5566
5629
|
A: [
|
|
5567
5630
|
"this._config",
|
|
@@ -5570,7 +5633,7 @@ var ClientServicesHost = class {
|
|
|
5570
5633
|
});
|
|
5571
5634
|
invariant16(this._storage, "storage not set", {
|
|
5572
5635
|
F: __dxlog_file19,
|
|
5573
|
-
L:
|
|
5636
|
+
L: 241,
|
|
5574
5637
|
S: this,
|
|
5575
5638
|
A: [
|
|
5576
5639
|
"this._storage",
|
|
@@ -5579,7 +5642,7 @@ var ClientServicesHost = class {
|
|
|
5579
5642
|
});
|
|
5580
5643
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5581
5644
|
F: __dxlog_file19,
|
|
5582
|
-
L:
|
|
5645
|
+
L: 242,
|
|
5583
5646
|
S: this,
|
|
5584
5647
|
A: [
|
|
5585
5648
|
"this._signalManager",
|
|
@@ -5588,7 +5651,7 @@ var ClientServicesHost = class {
|
|
|
5588
5651
|
});
|
|
5589
5652
|
invariant16(this._networkManager, "network manager not set", {
|
|
5590
5653
|
F: __dxlog_file19,
|
|
5591
|
-
L:
|
|
5654
|
+
L: 243,
|
|
5592
5655
|
S: this,
|
|
5593
5656
|
A: [
|
|
5594
5657
|
"this._networkManager",
|
|
@@ -5600,13 +5663,14 @@ var ClientServicesHost = class {
|
|
|
5600
5663
|
lockKey: this._resourceLock?.lockKey
|
|
5601
5664
|
}, {
|
|
5602
5665
|
F: __dxlog_file19,
|
|
5603
|
-
L:
|
|
5666
|
+
L: 246,
|
|
5604
5667
|
S: this,
|
|
5605
5668
|
C: (f, a) => f(...a)
|
|
5606
5669
|
});
|
|
5607
5670
|
if (!this._level) {
|
|
5608
5671
|
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5609
5672
|
}
|
|
5673
|
+
await this._level.open();
|
|
5610
5674
|
await this._resourceLock?.acquire();
|
|
5611
5675
|
await this._loggingService.open();
|
|
5612
5676
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
@@ -5637,7 +5701,7 @@ var ClientServicesHost = class {
|
|
|
5637
5701
|
await this._serviceContext.open(ctx);
|
|
5638
5702
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5639
5703
|
F: __dxlog_file19,
|
|
5640
|
-
L:
|
|
5704
|
+
L: 314,
|
|
5641
5705
|
S: this,
|
|
5642
5706
|
A: [
|
|
5643
5707
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5649,7 +5713,7 @@ var ClientServicesHost = class {
|
|
|
5649
5713
|
count: loadedInvitations.invitations?.length
|
|
5650
5714
|
}, {
|
|
5651
5715
|
F: __dxlog_file19,
|
|
5652
|
-
L:
|
|
5716
|
+
L: 317,
|
|
5653
5717
|
S: this,
|
|
5654
5718
|
C: (f, a) => f(...a)
|
|
5655
5719
|
});
|
|
@@ -5672,7 +5736,7 @@ var ClientServicesHost = class {
|
|
|
5672
5736
|
deviceKey
|
|
5673
5737
|
}, {
|
|
5674
5738
|
F: __dxlog_file19,
|
|
5675
|
-
L:
|
|
5739
|
+
L: 335,
|
|
5676
5740
|
S: this,
|
|
5677
5741
|
C: (f, a) => f(...a)
|
|
5678
5742
|
});
|
|
@@ -5680,7 +5744,7 @@ var ClientServicesHost = class {
|
|
|
5680
5744
|
id: traceId
|
|
5681
5745
|
}), {
|
|
5682
5746
|
F: __dxlog_file19,
|
|
5683
|
-
L:
|
|
5747
|
+
L: 336,
|
|
5684
5748
|
S: this,
|
|
5685
5749
|
C: (f, a) => f(...a)
|
|
5686
5750
|
});
|
|
@@ -5694,7 +5758,7 @@ var ClientServicesHost = class {
|
|
|
5694
5758
|
deviceKey
|
|
5695
5759
|
}, {
|
|
5696
5760
|
F: __dxlog_file19,
|
|
5697
|
-
L:
|
|
5761
|
+
L: 347,
|
|
5698
5762
|
S: this,
|
|
5699
5763
|
C: (f, a) => f(...a)
|
|
5700
5764
|
});
|
|
@@ -5712,7 +5776,7 @@ var ClientServicesHost = class {
|
|
|
5712
5776
|
deviceKey
|
|
5713
5777
|
}, {
|
|
5714
5778
|
F: __dxlog_file19,
|
|
5715
|
-
L:
|
|
5779
|
+
L: 356,
|
|
5716
5780
|
S: this,
|
|
5717
5781
|
C: (f, a) => f(...a)
|
|
5718
5782
|
});
|
|
@@ -5723,13 +5787,13 @@ var ClientServicesHost = class {
|
|
|
5723
5787
|
id: traceId
|
|
5724
5788
|
}), {
|
|
5725
5789
|
F: __dxlog_file19,
|
|
5726
|
-
L:
|
|
5790
|
+
L: 361,
|
|
5727
5791
|
S: this,
|
|
5728
5792
|
C: (f, a) => f(...a)
|
|
5729
5793
|
});
|
|
5730
5794
|
log16("resetting...", void 0, {
|
|
5731
5795
|
F: __dxlog_file19,
|
|
5732
|
-
L:
|
|
5796
|
+
L: 363,
|
|
5733
5797
|
S: this,
|
|
5734
5798
|
C: (f, a) => f(...a)
|
|
5735
5799
|
});
|
|
@@ -5737,7 +5801,7 @@ var ClientServicesHost = class {
|
|
|
5737
5801
|
await this._storage.reset();
|
|
5738
5802
|
log16("reset", void 0, {
|
|
5739
5803
|
F: __dxlog_file19,
|
|
5740
|
-
L:
|
|
5804
|
+
L: 366,
|
|
5741
5805
|
S: this,
|
|
5742
5806
|
C: (f, a) => f(...a)
|
|
5743
5807
|
});
|
|
@@ -5745,7 +5809,7 @@ var ClientServicesHost = class {
|
|
|
5745
5809
|
id: traceId
|
|
5746
5810
|
}), {
|
|
5747
5811
|
F: __dxlog_file19,
|
|
5748
|
-
L:
|
|
5812
|
+
L: 367,
|
|
5749
5813
|
S: this,
|
|
5750
5814
|
C: (f, a) => f(...a)
|
|
5751
5815
|
});
|
|
@@ -5758,7 +5822,7 @@ var ClientServicesHost = class {
|
|
|
5758
5822
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5759
5823
|
invariant16(automergeIndex, void 0, {
|
|
5760
5824
|
F: __dxlog_file19,
|
|
5761
|
-
L:
|
|
5825
|
+
L: 379,
|
|
5762
5826
|
S: this,
|
|
5763
5827
|
A: [
|
|
5764
5828
|
"automergeIndex",
|
|
@@ -5864,7 +5928,7 @@ export {
|
|
|
5864
5928
|
IdentityServiceImpl,
|
|
5865
5929
|
DeviceInvitationProtocol,
|
|
5866
5930
|
InvitationsHandler,
|
|
5867
|
-
|
|
5931
|
+
createAdmissionKeypair,
|
|
5868
5932
|
InvitationsServiceImpl,
|
|
5869
5933
|
SpaceInvitationProtocol,
|
|
5870
5934
|
ClientRpcServer,
|
|
@@ -5884,4 +5948,4 @@ export {
|
|
|
5884
5948
|
ClientServicesHost,
|
|
5885
5949
|
ClientServicesProviderResource
|
|
5886
5950
|
};
|
|
5887
|
-
//# sourceMappingURL=chunk-
|
|
5951
|
+
//# sourceMappingURL=chunk-3Z5ZPB7G.mjs.map
|