MCPcopy
hub / github.com/mailvelope/mailvelope / mapKeys

Function mapKeys

src/modules/key.js:111–145  ·  view source on GitHub ↗
(keys)

Source from the content-addressed store, hash-verified

109}
110
111export function mapKeys(keys) {
112 return Promise.all(keys.map(async key => {
113 let uiKey = {};
114 if (key.isPrivate()) {
115 uiKey.type = 'private';
116 } else {
117 uiKey.type = 'public';
118 }
119 uiKey.status = await verifyPrimaryKey(key);
120 uiKey.validity = uiKey.status === KEY_STATUS.valid;
121 uiKey.keyId = key.getKeyID().toHex().toUpperCase();
122 uiKey.fingerprint = key.getFingerprint();
123 // primary user
124 try {
125 const userInfo = await getUserInfo(key, {allowInvalid: true});
126 uiKey = {...uiKey, ...userInfo};
127 uiKey.exDate = await key.getExpirationTime();
128 if (uiKey.exDate === Infinity) {
129 uiKey.exDate = false;
130 } else if (uiKey.exDate !== null) {
131 uiKey.exDate = uiKey.exDate.toISOString();
132 }
133 } catch (e) {
134 uiKey.name = uiKey.name || 'NO USERID FOUND';
135 uiKey.email = uiKey.email || 'UNKNOWN';
136 uiKey.exDate = uiKey.exDate || null;
137 console.log(`Error in mapKeys on mapping primary user for key ${key.getFingerprint()}.`, e);
138 }
139 uiKey.crDate = key.keyPacket.created.toISOString();
140 const keyInfo = key.getAlgorithmInfo();
141 uiKey.algorithm = getAlgorithmString(keyInfo);
142 uiKey.bitLength = getKeyBitLength(keyInfo);
143 return uiKey;
144 }));
145}
146
147function getAlgorithmString({algorithm, curve}) {
148 let result = '';

Callers 9

key-test.jsFile · 0.90
addSignatureDetailsFunction · 0.90
getPublicKeysMethod · 0.90
getPrivateKeysMethod · 0.90
getValidSigningKeysMethod · 0.90
importKeyMethod · 0.90
readArmoredKeysMethod · 0.90

Calls 7

verifyPrimaryKeyFunction · 0.85
getAlgorithmStringFunction · 0.85
getKeyBitLengthFunction · 0.85
isPrivateMethod · 0.80
toHexMethod · 0.80
getUserInfoFunction · 0.70
getKeyIDMethod · 0.45

Tested by

no test coverage detected