This CLI has been deprecated in favor of open-attestation CLI. Please read OpenCerts documentation to find out more.
This library supplies the schemas used for OpenCerts standards, in the form of json schemas
npm install @govtechsg/open-certificate
If you are writing a certificate verifier or viewer: you probably want to
- validate that a certificate is well-formed
- verify that a certificate has not been tampered with
- retrieve certificate contents
- obfuscate fields
const openCert =const exampleCert = // reading an example certificate fileopenCert
This library comes with the schemas in the
./schema folder, all of them are loaded as valid schemas upon initialization.
Verifying Certificate Signature
Certificates are considered untampered-with if they have a valid signature field. Refer to the Open Attestation library for more details on this.
Issue a Certificate
A single Certificate can be issued using the
Issuing a certificate in this manner will append a signature field to the certificate.
The return value of the method will be the signed certificate.
const issuedCert = openCert
Issue Multiple Certificates
Multiple Certificates can be issued at once with the
The return value of the method will be an array of signed certificates.
const exampleCerts = cert1 cert2 cert3 ...const issuedCerts = openCert
Retrieving Certificate contents
The raw certificate has salt in the fields to prevent enumeration, we provide a convenience method to retrieve the unsalted contents of the certificate using the method
const data = openCert
Obfuscating Fields in a Certificate
To obfuscate fields in a cert, the method
.obfuscateFields(certificate, paths) is provided.
The paths parameter is simply the JSON path for the fields to be obfuscated.
The method returns the obfuscated certificate.
const obfuscatedCert = openCert;
The code is written to ES6 specs with stage-3 presets and is compiled by Babel.
npm run test
npm run build