Skip to content

Commit

Permalink
feat(inji-406): add logs for debugging tampered vc issues (mosip#900)
Browse files Browse the repository at this point in the history
Signed-off-by: Tilak Puli <[email protected]>
  • Loading branch information
tilak-puli committed Oct 11, 2023
1 parent e3523a0 commit a4d3be5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion shared/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
isCustomSecureKeystore,
} from './cryptoutil/cryptoUtil';
import {VCMetadata} from './VCMetadata';
import {ENOENT} from '../machines/store';
import {ENOENT, getItem} from '../machines/store';
import {MY_VCS_STORE_KEY} from './constants';

export const MMKV = new MMKVLoader().initialize();
const vcDirectoryPath = `${DocumentDirectoryPath}/inji/VC`;
Expand Down Expand Up @@ -81,6 +82,15 @@ class Storage {
const data = await this.readVCFromFile(key);
const isCorrupted = await this.isCorruptedVC(key, encryptionKey, data);

if (isCorrupted) {
console.debug('VC is corrupted and will be deleted from storage');
console.debug('VC key: ', key);
console.debug('is Data null', data === null);
getItem(MY_VCS_STORE_KEY, [], encryptionKey).then(res => {
console.debug('vcKeys are ', res);
});
}

return isCorrupted ? null : data;
}

Expand Down

0 comments on commit a4d3be5

Please sign in to comment.