MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / getReservedOperations

Function getReservedOperations

src/modules/pwdCache.js:226–233  ·  view source on GitHub ↗

* Get number of decryptable session keys * @param {openpgp.key.Key} key - private key, expected unlocked * @param {openpgp.message.Message} message - message with encrypted session keys * @return {Number} return the number of decryptable session keys

({key, message})

Source from the content-addressed store, hash-verified

224 * @return {Number} return the number of decryptable session keys
225 */
226function getReservedOperations({key, message}) {
227 if (!key) {
228 return 1;
229 }
230 const pkESKeyPacketlist = message.packets.filterByTag(enums.packet.publicKeyEncryptedSessionKey);
231 const keyIdsHex = key.getKeys().map(({keyPacket}) => keyPacket.getKeyID().toHex());
232 return pkESKeyPacketlist.filter(keyPacket => keyIdsHex.includes(keyPacket.publicKeyID.toHex())).length;
233}
234
235/**
236 * Unlocked key if required and update cache

Callers 2

getFunction · 0.85
unlockFunction · 0.85

Calls 3

getKeysMethod · 0.80
toHexMethod · 0.80
getKeyIDMethod · 0.45

Tested by

no test coverage detected