(unlockedKey, newExDate)
| 268 | } |
| 269 | |
| 270 | async setKeyExDate(unlockedKey, newExDate) { |
| 271 | const keyExpirationTime = newExDate ? (newExDate.getTime() - unlockedKey.keyPacket.created.getTime()) / 1000 : 0; |
| 272 | const userIDs = []; |
| 273 | for (const user of unlockedKey.users) { |
| 274 | if (await verifyUser(user) === KEY_STATUS.valid) { |
| 275 | if (!this.isRFC2822UserId(user)) { |
| 276 | throw new Error('Key contains a non-RFC2822 user ID. Change of expiration date not supported.'); |
| 277 | } |
| 278 | userIDs.push({name: user.userID.name, email: user.userID.email}); |
| 279 | } |
| 280 | } |
| 281 | const filteredSubkeys = []; |
| 282 | for (const subkey of unlockedKey.subkeys) { |
| 283 | if (await verifySubKey(subkey) === KEY_STATUS.valid) { |
| 284 | filteredSubkeys.push(subkey); |
| 285 | } |
| 286 | } |
| 287 | unlockedKey.subkeys = filteredSubkeys; |
| 288 | const {privateKey: reformatedKey} = await reformatKey({privateKey: unlockedKey, userIDs, keyExpirationTime, format: 'object'}); |
| 289 | await this.updateKey({srcKey: reformatedKey}); |
| 290 | } |
| 291 | |
| 292 | async updateKey({srcKey, destKey, store = true}) { |
| 293 | const fingerprint = srcKey.getFingerprint(); |
nothing calls this directly
no test coverage detected