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

Function get

src/modules/pwdCache.js:145–169  ·  view source on GitHub ↗
(primaryKeyFpr, message)

Source from the content-addressed store, hash-verified

143 * @return {Promise<Object>} - password of key, if available unlocked key
144 */
145export async function get(primaryKeyFpr, message) {
146 if (!await cache.has(primaryKeyFpr)) {
147 return;
148 }
149 const entry = await cache.get(primaryKeyFpr);
150 let operations = 1;
151 if (message) {
152 operations += getReservedOperations({key: entry.key, message});
153 }
154 entry.operations -= operations;
155 entry.tlOperations -= operations;
156 await cache.set(primaryKeyFpr, entry);
157 if (!Math.max(0, entry.tlOperations)) {
158 return;
159 }
160 if (Math.max(0, entry.operations)) {
161 return {
162 password: entry.password,
163 key: entry.key
164 };
165 } else {
166 // number of allowed operations exhausted
167 deleteEntry(primaryKeyFpr);
168 }
169}
170
171/**
172 * Return true if key is cached

Callers

nothing calls this directly

Calls 5

getReservedOperationsFunction · 0.85
deleteEntryFunction · 0.85
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected