Implement openpgp.getWorker().clearKeyCache()
This commit is contained in:
parent
523432334f
commit
fb666f0624
|
@ -134,6 +134,20 @@ AsyncProxy.prototype.seedRandom = async function(workerId, size) {
|
||||||
this.workers[workerId].postMessage({ event:'seed-random', buf }, util.getTransferables(buf, true));
|
this.workers[workerId].postMessage({ event:'seed-random', buf }, util.getTransferables(buf, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear key caches
|
||||||
|
* @async
|
||||||
|
*/
|
||||||
|
AsyncProxy.prototype.clearKeyCache = async function() {
|
||||||
|
await Promise.all(this.workers.map(worker => new Promise((resolve, reject) => {
|
||||||
|
const id = this.getID();
|
||||||
|
|
||||||
|
worker.postMessage({ id, event: 'clear-key-cache' });
|
||||||
|
|
||||||
|
this.tasks[id] = { resolve, reject };
|
||||||
|
})));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminates the workers
|
* Terminates the workers
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -119,6 +119,16 @@ function getCachedKey(key) {
|
||||||
* @param {Object} options The api function's options
|
* @param {Object} options The api function's options
|
||||||
*/
|
*/
|
||||||
function delegate(id, method, options) {
|
function delegate(id, method, options) {
|
||||||
|
if (method === 'clear-key-cache') {
|
||||||
|
Array.from(keyCache.values()).forEach(key => {
|
||||||
|
if (key.isPrivate()) {
|
||||||
|
key.clearPrivateParams();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keyCache.clear();
|
||||||
|
response({ id, event: 'method-return' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (typeof openpgp[method] !== 'function') {
|
if (typeof openpgp[method] !== 'function') {
|
||||||
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user