Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Travis CI User
Travis CI User Publish
 - @govtechsg/open-certificate@2.0.9
Latest commit 9087d80 Aug 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dependabot Added automerge Jul 10, 2019
schema Typo Jul 10, 2019
src Added parameter for schema version (#41) Jul 12, 2019
test Added test for signature and structure after obfuscation Oct 2, 2018
.babelrc added rollup build Aug 16, 2018
.eslintignore added rollup build Aug 16, 2018
.eslintrc.json
.gitignore added build steps Aug 8, 2018
.nycrc added rollup build Aug 16, 2018
.travis.yml Added testing in travis (#36) Jul 10, 2019
LICENSE
README.md filled Aug 27, 2018
lerna.json fixed lerna hopefully Apr 10, 2019
package.json Publish Aug 12, 2019
rollup.config.js lint fix Aug 16, 2018

README.md

Open Certificate

This library supplies the schemas used for OpenCerts standards, in the form of json schemas

Installation

Using npm:

npm install @govtechsg/open-certificate

Usage

If you are writing a certificate issuer: you probably want to issue a certificate or issue multiple certificates

If you are writing a certificate verifier or viewer: you probably want to

  1. validate that a certificate is well-formed
  2. verify that a certificate has not been tampered with
  3. retrieve certificate contents
  4. obfuscate fields

Using OpenCerts

const openCert = require("@govtechsg/open-certificate")

const exampleCert = require("exampleCert.json") // reading an example certificate file
openCert.verify(exampleCert)

Validate Schema

This library comes with the schemas in the ./schema folder, all of them are loaded as valid schemas upon initialization.

openCert.validateSchema(exampleCert)

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.

openCert.verifySignature(exampleCert)

Issue a Certificate

A single Certificate can be issued using the .issueCertificate(certificate) method. 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.issueCertificate(exampleCert)

Issue Multiple Certificates

Multiple Certificates can be issued at once with the .issueCertificates(certificate[]) method.

The return value of the method will be an array of signed certificates.

const exampleCerts = [cert1, cert2, cert3, ...]
const issuedCerts = openCert.issueCertificates(exampleCerts)

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 .certificateData(certificate)

const data = openCert.certificateData(exampleCert)

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.obfuscateFields(exampleCert, [
    "recipient.email",
    "recipient.phone"
]);

Developers

The code is written to ES6 specs with stage-3 presets and is compiled by Babel.

Test

npm run test

Build

npm run build

Related Projects

Open Attestation Certificate Contract OpenCert Web UI

You can’t perform that action at this time.