Skip to content

Commit

Permalink
update changelog
Browse files Browse the repository at this point in the history
Signed-off-by: F-Node-Karlsruhe <christian.fries@eecc.de>
  • Loading branch information
F-Node-Karlsruhe committed Oct 20, 2023
1 parent a21820c commit 8b84641
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WIP
---

- add support for SD-JWT
- add `did:jwk` support


1.7.4 (2023-10-10)
Expand Down
59 changes: 30 additions & 29 deletions api/src/services/verifier/dataintegrity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { documentLoader } from '../documentLoader/index.js';
const { createVerifyCryptosuite } = ecdsaSd2023Cryptosuite;
const { purposes: { AssertionProofPurpose } } = jsigs;


function getSuite(proof: Proof): unknown[] {

switch (proof.type) {
Expand Down Expand Up @@ -54,6 +53,8 @@ function getSuites(proof: Proof | Proof[]): unknown[] {

function getPresentationStatus(presentation: VerifiablePresentation): CredentialStatus[] | CredentialStatus | undefined {

if (!presentation.verifiableCredential) return undefined;

const credentials = (
Array.isArray(presentation.verifiableCredential)
? presentation.verifiableCredential
Expand Down Expand Up @@ -101,52 +102,52 @@ export async function verifyDataIntegrityProof(verifiable: Verifiable, challenge

const suite = getSuites(verifiable.proof);

let result;
let result;

if (verifiable.type.includes('VerifiableCredential')) {
if (verifiable.type.includes('VerifiableCredential')) {

const credential = verifiable as VerifiableCredential;
const credential = verifiable as VerifiableCredential;

const checkStatus = getCheckStatus(credential.credentialStatus);
const checkStatus = getCheckStatus(credential.credentialStatus);

if ((Array.isArray(credential.proof) ? credential.proof[0].type : credential.proof.type) == 'DataIntegrityProof') {
if ((Array.isArray(credential.proof) ? credential.proof[0].type : credential.proof.type) == 'DataIntegrityProof') {

result = await jsigs.verify(credential, {
suite,
purpose: new AssertionProofPurpose(),
documentLoader,
// give it to jsigs anyway - does not get verified
checkStatus
});
result = await jsigs.verify(credential, {
suite,
purpose: new AssertionProofPurpose(),
documentLoader,
// give it to jsigs anyway - does not get verified
checkStatus
});

} else {
} else {

result = await verifyCredential({ credential, suite, documentLoader, checkStatus });
result = await verifyCredential({ credential, suite, documentLoader, checkStatus });

}
}
}

if (verifiable.type.includes('VerifiablePresentation')) {
if (verifiable.type.includes('VerifiablePresentation')) {

const presentation = verifiable as VerifiablePresentation;
const presentation = verifiable as VerifiablePresentation;

// try to use challenge in proof if not provided in case no exchange protocol is used
if (!challenge) challenge = (Array.isArray(presentation.proof) ? presentation.proof[0].challenge : presentation.proof.challenge);
// try to use challenge in proof if not provided in case no exchange protocol is used
if (!challenge) challenge = (Array.isArray(presentation.proof) ? presentation.proof[0].challenge : presentation.proof.challenge);


const checkStatus = getCheckStatus(
getPresentationStatus(presentation)
);
const checkStatus = getCheckStatus(
getPresentationStatus(presentation)
);

result = await verify({ presentation, suite, documentLoader, challenge, domain, checkStatus });
result = await verify({ presentation, suite, documentLoader, challenge, domain, checkStatus });

}
}

if (!result) throw Error('Provided verifiable object is of unknown type!');
if (!result) throw Error('Provided verifiable object is of unknown type!');

// make non enumeratable errors enumeratable for the respsonse
if (result.error && !result.error.errors) result.error.name = result.error.message;
// make non enumeratable errors enumeratable for the respsonse
if (result.error && !result.error.errors) result.error.name = result.error.message;

return result;
return result;

}

0 comments on commit 8b84641

Please sign in to comment.