Skip to content

Commit

Permalink
fix: digest should handle falsy values correctly (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
HJunyuan authored Apr 11, 2024
1 parent fa8af20 commit 70059b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/3.0/digest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { OpenAttestationDocument } from "../__generated__/schema.3.0";
export const digestCredential = (document: OpenAttestationDocument, salts: Salt[], obfuscatedData: string[]) => {
// Prepare array of hashes from visible data
const hashedUnhashedDataArray = salts
.filter((salt) => get(document, salt.path))
// Explictly allow falsy values (e.g. false, 0, etc.) as they can exist in the document
.filter((salt) => get(document, salt.path) !== undefined)
.map((salt) => {
return keccak256(JSON.stringify({ [salt.path]: `${salt.value}:${get(document, salt.path)}` }));
});
Expand Down

0 comments on commit 70059b2

Please sign in to comment.