MCPcopy
hub / github.com/mailvelope/mailvelope / sanitizeKey

Function sanitizeKey

src/modules/key.js:459–490  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

457 * @return {openpgp.key.Key|null} the sanitized key or null if is invalid (expired and revoked keys are still considered as valid)
458 */
459export async function sanitizeKey(key) {
460 // filter out users with no or invalid self certificate
461 const users = [];
462 for (const user of key.users) {
463 try {
464 const status = await verifyUser(user);
465 if (status === KEY_STATUS.no_self_cert ||
466 status === KEY_STATUS.invalid) {
467 continue;
468 }
469 users.push(user);
470 } catch (e) {}
471 }
472 key.users = users;
473 // discard key without users
474 if (!key.users.length) {
475 return null;
476 }
477 // filter out sub keys with no or invalid binding signature
478 const subKeys = [];
479 for (const subKey of key.subkeys) {
480 try {
481 const status = await verifySubKey(subKey);
482 if (status === KEY_STATUS.invalid) {
483 continue;
484 }
485 subKeys.push(subKey);
486 } catch (e) {}
487 }
488 key.subkeys = subKeys;
489 return key;
490}
491
492export async function verifyForAddress(key, email) {
493 email = email.toLowerCase();

Callers 4

importPublicKeyMethod · 0.90
importPrivateKeyMethod · 0.90
importKeyMethod · 0.90
readArmoredKeysMethod · 0.90

Calls 3

verifyUserFunction · 0.85
verifySubKeyFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected