Skip to content

Commit

Permalink
feat(DataIntergrity): control issuer's key is approved for purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoustachiste committed Dec 2, 2024
1 parent 1cbdd80 commit 7f12d97
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ export class LDMerkleProof2019 extends LinkedDataProof {
let verified: boolean;
let error: string = '';

if (this.proof.proofPurpose && this.proof.proofPurpose !== this.proofPurpose) {
throw new Error(`Invalid proof purpose. Expected ${this.proofPurpose} but received ${this.proof.proofPurpose}`);
if (this.proof.proofPurpose) {
if (this.proof.proofPurpose !== this.proofPurpose) {
throw new Error(`Invalid proof purpose. Expected ${this.proofPurpose} but received ${this.proof.proofPurpose}`);
}

if (this.issuer && !this.issuer[this.proofPurpose]?.includes(this.proof.verificationMethod)) {
throw new Error(`The verification method ${this.proof.verificationMethod} is not allowed for the proof purpose ${this.proofPurpose}`);
}
}

try {
Expand Down
Loading

0 comments on commit 7f12d97

Please sign in to comment.