MCPcopy
hub / github.com/mailvelope/mailvelope / addSignatureDetails

Function addSignatureDetails

src/modules/pgpModel.js:112–139  ·  view source on GitHub ↗

* Add signing key details to signature. Validate if sender identity matches signature. * @param {Array} signatures * @param {KeyringBase} keyring

({signatures = [], keyring, senderAddress})

Source from the content-addressed store, hash-verified

110 * @param {KeyringBase} keyring
111 */
112async function addSignatureDetails({signatures = [], keyring, senderAddress}) {
113 let senderKeys;
114 if (senderAddress) {
115 // valid sender keys for verification of the message are keys with the sender email address as user ID
116 ({[senderAddress]: senderKeys} = await keyring.getKeyByAddress(senderAddress));
117 }
118 for (const signature of signatures) {
119 if (signature.valid === null) {
120 continue;
121 }
122 const signingKey = keyring.keystore.getKeysForId(signature.fingerprint ?? signature.keyId, true);
123 if (signingKey) {
124 [signature.keyDetails] = await mapKeys(signingKey);
125 }
126 if (!signature.valid) {
127 continue;
128 }
129 if (senderKeys) {
130 if (!senderKeys.length) {
131 // we don't have the sender email and therefore the connection between this signature and the sender is uncertain
132 signature.uncertainSender = true;
133 } else if (!senderKeys.some(key => key.getKeys(keyIDfromHex(signature)).length)) {
134 // sender email is not present in user ID of key that created this signature
135 signature.senderMismatch = true;
136 }
137 }
138 }
139}
140
141export function noKeyFoundError(encryptionKeyIds) {
142 const keyId = encryptionKeyIds[0].toHex();

Callers 4

decryptMessageFunction · 0.85
verifyMessageFunction · 0.85
verifyDetachedSignatureFunction · 0.85
decryptFileFunction · 0.85

Calls 5

mapKeysFunction · 0.90
keyIDfromHexFunction · 0.90
getKeyByAddressMethod · 0.80
getKeysForIdMethod · 0.80
getKeysMethod · 0.80

Tested by

no test coverage detected