jsgar 4.13.3 → 4.13.4
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/gar.umd.js +36 -15
- package/gar.js +36 -15
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -1551,27 +1551,48 @@
|
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
1553
|
/**
|
|
1554
|
-
*
|
|
1554
|
+
* Remove a single class from a key by sending a KeyIntroduction with deleted_class set, if the
|
|
1555
|
+
* key exists in the localKeyMap. Safe to call multiple times. The key may still exist on the
|
|
1556
|
+
* server in other classes, so the localKeyMap entry is preserved. Careful: every record that
|
|
1557
|
+
* applied to className but to no remaining class is deleted.
|
|
1555
1558
|
* @param {string} keyName - Key name
|
|
1556
|
-
* @param {string
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1559
|
+
* @param {string} className - Class to remove from the key
|
|
1560
|
+
* @param {string|Array<string>|null} [downgradeToClassList=null] - If set, populates
|
|
1561
|
+
* key_introduction::class_list in the same message — the classes the key should apply to
|
|
1562
|
+
* alongside the removal. A single key_introduction may both add classes (class_list) and
|
|
1563
|
+
* remove one (deleted_class).
|
|
1561
1564
|
*/
|
|
1562
|
-
|
|
1565
|
+
deleteClass(keyName, className, downgradeToClassList = null) {
|
|
1563
1566
|
const keyId = this.localKeyMap.get(keyName);
|
|
1564
1567
|
if (keyId === undefined) return;
|
|
1568
|
+
const value = { key_id: keyId, name: keyName, deleted_class: className };
|
|
1569
|
+
if (downgradeToClassList) {
|
|
1570
|
+
value.class_list = typeof downgradeToClassList === 'string'
|
|
1571
|
+
? downgradeToClassList.split(/\s+/).filter(Boolean)
|
|
1572
|
+
: downgradeToClassList;
|
|
1573
|
+
}
|
|
1574
|
+
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
|
|
1579
|
+
* @param {string} keyName - Key name
|
|
1580
|
+
* @param {string|null} [className=null] - If set, delegates to deleteClass (KeyIntroduction
|
|
1581
|
+
* with deleted_class set); the key may still exist on the server in other classes and the
|
|
1582
|
+
* localKeyMap entry is preserved. If unset, sends DeleteKey to remove the key entirely and
|
|
1583
|
+
* forgets the local id so a future getAndPossiblyIntroduceKeyId(keyName) re-introduces with
|
|
1584
|
+
* a fresh id.
|
|
1585
|
+
*/
|
|
1586
|
+
deleteKey(keyName, className = null) {
|
|
1565
1587
|
if (className) {
|
|
1566
|
-
this.
|
|
1567
|
-
|
|
1568
|
-
value: { key_id: keyId, name: keyName, deleted_class: className },
|
|
1569
|
-
});
|
|
1570
|
-
} else {
|
|
1571
|
-
this.publishDeleteKey(keyId);
|
|
1572
|
-
// Forget the local id so future re-introduction allocates a new one.
|
|
1573
|
-
this.localKeyMap.delete(keyName);
|
|
1588
|
+
this.deleteClass(keyName, className);
|
|
1589
|
+
return;
|
|
1574
1590
|
}
|
|
1591
|
+
const keyId = this.localKeyMap.get(keyName);
|
|
1592
|
+
if (keyId === undefined) return;
|
|
1593
|
+
this.publishDeleteKey(keyId);
|
|
1594
|
+
// Forget the local id so future re-introduction allocates a new one.
|
|
1595
|
+
this.localKeyMap.delete(keyName);
|
|
1575
1596
|
}
|
|
1576
1597
|
|
|
1577
1598
|
/**
|
package/gar.js
CHANGED
|
@@ -1544,27 +1544,48 @@ class GARClient {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
|
|
1546
1546
|
/**
|
|
1547
|
-
*
|
|
1547
|
+
* Remove a single class from a key by sending a KeyIntroduction with deleted_class set, if the
|
|
1548
|
+
* key exists in the localKeyMap. Safe to call multiple times. The key may still exist on the
|
|
1549
|
+
* server in other classes, so the localKeyMap entry is preserved. Careful: every record that
|
|
1550
|
+
* applied to className but to no remaining class is deleted.
|
|
1548
1551
|
* @param {string} keyName - Key name
|
|
1549
|
-
* @param {string
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1552
|
+
* @param {string} className - Class to remove from the key
|
|
1553
|
+
* @param {string|Array<string>|null} [downgradeToClassList=null] - If set, populates
|
|
1554
|
+
* key_introduction::class_list in the same message — the classes the key should apply to
|
|
1555
|
+
* alongside the removal. A single key_introduction may both add classes (class_list) and
|
|
1556
|
+
* remove one (deleted_class).
|
|
1554
1557
|
*/
|
|
1555
|
-
|
|
1558
|
+
deleteClass(keyName, className, downgradeToClassList = null) {
|
|
1556
1559
|
const keyId = this.localKeyMap.get(keyName);
|
|
1557
1560
|
if (keyId === undefined) return;
|
|
1561
|
+
const value = { key_id: keyId, name: keyName, deleted_class: className };
|
|
1562
|
+
if (downgradeToClassList) {
|
|
1563
|
+
value.class_list = typeof downgradeToClassList === 'string'
|
|
1564
|
+
? downgradeToClassList.split(/\s+/).filter(Boolean)
|
|
1565
|
+
: downgradeToClassList;
|
|
1566
|
+
}
|
|
1567
|
+
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
|
|
1572
|
+
* @param {string} keyName - Key name
|
|
1573
|
+
* @param {string|null} [className=null] - If set, delegates to deleteClass (KeyIntroduction
|
|
1574
|
+
* with deleted_class set); the key may still exist on the server in other classes and the
|
|
1575
|
+
* localKeyMap entry is preserved. If unset, sends DeleteKey to remove the key entirely and
|
|
1576
|
+
* forgets the local id so a future getAndPossiblyIntroduceKeyId(keyName) re-introduces with
|
|
1577
|
+
* a fresh id.
|
|
1578
|
+
*/
|
|
1579
|
+
deleteKey(keyName, className = null) {
|
|
1558
1580
|
if (className) {
|
|
1559
|
-
this.
|
|
1560
|
-
|
|
1561
|
-
value: { key_id: keyId, name: keyName, deleted_class: className },
|
|
1562
|
-
});
|
|
1563
|
-
} else {
|
|
1564
|
-
this.publishDeleteKey(keyId);
|
|
1565
|
-
// Forget the local id so future re-introduction allocates a new one.
|
|
1566
|
-
this.localKeyMap.delete(keyName);
|
|
1581
|
+
this.deleteClass(keyName, className);
|
|
1582
|
+
return;
|
|
1567
1583
|
}
|
|
1584
|
+
const keyId = this.localKeyMap.get(keyName);
|
|
1585
|
+
if (keyId === undefined) return;
|
|
1586
|
+
this.publishDeleteKey(keyId);
|
|
1587
|
+
// Forget the local id so future re-introduction allocates a new one.
|
|
1588
|
+
this.localKeyMap.delete(keyName);
|
|
1568
1589
|
}
|
|
1569
1590
|
|
|
1570
1591
|
/**
|