Open-Attestation / open-attestation

Meta framework for providing digital provenance and integrity to documents.
https://openattestation.com
Apache License 2.0
54 stars 18 forks source link

Fix/document loader #191

Closed eugbyte closed 3 years ago

eugbyte commented 3 years ago

Testing

Run npm run test:custom-document-loader, or npm run test to test the custom document loader.

Integrating with open-attestation-cli

In open-attestation-cli/package.json, specify the version of open-attestation as "@govtechsg/open-attestation": "github:eugbyte/open-attestation#fix/document-loader", Add the following script command: "build:binary": "npm run build && pkg ./package.json --out-path dist/@govtechsg", Run npm i. Run npm build:binary

Result

Still does not work, Error message and the stack trace is oddly still the same. This is despite the fact that the verify file in open-attestation no longer uses the loader component of jsonLd.

Error: Cannot find module './main.js'
Require stack:
- /snapshot/open-attestation-cli/node_modules/@digitalbazaar/http-client/index.js
- /snapshot/open-attestation-cli/node_modules/jsonld/lib/documentLoaders/node.js
- /snapshot/open-attestation-cli/node_modules/jsonld/lib/platform.js
- /snapshot/open-attestation-cli/node_modules/jsonld/lib/jsonld.js
- /snapshot/open-attestation-cli/node_modules/jsonld/lib/index.js
- /snapshot/open-attestation-cli/node_modules/@govtechsg/open-attestation/dist/cjs/3.0/validate/validate.js

My hypothesis is that there are other component that uses the unforked version of open-attestation, where this change has not been implemented.

If you peer into package.lock.json, you will notice govtechsg/oa-verify depending on the unabridged version of open-attestation

 "@govtechsg/oa-verify": {
      "version": "7.4.3",
     ...
      "requires": {
        "@govtechsg/open-attestation": "^5.2.3",
....
      },
      "dependencies": {
        "@govtechsg/open-attestation": {
          "version": "5.3.4",
          "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-5.3.4.tgz",
          "requires": {
...
  }
  "@govtechsg/open-attestation": {
    "version": "github:eugbyte/open-attestation#acd20c9ff7364826f87a205bfc99332f3b8dddaa",
    "from": "github:eugbyte/open-attestation#fix/document-loader",