Skip to content

Commit

Permalink
fix: revert back to opencerts-verify
Browse files Browse the repository at this point in the history
  • Loading branch information
HJunyuan committed Aug 31, 2024
1 parent 896e504 commit 2d138b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 61 deletions.
37 changes: 0 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"license": "ISC",
"dependencies": {
"@govtechsg/oa-encryption": "^1.3.5",
"@govtechsg/oa-verify": "^9.3.1",
"@govtechsg/open-attestation": "^6.9.5",
"@govtechsg/opencerts-verify": "^3.1.3",
"@middy/core": "^5.1.0",
Expand Down
30 changes: 7 additions & 23 deletions src/shared/verify.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const { getData, validateSchema } = require("@govtechsg/open-attestation");
const {
verificationBuilder,
openAttestationVerifiers
} = require("@govtechsg/oa-verify");
const { registryVerifier } = require("@govtechsg/opencerts-verify");
const { getData, utils } = require("@govtechsg/open-attestation");
const { verify: ocVerify } = require("@govtechsg/opencerts-verify");

const config = require("./config");

const IS_MAINNET =
config.network === "mainnet" || config.network === "homestead";

function getNetworkName(document) {
const data = getData(document);
const data = utils.isWrappedV2Document(document)
? getData(document)
: document;

if (IS_MAINNET && data.network) {
/* Production Network Whitelist */
Expand Down Expand Up @@ -51,19 +49,5 @@ function getNetworkName(document) {
/**
* A wrapper of verify to auto-switch between Ethereum and Polygon
*/
export const verify = (document) => {
if (!validateSchema(document)) {
// Following current behaviour of from "@govtechsg/opencerts-verify"
// E.g. await verify({ "bad": "document" }) // returns undefined
return undefined;
}

const oaVerify = verificationBuilder(
[...openAttestationVerifiers, registryVerifier],
{
network: getNetworkName(document)
}
);

return oaVerify(document);
};
export const verify = (document) =>
ocVerify({ network: getNetworkName(document) })(document);

0 comments on commit 2d138b6

Please sign in to comment.