Skip to content

Commit

Permalink
feat(inji-533): add null check for decrypt json for both hardware ke…
Browse files Browse the repository at this point in the history
…ystore and cryptojs

Signed-off-by: Tilak Puli <[email protected]>
  • Loading branch information
tilak-puli committed Nov 3, 2023
1 parent 9e0492d commit 6c9d9b1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions shared/cryptoutil/cryptoUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export async function decryptJson(
encryptedData: string,
): Promise<string> {
try {
if (encryptedData === null || encryptedData === undefined) {
// to avoid crash in case of null or undefined
return '';
}
// Disable Encryption in debug mode
if (DEBUG_MODE_ENABLED && __DEV__) {
return JSON.parse(encryptedData);
Expand All @@ -126,11 +130,6 @@ export async function decryptJson(
);
}

if (encryptedData === null || encryptedData === undefined) {
// to avoid crash in case of null or undefined
return '';
}

return await SecureKeystore.decryptData(ENCRYPTION_ID, encryptedData);
} catch (e) {
console.error('error decryptJson:', e);
Expand Down

0 comments on commit 6c9d9b1

Please sign in to comment.