2.1.1 • Published 2 years ago

chainpoint-proof-json-schema v2.1.1

Weekly downloads
69
License
Apache-2.0
Repository
github
Last release
2 years ago

IMPORTANT

The package is for the Chainpont v4 proof schema. If you're looking to validate proofs schemas from the older Chainpoint V3 Network (chainpoint-services), use version 1.1.0.

This package does not validate that the hashes in a proof are valid up to an anchor (e.g. BTC, ETH). In fact this package doesn't know what a hash is! It only validates that the proof you provide it with is a well formed proof according to its schema. Nothing more, nothing less.

Chainpoint Proof v4 JSON Schema Validator

code style: prettier

License

npm version

A simple npm package to validate a Chainpoint v4 Proof, in JSON format, against a JSON Schema (Draft 04).

Take a look here to learn more about https://chainpoint.org

Learn More About JSON Schema:

http://json-schema.org/

https://spacetelescope.github.io/understanding-json-schema/index.html

Usage

Node.js

yarn add chainpoint-proof-json-schema
const chainpointProofSchema = require('chainpoint-proof-json-schema')
let objectToValidate = {}
let res = chainpointProofSchema.validate(objectToValidate)

// {valid: true, errors: null}
if (res.valid) {
    console.log('valid')
} else {
    console.log(res.errors)
}

Browser

You can copy docs/bundle.js into your app to include in a script tag.

Or install the npm package in a place available to your web pages and set the script src tag to something like the following. A window global function chainpointProofSchema.validate() will be available and operate the same as the Node.js example above.

<script src="./node_modules/chainpoint-proof-json-schema/docs/bundle.js">

Development

Test

yarn test

Browser Packaging

Will store a browserify bundle to docs/bundle.js which can also be used from directly within the <script> tag in an HTML page.

yarn bundle

Open a local copy of the test page in your browser after bundling

yarn browser
2.1.1

2 years ago

2.1.0

2 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

5 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago