From 859c7c9461f4b4bc780f67196ee1fc5383d89500 Mon Sep 17 00:00:00 2001 From: gregory1996 Date: Mon, 11 Mar 2024 15:30:25 +0200 Subject: [PATCH] Fix code format on ApiFetchCredentials --- .../Credentials/ApiFetchCredential.ts | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/components/Credentials/ApiFetchCredential.ts b/src/components/Credentials/ApiFetchCredential.ts index ce24017ae..caca07073 100644 --- a/src/components/Credentials/ApiFetchCredential.ts +++ b/src/components/Credentials/ApiFetchCredential.ts @@ -25,14 +25,14 @@ const hasherAndAlgorithm: HasherAndAlgorithm = { const parseCredentialDependingOnFormat = async (credential: string, format: string): Promise => { switch (format) { - case CredentialFormat.JWT_VC_JSON: - return parseJwt(credential); - case CredentialFormat.VC_SD_JWT: - return SdJwt.fromCompact, any>(credential) - .withHasher(hasherAndAlgorithm) - .getPrettyClaims(); - default: - throw new Error("Format is not recognised"); + case CredentialFormat.JWT_VC_JSON: + return parseJwt(credential); + case CredentialFormat.VC_SD_JWT: + return SdJwt.fromCompact, any>(credential) + .withHasher(hasherAndAlgorithm) + .getPrettyClaims(); + default: + throw new Error("Format is not recognised"); } } @@ -40,37 +40,37 @@ export async function fetchCredentialData(api: BackendApi, id = null) { try { const response = await api.get('/storage/vc'); - if (id) { - const targetImage = response.data.vc_list.find((img) => img.id.toString() === id); - const newImages = targetImage - ? await Promise.all([targetImage].map(async (item) => { + if (id) { + const targetImage = response.data.vc_list.find((img) => img.id.toString() === id); + const newImages = targetImage + ? await Promise.all([targetImage].map(async (item) => { const credentialPayload = await parseCredentialDependingOnFormat(item.credential, item.format); return ({ - id: item.id, - credentialIdentifier:item.credentialIdentifier, - src: item.logoURL, - alt: item.issuerFriendlyName, - data: credentialPayload["vc"]['credentialSubject'], - type: credentialPayload['vc']["type"]["2"], - expdate: credentialPayload['vc']["expirationDate"], + id: item.id, + credentialIdentifier: item.credentialIdentifier, + src: item.logoURL, + alt: item.issuerFriendlyName, + data: credentialPayload["vc"]['credentialSubject'], + type: credentialPayload['vc']["type"]["2"], + expdate: credentialPayload['vc']["expirationDate"], json: JSON.stringify(credentialPayload["vc"], null, 2) - }); + }); })) - : []; + : []; - return newImages[0]; - } else { - const newImages = await Promise.all(response.data.vc_list.map(async (item) => { + return newImages[0]; + } else { + const newImages = await Promise.all(response.data.vc_list.map(async (item) => { const credentialPayload = await parseCredentialDependingOnFormat(item.credential, item.format); return ({ id: item.id, - credentialIdentifier:item.credentialIdentifier, + credentialIdentifier: item.credentialIdentifier, src: item.logoURL, alt: item.issuerFriendlyName, data: credentialPayload["vc"]['credentialSubject'], type: credentialPayload['vc']["type"]["2"], expdate: credentialPayload['vc']["expirationDate"], - json:JSON.stringify(credentialPayload["vc"], null, 2) + json: JSON.stringify(credentialPayload["vc"], null, 2) }) }));