MCPcopy
hub / github.com/mailvelope/mailvelope / getUserInfo

Function getUserInfo

src/modules/key.js:19–40  ·  view source on GitHub ↗
(key, {allowInvalid = false, strict = false} = {})

Source from the content-addressed store, hash-verified

17 * @return {Object<userId, email, content>}
18 */
19export async function getUserInfo(key, {allowInvalid = false, strict = false} = {}) {
20 let primaryUser;
21 try {
22 ({user: primaryUser} = await key.getPrimaryUser());
23 } catch (e) {
24 console.log('No valid primary user found for key', e);
25 }
26 if (!primaryUser && strict) {
27 return null;
28 }
29 if (!primaryUser && allowInvalid) {
30 // take first available user with user ID
31 primaryUser = key.users.find(user => user.userID);
32 }
33 if (!primaryUser) {
34 return {userId: l10n.get('keygrid_invalid_userid'), email: '', name: ''};
35 }
36 const {userID: userId, name, email} = primaryUser.userID;
37 const result = {userId, name, email};
38 parseUserId(result);
39 return result;
40}
41
42export async function cloneKey(key) {
43 const binaryKey = key.toPacketList().write();

Callers 9

key-test.jsFile · 0.90
logEncryptionFunction · 0.90
logDecryptionFunction · 0.90
importPublicKeyMethod · 0.90
importPrivateKeyMethod · 0.90
getKeyDataMethod · 0.90
onPwdDialogInitMethod · 0.90
mapKeysFunction · 0.70
mapUsersFunction · 0.70

Calls 2

parseUserIdFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected