MCPcopy
hub / github.com/mailvelope/mailvelope / setKeyExDate

Method setKeyExDate

src/modules/KeyringLocal.js:270–290  ·  view source on GitHub ↗
(unlockedKey, newExDate)

Source from the content-addressed store, hash-verified

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();

Callers

nothing calls this directly

Calls 5

isRFC2822UserIdMethod · 0.95
updateKeyMethod · 0.95
verifyUserFunction · 0.90
verifySubKeyFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected