Skip to content
Snippets Groups Projects

908 account recovery ability to add contacts to trusted contacts list for account recovery

Compare and
7 files
+ 1126
6
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -40,6 +40,11 @@ import {
STATUS_USER_BLOCKED
} from "../constants/statuses";
import generateQrCode from "../utilities/generateQrCode";
import {
generateRecoveryKey,
divideSecretToShares,
combineSecret
} from "../utilities/secrets";
const penpalMethods = require("../../temp/penpal-methods").default;
const WopiAPI = require("./wopiapi-iframe");
@@ -717,10 +722,7 @@ const connection = Penpal.connectToParent({
});
});
},
finalizeEmployeeRegistration: async (
identity,
identifier
) => {
finalizeEmployeeRegistration: async (identity, identifier) => {
viamApi.setIdentity(identity.authentication.publicKey);
return executeRestfulFunction(
"public",
@@ -970,6 +972,47 @@ const connection = Penpal.connectToParent({
});
});
},
contactsGetTrusteeContactsPublicKeys: async () => {
try {
console.log("getting public keys");
const response = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.contactsGetTrusteeContactsPublicKeys,
null
);
console.log({ response });
if (response.code !== "200") return response;
const responseData = response.data;
console.log({ responseData });
const contactsPublicKeys = Object.values(responseData).flat();
console.log({ contactsPublicKeys });
const sharesNumber = contactsPublicKeys.length;
const getThreshold = () =>
sharesNumber === 3 ? 2 : parseInt(sharesNumber / 2);
const threshold = getThreshold();
console.log({ threshold });
const recoveryKey = generateRecoveryKey(512);
console.log({ recoveryKey });
const recoveryKeyShares = divideSecretToShares(
recoveryKey,
sharesNumber,
threshold
);
// Sanity check
const checkKey = combineSecret(recoveryKeyShares.slice(0, 1));
console.log("first sanity check", checkKey === recoveryKey);
return response;
} catch (error) {
return {
data: "",
code: "400",
status: error.message
};
}
},
parseSMIME,
getCurrentlyLoggedInUUID() {
return new Penpal.Promise(result => {
Loading