2.0.63 • Published 4 years ago

@govtechsg/open-certificate v2.0.63

Weekly downloads
191
License
Apache-2.0
Repository
github
Last release
4 years ago

DEPRECATED

This CLI has been deprecated in favor of open-attestation CLI. Please read OpenCerts documentation to find out more.

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 1. verify that a certificate has not been tampered with 1. retrieve certificate contents 1. 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

2.0.63

4 years ago

2.0.62

4 years ago

2.0.61

4 years ago

2.0.60

4 years ago

2.0.59

4 years ago

2.0.57

4 years ago

2.0.56

4 years ago

2.0.55

4 years ago

2.0.54

4 years ago

2.0.53

4 years ago

2.0.52

4 years ago

2.0.51

4 years ago

2.0.50

4 years ago

2.0.49

4 years ago

2.0.48

4 years ago

2.0.47

4 years ago

2.0.46

4 years ago

2.0.45

4 years ago

2.0.44

4 years ago

2.0.43

4 years ago

2.0.42

4 years ago

2.0.41

4 years ago

2.0.40

4 years ago

2.0.39

4 years ago

2.0.38

4 years ago

2.0.37

4 years ago

2.0.36

4 years ago

2.0.35

4 years ago

2.0.34

4 years ago

2.0.33

4 years ago

2.0.32

4 years ago

2.0.31

4 years ago

2.0.30

4 years ago

2.0.29

4 years ago

2.0.28

4 years ago

2.0.27

4 years ago

2.0.26

4 years ago

2.0.25

4 years ago

2.0.24

4 years ago

2.0.23

4 years ago

2.0.22

4 years ago

2.0.21

4 years ago

2.0.20

4 years ago

2.0.19

4 years ago

2.0.18

4 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

1.1.45

5 years ago

1.1.44

5 years ago

1.1.43

5 years ago

1.1.42

5 years ago

1.1.41

5 years ago

1.1.40

5 years ago

1.1.39

5 years ago

1.1.38

5 years ago

1.1.37

5 years ago

1.1.35

5 years ago

1.1.34

6 years ago

1.1.33

6 years ago

1.1.32

6 years ago

1.1.31

6 years ago

1.1.30

6 years ago

1.1.29

6 years ago

1.1.28

6 years ago

1.1.27

6 years ago

1.1.26

6 years ago

1.1.25

6 years ago

1.1.24

6 years ago

1.1.22

6 years ago

1.1.21

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.17-0

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.8

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago