From 1c0cc471b36aaa0ec9383629b04e5335509cdc8a Mon Sep 17 00:00:00 2001 From: Alka Prasad Date: Mon, 9 Dec 2024 12:09:16 +0530 Subject: [PATCH] [INJIMOB-2415] store the wellknown data as object in activity log file (#1733) Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com> Co-authored-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com> --- components/VC/common/VCUtils.tsx | 26 +++++++++++++++----------- machines/activityLog.ts | 5 +++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/components/VC/common/VCUtils.tsx b/components/VC/common/VCUtils.tsx index 6e02ae6b19..7992455a96 100644 --- a/components/VC/common/VCUtils.tsx +++ b/components/VC/common/VCUtils.tsx @@ -269,19 +269,23 @@ export const getCredentialTypeFromWellKnown = ( wellknown: IssuerWellknownResponse, credentialConfigurationId: string | undefined = undefined, ): string => { - if (credentialConfigurationId !== undefined) { - const supportedCredentialsWellknown = getMatchingCredentialIssuerMetadata( - wellknown, - credentialConfigurationId, + try { + if (credentialConfigurationId !== undefined) { + const supportedCredentialsWellknown = getMatchingCredentialIssuerMetadata( + wellknown, + credentialConfigurationId, + ); + return getCredentialType(supportedCredentialsWellknown); + } + console.error( + 'credentialConfigurationId not available for fetching the Credential type', + ); + throw new Error( + `Invalid credentialConfigurationId - ${credentialConfigurationId} passed`, ); - return getCredentialType(supportedCredentialsWellknown); + } catch (error) { + return i18n.t('VcDetails:identityCard'); } - console.error( - 'credentialConfigurationId not available for fetching the Credential type', - ); - throw new Error( - `Invalid credentialConfigurationId - ${credentialConfigurationId} passed`, - ); }; export class Display { diff --git a/machines/activityLog.ts b/machines/activityLog.ts index ec5a0ca466..3b3f750688 100644 --- a/machines/activityLog.ts +++ b/machines/activityLog.ts @@ -6,6 +6,7 @@ import {StoreEvents} from './store'; import {VCActivityLog} from '../components/ActivityLogEvent'; import {IssuerWellknownResponse} from './VerifiableCredential/VCMetaMachine/vc'; import {VPShareActivityLog} from '../components/VPShareActivityLogEvent'; +import {parseJSON} from '../shared/Utils'; const model = createModel( { @@ -155,6 +156,10 @@ export const activityLogMachine = setAllWellknownConfigResponse: model.assign({ wellKnownIssuerMap: (_, event) => { + Object.entries(event.response).forEach(([key, value]) => { + event.response[key] = parseJSON(value); + }); + return event.response as Record; }, }),