Remove storage of protected key

This commit is contained in:
Tuan Dang
2023-02-21 12:31:19 +07:00
parent 74e78bb967
commit 1ff2c61b3a
8 changed files with 14 additions and 15 deletions
@@ -166,9 +166,6 @@ export default function UserInfoStep({
SecurityClient.setToken(response.token); SecurityClient.setToken(response.token);
saveTokenToLocalStorage({ saveTokenToLocalStorage({
protectedKey,
protectedKeyIV,
protectedKeyTag,
publicKey, publicKey,
encryptedPrivateKey, encryptedPrivateKey,
iv: encryptedPrivateKeyIV, iv: encryptedPrivateKeyIV,
@@ -97,9 +97,6 @@ const attemptLogin = async (
}); });
saveTokenToLocalStorage({ saveTokenToLocalStorage({
protectedKey,
protectedKeyIV,
protectedKeyTag,
publicKey, publicKey,
encryptedPrivateKey, encryptedPrivateKey,
iv, iv,
@@ -70,9 +70,6 @@ const attemptLoginMfa = async ({
}); });
saveTokenToLocalStorage({ saveTokenToLocalStorage({
protectedKey,
protectedKeyIV,
protectedKeyTag,
publicKey, publicKey,
encryptedPrivateKey, encryptedPrivateKey,
iv, iv,
@@ -117,9 +117,6 @@ const changePassword = async (
}); });
saveTokenToLocalStorage({ saveTokenToLocalStorage({
protectedKey,
protectedKeyIV,
protectedKeyTag,
encryptedPrivateKey, encryptedPrivateKey,
iv: encryptedPrivateKeyIV, iv: encryptedPrivateKeyIV,
tag: encryptedPrivateKeyTag tag: encryptedPrivateKeyTag
+3
View File
@@ -1,6 +1,8 @@
import Aes256Gcm from '@app/components/utilities/cryptography/aes-256-gcm'; import Aes256Gcm from '@app/components/utilities/cryptography/aes-256-gcm';
import { deriveArgonKey } from '@app/components/utilities/cryptography/crypto'; import { deriveArgonKey } from '@app/components/utilities/cryptography/crypto';
import { KeyService } from '../services';
/** /**
* @param {Object} obj * @param {Object} obj
* @param {Number} obj.encryptionVersion * @param {Number} obj.encryptionVersion
@@ -79,6 +81,7 @@ let privateKey;
throw new Error('Failed to decrypt private key'); throw new Error('Failed to decrypt private key');
} }
KeyService.setPrivateKey(privateKey);
return privateKey; return privateKey;
} }
-3
View File
@@ -152,9 +152,6 @@ export default function SignupInvite() {
SecurityClient.setToken(jwtToken); SecurityClient.setToken(jwtToken);
saveTokenToLocalStorage({ saveTokenToLocalStorage({
protectedKey,
protectedKeyIV,
protectedKeyTag,
publicKey, publicKey,
encryptedPrivateKey, encryptedPrivateKey,
iv: encryptedPrivateKeyIV, iv: encryptedPrivateKeyIV,
+4
View File
@@ -13,6 +13,10 @@ import {
class KeyService { class KeyService {
private static privateKey: string = ''; private static privateKey: string = '';
static setPrivateKey(privateKey: string) {
KeyService.privateKey = privateKey;
}
/** Return the user's decrypted private key /** Return the user's decrypted private key
* @param {Object} obj * @param {Object} obj
* @param {Number} obj.encryptionVersion * @param {Number} obj.encryptionVersion
+7
View File
@@ -0,0 +1,7 @@
import KeyService from './KeyService';
import ProjectService from './ProjectService';
export {
KeyService,
ProjectService
}