Skip to content
Snippets Groups Projects
Commit e50fd3f5 authored by Sasha Ilieva's avatar Sasha Ilieva
Browse files

Wrap in try catch

parent 9086c180
Branches
Tags
1 merge request!88908 account recovery ability to add contacts to trusted contacts list for account recovery
......@@ -290,28 +290,32 @@ const handleIdentityLogin = (identity, uuid, token) => {
const getTrusteeContactsPublicKeys = async () => {
const { viamApi } = window;
const response = await viamApi.contactsGetTrusteeContactsPublicKeys();
console.log({ response });
if (response.data.code !== "200") return response.data;
const responseData = response.data.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);
const recoveryKeyShares = divideSecretToShares(
recoveryKey,
sharesNumber,
threshold
);
// Sanity check
const checkKey = combineSecret(recoveryKeyShares.slice(0, 1));
console.log("first sanity check", checkKey === recoveryKey);
try {
const response = await viamApi.contactsGetTrusteeContactsPublicKeys();
console.log({ response });
if (response.data.code !== "200") return response.data;
const responseData = response.data.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);
const recoveryKeyShares = divideSecretToShares(
recoveryKey,
sharesNumber,
threshold
);
// Sanity check
const checkKey = combineSecret(recoveryKeyShares.slice(0, 1));
console.log("first sanity check", checkKey === recoveryKey);
} catch (error) {
console.warn(error);
}
};
async function executeRestfulFunction(type, that, fn, config, ...args) {
......@@ -426,7 +430,7 @@ function loadIdentityInternal(identityKey, pinCode) {
window.viamAnonymousApi.setIdentity(
window.currentlyLoadedIdentity.authentication.publicKey
);
getTrusteeContactsPublicKeys();
const { publicKey, x509Certificate } = loadedIdentity.authentication;
result({
......@@ -2180,6 +2184,7 @@ connection.promise.then(parent => {
}
});
}
getTrusteeContactsPublicKeys();
}
let anynomousDeviceKeyEventsProcessing = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment