MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / updateKey

Method updateKey

src/controller/import.controller.js:122–144  ·  view source on GitHub ↗
(fingerprint, stockKey, newKey)

Source from the content-addressed store, hash-verified

120 }
121
122 async updateKey(fingerprint, stockKey, newKey) {
123 const statusBefore = await verifyPrimaryKey(stockKey);
124 const updatedKey = await stockKey.update(newKey);
125 const statusAfter = await verifyPrimaryKey(updatedKey);
126 if (statusBefore !== statusAfter) {
127 // key validity changes -> User confirmation required
128 if (statusAfter !== KEY_STATUS.valid) {
129 this.invalidated = true;
130 }
131 return this.openPopup();
132 }
133 const beforeLastModified = getLastModifiedDate(stockKey);
134 const afterLastModified = getLastModifiedDate(updatedKey);
135 if (beforeLastModified.valueOf() !== afterLastModified.valueOf()) {
136 // update is non-critical, no user confirmation required
137 const [importResult] = await this.keyring.importKeys([{type: 'public', armored: this.armored}]);
138 if (importResult.type === 'error') {
139 throw new Error(importResult.message);
140 }
141 }
142 // even if key does not change, we still reply with status UPDATED -> User will not be notified
143 return 'UPDATED';
144 }
145
146 openPopup() {
147 return new Promise((resolve, reject) => {

Callers 1

importKeyMethod · 0.95

Calls 5

openPopupMethod · 0.95
verifyPrimaryKeyFunction · 0.90
getLastModifiedDateFunction · 0.90
updateMethod · 0.80
importKeysMethod · 0.45

Tested by

no test coverage detected