presentationVerification callback not waiting
Closed this issue · 4 comments
RpBuilder.wothPresentationVerification(presentationVerification) seems like is not being awaiting
I mean the callback result is not being awaited
private static async validatePresentationsAgainstDefinition(
definition: IPresentationDefinition,
vpPayloads: WrappedVerifiablePresentation[],
verifyPresentationCallback: PresentationVerificationCallback | undefined,
opts?: {
limitDisclosureSignatureSuites?: string[];
restrictToFormats?: Format;
restrictToDIDMethods?: string[];
presentationSubmission?: PresentationSubmission;
hasher?: Hasher;
}
) {
const pex = new PEX({ hasher: opts?.hasher });
function filterOutCorrectPresentation() {
//TODO: add support for multiple VPs here
return vpPayloads.filter(async (vpw: WrappedVerifiablePresentation) => {
const presentationSubmission =
opts?.presentationSubmission ??
(CredentialMapper.isWrappedW3CVerifiablePresentation(vpw) ? vpw.presentation.presentation_submission : undefined);
const presentation = vpw.presentation;
if (!definition) {
throw new Error(SIOPErrors.NO_PRESENTATION_SUBMISSION);
} else if (
!vpw.presentation ||
(CredentialMapper.isWrappedW3CVerifiablePresentation(vpw) &&
(!vpw.presentation.verifiableCredential || vpw.presentation.verifiableCredential.length === 0))
) {
throw new Error(SIOPErrors.NO_VERIFIABLE_PRESENTATION_NO_CREDENTIALS);
}
// The verifyPresentationCallback function is mandatory for RP only,
// So the behavior here is to bypass it if not present
if (verifyPresentationCallback) {
try {
await verifyPresentationCallback(vpw.original as W3CVerifiablePresentation, presentationSubmission);
} catch (error: unknown) {
throw new Error(SIOPErrors.VERIFIABLE_PRESENTATION_SIGNATURE_NOT_VALID);
}
}
// console.log(`Presentation (filter): ${JSON.stringify(presentation)}`);
const evaluationResults = pex.evaluatePresentation(definition, vpw.original, {
...opts,
presentationSubmission,
});
const submission = evaluationResults.value;
if (!presentation || !submission) {
throw new Error(SIOPErrors.NO_PRESENTATION_SUBMISSION);
}
return submission && submission.definition_id === definition.id;
});
}
const checkedPresentations: WrappedVerifiablePresentation[] = filterOutCorrectPresentation();
if (checkedPresentations.length !== 1) {
throw new Error(`${SIOPErrors.COULD_NOT_FIND_VCS_MATCHING_PD}`);
}
const checkedPresentation = checkedPresentations[0];
const presentation = checkedPresentation.presentation;
// console.log(`Presentation (checked): ${JSON.stringify(checkedPresentation.presentation)}`);
if (
!checkedPresentation.presentation ||
(CredentialMapper.isWrappedW3CVerifiablePresentation(checkedPresentation) &&
(!checkedPresentation.presentation.verifiableCredential || checkedPresentation.presentation.verifiableCredential.length === 0))
) {
throw new Error(SIOPErrors.NO_VERIFIABLE_PRESENTATION_NO_CREDENTIALS);
}
const presentationSubmission =
opts?.presentationSubmission ?? (CredentialMapper.isW3cPresentation(presentation) ? presentation.presentation_submission : undefined);
const evaluationResults = pex.evaluatePresentation(definition, checkedPresentation.original, {
...opts,
presentationSubmission,
});
PresentationExchange.assertValidPresentationSubmission(evaluationResults.value);
await PresentationExchange.validatePresentationAgainstDefinition(definition, checkedPresentation, {
...opts,
presentationSubmission,
hasher: opts?.hasher,
});
}
i am not very sure, but i think problem maybe around this function, maybe the filterOutCorrectPresentation() should be awaited?
Is this still an issue @cindy-chin ? If so could you clarify which callback is not being awaited according to you?
Closing; no response