Comparing version 3.1.2 to 3.2.0
112
index.js
@@ -70,5 +70,9 @@ (function() { | ||
this.beta = beta; | ||
this.checkRootInChain = __bind(this.checkRootInChain, this); | ||
this.checkSiblings = __bind(this.checkSiblings, this); | ||
this.prove = __bind(this.prove, this); | ||
this._merkleMixer = __bind(this._merkleMixer, this); | ||
this.receiveMissedProofs = __bind(this.receiveMissedProofs, this); | ||
this._handleQueueConsumingForHash = __bind(this._handleQueueConsumingForHash, this); | ||
this._sumSiblings = __bind(this._sumSiblings, this); | ||
this._auth = __bind(this._auth, this); | ||
@@ -385,3 +389,2 @@ this._connectRabbit = __bind(this._connectRabbit, this); | ||
})(function() { | ||
console.log('RES', err, res); | ||
if (!_this.authed) { | ||
@@ -413,7 +416,45 @@ return _this.emit('error', 'Not authenticated'); | ||
Stampery.prototype.prove = function(hash, proof) { | ||
var rootIsInChain, siblingsAreOK; | ||
siblingsAreOK = this.checkSiblings(hash, proof[1], proof[2]); | ||
rootIsInChain = this.checkRootInChain(proof[2], proof[3][0], proof[3][1]); | ||
return siblingsAreOK && rootIsInChain; | ||
Stampery.prototype.prove = function(hash, proof, cb) { | ||
var rootIsInChain, siblingsAreOK, ___iced_passed_deferral, __iced_deferrals, __iced_k; | ||
__iced_k = __iced_k_noop; | ||
___iced_passed_deferral = iced.findDeferral(arguments); | ||
(function(_this) { | ||
return (function(__iced_k) { | ||
__iced_deferrals = new iced.Deferrals(__iced_k, { | ||
parent: ___iced_passed_deferral, | ||
filename: "./index.iced", | ||
funcname: "Stampery.prove" | ||
}); | ||
_this.checkSiblings(hash, proof[1], proof[2], __iced_deferrals.defer({ | ||
assign_fn: (function() { | ||
return function() { | ||
return siblingsAreOK = arguments[0]; | ||
}; | ||
})(), | ||
lineno: 162 | ||
})); | ||
__iced_deferrals._fulfill(); | ||
}); | ||
})(this)((function(_this) { | ||
return function() { | ||
(function(__iced_k) { | ||
__iced_deferrals = new iced.Deferrals(__iced_k, { | ||
parent: ___iced_passed_deferral, | ||
filename: "./index.iced", | ||
funcname: "Stampery.prove" | ||
}); | ||
_this.checkRootInChain(proof[2], proof[3][0], proof[3][1], __iced_deferrals.defer({ | ||
assign_fn: (function() { | ||
return function() { | ||
return rootIsInChain = arguments[0]; | ||
}; | ||
})(), | ||
lineno: 163 | ||
})); | ||
__iced_deferrals._fulfill(); | ||
})(function() { | ||
return cb(siblingsAreOK && rootIsInChain); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
@@ -438,3 +479,3 @@ | ||
})(), | ||
lineno: 168 | ||
lineno: 167 | ||
})); | ||
@@ -450,3 +491,3 @@ __iced_deferrals._fulfill(); | ||
Stampery.prototype.checkSiblings = function(hash, siblings, root) { | ||
Stampery.prototype.checkSiblings = function(hash, siblings, root, cb) { | ||
var head, tail, ___iced_passed_deferral, __iced_deferrals, __iced_k; | ||
@@ -471,3 +512,3 @@ __iced_k = __iced_k_noop; | ||
})(), | ||
lineno: 175 | ||
lineno: 174 | ||
})); | ||
@@ -478,31 +519,57 @@ __iced_deferrals._fulfill(); | ||
return function() { | ||
return __iced_k(_this.checkSiblings(hash, tail, root)); | ||
return __iced_k(cb(_this.checkSiblings(hash, tail, root, cb))); | ||
}; | ||
})(this)); | ||
} else { | ||
return __iced_k(hash === root); | ||
return __iced_k(cb(hash === root)); | ||
} | ||
}; | ||
Stampery.prototype.checkRootInChain = function(root, chain, txid) { | ||
var tx, txData; | ||
txData = this._getBTCtx(txid); | ||
Stampery.prototype.checkRootInChain = function(root, chain, txid, cb) { | ||
var data, f, ___iced_passed_deferral, __iced_deferrals, __iced_k; | ||
__iced_k = __iced_k_noop; | ||
___iced_passed_deferral = iced.findDeferral(arguments); | ||
f = this._getBTCtx; | ||
if (chain === 2) { | ||
tx = this._getETHtx(txid); | ||
f = this._getETHtx; | ||
} | ||
return txData.indexOf(root.toLowerCase()); | ||
(function(_this) { | ||
return (function(__iced_k) { | ||
__iced_deferrals = new iced.Deferrals(__iced_k, { | ||
parent: ___iced_passed_deferral, | ||
filename: "./index.iced", | ||
funcname: "Stampery.checkRootInChain" | ||
}); | ||
f(txid, __iced_deferrals.defer({ | ||
assign_fn: (function() { | ||
return function() { | ||
return data = arguments[0]; | ||
}; | ||
})(), | ||
lineno: 183 | ||
})); | ||
__iced_deferrals._fulfill(); | ||
}); | ||
})(this)((function(_this) { | ||
return function() { | ||
return cb(data.indexOf(root.toLowerCase()) >= 0); | ||
}; | ||
})(this)); | ||
}; | ||
Stampery.prototype._getBTCtx = function(txid) { | ||
Stampery.prototype._getBTCtx = function(txid, cb) { | ||
return request("https://api.blockcypher.com/v1/btc/main/txs/" + txid, function(err, res, body) { | ||
if (err || !body || !JSON.parse(body).data_hex) { | ||
var tx; | ||
if (err || !body || !JSON.parse(body).outputs) { | ||
console.error('ERR-', JSON.parse(body)); | ||
throw new Error('BTC explorer error'); | ||
} | ||
return JSON.parse(body).outputs.find(function(e) { | ||
return e.data_hex && e.data_hex; | ||
tx = JSON.parse(body).outputs.find(function(e) { | ||
return e.data_hex != null; | ||
}); | ||
return cb(tx.data_hex); | ||
}); | ||
}; | ||
Stampery.prototype._getETHtx = function(txid) { | ||
Stampery.prototype._getETHtx = function(txid, cb) { | ||
return request("https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash=" + txid, function(err, res, body) { | ||
@@ -512,4 +579,3 @@ if (err || !body || !JSON.parse(body).result) { | ||
} | ||
console.log(body); | ||
return JSON.parse(body).result.input; | ||
return cb(JSON.parse(body).result.input); | ||
}); | ||
@@ -516,0 +582,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! stampery-node 2016-06-22 */ | ||
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=function(a,b){return function(){return a.apply(b,arguments)}};j=require("iced-runtime"),o=p=function(){},h=require("crypto"),m=require("stream"),d=require("sha3"),c=require("rocksolidsocket"),b=require("msgpackrpc"),f=require("amqplib/callback_api"),k=require("msgpack"),i=require("domain"),n=require("util"),l=require("request"),a=require("events").EventEmitter,g=i.create(),g.on("error",function(a){return function(a){return console.log("[QUEUE] Error with queue: "+a)}}(this)),e=function(){function a(a,d){var e,f;this.clientSecret=a,this.beta=d,this._merkleMixer=q(this._merkleMixer,this),this.receiveMissedProofs=q(this.receiveMissedProofs,this),this._handleQueueConsumingForHash=q(this._handleQueueConsumingForHash,this),this._auth=q(this._auth,this),this._connectRabbit=q(this._connectRabbit,this),this._recursiveConvert=q(this._recursiveConvert,this),this._convertSiblingArray=q(this._convertSiblingArray,this),this.clientId=this._hash("md5",this.clientSecret).substring(0,15),e=this.beta?"api-beta.stampery.com:4000":"api.stampery.com:4000",f=new c(e),this.rpc=new b("stampery.3",f),this._connectRabbit()}return a.prototype.ethSiblings={},a.prototype.authed=!1,a.prototype._convertSiblingArray=function(a){return""===a?[]:a.map(function(a,b){return a.toString()})},a.prototype._recursiveConvert=function(a){return a.map(function(a){return function(b){return b instanceof Buffer?b=b.toString("utf8"):b instanceof Array&&(b=a._recursiveConvert(b)),b}}(this))},a.prototype._connectRabbit=function(){var a,b,c,d;d=p,b=j.findDeferral(arguments),function(d){return function(e){d.beta?!function(e){c=new j.Deferrals(e,{parent:b,filename:"./index.iced",funcname:"Stampery._connectRabbit"}),f.connect("amqp://consumer:9FBln3UxOgwgLZtYvResNXE7@young-squirrel.rmq.cloudamqp.com/beta",c.defer({assign_fn:function(b){return function(){return a=arguments[0],b.rabbit=arguments[1]}}(d),lineno:50})),c._fulfill()}(e):!function(e){c=new j.Deferrals(e,{parent:b,filename:"./index.iced",funcname:"Stampery._connectRabbit"}),f.connect("amqp://consumer:9FBln3UxOgwgLZtYvResNXE7@young-squirrel.rmq.cloudamqp.com/ukgmnhoi",c.defer({assign_fn:function(b){return function(){return a=arguments[0],b.rabbit=arguments[1]}}(d),lineno:52})),c._fulfill()}(e)}}(this)(function(b){return function(){return a?console.log("[QUEUE] Error connecting "+a):(console.log("[QUEUE] Connected to Rabbit!"),b.emit("ready"),g.add(b.rabbit),b.rabbit.on("error",function(a){return b.emit("error",a),b._connectRabbit}))}}(this))},a.prototype._hash=function(a,b){return h.createHash(a).update(b).digest("hex")},a.prototype.hash=function(a,b){var c;return a instanceof m?this._hashFile(a,b):(c=new d.SHA3Hash,c.update(a),b(c.digest("hex").toUpperCase()))},a.prototype._sha3Hash=function(a,b){var c;return c=new d.SHA3Hash,c.update(a),b(c.digest("hex"))},a.prototype._hashFile=function(a,b){var c;return c=new d.SHA3Hash,a.on("end",function(){return b(c.digest("hex"))}),a.on("data",function(a){return c.update(a)})},a.prototype._auth=function(a){var b,c,d,e,f;f=p,d=j.findDeferral(arguments),function(a){return function(f){e=new j.Deferrals(f,{parent:d,filename:"./index.iced",funcname:"Stampery._auth"}),a.rpc.invoke("auth",[a.clientId,a.clientSecret],e.defer({assign_fn:function(){return function(){return b=arguments[0],c=arguments[1]}}(),lineno:86})),e._fulfill()}}(this)(function(d){return function(){return console.log("[RPC] Auth: ",b,c),b?d.emit("error",b):a(!0)}}(this))},a.prototype.calculateProof=function(a,b,c){var d,e,f;e=a;for(d in b)f=b[d],console.log("[SIBLINGS] Calculating sibling "+d,e,f),this._sumSiblings(e,f,function(a){return console.log("[SIBLINGS] Calculated "+a),e=a});return c(e)},a.prototype._sumSiblings=function(a,b,c){var d,e,f,g;g=p,e=j.findDeferral(arguments),parseInt(a,16)>parseInt(b,16)?(console.log("[SIBLINGS] Leaf1 is bigger than Leaf2"),function(c){return function(g){f=new j.Deferrals(g,{parent:e,filename:"./index.iced",funcname:"Stampery._sumSiblings"}),c._sha3Hash(""+a+b,f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:105})),f._fulfill()}}(this)(function(a){return function(){return g(c(d))}}(this))):(console.log("[SIBLINGS] Leaf2 is bigger than Leaf1"),function(c){return function(g){f=new j.Deferrals(g,{parent:e,filename:"./index.iced",funcname:"Stampery._sumSiblings"}),c._sha3Hash(""+b+a,f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:109})),f._fulfill()}}(this)(function(a){return function(){return g(c(d))}}(this)))},a.prototype._handleQueueConsumingForHash=function(a){var b,c,d,e;return e=p,c=j.findDeferral(arguments),this.rabbit?void!function(a){return function(e){d=new j.Deferrals(e,{parent:c,filename:"./index.iced",funcname:"Stampery._handleQueueConsumingForHash"}),a.rabbit.createChannel(d.defer({assign_fn:function(a){return function(){return b=arguments[0],a.channel=arguments[1]}}(a),lineno:114})),d._fulfill()}}(this)(function(c){return function(){return console.log("[QUEUE] Bound to "+a+"-clnt",b),e(c.channel.consume(""+a+"-clnt",function(a){var b,d,e;return console.log("[QUEUE] Received data!"),e=k.unpack(a.content),b=a.fields.routingKey,1===e[3][0]||e[3][0]===-1?(console.log("[QUEUE] Received BTC proof for "+b),e[1]=(c.ethSiblings[b]||[]).concat(e[1]||[])):2!==e[3][0]&&e[3][0]!==-2||(console.log("[QUEUE] Received ETH proof for "+b),c.ethSiblings[b]=c._convertSiblingArray(e[1])),c.channel.ack(a),d=c._recursiveConvert(e),c.emit("proof",b,d)}))}}(this)):e(this.emit("error","Error binding to "+hash+"-clnt"))},a.prototype.stamp=function(a){var b,c,d,e,f;f=p,d=j.findDeferral(arguments),console.log("Stamping "+a),function(a){return function(b){return a.authed?b():void!function(b){e=new j.Deferrals(b,{parent:d,filename:"./index.iced",funcname:"Stampery.stamp"}),a._auth(e.defer({assign_fn:function(a){return function(){return a.authed=arguments[0]}}(a),lineno:141})),e._fulfill()}(b)}}(this)(function(f){return function(){return a=a.toUpperCase(),console.log("Let's stamp "+a),f.rabbit?void function(g){e=new j.Deferrals(g,{parent:d,filename:"./index.iced",funcname:"Stampery.stamp"}),f.rpc.invoke("stamp",[a],e.defer({assign_fn:function(){return function(){return b=arguments[0],c=arguments[1]}}(),lineno:145})),e._fulfill()}(function(){return console.log("RES",b,c),f.authed?(console.log("[API] Received response: ",c),b?(console.log("[RPC] Error: "+b),f.emit("error",b)):void 0):f.emit("error","Not authenticated")}):setTimeout(f.stamp.bind(f,a),500)}}(this))},a.prototype.receiveMissedProofs=function(){return this._handleQueueConsumingForHash(this.clientId)},a.prototype._merkleMixer=function(a,b,c){var d,e;return b>a&&(e=[b,a],a=e[0],b=e[1]),d=a+b,_sha3Hash(d,c)},a.prototype.prove=function(a,b){var c,d;return d=this.checkSiblings(a,b[1],b[2]),c=this.checkRootInChain(b[2],b[3][0],b[3][1]),d&&c},a.prototype.checkDataIntegrity=function(a,b){var c,d,e,f;f=p,d=j.findDeferral(arguments),function(b){return function(f){e=new j.Deferrals(f,{parent:d,filename:"./index.iced",funcname:"Stampery.checkDataIntegrity"}),b.hash(a,e.defer({assign_fn:function(){return function(){return c=arguments[0]}}(),lineno:168})),e._fulfill()}}(this)(function(a){return function(){return a.prove(c,b)}}(this))},a.prototype.checkSiblings=function(a,b,c){var d,e,f,g,h;return h=p,f=j.findDeferral(arguments),b.length>0?(d=b[0],e=b.slice(1),function(b){return function(c){g=new j.Deferrals(c,{parent:f,filename:"./index.iced",funcname:"Stampery.checkSiblings"}),b._merkleMixer(a,d,g.defer({assign_fn:function(){return function(){return a=arguments[0]}}(),lineno:175})),g._fulfill()}}(this)(function(b){return function(){return h(b.checkSiblings(a,e,c))}}(this)),void 0):h(a===c)},a.prototype.checkRootInChain=function(a,b,c){var d,e;return e=this._getBTCtx(c),2===b&&(d=this._getETHtx(c)),e.indexOf(a.toLowerCase())},a.prototype._getBTCtx=function(a){return l("https://api.blockcypher.com/v1/btc/main/txs/"+a,function(a,b,c){if(a||!c||!JSON.parse(c).data_hex)throw new Error("BTC explorer error");return JSON.parse(c).outputs.find(function(a){return a.data_hex&&a.data_hex})})},a.prototype._getETHtx=function(a){return l("https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash="+a,function(a,b,c){if(a||!c||!JSON.parse(c).result)throw new Error("ETH explorer error");return console.log(c),JSON.parse(c).result.input})},a}(),n.inherits(e,a),module.exports=e}).call(this); | ||
/*! stampery-node 2016-07-19 */ | ||
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=function(a,b){return function(){return a.apply(b,arguments)}};j=require("iced-runtime"),o=p=function(){},h=require("crypto"),m=require("stream"),d=require("sha3"),c=require("rocksolidsocket"),b=require("msgpackrpc"),f=require("amqplib/callback_api"),k=require("msgpack"),i=require("domain"),n=require("util"),l=require("request"),a=require("events").EventEmitter,g=i.create(),g.on("error",function(a){return function(a){return console.log("[QUEUE] Error with queue: "+a)}}(this)),e=function(){function a(a,d){var e,f;this.clientSecret=a,this.beta=d,this.checkRootInChain=q(this.checkRootInChain,this),this.checkSiblings=q(this.checkSiblings,this),this.prove=q(this.prove,this),this._merkleMixer=q(this._merkleMixer,this),this.receiveMissedProofs=q(this.receiveMissedProofs,this),this._handleQueueConsumingForHash=q(this._handleQueueConsumingForHash,this),this._sumSiblings=q(this._sumSiblings,this),this._auth=q(this._auth,this),this._connectRabbit=q(this._connectRabbit,this),this._recursiveConvert=q(this._recursiveConvert,this),this._convertSiblingArray=q(this._convertSiblingArray,this),this.clientId=this._hash("md5",this.clientSecret).substring(0,15),e=this.beta?"api-beta.stampery.com:4000":"api.stampery.com:4000",f=new c(e),this.rpc=new b("stampery.3",f),this._connectRabbit()}return a.prototype.ethSiblings={},a.prototype.authed=!1,a.prototype._convertSiblingArray=function(a){return""===a?[]:a.map(function(a,b){return a.toString()})},a.prototype._recursiveConvert=function(a){return a.map(function(a){return function(b){return b instanceof Buffer?b=b.toString("utf8"):b instanceof Array&&(b=a._recursiveConvert(b)),b}}(this))},a.prototype._connectRabbit=function(){var a,b,c,d;d=p,b=j.findDeferral(arguments),function(d){return function(e){d.beta?!function(e){c=new j.Deferrals(e,{parent:b,filename:"./index.iced",funcname:"Stampery._connectRabbit"}),f.connect("amqp://consumer:9FBln3UxOgwgLZtYvResNXE7@young-squirrel.rmq.cloudamqp.com/beta",c.defer({assign_fn:function(b){return function(){return a=arguments[0],b.rabbit=arguments[1]}}(d),lineno:50})),c._fulfill()}(e):!function(e){c=new j.Deferrals(e,{parent:b,filename:"./index.iced",funcname:"Stampery._connectRabbit"}),f.connect("amqp://consumer:9FBln3UxOgwgLZtYvResNXE7@young-squirrel.rmq.cloudamqp.com/ukgmnhoi",c.defer({assign_fn:function(b){return function(){return a=arguments[0],b.rabbit=arguments[1]}}(d),lineno:52})),c._fulfill()}(e)}}(this)(function(b){return function(){return a?console.log("[QUEUE] Error connecting "+a):(console.log("[QUEUE] Connected to Rabbit!"),b.emit("ready"),g.add(b.rabbit),b.rabbit.on("error",function(a){return b.emit("error",a),b._connectRabbit}))}}(this))},a.prototype._hash=function(a,b){return h.createHash(a).update(b).digest("hex")},a.prototype.hash=function(a,b){var c;return a instanceof m?this._hashFile(a,b):(c=new d.SHA3Hash,c.update(a),b(c.digest("hex").toUpperCase()))},a.prototype._sha3Hash=function(a,b){var c;return c=new d.SHA3Hash,c.update(a),b(c.digest("hex"))},a.prototype._hashFile=function(a,b){var c;return c=new d.SHA3Hash,a.on("end",function(){return b(c.digest("hex"))}),a.on("data",function(a){return c.update(a)})},a.prototype._auth=function(a){var b,c,d,e,f;f=p,d=j.findDeferral(arguments),function(a){return function(f){e=new j.Deferrals(f,{parent:d,filename:"./index.iced",funcname:"Stampery._auth"}),a.rpc.invoke("auth",[a.clientId,a.clientSecret],e.defer({assign_fn:function(){return function(){return b=arguments[0],c=arguments[1]}}(),lineno:86})),e._fulfill()}}(this)(function(d){return function(){return console.log("[RPC] Auth: ",b,c),b?d.emit("error",b):a(!0)}}(this))},a.prototype.calculateProof=function(a,b,c){var d,e,f;e=a;for(d in b)f=b[d],console.log("[SIBLINGS] Calculating sibling "+d,e,f),this._sumSiblings(e,f,function(a){return console.log("[SIBLINGS] Calculated "+a),e=a});return c(e)},a.prototype._sumSiblings=function(a,b,c){var d,e,f,g;g=p,e=j.findDeferral(arguments),parseInt(a,16)>parseInt(b,16)?(console.log("[SIBLINGS] Leaf1 is bigger than Leaf2"),function(c){return function(g){f=new j.Deferrals(g,{parent:e,filename:"./index.iced",funcname:"Stampery._sumSiblings"}),c._sha3Hash(""+a+b,f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:105})),f._fulfill()}}(this)(function(a){return function(){return g(c(d))}}(this))):(console.log("[SIBLINGS] Leaf2 is bigger than Leaf1"),function(c){return function(g){f=new j.Deferrals(g,{parent:e,filename:"./index.iced",funcname:"Stampery._sumSiblings"}),c._sha3Hash(""+b+a,f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:109})),f._fulfill()}}(this)(function(a){return function(){return g(c(d))}}(this)))},a.prototype._handleQueueConsumingForHash=function(a){var b,c,d,e;return e=p,c=j.findDeferral(arguments),this.rabbit?void!function(a){return function(e){d=new j.Deferrals(e,{parent:c,filename:"./index.iced",funcname:"Stampery._handleQueueConsumingForHash"}),a.rabbit.createChannel(d.defer({assign_fn:function(a){return function(){return b=arguments[0],a.channel=arguments[1]}}(a),lineno:114})),d._fulfill()}}(this)(function(c){return function(){return console.log("[QUEUE] Bound to "+a+"-clnt",b),e(c.channel.consume(""+a+"-clnt",function(a){var b,d,e;return console.log("[QUEUE] Received data!"),e=k.unpack(a.content),b=a.fields.routingKey,1===e[3][0]||e[3][0]===-1?(console.log("[QUEUE] Received BTC proof for "+b),e[1]=(c.ethSiblings[b]||[]).concat(e[1]||[])):2!==e[3][0]&&e[3][0]!==-2||(console.log("[QUEUE] Received ETH proof for "+b),c.ethSiblings[b]=c._convertSiblingArray(e[1])),c.channel.ack(a),d=c._recursiveConvert(e),c.emit("proof",b,d)}))}}(this)):e(this.emit("error","Error binding to "+hash+"-clnt"))},a.prototype.stamp=function(a){var b,c,d,e,f;f=p,d=j.findDeferral(arguments),console.log("Stamping "+a),function(a){return function(b){return a.authed?b():void!function(b){e=new j.Deferrals(b,{parent:d,filename:"./index.iced",funcname:"Stampery.stamp"}),a._auth(e.defer({assign_fn:function(a){return function(){return a.authed=arguments[0]}}(a),lineno:141})),e._fulfill()}(b)}}(this)(function(f){return function(){return a=a.toUpperCase(),console.log("Let's stamp "+a),f.rabbit?void function(g){e=new j.Deferrals(g,{parent:d,filename:"./index.iced",funcname:"Stampery.stamp"}),f.rpc.invoke("stamp",[a],e.defer({assign_fn:function(){return function(){return b=arguments[0],c=arguments[1]}}(),lineno:145})),e._fulfill()}(function(){return f.authed?(console.log("[API] Received response: ",c),b?(console.log("[RPC] Error: "+b),f.emit("error",b)):void 0):f.emit("error","Not authenticated")}):setTimeout(f.stamp.bind(f,a),500)}}(this))},a.prototype.receiveMissedProofs=function(){return this._handleQueueConsumingForHash(this.clientId)},a.prototype._merkleMixer=function(a,b,c){var d,e;return b>a&&(e=[b,a],a=e[0],b=e[1]),d=a+b,_sha3Hash(d,c)},a.prototype.prove=function(a,b,c){var d,e,f,g,h;h=p,f=j.findDeferral(arguments),function(c){return function(d){g=new j.Deferrals(d,{parent:f,filename:"./index.iced",funcname:"Stampery.prove"}),c.checkSiblings(a,b[1],b[2],g.defer({assign_fn:function(){return function(){return e=arguments[0]}}(),lineno:162})),g._fulfill()}}(this)(function(a){return function(){!function(c){g=new j.Deferrals(c,{parent:f,filename:"./index.iced",funcname:"Stampery.prove"}),a.checkRootInChain(b[2],b[3][0],b[3][1],g.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:163})),g._fulfill()}(function(){return c(e&&d)})}}(this))},a.prototype.checkDataIntegrity=function(a,b){var c,d,e,f;f=p,d=j.findDeferral(arguments),function(b){return function(f){e=new j.Deferrals(f,{parent:d,filename:"./index.iced",funcname:"Stampery.checkDataIntegrity"}),b.hash(a,e.defer({assign_fn:function(){return function(){return c=arguments[0]}}(),lineno:167})),e._fulfill()}}(this)(function(a){return function(){return a.prove(c,b)}}(this))},a.prototype.checkSiblings=function(a,b,c,d){var e,f,g,h,i;return i=p,g=j.findDeferral(arguments),b.length>0?(e=b[0],f=b.slice(1),function(b){return function(c){h=new j.Deferrals(c,{parent:g,filename:"./index.iced",funcname:"Stampery.checkSiblings"}),b._merkleMixer(a,e,h.defer({assign_fn:function(){return function(){return a=arguments[0]}}(),lineno:174})),h._fulfill()}}(this)(function(b){return function(){return i(d(b.checkSiblings(a,f,c,d)))}}(this)),void 0):i(d(a===c))},a.prototype.checkRootInChain=function(a,b,c,d){var e,f,g,h,i;i=p,g=j.findDeferral(arguments),f=this._getBTCtx,2===b&&(f=this._getETHtx),function(a){return function(a){h=new j.Deferrals(a,{parent:g,filename:"./index.iced",funcname:"Stampery.checkRootInChain"}),f(c,h.defer({assign_fn:function(){return function(){return e=arguments[0]}}(),lineno:183})),h._fulfill()}}(this)(function(b){return function(){return d(e.indexOf(a.toLowerCase())>=0)}}(this))},a.prototype._getBTCtx=function(a,b){return l("https://api.blockcypher.com/v1/btc/main/txs/"+a,function(a,c,d){var e;if(a||!d||!JSON.parse(d).outputs)throw console.error("ERR-",JSON.parse(d)),new Error("BTC explorer error");return e=JSON.parse(d).outputs.find(function(a){return null!=a.data_hex}),b(e.data_hex)})},a.prototype._getETHtx=function(a,b){return l("https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash="+a,function(a,c,d){if(a||!d||!JSON.parse(d).result)throw new Error("ETH explorer error");return b(JSON.parse(d).result.input)})},a}(),n.inherits(e,a),module.exports=e}).call(this); |
{ | ||
"name": "stampery", | ||
"version": "3.1.2", | ||
"version": "3.2.0", | ||
"description": "Stampery API for NodeJS. Notarize all your data using the blockchain", | ||
@@ -22,3 +22,2 @@ "main": "index.js", | ||
"amqplib": "^0.4.1", | ||
"grunt": "^1.0.1", | ||
"iced-runtime": "^1.0.2", | ||
@@ -37,2 +36,3 @@ "msgpack": "^1.0.2", | ||
"devDependencies": { | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-uglify": "^1.0.1", | ||
@@ -39,0 +39,0 @@ "grunt-iced-coffee": "^0.7.0", |
@@ -16,4 +16,5 @@ Stampery | ||
console.log("Received proof for " + hash, proof); | ||
valid = stampery.prove(hash, proof); | ||
console.log('Proof validity:', valid); | ||
stampery.prove(hash, proof, function (valid) { | ||
console.log('Proof validity:', valid); | ||
}); | ||
}); | ||
@@ -20,0 +21,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43797
8
543
102
4
- Removedgrunt@^1.0.1
- Removedabbrev@1.1.1(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedargparse@1.0.10(transitive)
- Removedarray-each@1.0.1(transitive)
- Removedarray-slice@1.1.0(transitive)
- Removedasync@3.2.6(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@3.0.3(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcolors@1.1.2(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddateformat@4.6.3(transitive)
- Removeddetect-file@1.0.0(transitive)
- Removedesprima@4.0.1(transitive)
- Removedeventemitter2@0.4.14(transitive)
- Removedexit@0.1.2(transitive)
- Removedexpand-tilde@2.0.2(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfindup-sync@4.0.05.0.0(transitive)
- Removedfined@1.2.0(transitive)
- Removedflagged-respawn@1.0.1(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@1.0.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedgetobject@1.0.2(transitive)
- Removedglob@7.1.7(transitive)
- Removedglobal-modules@1.0.0(transitive)
- Removedglobal-prefix@1.0.2(transitive)
- Removedgrunt@1.6.1(transitive)
- Removedgrunt-cli@1.4.3(transitive)
- Removedgrunt-known-options@2.0.0(transitive)
- Removedgrunt-legacy-log@3.0.0(transitive)
- Removedgrunt-legacy-log-utils@2.1.0(transitive)
- Removedgrunt-legacy-util@2.0.1(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedhooker@0.2.3(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedini@1.3.8(transitive)
- Removedinterpret@1.1.0(transitive)
- Removedis-absolute@1.0.0(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-relative@1.0.0(transitive)
- Removedis-unc-path@1.0.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisobject@3.0.1(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedliftup@3.0.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmake-iterator@1.0.1(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedminimatch@3.0.8(transitive)
- Removednopt@3.0.64.0.3(transitive)
- Removedobject.defaults@1.1.0(transitive)
- Removedobject.map@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedparse-filepath@1.0.2(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-root@0.1.1(transitive)
- Removedpath-root-regex@0.1.2(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedrechoir@0.7.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-dir@1.0.1(transitive)
- Removedsprintf-js@1.0.31.1.3(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedunc-path-regex@0.1.2(transitive)
- Removedunderscore.string@3.3.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedv8flags@3.2.0(transitive)
- Removedwhich@1.3.12.0.2(transitive)
- Removedwrappy@1.0.2(transitive)