This commit is contained in:
Manav Rathi 2024-05-25 16:31:42 +05:30
parent 621c482529
commit 76f7215269
No known key found for this signature in database

View file

@ -26,6 +26,8 @@ export const getAuthCodes = async (): Promise<Code[]> => {
authEntity
.filter((f) => !f.isDeleted)
.map(async (entity) => {
if (!entity.encryptedData) return undefined;
if (!entity.header) return undefined;
try {
const decryptedCode =
await cryptoWorker.decryptMetadata(
@ -36,14 +38,12 @@ export const getAuthCodes = async (): Promise<Code[]> => {
return codeFromURIString(entity.id, decryptedCode);
} catch (e) {
log.error(`Failed to parse codeID ${entity.id}`, e);
return null;
return undefined;
}
}),
);
// Remove null and undefined values
const filteredAuthCodes = authCodes.filter(
(f) => f !== null && f !== undefined,
);
// Remove undefined values
const filteredAuthCodes = authCodes.filter((f): f is Code => !!f);
filteredAuthCodes.sort((a, b) => {
if (a.issuer && b.issuer) {
return a.issuer.localeCompare(b.issuer);