mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
@@ -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
|
||||||
|
|||||||
@@ -82,4 +82,6 @@ let privateKey;
|
|||||||
return privateKey;
|
return privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { decryptPrivateKeyHelper };
|
export {
|
||||||
|
decryptPrivateKeyHelper
|
||||||
|
};
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
import { decryptPrivateKeyHelper } from '@app/helpers/key';
|
import {
|
||||||
|
decryptAssymmetric,
|
||||||
|
encryptAssymmetric} from '@app/components/utilities/cryptography/crypto';
|
||||||
|
import {
|
||||||
|
decryptPrivateKeyHelper
|
||||||
|
} from '@app/helpers/key';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle key actions
|
* Class to handle key actions
|
||||||
|
* TODO: in future, all private key-related encryption operations
|
||||||
|
* must pass through this class
|
||||||
*/
|
*/
|
||||||
class KeyService {
|
class KeyService {
|
||||||
|
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
|
||||||
@@ -51,6 +63,49 @@ class KeyService {
|
|||||||
protectedKeyTag
|
protectedKeyTag
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return [plaintext] encrypted by the user's private key
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {String} obj.plaintext - plaintext to encrypt
|
||||||
|
*/
|
||||||
|
static encryptWithPrivateKey({
|
||||||
|
plaintext,
|
||||||
|
publicKey,
|
||||||
|
}: {
|
||||||
|
plaintext: string;
|
||||||
|
publicKey: string;
|
||||||
|
}) {
|
||||||
|
return encryptAssymmetric({
|
||||||
|
plaintext,
|
||||||
|
publicKey,
|
||||||
|
privateKey: KeyService.privateKey
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return [ciphertext] decrypted by the user's private key
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {String} obj.ciphertext - ciphertext to decrypt
|
||||||
|
* @param {String} obj.ciphertext - iv of ciphertext
|
||||||
|
* @param {String} obj.ciphertext - tag of ciphertext
|
||||||
|
*/
|
||||||
|
static decryptWithPrivateKey({
|
||||||
|
ciphertext,
|
||||||
|
nonce,
|
||||||
|
publicKey
|
||||||
|
}: {
|
||||||
|
ciphertext: string;
|
||||||
|
nonce: string;
|
||||||
|
publicKey: string;
|
||||||
|
}) {
|
||||||
|
return decryptAssymmetric({
|
||||||
|
ciphertext,
|
||||||
|
nonce,
|
||||||
|
publicKey,
|
||||||
|
privateKey: KeyService.privateKey
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default KeyService;
|
export default KeyService;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import KeyService from './KeyService';
|
||||||
|
import ProjectService from './ProjectService';
|
||||||
|
|
||||||
|
export {
|
||||||
|
KeyService,
|
||||||
|
ProjectService
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user