Skip to content

Commit

Permalink
[INJIMOB-2571]: refactor verifyCredential method and its usages
Browse files Browse the repository at this point in the history
Signed-off-by: Alka Prasad <[email protected]>
  • Loading branch information
Alka1703 committed Dec 18, 2024
1 parent ab180d6 commit bf7fd53
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 627 deletions.
25 changes: 7 additions & 18 deletions machines/Issuers/IssuersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../shared/telemetry/TelemetryConstants';
import {VciClient} from '../../shared/vciClient/VciClient';
import {isMockVC} from '../../shared/Utils';
import {isMockVC, verifyCredentialData} from '../../shared/Utils';
import {VCFormat} from '../../shared/VCFormat';

export const IssuersService = () => {
Expand Down Expand Up @@ -151,26 +151,15 @@ export const IssuersService = () => {
},

verifyCredential: async (context: any) => {
//TODO: Remove bypassing verification of mock VCs once mock VCs are verifiable
if (
context.selectedCredentialType.format === VCFormat.mso_mdoc ||
!isMockVC(context.selectedIssuerId)
) {
const verificationResult = await verifyCredential(
context.verifiableCredential?.credential,
context.selectedCredentialType.format,
);
if (!verificationResult.isVerified) {
const verificationResult = await verifyCredentialData(
context.verifiableCredential?.credential,
context.selectedCredentialType.format,
context.selectedIssuerId
);
if(!verificationResult.isVerified) {
throw new Error(verificationResult.verificationErrorCode);
}
return verificationResult;
} else {
return {
isVerified: true,
verificationMessage: VerificationErrorMessage.NO_ERROR,
verificationErrorCode: VerificationErrorType.NO_ERROR,
};
}
},
};
};
Loading

0 comments on commit bf7fd53

Please sign in to comment.