Skip to content

Commit

Permalink
fix: getDocumentData for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
HJunyuan committed Sep 6, 2023
1 parent d35c778 commit 4f9cb7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shared/utils/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ describe("Util Functions", () => {
},
};
expect(() => utils.getDocumentData(document)).toThrow(
"Unsupported document type: Only can retrieve document data for wrapped OpenAttestation v2 & v3 documents."
"Unsupported document type: Only can retrieve document data for wrapped OpenAttestation v2, v3 & v4 documents."
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/shared/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const getTemplateURL = (document: any): string | undefined => {
};

export const getDocumentData = (document: WrappedDocument<OpenAttestationDocument>): OpenAttestationDocument => {
if (isWrappedV3Document(document)) {
if (isWrappedV3Document(document) || isWrappedV4Document(document)) {
const omit = (keys: any, obj: any): any =>
Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
return omit(["proof"], document);
Expand All @@ -148,7 +148,7 @@ export const getDocumentData = (document: WrappedDocument<OpenAttestationDocumen
}

throw new Error(
"Unsupported document type: Only can retrieve document data for wrapped OpenAttestation v2 & v3 documents."
"Unsupported document type: Only can retrieve document data for wrapped OpenAttestation v2, v3 & v4 documents."
);
};

Expand Down

0 comments on commit 4f9cb7b

Please sign in to comment.