MCPcopy
hub / github.com/mailvelope/mailvelope / addUser

Method addUser

src/modules/KeyringLocal.js:255–268  ·  view source on GitHub ↗
(unlockedKey, user)

Source from the content-addressed store, hash-verified

253 }
254
255 async addUser(unlockedKey, user) {
256 const {user: {userID: primaryUserId}, selfCertification: primaryUserSelfCertification} = await unlockedKey.getPrimaryUser();
257 const {privateKey: updatedKey} = await reformatKey({privateKey: unlockedKey, userIDs: [{name: primaryUserId.name, email: primaryUserId.email}, user], keyExpirationTime: primaryUserSelfCertification.keyExpirationTime, format: 'object'});
258 const fingerprint = updatedKey.getFingerprint();
259 await this.sync.add(fingerprint, keyringSync.UPDATE);
260 const originalKey = this.getPrivateKeyByFpr(fingerprint);
261 originalKey.users.push(updatedKey.users[1]);
262 if (primaryUserSelfCertification.isPrimaryUserID !== true) {
263 // openpgp.reformatKey sets the first user ID as primary. We update the old user ID if primary flag is not yet set.
264 await originalKey.users.find(({userID: {userID}}) => userID === primaryUserId.userID).update(updatedKey.users[0]);
265 }
266 await this.keystore.store();
267 await this.sync.commit();
268 }
269
270 async setKeyExDate(unlockedKey, newExDate) {
271 const keyExpirationTime = newExDate ? (newExDate.getTime() - unlockedKey.keyPacket.created.getTime()) / 1000 : 0;

Callers

nothing calls this directly

Calls 6

addMethod · 0.80
getPrivateKeyByFprMethod · 0.80
updateMethod · 0.80
commitMethod · 0.80
pushMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected