MCPcopy
hub / github.com/mailvelope/mailvelope / hasPrivateKey

Method hasPrivateKey

src/controller/api.controller.js:124–144  ·  view source on GitHub ↗
({keyringId, fingerprint, email})

Source from the content-addressed store, hash-verified

122 }
123
124 async hasPrivateKey({keyringId, fingerprint, email}) {
125 const keyring = await keyringById(keyringId);
126 if (fingerprint && email) {
127 throw new MvError('Use either fingerprint or email parameter.', 'INVALID_OPTIONS');
128 }
129 if (email) {
130 const keyMap = await keyring.getKeyByAddress(email, {pub: false, priv: true, sort: true});
131 return Boolean(keyMap[email]);
132 } else if (fingerprint) {
133 const fpr = fingerprint.toLowerCase().replace(/\s/g, '');
134 const key = keyring.keystore.privateKeys.getForId(fpr);
135 if (!key) {
136 return false;
137 }
138 const status = await verifyPrimaryKey(key);
139 return status === KEY_STATUS.valid;
140 } else {
141 const hasPrivateKey = keyring.hasPrivateKey();
142 return hasPrivateKey;
143 }
144 }
145
146 async openSettings({keyringId = MAIN_KEYRING_ID, options = {}}) {
147 let fragment;

Callers

nothing calls this directly

Calls 3

verifyPrimaryKeyFunction · 0.90
getKeyByAddressMethod · 0.80
getForIdMethod · 0.80

Tested by

no test coverage detected