diff --git a/frontend/src/components/signup/UserInfoStep.tsx b/frontend/src/components/signup/UserInfoStep.tsx index a7aad081c..32504cb2c 100644 --- a/frontend/src/components/signup/UserInfoStep.tsx +++ b/frontend/src/components/signup/UserInfoStep.tsx @@ -166,9 +166,6 @@ export default function UserInfoStep({ SecurityClient.setToken(response.token); saveTokenToLocalStorage({ - protectedKey, - protectedKeyIV, - protectedKeyTag, publicKey, encryptedPrivateKey, iv: encryptedPrivateKeyIV, diff --git a/frontend/src/components/utilities/attemptLogin.ts b/frontend/src/components/utilities/attemptLogin.ts index 464a4a4fe..e92a65e77 100644 --- a/frontend/src/components/utilities/attemptLogin.ts +++ b/frontend/src/components/utilities/attemptLogin.ts @@ -97,9 +97,6 @@ const attemptLogin = async ( }); saveTokenToLocalStorage({ - protectedKey, - protectedKeyIV, - protectedKeyTag, publicKey, encryptedPrivateKey, iv, diff --git a/frontend/src/components/utilities/attemptLoginMfa.ts b/frontend/src/components/utilities/attemptLoginMfa.ts index 8bec76b86..58d3b2330 100644 --- a/frontend/src/components/utilities/attemptLoginMfa.ts +++ b/frontend/src/components/utilities/attemptLoginMfa.ts @@ -70,9 +70,6 @@ const attemptLoginMfa = async ({ }); saveTokenToLocalStorage({ - protectedKey, - protectedKeyIV, - protectedKeyTag, publicKey, encryptedPrivateKey, iv, diff --git a/frontend/src/components/utilities/cryptography/changePassword.ts b/frontend/src/components/utilities/cryptography/changePassword.ts index aeb138ec6..e5b8fffb5 100644 --- a/frontend/src/components/utilities/cryptography/changePassword.ts +++ b/frontend/src/components/utilities/cryptography/changePassword.ts @@ -117,9 +117,6 @@ const changePassword = async ( }); saveTokenToLocalStorage({ - protectedKey, - protectedKeyIV, - protectedKeyTag, encryptedPrivateKey, iv: encryptedPrivateKeyIV, tag: encryptedPrivateKeyTag diff --git a/frontend/src/helpers/key.ts b/frontend/src/helpers/key.ts index 05562628d..57485a35a 100644 --- a/frontend/src/helpers/key.ts +++ b/frontend/src/helpers/key.ts @@ -1,6 +1,8 @@ import Aes256Gcm from '@app/components/utilities/cryptography/aes-256-gcm'; import { deriveArgonKey } from '@app/components/utilities/cryptography/crypto'; +import { KeyService } from '../services'; + /** * @param {Object} obj * @param {Number} obj.encryptionVersion @@ -79,6 +81,7 @@ let privateKey; throw new Error('Failed to decrypt private key'); } + KeyService.setPrivateKey(privateKey); return privateKey; } diff --git a/frontend/src/pages/signupinvite.tsx b/frontend/src/pages/signupinvite.tsx index 0e5db027a..abe5d3770 100644 --- a/frontend/src/pages/signupinvite.tsx +++ b/frontend/src/pages/signupinvite.tsx @@ -152,9 +152,6 @@ export default function SignupInvite() { SecurityClient.setToken(jwtToken); saveTokenToLocalStorage({ - protectedKey, - protectedKeyIV, - protectedKeyTag, publicKey, encryptedPrivateKey, iv: encryptedPrivateKeyIV, diff --git a/frontend/src/services/KeyService.ts b/frontend/src/services/KeyService.ts index 0213cbc08..004b92c71 100644 --- a/frontend/src/services/KeyService.ts +++ b/frontend/src/services/KeyService.ts @@ -12,6 +12,10 @@ import { */ class KeyService { private static privateKey: string = ''; + + static setPrivateKey(privateKey: string) { + KeyService.privateKey = privateKey; + } /** Return the user's decrypted private key * @param {Object} obj diff --git a/frontend/src/services/index.ts b/frontend/src/services/index.ts new file mode 100644 index 000000000..35214c8a9 --- /dev/null +++ b/frontend/src/services/index.ts @@ -0,0 +1,7 @@ +import KeyService from './KeyService'; +import ProjectService from './ProjectService'; + +export { + KeyService, + ProjectService +}