(fingerprint, stockKey, newKey)
| 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) => { |
no test coverage detected