Skip to content

Commit

Permalink
added missing crypto environment vars
Browse files Browse the repository at this point in the history
  • Loading branch information
larryrider committed Feb 12, 2024
1 parent 5390403 commit abae74a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ DRIVE_API_URL=
DRIVE_NEW_API_URL=
PAYMENTS_API_URL=
PHOTOS_API_URL=
REACT_APP_CRYPTO_SECRET=
APP_CRYPTO_SECRET=
APP_MAGIC_IV=
APP_MAGIC_SALT=
4 changes: 2 additions & 2 deletions src/services/keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class KeysService {
};

public getAesInitFromEnv = (): { iv: string; salt: string } => {
const MAGIC_IV = ConfigService.instance.get('REACT_APP_MAGIC_IV');
const MAGIC_SALT = ConfigService.instance.get('REACT_APP_MAGIC_SALT');
const MAGIC_IV = ConfigService.instance.get('APP_MAGIC_IV');
const MAGIC_SALT = ConfigService.instance.get('APP_MAGIC_SALT');

return { iv: MAGIC_IV as string, salt: MAGIC_SALT as string };
};
Expand Down
4 changes: 3 additions & 1 deletion src/types/config.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export interface ConfigKeys {
readonly DRIVE_API_URL: string;
readonly DRIVE_NEW_API_URL: string;
readonly REACT_APP_CRYPTO_SECRET: string;
readonly PAYMENTS_API_URL: string;
readonly PHOTOS_API_URL: string;
readonly APP_CRYPTO_SECRET: string;
readonly APP_MAGIC_IV: string;
readonly APP_MAGIC_SALT: string;
}
8 changes: 4 additions & 4 deletions src/utils/crypto.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const passToHash = (passObject: PassObjectInterface): { salt: string; has

// AES Plain text encryption method
export const encryptText = (textToEncrypt: string): string => {
const REACT_APP_CRYPTO_SECRET = ConfigService.instance.get('REACT_APP_CRYPTO_SECRET');
return encryptTextWithKey(textToEncrypt, REACT_APP_CRYPTO_SECRET);
const APP_CRYPTO_SECRET = ConfigService.instance.get('APP_CRYPTO_SECRET');
return encryptTextWithKey(textToEncrypt, APP_CRYPTO_SECRET);
};

// AES Plain text decryption method
export const decryptText = (encryptedText: string): string => {
const REACT_APP_CRYPTO_SECRET = ConfigService.instance.get('REACT_APP_CRYPTO_SECRET');
return decryptTextWithKey(encryptedText, REACT_APP_CRYPTO_SECRET);
const APP_CRYPTO_SECRET = ConfigService.instance.get('APP_CRYPTO_SECRET');
return decryptTextWithKey(encryptedText, APP_CRYPTO_SECRET);
};

// AES Plain text encryption method with enc. key
Expand Down

0 comments on commit abae74a

Please sign in to comment.