Skip to content
Snippets Groups Projects

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

Compare and
7 files
+ 1139
6
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -40,6 +40,14 @@ import {
@@ -40,6 +40,14 @@ import {
STATUS_USER_BLOCKED
STATUS_USER_BLOCKED
} from "../constants/statuses";
} from "../constants/statuses";
import generateQrCode from "../utilities/generateQrCode";
import generateQrCode from "../utilities/generateQrCode";
 
import {
 
initSecrets,
 
generateRecoveryKey,
 
divideSecretToShares,
 
combineSecret,
 
setRNG,
 
getSecretsConfig
 
} from "../utilities/secrets";
const penpalMethods = require("../../temp/penpal-methods").default;
const penpalMethods = require("../../temp/penpal-methods").default;
const WopiAPI = require("./wopiapi-iframe");
const WopiAPI = require("./wopiapi-iframe");
@@ -717,10 +725,7 @@ const connection = Penpal.connectToParent({
@@ -717,10 +725,7 @@ const connection = Penpal.connectToParent({
});
});
});
});
},
},
finalizeEmployeeRegistration: async (
finalizeEmployeeRegistration: async (identity, identifier) => {
identity,
identifier
) => {
viamApi.setIdentity(identity.authentication.publicKey);
viamApi.setIdentity(identity.authentication.publicKey);
return executeRestfulFunction(
return executeRestfulFunction(
"public",
"public",
@@ -970,6 +975,50 @@ const connection = Penpal.connectToParent({
@@ -970,6 +975,50 @@ const connection = Penpal.connectToParent({
});
});
});
});
},
},
 
contactsGetTrusteeContactsPublicKeys: async () => {
 
try {
 
initSecrets();
 
setRNG("browserCryptoGetRandomValues");
 
getSecretsConfig();
 
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,
parseSMIME,
getCurrentlyLoggedInUUID() {
getCurrentlyLoggedInUUID() {
return new Penpal.Promise(result => {
return new Penpal.Promise(result => {
Loading