MCPcopy
hub / github.com/mailvelope/mailvelope / getArmoredKeys

Method getArmoredKeys

src/modules/KeyringBase.js:186–206  ·  view source on GitHub ↗

* Get armored keys by fingerprints * @param {Array |String} keyFprs * @param {Boolean} options.all - return all keys in the keyring * @param {Boolean} options.pub - return all keys as public armored * @param {Boolean} options.pub - return all private keys as private armored

(keyFprs, options)

Source from the content-addressed store, hash-verified

184 * @return {Array<Strin>}
185 */
186 getArmoredKeys(keyFprs, options) {
187 const result = [];
188 keyFprs = toArray(keyFprs);
189 let keys = null;
190 if (options.all) {
191 keys = this.keystore.getAllKeys();
192 } else {
193 keys = keyFprs.map(keyFpr => this.keystore.getKeysForId(keyFpr)[0]);
194 }
195 for (const key of keys) {
196 const armored = {};
197 if (options.pub) {
198 armored.armoredPublic = key.toPublic().armor();
199 }
200 if (options.priv && key.isPrivate()) {
201 armored.armoredPrivate = key.armor();
202 }
203 result.push(armored);
204 }
205 return result;
206 }
207
208 async hasDefaultKey() {
209 return Boolean(await this.keystore.getDefaultKeyFpr());

Callers 1

Calls 5

toArrayFunction · 0.90
getAllKeysMethod · 0.80
getKeysForIdMethod · 0.80
isPrivateMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected