Skip to content

Commit

Permalink
fix: CType does not check credential ctype in presentation (#867)
Browse files Browse the repository at this point in the history
* fix: bug where ctype provided does not match credential ctype id

* feat: using the helper function for ctype hash to id

* fix: updating to check if ctype id is correct
  • Loading branch information
Dudleyneedham authored May 23, 2024
1 parent baf13e0 commit 23c5b04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/legacy-credentials/src/Credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ export function verifyWellFormed(
): void {
verifyDataStructure(credential)
verifyDataIntegrity(credential)

if (ctype) {
const credentialCTypeId = CType.hashToId(credential.claim.cTypeHash)
if (credentialCTypeId !== ctype.$id) {
throw new SDKErrors.CTypeIdMismatchError(ctype.$id, credentialCTypeId)
}
CType.verifyClaimAgainstSchema(credential.claim.contents, ctype)
}
}
Expand Down

0 comments on commit 23c5b04

Please sign in to comment.