Socket
Socket
Sign inDemoInstall

stampery

Package Overview
Dependencies
47
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.1 to 6.0.2

.travis.yml

4

deleteme.js
const Stampery = require('./dist/stampery.js');
var s = new Stampery('');
var valid = s.prove({receipts:{btc:{
var stampery = new Stampery('');
var valid = stampery.prove({receipts:{btc:{
"@context": "https://w3id.org/chainpoint/v2",

@@ -5,0 +5,0 @@ "type": "BTA-SHA256",

@@ -177,2 +177,3 @@ (function() {

Stampery.prototype.prove = function(receipt) {
var hash;
if ('receipts' in receipt) {

@@ -187,3 +188,4 @@ receipt = receipt.receipts;

if (receipt) {
return this._checkSiblings(receipt.targetHash, receipt.proof, receipt.merkleRoot);
hash = Buffer(receipt.targetHash, 'hex');
return this._checkSiblings(hash, receipt.proof, receipt.merkleRoot);
}

@@ -209,3 +211,3 @@ return false;

root = new Buffer(root, 'hex');
return hash.equals(root);
return root.equals(hash);
}

@@ -212,0 +214,0 @@ };

@@ -1,1 +0,1 @@

(function(){var a,b,c,d=function(a,b){return function(){return a.apply(b,arguments)}};b=require("crypto"),c=require("request"),a=function(){function a(a,c){var e;this.clientSecret=a,this.env=null!=c?c:"prod",this._merkleMix=d(this._merkleMix,this),this._checkSiblings=d(this._checkSiblings,this),this.prove=d(this.prove,this),this._req=d(this._req,this),this._post=d(this._post,this),this._get=d(this._get,this),this.stamp=d(this.stamp,this),this.getAll=d(this.getAll,this),this.getByHash=d(this.getByHash,this),this.getById=d(this.getById,this),this.clientId=b.createHash("md5").update(this.clientSecret).digest("hex").substring(0,15),e=new Buffer(this.clientId+":"+this.clientSecret),this.auth="Basic "+e.toString("base64"),this.host="beta"===this.env?"https://api-beta.stampery.com":"https://api-prod.stampery.com"}return a.prototype.hash=function(a){return b.createHash("sha256").update(a).digest()},a.prototype.getById=function(a,b){return this._get("stamps/"+a,function(a,c){return c&&(c=c[0]),b(a,c)})},a.prototype.getByHash=function(a,b){return a instanceof Buffer&&(a=a.toString("hex")),this._get("stamps/"+a,b)},a.prototype.getAll=function(a,b){var c,d;return d=null!=b?[a,b]:[0,a],c=d[0],a=d[1],this._get("stamps?page="+c,a)},a.prototype.stamp=function(a,b){return a instanceof Buffer&&(a=a.toString("hex")),this._post("stamps",{hash:a},b)},a.prototype._get=function(a,b){return this._req("GET",a,{},b)},a.prototype._post=function(a,b,c){return this._req("POST",a,b,c)},a.prototype._req=function(a,b,d,e){var f;return f={method:a,url:this.host+"/"+b,headers:{Authorization:this.auth,"Content-Type":"application/json"}},d&&(f.json=d),c(f,function(a,b,c){return a?e(a,null):b.statusCode>=400?e({code:b.statusCode,message:b.statusMessage},null):e(null,c.result)})},a.prototype.prove=function(a){return"receipts"in a&&(a=a.receipts),"btc"in a&&(a=[a.btc,a.eth].find(function(a){return"number"!=typeof a})),!!a&&this._checkSiblings(a.targetHash,a.proof,a.merkleRoot)},a.prototype._checkSiblings=function(a,b,c){var d,e,f,g;return b.length>0?(e=b[0],g=b.slice(1),d="left"in e?[e.left,a]:[a,e.right],f=this._merkleMix(d),this._checkSiblings(f,g,c)):(c=new Buffer(c,"hex"),a.equals(c))},a.prototype._merkleMix=function(a){var b;return b=Buffer.concat(a.map(function(a){return Buffer(a,"hex")})),this.hash(b)},a}(),module.exports=a}).call(this);
(function(){var a,b,c,d=function(a,b){return function(){return a.apply(b,arguments)}};b=require("crypto"),c=require("request"),a=function(){function a(a,c){var e;this.clientSecret=a,this.env=null!=c?c:"prod",this._merkleMix=d(this._merkleMix,this),this._checkSiblings=d(this._checkSiblings,this),this.prove=d(this.prove,this),this._req=d(this._req,this),this._post=d(this._post,this),this._get=d(this._get,this),this.stamp=d(this.stamp,this),this.getAll=d(this.getAll,this),this.getByHash=d(this.getByHash,this),this.getById=d(this.getById,this),this.clientId=b.createHash("md5").update(this.clientSecret).digest("hex").substring(0,15),e=new Buffer(this.clientId+":"+this.clientSecret),this.auth="Basic "+e.toString("base64"),this.host="beta"===this.env?"https://api-beta.stampery.com":"https://api-prod.stampery.com"}return a.prototype.hash=function(a){return b.createHash("sha256").update(a).digest()},a.prototype.getById=function(a,b){return this._get("stamps/"+a,function(a,c){return c&&(c=c[0]),b(a,c)})},a.prototype.getByHash=function(a,b){return a instanceof Buffer&&(a=a.toString("hex")),this._get("stamps/"+a,b)},a.prototype.getAll=function(a,b){var c,d;return d=null!=b?[a,b]:[0,a],c=d[0],a=d[1],this._get("stamps?page="+c,a)},a.prototype.stamp=function(a,b){return a instanceof Buffer&&(a=a.toString("hex")),this._post("stamps",{hash:a},b)},a.prototype._get=function(a,b){return this._req("GET",a,{},b)},a.prototype._post=function(a,b,c){return this._req("POST",a,b,c)},a.prototype._req=function(a,b,d,e){var f;return f={method:a,url:this.host+"/"+b,headers:{Authorization:this.auth,"Content-Type":"application/json"}},d&&(f.json=d),c(f,function(a,b,c){return a?e(a,null):b.statusCode>=400?e({code:b.statusCode,message:b.statusMessage},null):e(null,c.result)})},a.prototype.prove=function(a){var b;return"receipts"in a&&(a=a.receipts),"btc"in a&&(a=[a.btc,a.eth].find(function(a){return"number"!=typeof a})),!!a&&(b=Buffer(a.targetHash,"hex"),this._checkSiblings(b,a.proof,a.merkleRoot))},a.prototype._checkSiblings=function(a,b,c){var d,e,f,g;return b.length>0?(e=b[0],g=b.slice(1),d="left"in e?[e.left,a]:[a,e.right],f=this._merkleMix(d),this._checkSiblings(f,g,c)):(c=new Buffer(c,"hex"),c.equals(a))},a.prototype._merkleMix=function(a){var b;return b=Buffer.concat(a.map(function(a){return Buffer(a,"hex")})),this.hash(b)},a}(),module.exports=a}).call(this);
{
"name": "stampery",
"version": "6.0.1",
"version": "6.0.2",
"description": "Stampery API for NodeJS: seamlessly integrate the blockchain-powered, industrial-scale certification platform into your NodeJS apps.",

@@ -29,8 +29,12 @@ "main": "dist/stampery.min.js",

"build": "grunt",
"example": "coffee src/example.coffee"
"example": "coffee src/example.coffee",
"test": "mocha"
},
"devDependencies": {
"chai": "^3.5.0",
"coffee-script": "^1.12.2",
"grunt": "^1.0.1",
"grunt-contrib-coffee": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0"
"grunt-contrib-uglify": "^2.0.0",
"mocha": "^3.2.0"
},

@@ -37,0 +41,0 @@ "engines": {

# Stampery
[![NPM Package](https://img.shields.io/npm/v/stampery.svg?style=flat-square)](https://www.npmjs.org/package/stampery)
[![Build Status](https://travis-ci.org/stampery/node.svg?branch=master)](https://travis-ci.org/stampery/node)

@@ -5,0 +6,0 @@ __NodeJS__ client library for [__Stampery API__](https://stampery.com/api), the __blockchain-powered__, __industrial-scale certification platform__.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc