@dxos/credentials 0.7.5-labs.35b4b42 → 0.7.5-labs.8a82073
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/index.mjs +18 -43
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +18 -43
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +18 -43
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/processor/device-state-machine.d.ts.map +1 -1
- package/dist/types/src/state-machine/space-state-machine.d.ts +0 -1
- package/dist/types/src/state-machine/space-state-machine.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/processor/device-state-machine.ts +3 -2
- package/src/state-machine/space-state-machine.ts +6 -19
|
@@ -1535,15 +1535,18 @@ var SpaceStateMachine = class {
|
|
|
1535
1535
|
* @param fromFeed Key of the feed where this credential is recorded.
|
|
1536
1536
|
*/
|
|
1537
1537
|
async process(credential, { sourceFeed, skipVerification }) {
|
|
1538
|
-
if (credential.id
|
|
1539
|
-
|
|
1538
|
+
if (credential.id) {
|
|
1539
|
+
if (this._processedCredentials.has(credential.id)) {
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
this._processedCredentials.add(credential.id);
|
|
1540
1543
|
}
|
|
1541
1544
|
if (!skipVerification) {
|
|
1542
1545
|
const result = await verifyCredential(credential);
|
|
1543
1546
|
if (result.kind !== "pass") {
|
|
1544
1547
|
log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
|
|
1545
1548
|
F: __dxlog_file6,
|
|
1546
|
-
L:
|
|
1549
|
+
L: 156,
|
|
1547
1550
|
S: this,
|
|
1548
1551
|
C: (f, a) => f(...a)
|
|
1549
1552
|
});
|
|
@@ -1556,7 +1559,7 @@ var SpaceStateMachine = class {
|
|
|
1556
1559
|
if (this._genesisCredential) {
|
|
1557
1560
|
log3.warn("Space already has a genesis credential.", void 0, {
|
|
1558
1561
|
F: __dxlog_file6,
|
|
1559
|
-
L:
|
|
1562
|
+
L: 165,
|
|
1560
1563
|
S: this,
|
|
1561
1564
|
C: (f, a) => f(...a)
|
|
1562
1565
|
});
|
|
@@ -1565,7 +1568,7 @@ var SpaceStateMachine = class {
|
|
|
1565
1568
|
if (!credential.issuer.equals(this._spaceKey)) {
|
|
1566
1569
|
log3.warn("Space genesis credential must be issued by space.", void 0, {
|
|
1567
1570
|
F: __dxlog_file6,
|
|
1568
|
-
L:
|
|
1571
|
+
L: 169,
|
|
1569
1572
|
S: this,
|
|
1570
1573
|
C: (f, a) => f(...a)
|
|
1571
1574
|
});
|
|
@@ -1574,7 +1577,7 @@ var SpaceStateMachine = class {
|
|
|
1574
1577
|
if (!credential.subject.id.equals(this._spaceKey)) {
|
|
1575
1578
|
log3.warn("Space genesis credential must be issued to space.", void 0, {
|
|
1576
1579
|
F: __dxlog_file6,
|
|
1577
|
-
L:
|
|
1580
|
+
L: 173,
|
|
1578
1581
|
S: this,
|
|
1579
1582
|
C: (f, a) => f(...a)
|
|
1580
1583
|
});
|
|
@@ -1590,7 +1593,7 @@ var SpaceStateMachine = class {
|
|
|
1590
1593
|
if (!this._genesisCredential) {
|
|
1591
1594
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1592
1595
|
F: __dxlog_file6,
|
|
1593
|
-
L:
|
|
1596
|
+
L: 186,
|
|
1594
1597
|
S: this,
|
|
1595
1598
|
C: (f, a) => f(...a)
|
|
1596
1599
|
});
|
|
@@ -1599,7 +1602,7 @@ var SpaceStateMachine = class {
|
|
|
1599
1602
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1600
1603
|
log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1601
1604
|
F: __dxlog_file6,
|
|
1602
|
-
L:
|
|
1605
|
+
L: 190,
|
|
1603
1606
|
S: this,
|
|
1604
1607
|
C: (f, a) => f(...a)
|
|
1605
1608
|
});
|
|
@@ -1613,7 +1616,7 @@ var SpaceStateMachine = class {
|
|
|
1613
1616
|
if (!this._genesisCredential) {
|
|
1614
1617
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1615
1618
|
F: __dxlog_file6,
|
|
1616
|
-
L:
|
|
1619
|
+
L: 201,
|
|
1617
1620
|
S: this,
|
|
1618
1621
|
C: (f, a) => f(...a)
|
|
1619
1622
|
});
|
|
@@ -1626,19 +1629,7 @@ var SpaceStateMachine = class {
|
|
|
1626
1629
|
if (!this._genesisCredential) {
|
|
1627
1630
|
log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
|
|
1628
1631
|
F: __dxlog_file6,
|
|
1629
|
-
L:
|
|
1630
|
-
S: this,
|
|
1631
|
-
C: (f, a) => f(...a)
|
|
1632
|
-
});
|
|
1633
|
-
return false;
|
|
1634
|
-
}
|
|
1635
|
-
if (!this._canAdmitFeeds(credential.issuer)) {
|
|
1636
|
-
log3.warn(`Space member is not authorized to admit feeds: ${credential.issuer}`, {
|
|
1637
|
-
sourceFeed: sourceFeed.toHex(),
|
|
1638
|
-
feed: credential.subject.id.toHex()
|
|
1639
|
-
}, {
|
|
1640
|
-
F: __dxlog_file6,
|
|
1641
|
-
L: 212,
|
|
1632
|
+
L: 211,
|
|
1642
1633
|
S: this,
|
|
1643
1634
|
C: (f, a) => f(...a)
|
|
1644
1635
|
});
|
|
@@ -1652,7 +1643,7 @@ var SpaceStateMachine = class {
|
|
|
1652
1643
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1653
1644
|
log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1654
1645
|
F: __dxlog_file6,
|
|
1655
|
-
L:
|
|
1646
|
+
L: 222,
|
|
1656
1647
|
S: this,
|
|
1657
1648
|
C: (f, a) => f(...a)
|
|
1658
1649
|
});
|
|
@@ -1677,9 +1668,6 @@ var SpaceStateMachine = class {
|
|
|
1677
1668
|
}
|
|
1678
1669
|
}
|
|
1679
1670
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1680
|
-
if (credential.id) {
|
|
1681
|
-
this._processedCredentials.add(credential.id);
|
|
1682
|
-
}
|
|
1683
1671
|
return true;
|
|
1684
1672
|
}
|
|
1685
1673
|
getMemberRole(memberKey) {
|
|
@@ -1691,10 +1679,6 @@ var SpaceStateMachine = class {
|
|
|
1691
1679
|
_canInviteNewMembers(key) {
|
|
1692
1680
|
return key.equals(this._spaceKey) || this._members.getRole(key) === SpaceMember3.Role.ADMIN || this._members.getRole(key) === SpaceMember3.Role.OWNER;
|
|
1693
1681
|
}
|
|
1694
|
-
_canAdmitFeeds(key) {
|
|
1695
|
-
const role = this._members.getRole(key);
|
|
1696
|
-
return role === SpaceMember3.Role.EDITOR || role === SpaceMember3.Role.ADMIN || role === SpaceMember3.Role.OWNER;
|
|
1697
|
-
}
|
|
1698
1682
|
};
|
|
1699
1683
|
_ts_decorate([
|
|
1700
1684
|
synchronized
|
|
@@ -1706,7 +1690,7 @@ var CredentialConsumer = class {
|
|
|
1706
1690
|
this._onClose = _onClose;
|
|
1707
1691
|
this._ctx = new Context(void 0, {
|
|
1708
1692
|
F: __dxlog_file6,
|
|
1709
|
-
L:
|
|
1693
|
+
L: 267
|
|
1710
1694
|
});
|
|
1711
1695
|
this._isReadyForLiveCredentials = false;
|
|
1712
1696
|
}
|
|
@@ -1763,15 +1747,6 @@ var DeviceStateMachine = class {
|
|
|
1763
1747
|
const assertion = getCredentialAssertion(credential);
|
|
1764
1748
|
switch (assertion["@type"]) {
|
|
1765
1749
|
case "dxos.halo.credentials.AuthorizedDevice": {
|
|
1766
|
-
invariant6(!this.authorizedDeviceKeys.has(assertion.deviceKey), "Device already added.", {
|
|
1767
|
-
F: __dxlog_file7,
|
|
1768
|
-
L: 51,
|
|
1769
|
-
S: this,
|
|
1770
|
-
A: [
|
|
1771
|
-
"!this.authorizedDeviceKeys.has(assertion.deviceKey)",
|
|
1772
|
-
"'Device already added.'"
|
|
1773
|
-
]
|
|
1774
|
-
});
|
|
1775
1750
|
this.authorizedDeviceKeys.set(assertion.deviceKey, {});
|
|
1776
1751
|
log4("added device", {
|
|
1777
1752
|
localDeviceKey: this._params.deviceKey,
|
|
@@ -1779,7 +1754,7 @@ var DeviceStateMachine = class {
|
|
|
1779
1754
|
size: this.authorizedDeviceKeys.size
|
|
1780
1755
|
}, {
|
|
1781
1756
|
F: __dxlog_file7,
|
|
1782
|
-
L:
|
|
1757
|
+
L: 55,
|
|
1783
1758
|
S: this,
|
|
1784
1759
|
C: (f, a) => f(...a)
|
|
1785
1760
|
});
|
|
@@ -1789,7 +1764,7 @@ var DeviceStateMachine = class {
|
|
|
1789
1764
|
case "dxos.halo.credentials.DeviceProfile": {
|
|
1790
1765
|
invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
|
|
1791
1766
|
F: __dxlog_file7,
|
|
1792
|
-
L:
|
|
1767
|
+
L: 65,
|
|
1793
1768
|
S: this,
|
|
1794
1769
|
A: [
|
|
1795
1770
|
"this.authorizedDeviceKeys.has(credential.subject.id)",
|
|
@@ -1802,7 +1777,7 @@ var DeviceStateMachine = class {
|
|
|
1802
1777
|
profile: assertion.profile
|
|
1803
1778
|
}, {
|
|
1804
1779
|
F: __dxlog_file7,
|
|
1805
|
-
L:
|
|
1780
|
+
L: 68,
|
|
1806
1781
|
S: this,
|
|
1807
1782
|
C: (f, a) => f(...a)
|
|
1808
1783
|
});
|