GithubHelp home page GithubHelp logo

carbonregistry / chainpoint-proof-json-schema Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chainpoint/chainpoint-proof-json-schema

0.0 2.0 0.0 41 KB

A Javascript NPM package to validate Chainpoint v3 Proofs with a formal JSON Schema (Draft 04) validator

JavaScript 100.00%

chainpoint-proof-json-schema's Introduction

Chainpoint Proof v3 JSON Schema Validator

npm version

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

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

IMPORTANT

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.

Try it out

Test out the schema validation with a sample proof, or one of your own.

https://chainpoint.org/chainpoint-proof-json-schema/

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

Note : You can copy docs/bundle.js into your app to include in a script tag, or use the http://rawgit.com/ CDN version (make sure the Git commit SHA1 in the URL is current). Rawgit is a free service and makes no guarantees for uptime.

  <script src="https://cdn.rawgit.com/chainpoint/chainpoint-proof-json-schema/495732a06654615f2b2d4c5716c59f769a99d3c2/docs/bundle.js"></script>

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

chainpoint-proof-json-schema's People

Contributors

jasonbukowski avatar

Watchers

James Cloos avatar Dazza Greenwood avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.