{"_id":"@bchr73/cert-verifier-js","_rev":"1-bc694e3e509eb9daf783b7a8eb65117c","name":"@bchr73/cert-verifier-js","dist-tags":{"latest":"0.0.0-dev"},"versions":{"0.0.0-dev":{"name":"@bchr73/cert-verifier-js","version":"0.0.0-dev","description":"Javascript library for verifying Blockcerts","repository":{"type":"git","url":"git+https://github.com/blockchain-certificates/cert-verifier-js.git"},"main":"dist/verifier.js","module":"dist/verifier-es.js","scripts":{"test":"jest --runInBand","test:build":"jest --testRegex \"/*(.test.build.js)\" --runInBand && npm run test:build:iife","test:build:iife":"karma start --single-run","test:watch":"jest --watch --runInBand","test:coverage":"jest --maxWorkers=4 --silent --noStackTrace --coverage","test:coverage:report":"codecov","build":"npm run build:esm && npm run build:es5 && npm run transpile:node && npm run test:build","build:esm":"rollup -c","build:es5":"rollup -c rollup-es5.config.js","transpile:node":"npx babel src -d lib --copy-files","lint":"semistandard --verbose | snazzy","semantic-release":"semantic-release"},"publishConfig":{"access":"public"},"author":{"name":"Kim Duffy"},"license":"MIT","jest":{"modulePaths":["<rootDir>/src/","<rootDir>/node_modules"],"moduleFileExtensions":["js","json"]},"semistandard":{"globals":["XMLHttpRequest"],"env":"jest","ignore":["dist/"]},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"npm run lint","pre-push":"npm run lint && npm run test"}},"dependencies":{"@babel/runtime":"^7.8.7","@babel/runtime-corejs3":"^7.8.7","@vaultie/lds-merkle-proof-2019":"0.0.6","bigi":"^1.4.2","bitcoinjs-lib":"^5.0.3","bs58":"^4.0.1","buffer":"^5.1.0","core-js":"^3.6.4","debug":"^4.1.1","ecurve":"^1.0.4","elliptic":"github:xg-wang/elliptic","jsonld":"^1.8.1","sha256":"^0.2.0","xmlhttprequest":"^1.8.0"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.8.7","@babel/plugin-transform-runtime":"^7.4.4","@babel/preset-env":"^7.4.4","@commitlint/cli":"^8.0.0","@commitlint/config-conventional":"^8.0.0","brfs":"^2.0.2","codecov":"^3.0.4","eslint-config-semistandard":"^13.0.0","eslint-plugin-import":"^2.17.2","husky":"^4.0.0","jasmine-core":"^3.5.0","jest":"^25.1.0","karma":"^4.4.1","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^1.3.0","karma-jasmine":"^3.1.1","rollup":"^2.1.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^10.0.1","rollup-plugin-json":"^4.0.0","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.2.1","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-re":"^1.0.7","rollup-plugin-terser":"^5.1.0","semantic-release":"^17.0.2","semistandard":"^13.0.1","sinon":"^9.0.0","snazzy":"^8.0.0"},"gitHead":"1564093ed2ad1cf4bd529dd4cf4144931b7db633","bugs":{"url":"https://github.com/blockchain-certificates/cert-verifier-js/issues"},"homepage":"https://github.com/blockchain-certificates/cert-verifier-js#readme","_id":"@bchr73/cert-verifier-js@0.0.0-dev","_nodeVersion":"13.12.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-V5t2psZnKkhVYMgdKmAm/5WR+AzrYNQrJkb14i9E7vQTDxkGDBPr98QKuhsgfqVSXduPZQiyCL9RMjaH8e0v8w==","shasum":"d668677e372c873ec423c9b02bd0e5b77fd5738c","tarball":"https://registry.npmjs.org/@bchr73/cert-verifier-js/-/cert-verifier-js-0.0.0-dev.tgz","fileCount":164,"unpackedSize":3146420,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejXzPCRA9TVsSAnZWagAATtYP/37BcJU1KuqbgwB7/XmP\nBRb6rVduCxn/6cebgq/T1NAsHbkFxLQrXnnboNu3hnptAchW9bys8Fvkgzw4\n3REuzZVVydnNJkZidbidPvGxaA6srAFvDuI0gOkou0gGx24zCwD3bkT0H8FQ\nOofw+1bU70JKJYiGo3A5+S1NRuiee3BqSxlsoyVbxfGpUiuMzTWPmiba9y85\nPMzfy9nJNijskCcLVhaOcVkgUc5fIqx+v3iOui3BZ9nv+XW49DnL4aRo2iyC\nISpPf8zM9A67IO2+NufkJweIc/qJkab+HLaDGC7VMmLA/x5eXlF5GOsVX9wu\neVQ42btuq/Xqt26MmJTMzcwVEvr5XVxF1cpfJz5yDz1/4slE1SV9AZi4Ng/g\nYk9ynObYZ3uk35l2SzYnXZTQ/mqamuAuPnone/VSrhxw/85CDhw4kWTB16Lr\noeFszak5raBFX6L3fHiYEGGpVtV0BztXOHwXjGmaY4z1KMsf4V3ypldxV9kx\nJvEAAf3vt/tcLBILd3ea6WzYdDYWCs6Sn1WWHsXo34jj4p7sw66tLREhPbWx\nWFcWwLJX550lxsjpd7KxjSAzl0Z0A3FOy0Ji5PVGETn4oRWED+cQ0ZQLTren\n5AD01zLWlwUZ5XPiaeVx9pKSKamuQrfH4bCHeC+0ue4/p3Ymj+3/MZngL3Gh\nsClg\r\n=lgrh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHLQA1M3qdfzHvxp7eYc0w3GZhkmgPouTGxttUIc5HfzAiBmbqnbbFudgZ5F2Vt4sM0/SCxo2bE/OU4UIdlCRcB4hw=="}]},"maintainers":[{"name":"bchr73","email":"karim.boucher@fluidchains.com"}],"_npmUser":{"name":"bchr73","email":"karim.boucher@fluidchains.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cert-verifier-js_0.0.0-dev_1586330830917_0.44696890687698887"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-08T07:27:10.682Z","0.0.0-dev":"2020-04-08T07:27:11.164Z","modified":"2022-04-04T18:01:57.589Z"},"maintainers":[{"name":"bchr73","email":"karim.boucher@fluidchains.com"}],"description":"Javascript library for verifying Blockcerts","homepage":"https://github.com/blockchain-certificates/cert-verifier-js#readme","repository":{"type":"git","url":"git+https://github.com/blockchain-certificates/cert-verifier-js.git"},"author":{"name":"Kim Duffy"},"bugs":{"url":"https://github.com/blockchain-certificates/cert-verifier-js/issues"},"license":"MIT","readme":"# @blockcerts/cert-verifier-js\n\n[![Build Status](https://travis-ci.com/blockchain-certificates/cert-verifier-js.svg?branch=master)](https://travis-ci.com/blockchain-certificates/cert-verifier-js)\n[![codecov](https://codecov.io/gh/blockchain-certificates/cert-verifier-js/branch/master/graph/badge.svg)](https://codecov.io/gh/blockchain-certificates/cert-verifier-js)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\nA library to parse and verify [Blockcerts](https://www.blockcerts.org/) certificates.\n\n# Usage\n\n## Install\n\n```shell\n$ npm i @blockcerts/cert-verifier-js\n```\n\n## Import\n\n#### Commonjs\nExposed by default:\n\n```javascript\nconst { Certificate } = require('@blockcerts/cert-verifier-js');\nvar certificate = new Certificate(certificateDefinition);\n```\n\n### Running in Nodejs\n```javascript\nconst { Certificate } = require('@blockcerts/cert-verifier-js/lib');\nvar certificate = new Certificate(certificateDefinition);\n```\n\n#### ES module\n```javascript\nimport { Certificate } from '@blockcerts/cert-verifier-js';\nlet certificate = new Certificate(certificateDefinition);\n```\n\n#### Script tag (iife)\n[Check an example here](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/test/e2e/script-tag.html)\n```html\n<script src='node_modules/@blockcerts/cert-verifier-js/dist/verifier-iife.js'></script>\n<script>\n  var certificate = new Verifier.Certificate(certificateDefinition);\n</script>\n```\n\n## Examples\n\nYou can find more examples in the [test folder](./test/e2e/).\n\n### Parse a Blockcert certificate\n\n```javascript\nvar fs = require('fs');\n\nfs.readFile('./certificate.json', 'utf8', function (err, data) {\n  if (err) {\n    console.log(err);\n  }\n\n  let certificate = new Certificate(data);\n  console.log(cert.name);\n});\n```\n\n### Verify a Blockcert certificate\n\n```javascript\nvar fs = require('fs');\n\nfs.readFile('./certificate.json', 'utf8', function (err, data) {\n  if (err) {\n    console.log(err);\n  }\n\n  let certificate = new Certificate(data);\n  const verificationResult = await certificate.verify(({code, label, status, errorMessage}) => {\n    console.log('Code:', code, label, ' - Status:', status);\n    if (errorMessage) {\n      console.log(`The step ${code} fails with the error: ${errorMessage}`);\n    }\n  });\n\n  if (verificationResult.status === 'failure') {\n    console.log(`The certificate is not valid. Error: ${verificationResult.errorMessage}`);\n  }\n});\n```\n\n# API\n\n## `Certificate`\n\n### `new Certificate(certificateDefinition, options)`\n```javascript\nconst certificate = new Certificate(certificateDefinition);\n```\nThe constructor automatically parses a certificate.\n\n#### Parameter\n- `certificateDefinition` (`String|Object`): the certificate definition. Can either be a string or a JSON object.\n- `options`: (`Object`): an object of options. The following properties are used:\n    - locale: (`String`): language code used to set the language used by the verifier. Default: `en-US`.\n\n#### Returns\nThe certificate instance has the following properties:\n- `certificateImage`: `String`. Raw data of the certificate image\n- `certificateJson`: `Object`. Certificate JSON object\n- `chain`: `Object`. Chain the certificate was issued on\n- `description`: `String`. Description of the certificate\n- `expires`: `String|null`. Expiration date\n- `id`: `String`. Certificate's ID\n- `isFormatValid`: `Boolean`. Indicates whether or not the certificate has a valid format\n- `issuedOn`: `String`. Datetime of issuance (ISO-8601)\n- `issuer`: `Object`. Certificate issuer\n- `locale`: `String`. Language code used by the verifier\n- `metadataJson`: `Object|null `. Certificate metadata object\n- `name`: `String`. Name of the certificate\n- `publicKey`: `String`. Certificate's public key\n- `receipt`: `Object`. Certificate's receipt\n- `recipientFullName`: `String`. Full name of recipient\n- `recordLink`: `String`. Link to the certificate record\n- `revocationKey`: `String|null`. Revocation key (if any)\n- `sealImage`: `String`. Raw data of the seal's image;\n- `signature`: `String|null`. Certificate's signature\n- `signatureImage`: [`SignatureImage[]`][signatureLineModel]. Array of certificate [signature lines][signatureLineModel].\n- `subtitle`: `String|null`. Subtitle of the certificate\n- `transactionId`: `String`. Transaction ID\n- `rawTransactionLink`: `String`. Raw transaction ID\n- `transactionLink`: `String`. Transaction link\n- `verificationSteps`: `VerificationStep[]`. The array of steps the certificate will have to go through during verification\n- `version`: `CertificateVersion`. [Version of the certificate](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/certificateVersions.js)\n\n[signatureLineModel]: src/models/signatureImage.js\n\n**Note:** `verificationSteps` is generated according to the nature of the certificate. The full steps array is provided ahead of verification in order to give more flexibility to the consumer. For example, you might want to pre-render the verification steps for animation, or render a count of steps and/or sub-steps.\n\n`VerificationStep` has the following shape:\n```javascript\n{\n    code: 'formatValidation',\n    label: 'Format validation',\n    labelPending: 'Validating format',\n    subSteps: [\n      {\n        code: 'getTransactionId',\n        label: 'Get transaction ID',\n        labelPending: 'Getting transaction ID',\n        parentStep: 'formatValidation'\n      },\n      ...\n    ]\n}\n```\n\n### `verify(stepCallback)`\nThis will run the verification of a certificate. The function is asynchronous.\n\n```javascript\nconst certificateVerification = await certificate.verify(({code, label, status, errorMessage}) => {\n    console.log('Sub step update:', code, label, status);\n}));\nconsole.log(`Verification was a ${certificateVerification.status}:`, certificateVerification.message);\n```\n\n#### Parameters\n- `({code, label, status, errorMessage}) => {}` (`Function`): callback function called whenever a substep status has changed. The callback parameter has 4 properties:\n  - `code`: substep code\n  - `label`: readable label of the substep\n  - `status`: substep status (`success`, `failure`, `starting`)\n  - `errorMessage`: error message (optional)\n\n#### Returns\nThe final verification status:\n```javascript\n{ code, status, message }\n```\n- `code`: code of the final step (`final`)\n- `status`: final verification status (`success`, `failure`)\n- `message` string | Object: status message. It is internationalized and in case of failure it returns the error message of the failed step. When an object, it takes the following shape:\n  - `label`: Main label of the final step\n  - `description`: further details about the issuance\n  - `linkText`: translation provided for a link text towards the transaction\n\nShape of the returned object can be checked here: https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/data/i18n.json#L41\n\n### Constants\nSeveral constants are being exposed:\n```javascript\nimport { BLOCKCHAINS, STEPS, SUB_STEPS, CERTIFICATE_VERSIONS, VERIFICATION_STATUSES } from '@blockcerts/cert-verifier-js';\n```\n- [`BLOCKCHAINS`](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/blockchains.js): descriptive object of all blockchains supported by the library\n- [`STEPS`](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/verificationSteps.js): descriptive object of all verification steps (top level)\n- [`SUB_STEPS`](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/verificationSubSteps.js): descriptive object of all verification substeps\n- [`CERTIFICATE_VERSIONS`](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/certificateVersions.js): list of all certificate versions\n- [`VERIFICATION_STATUSES`](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/src/constants/verificationStatuses.js)\n\n### i18n\nThe exposed function `getSupportedLanguages()` returns an array of language codes supported by the library.\n```javascript\nimport { getSupportedLanguages } from '@blockcerts/cert-verifier-js';\ngetSupportedLanguages(); // ['en-US', 'es-ES', 'mt', ...]\n```\nYou can use the codes for the `locale` option.\n\nPlease note that while we are working to add new languages, any new translation is welcome through forking & PR.\n\n## Contribute\n\n### Run the tests\n```shell\n$ npm run test\n```\n\n### Build\n```shell\n$ npm run build\n```\nThe build files are in the `dist` folder.\n\n## Verification process\nIf you want more details about the verification process, please check out the [documentation](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/docs/verification-process.md).\n\n# Contact\n\nContact us at [the Blockcerts community forum](http://community.blockcerts.org/).\n","readmeFilename":"README.md"}