(keys)
| 109 | } |
| 110 | |
| 111 | export 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 | |
| 147 | function getAlgorithmString({algorithm, curve}) { |
| 148 | let result = ''; |
no test coverage detected