Socket
Socket
Sign inDemoInstall

chainpoint-proof-json-schema

Package Overview
Dependencies
7
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

docs/samples/chainpoint-proof-v3.chp.json

8

index.js
'use strict'
/* Copyright 2017 Tierion
/* Copyright 2017-2018 Tierion
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -52,5 +52,5 @@ * you may not use this file except in compliance with the License.

'description': 'A trust anchor',
'title': 'One of the known trust anchor types. Calendar (cal), Ethereum (eth), and Bitcoin (btc).',
'type': 'string',
'enum': ['cal', 'eth', 'btc']
'pattern': '^[a-z]{3,10}$',
'title': 'A trust anchor type. e.g. Chainpoint Calendar (cal), Ethereum (eth), or Bitcoin (btc). It must be between 3 and 10 characters in length and match the Regex /^[a-z]{3,10}$/',
'type': 'string'
},

@@ -57,0 +57,0 @@ 'anchor_id': {

{
"name": "chainpoint-proof-json-schema",
"version": "1.0.1",
"version": "1.0.2",
"description": "A JSON Schema (Draft 04) validator for Chainpoint v3 Proofs",

@@ -13,5 +13,5 @@ "main": "index.js",

"devDependencies": {
"browserify": "^14.3.0",
"mocha": "^3.3.0",
"should": "^11.2.1"
"browserify": "^16.2.3",
"mocha": "^5.2.0",
"should": "^13.2.3"
},

@@ -18,0 +18,0 @@ "scripts": {

@@ -13,10 +13,2 @@ # Chainpoint Proof v3 JSON Schema Validator

## Try it out
Test out the schema validation with a sample proof,
or one of your own.
[https://chainpoint.org/chainpoint-proof-json-schema/](https://chainpoint.org/chainpoint-proof-json-schema/)
## Learn More About JSON Schema:

@@ -51,9 +43,4 @@

Note : You can copy `docs/bundle.js` into your app to include in a script tag, or use the [http://rawgit.com/](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.
You can copy `docs/bundle.js` into your app to include in a script tag.
```
<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.

@@ -60,0 +47,0 @@

'use strict'
const cps = require('../index')
const sampleProofFromFile = require('../docs/samples/chainpoint-proof-v3.json')
const sampleProofFromFile = require('../docs/samples/chainpoint-proof-v3.chp.json')

@@ -328,6 +328,6 @@ let sampleProof

it('should be invalid with an unknown type', function (done) {
it('should be invalid with an incorrectly cased type', function (done) {
// get the last ops, which should be an anchor
let lastAnchorIndex = sampleProof.branches[0].ops.length - 1
sampleProof.branches[0].ops[lastAnchorIndex].anchors[0].type = 'foo'
sampleProof.branches[0].ops[lastAnchorIndex].anchors[0].type = 'bTc'
cps.validate(sampleProof).should.have.property('valid', false)

@@ -337,2 +337,26 @@ done()

it('should be invalid with a too short type', function (done) {
// get the last ops, which should be an anchor
let lastAnchorIndex = sampleProof.branches[0].ops.length - 1
sampleProof.branches[0].ops[lastAnchorIndex].anchors[0].type = 'ab'
cps.validate(sampleProof).should.have.property('valid', false)
done()
})
it('should be invalid with a too long type', function (done) {
// get the last ops, which should be an anchor
let lastAnchorIndex = sampleProof.branches[0].ops.length - 1
sampleProof.branches[0].ops[lastAnchorIndex].anchors[0].type = 'abcdefghijk'
cps.validate(sampleProof).should.have.property('valid', false)
done()
})
it('should be valid with an arbitrary anchor type', function (done) {
// get the last ops, which should be an anchor
let lastAnchorIndex = sampleProof.branches[0].ops.length - 1
sampleProof.branches[0].ops[lastAnchorIndex].anchors[0].type = 'foo'
cps.validate(sampleProof).should.have.property('valid', true)
done()
})
it('should be valid with an unknown anchor_id', function (done) {

@@ -339,0 +363,0 @@ // get the last ops, which should be an anchor

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc