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 0.0.2 to 1.0.0

6

docs/samples/chainpoint-proof-v3.json

@@ -5,4 +5,6 @@ {

"hash": "bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2",
"hash_id": "5cf0a860-0f52-11e7-947d-7fde4e7ca024",
"hash_submitted_at": "2017-03-23T11:30:33Z",
"hash_id_node": "5cf0a860-0f52-11e7-947d-7fde4e7ca024",
"hash_submitted_node_at": "2017-03-23T11:30:33Z",
"hash_id_core": "e6bf9cc1-67dd-11e7-af4a-e7bc0011940a",
"hash_submitted_core_at": "2017-07-13T15:14:02Z",
"branches": [{

@@ -9,0 +11,0 @@ "label": "root_branch",

@@ -124,4 +124,4 @@ 'use strict'

},
'hash_id': {
'description': 'The Type 1 (timestamp) UUID used to identify and track a hash or retrieve a Chainpoint proof',
'hash_id_node': {
'description': 'The Type 1 (timestamp) UUID used to identify and track a hash or retrieve a Chainpoint proof from a Chainpoint Node',
'pattern': '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$',

@@ -131,8 +131,20 @@ 'title': 'A Type 1 (timestamp) UUID that identifies a hash',

},
'hash_submitted_at': {
'description': 'The timestamp, in ISO8601 form, extracted from the hash_id that represents the time the hash was submitted for anchoring. Must be in "2017-03-23T11:30:33Z" form with granularity only to seconds and UTC zone.',
'hash_submitted_node_at': {
'description': 'The timestamp, in ISO8601 form, extracted from the hash_id_node that represents the time the hash was submitted to Chainpoint Node. Must be in "2017-03-23T11:30:33Z" form with granularity only to seconds and UTC zone.',
'pattern': '^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\dZ$',
'title': 'An ISO8601 timestamp, extracted from the hash_id',
'title': 'An ISO8601 timestamp, extracted from hash_id_node',
'type': 'string'
},
'hash_id_core': {
'description': 'The Type 1 (timestamp) UUID used to by Chainpoint Node to identify and track a hash or retrieve a Chainpoint proof from Chainpoint Core',
'pattern': '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$',
'title': 'A Type 1 (timestamp) UUID that identifies a hash',
'type': 'string'
},
'hash_submitted_core_at': {
'description': 'The timestamp, in ISO8601 form, extracted from the hash_id_core that represents the time the hash was submitted to Chainpoint Core. Must be in "2017-03-23T11:30:33Z" form with granularity only to seconds and UTC zone.',
'pattern': '^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\dZ$',
'title': 'An ISO8601 timestamp, extracted from hash_id_core',
'type': 'string'
},
'branches': {

@@ -146,3 +158,3 @@ 'items': {

},
'required': ['@context', 'type', 'hash', 'hash_id', 'hash_submitted_at', 'branches'],
'required': ['@context', 'type', 'hash', 'hash_id_node', 'hash_submitted_node_at', 'hash_id_core', 'hash_submitted_core_at', 'branches'],
'title': 'Chainpoint v3 JSON Schema.',

@@ -149,0 +161,0 @@ 'type': 'object'

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

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

# Chainpoint Proof v3 JSON Schema Validator
[![npm version](https://badge.fury.io/js/chainpoint-proof-json-schema.svg)](https://badge.fury.io/js/chainpoint-proof-json-schema)
A simple npm package to validate a Chainpoint v3 Proof, in JSON format, against a JSON Schema (Draft 04).

@@ -4,0 +6,0 @@

@@ -71,6 +71,6 @@ 'use strict'

it('should be invalid with missing hash_id', function (done) {
delete sampleProof['hash_id']
it('should be invalid with missing hash_id_node', function (done) {
delete sampleProof['hash_id_node']
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id')
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id_node')
cps.validate(sampleProof).errors[0].should.have.property('message', 'is required')

@@ -80,6 +80,6 @@ done()

it('should be invalid with non-UUID hash_id', function (done) {
sampleProof['hash_id'] = 'abc'
it('should be invalid with non-UUID hash_id_node', function (done) {
sampleProof['hash_id_node'] = 'abc'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id')
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id_node')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')

@@ -89,6 +89,6 @@ done()

it('should be invalid with missing hash_submitted_at', function (done) {
delete sampleProof['hash_submitted_at']
it('should be invalid with missing hash_submitted_node_at', function (done) {
delete sampleProof['hash_submitted_node_at']
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_at')
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_node_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'is required')

@@ -98,6 +98,6 @@ done()

it('should be invalid with non ISO8601 date hash_submitted_at', function (done) {
sampleProof['hash_submitted_at'] = 'March 1, 2017'
it('should be invalid with non ISO8601 date hash_submitted_node_at', function (done) {
sampleProof['hash_submitted_node_at'] = 'March 1, 2017'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_at')
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_node_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')

@@ -107,6 +107,6 @@ done()

it('should be invalid with ISO8601 date hash_submitted_at in non-strict millisecond granularity form', function (done) {
sampleProof['hash_submitted_at'] = '2017-04-25T19:10:07.171Z'
it('should be invalid with ISO8601 date hash_submitted_node_at in non-strict millisecond granularity form', function (done) {
sampleProof['hash_submitted_node_at'] = '2017-04-25T19:10:07.171Z'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_at')
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_node_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')

@@ -116,2 +116,42 @@ done()

it('should be invalid with missing hash_id_core', function (done) {
delete sampleProof['hash_id_core']
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id_core')
cps.validate(sampleProof).errors[0].should.have.property('message', 'is required')
done()
})
it('should be invalid with non-UUID hash_id_core', function (done) {
sampleProof['hash_id_core'] = 'abc'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_id_core')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')
done()
})
it('should be invalid with missing hash_submitted_core_at', function (done) {
delete sampleProof['hash_submitted_core_at']
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_core_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'is required')
done()
})
it('should be invalid with non ISO8601 date hash_submitted_core_at', function (done) {
sampleProof['hash_submitted_core_at'] = 'March 1, 2017'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_core_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')
done()
})
it('should be invalid with ISO8601 date hash_submitted_core_at in non-strict millisecond granularity form', function (done) {
sampleProof['hash_submitted_core_at'] = '2017-04-25T19:10:07.171Z'
cps.validate(sampleProof).should.have.property('valid', false)
cps.validate(sampleProof).errors[0].should.have.property('field', 'data.hash_submitted_core_at')
cps.validate(sampleProof).errors[0].should.have.property('message', 'pattern mismatch')
done()
})
it('should be invalid with missing branches at the root', function (done) {

@@ -118,0 +158,0 @@ delete sampleProof['branches']

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

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