Socket
Socket
Sign inDemoInstall

stampery

Package Overview
Dependencies
73
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.0 to 3.4.1

beta.iced

83

example.js

@@ -1,22 +0,73 @@

Stampery = require('./index.js');
// Generated by IcedCoffeeScript 108.0.11
(function() {
var Stampery, iced, stampery, __iced_k, __iced_k_noop;
stampery = new Stampery('2d4cdee7-38b0-4a66-da87-c1ab05b43768');
iced = require('iced-runtime');
__iced_k = __iced_k_noop = function() {};
stampery.on('proof', function(hash, proof) {
console.log("Received proof for " + hash, proof);
stampery.prove(hash, proof, function (valid) {
console.log('Proof validity:', valid);
Stampery = require('./index');
stampery = new Stampery('user-secret');
stampery.on('proof', function(hash, proof) {
var valid, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
console.log("Received proof for " + hash, proof);
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Desarrollo/Stampery/node/example.iced"
});
stampery.prove(hash, proof, __iced_deferrals.defer({
assign_fn: (function() {
return function() {
return valid = arguments[0];
};
})(),
lineno: 7
}));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return console.log('Proof validity:', valid);
};
})(this));
});
});
stampery.on('error', function(err) {
console.log('woot: ', err);
});
stampery.on('error', function(err) {
return console.log('woot: ', err);
});
stampery.on('ready', function() {
stampery.receiveMissedProofs();
var random = Math.random().toString(36).slice(2)
stampery.hash('The piano has been drinking ' + random, function(hash) {
stampery.stamp(hash);
stampery.on('ready', function() {
var hash, random, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
stampery.receiveMissedProofs();
random = Math.random().toString(36).slice(2);
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Desarrollo/Stampery/node/example.iced"
});
stampery.hash("The piano has been drinking " + random, __iced_deferrals.defer({
assign_fn: (function() {
return function() {
return hash = arguments[0];
};
})(),
lineno: 16
}));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return stampery.stamp(hash);
};
})(this));
});
});
}).call(this);

94

index.js
(function() {
var EventEmitter, MsgpackRPC, RockSolidSocket, SHA3, Stampery, amqp, amqpDomain, crypto, domain, iced, msgpack, request, stream, util, __iced_k, __iced_k_noop,
var EventEmitter, MsgpackRPC, RockSolidSocket, SHA3, Stampery, amqp, amqpDomain, crypto, domain, iced, msgpack, pjson, request, stream, util, __iced_k, __iced_k_noop,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -12,3 +12,3 @@

SHA3 = require('sha3');
SHA3 = require('js-sha3');

@@ -31,2 +31,4 @@ RockSolidSocket = require('rocksolidsocket');

pjson = require('./package.json');
amqpDomain = domain.create();

@@ -53,4 +55,2 @@

this.prove = __bind(this.prove, this);
this._getETHtx = __bind(this._getETHtx, this);
this._getBTCtx = __bind(this._getBTCtx, this);
this._merkleMixer = __bind(this._merkleMixer, this);

@@ -116,3 +116,3 @@ this._handleQueueConsumingForHash = __bind(this._handleQueueConsumingForHash, this);

})(_this),
lineno: 54
lineno: 56
}));

@@ -135,3 +135,3 @@ __iced_deferrals._fulfill();

})(_this),
lineno: 56
lineno: 58
}));

@@ -159,6 +159,3 @@ __iced_deferrals._fulfill();

Stampery.prototype._sha3Hash = function(stringToHash, cb) {
var hash;
hash = new SHA3.SHA3Hash();
hash.update(stringToHash);
return cb(hash.digest('hex'));
return cb(SHA3.sha3_512(stringToHash));
};

@@ -168,5 +165,5 @@

var hash;
hash = new SHA3.SHA3Hash();
hash = new SHA3.sha3_512.create();
fd.on('end', function() {
return cb(hash.digest('hex'));
return cb(hash.hex());
});

@@ -189,3 +186,3 @@ return fd.on('data', function(data) {

});
_this.rpc.invoke('auth', [_this.clientId, _this.clientSecret], __iced_deferrals.defer({
_this.rpc.invoke('auth', [_this.clientId, _this.clientSecret, "nodejs-" + pjson.version], __iced_deferrals.defer({
assign_fn: (function() {

@@ -270,30 +267,4 @@ return function() {

Stampery.prototype._getBTCtx = function(txid, cb) {
return request("https://api.blockcypher.com/v1/btc/main/txs/" + txid, (function(_this) {
return function(err, res, body) {
var tx;
if (err || !body || !JSON.parse(body).outputs) {
_this.emit('error', 'BTC explorer error');
}
tx = JSON.parse(body).outputs.find(function(e) {
return e.data_hex != null;
});
return cb(tx.data_hex);
};
})(this));
};
Stampery.prototype._getETHtx = function(txid, cb) {
return request("https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash=" + txid, (function(_this) {
return function(err, res, body) {
if (err || !body || !JSON.parse(body).result) {
_this.emit('error', 'ETH explorer error');
}
return cb(JSON.parse(body).result.input);
};
})(this));
};
Stampery.prototype.prove = function(hash, proof, cb) {
var rootIsInChain, siblingsAreOK, ___iced_passed_deferral, __iced_deferrals, __iced_k;
var siblingsAreOK, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;

@@ -314,3 +285,3 @@ ___iced_passed_deferral = iced.findDeferral(arguments);

})(),
lineno: 132
lineno: 118
}));

@@ -321,20 +292,3 @@ __iced_deferrals._fulfill();

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: 133
}));
__iced_deferrals._fulfill();
})(function() {
return cb(siblingsAreOK && rootIsInChain);
});
return cb(siblingsAreOK);
};

@@ -361,3 +315,3 @@ })(this));

})(),
lineno: 137
lineno: 122
}));

@@ -374,3 +328,3 @@ __iced_deferrals._fulfill();

})(),
lineno: 138
lineno: 123
}));

@@ -402,3 +356,3 @@ return cb(valid);

})(),
lineno: 145
lineno: 130
}));

@@ -409,2 +363,3 @@ __iced_deferrals._fulfill();

return function() {
console.log('Resulting in', hash);
(function(__iced_k) {

@@ -424,2 +379,4 @@ __iced_deferrals = new iced.Deferrals(__iced_k, {

} else {
console.log('A_Root', hash);
console.log('B_Root', root);
return __iced_k(cb(hash === root));

@@ -450,3 +407,3 @@ }

})(),
lineno: 155
lineno: 143
}));

@@ -486,3 +443,3 @@ __iced_deferrals._fulfill();

})(_this),
lineno: 165
lineno: 153
}));

@@ -515,3 +472,3 @@ __iced_deferrals._fulfill();

})(),
lineno: 169
lineno: 157
}));

@@ -534,9 +491,8 @@ __iced_deferrals._fulfill();

Stampery.prototype.hash = function(data, cb) {
var sha3;
if (data instanceof stream) {
return this._hashFile(data, cb);
} else {
sha3 = new SHA3.SHA3Hash();
sha3.update(data);
return cb(sha3.digest('hex').toUpperCase());
return this._sha3Hash(data, function(hash) {
return cb(hash.toUpperCase());
});
}

@@ -543,0 +499,0 @@ };

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

/*! stampery-node 2016-08-02 */
(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.receiveMissedProofs=q(this.receiveMissedProofs,this),this.checkRootInChain=q(this.checkRootInChain,this),this.checkSiblings=q(this.checkSiblings,this),this.prove=q(this.prove,this),this._getETHtx=q(this._getETHtx,this),this._getBTCtx=q(this._getBTCtx,this),this._merkleMixer=q(this._merkleMixer,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=h.createHash("md5").update(this.clientSecret).digest("hex").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:54})),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:56})),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._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:80})),e._fulfill()}}(this)(function(d){return function(){return console.log("[RPC] Auth: ",b,c),b?d.emit("error",b):a(!0)}}(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:87})),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._merkleMixer=function(a,b,c){var d,e;return b>a&&(e=[b,a],a=e[0],b=e[1]),d=a+b,this._sha3Hash(d,c)},a.prototype._getBTCtx=function(a,b){return l("https://api.blockcypher.com/v1/btc/main/txs/"+a,function(a){return function(c,d,e){var f;return!c&&e&&JSON.parse(e).outputs||a.emit("error","BTC explorer error"),f=JSON.parse(e).outputs.find(function(a){return null!=a.data_hex}),b(f.data_hex)}}(this))},a.prototype._getETHtx=function(a,b){return l("https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash="+a,function(a){return function(c,d,e){return!c&&e&&JSON.parse(e).result||a.emit("error","ETH explorer error"),b(JSON.parse(e).result.input)}}(this))},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:132})),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:133})),g._fulfill()}(function(){return c(e&&d)})}}(this))},a.prototype.checkDataIntegrity=function(a,b,c){var d,e,f,g,h;h=p,f=j.findDeferral(arguments),function(b){return function(c){g=new j.Deferrals(c,{parent:f,filename:"./index.iced",funcname:"Stampery.checkDataIntegrity"}),b.hash(a,g.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:137})),g._fulfill()}}(this)(function(a){return function(){return a.prove(d,b,g.defer({assign_fn:function(){return function(){return e=arguments[0]}}(),lineno:138})),c(e)}}(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:145})),h._fulfill()}}(this)(function(b){return function(){!function(e){h=new j.Deferrals(e,{parent:g,filename:"./index.iced",funcname:"Stampery.checkSiblings"}),b.checkSiblings(a,f,c,function(a){return d(a)}),h._fulfill()}(i)}}(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:155})),h._fulfill()}}(this)(function(b){return function(){return d(e.indexOf(a.toLowerCase())>=0)}}(this))},a.prototype.receiveMissedProofs=function(){return this._handleQueueConsumingForHash(this.clientId)},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:165})),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:169})),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.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}(),n.inherits(e,a),module.exports=e}).call(this);
/*! stampery-node 2016-10-26 */
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=function(a,b){return function(){return a.apply(b,arguments)}};j=require("iced-runtime"),p=q=function(){},h=require("crypto"),n=require("stream"),d=require("js-sha3"),c=require("rocksolidsocket"),b=require("msgpackrpc"),f=require("amqplib/callback_api"),k=require("msgpack"),i=require("domain"),o=require("util"),m=require("request"),a=require("events").EventEmitter,l=require("./package.json"),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.receiveMissedProofs=r(this.receiveMissedProofs,this),this.checkRootInChain=r(this.checkRootInChain,this),this.checkSiblings=r(this.checkSiblings,this),this.prove=r(this.prove,this),this._merkleMixer=r(this._merkleMixer,this),this._handleQueueConsumingForHash=r(this._handleQueueConsumingForHash,this),this._auth=r(this._auth,this),this._connectRabbit=r(this._connectRabbit,this),this._recursiveConvert=r(this._recursiveConvert,this),this._convertSiblingArray=r(this._convertSiblingArray,this),this.clientId=h.createHash("md5").update(this.clientSecret).digest("hex").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=q,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:56})),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:58})),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._sha3Hash=function(a,b){return b(d.sha3_512(a))},a.prototype._hashFile=function(a,b){var c;return c=new d.sha3_512.create,a.on("end",function(){return b(c.hex())}),a.on("data",function(a){return c.update(a)})},a.prototype._auth=function(a){var b,c,d,e,f;f=q,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,"nodejs-"+l.version],e.defer({assign_fn:function(){return function(){return b=arguments[0],c=arguments[1]}}(),lineno:80})),e._fulfill()}}(this)(function(d){return function(){return console.log("[RPC] Auth: ",b,c),b?d.emit("error",b):a(!0)}}(this))},a.prototype._handleQueueConsumingForHash=function(a){var b,c,d,e;return e=q,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:87})),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._merkleMixer=function(a,b,c){var d,e;return b>a&&(e=[b,a],a=e[0],b=e[1]),d=a+b,this._sha3Hash(d,c)},a.prototype.prove=function(a,b,c){var d,e,f,g;g=q,e=j.findDeferral(arguments),function(c){return function(g){f=new j.Deferrals(g,{parent:e,filename:"./index.iced",funcname:"Stampery.prove"}),c.checkSiblings(a,b[1],b[2],f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:118})),f._fulfill()}}(this)(function(a){return function(){return c(d)}}(this))},a.prototype.checkDataIntegrity=function(a,b,c){var d,e,f,g,h;h=q,f=j.findDeferral(arguments),function(b){return function(c){g=new j.Deferrals(c,{parent:f,filename:"./index.iced",funcname:"Stampery.checkDataIntegrity"}),b.hash(a,g.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:122})),g._fulfill()}}(this)(function(a){return function(){return a.prove(d,b,g.defer({assign_fn:function(){return function(){return e=arguments[0]}}(),lineno:123})),c(e)}}(this))},a.prototype.checkSiblings=function(a,b,c,d){var e,f,g,h,i;return i=q,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:130})),h._fulfill()}}(this)(function(b){return function(){console.log("Resulting in",a),function(e){h=new j.Deferrals(e,{parent:g,filename:"./index.iced",funcname:"Stampery.checkSiblings"}),b.checkSiblings(a,f,c,function(a){return d(a)}),h._fulfill()}(i)}}(this)),void 0):(console.log("A_Root",a),console.log("B_Root",c),i(d(a===c)))},a.prototype.checkRootInChain=function(a,b,c,d){var e,f,g,h,i;i=q,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:143})),h._fulfill()}}(this)(function(b){return function(){return d(e.indexOf(a.toLowerCase())>=0)}}(this))},a.prototype.receiveMissedProofs=function(){return this._handleQueueConsumingForHash(this.clientId)},a.prototype.stamp=function(a){var b,c,d,e,f;f=q,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:153})),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:157})),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.hash=function(a,b){return a instanceof n?this._hashFile(a,b):this._sha3Hash(a,function(a){return b(a.toUpperCase())})},a}(),o.inherits(e,a),module.exports=e}).call(this);
{
"name": "stampery",
"version": "3.4.0",
"version": "3.4.1",
"description": "Stampery API for NodeJS. Notarize all your data using the blockchain",

@@ -14,7 +14,10 @@ "main": "index.js",

],
"author": "Luis Iván Cuende <luis@stampery.co>",
"contributors": {
"name": "Adán Sánchez de Pedro Crespo",
"email": "adan@stampery.co"
},
"author": "Luis Iván Cuende",
"contributors": [{
"name": "Adán Sánchez de Pedro",
"email": "adan@stampery.com"
}, {
"name": "Johann Ortiz",
"email": "johann@stampery.com"
}],
"license": "MIT",

@@ -24,2 +27,3 @@ "dependencies": {

"iced-runtime": "^1.0.2",
"js-sha3": "^0.5.5",
"msgpack": "^1.0.2",

@@ -29,4 +33,3 @@ "msgpackrpc": "^1.2.0",

"retry": "^0.8.0",
"rocksolidsocket": "^1.0.0",
"sha3": "^1.2.0"
"rocksolidsocket": "^1.0.0"
},

@@ -33,0 +36,0 @@ "repository": {

@@ -1,12 +0,25 @@

Stampery
=======
# Stampery
[![NPM Package](https://img.shields.io/npm/v/stampery.svg?style=flat-square)](https://www.npmjs.org/package/stampery)
NodeJS client library for [Stampery API](https://stampery.com/api), the blockchain-powered, industrial-scale certification platform.
# Usage
Seamlessly integrate industrial-scale data certification into your own NodeJS apps. The Stampery API adds a layer of transparency, attribution, accountability and auditability to your applications by connecting them to Stampery's infinitely scalable [Blockchain Timestamping Architecture](https://stampery.com/tech).
## Installation
1. Install `stampery` into your project and add it as a dependency in your `package.json`:
npm install --save stampery
2. Go to the [API dashboard](https://api-dashboard.stampery.com), sign up and create a token for your application. It will resemble this:
2f6215c7-ad87-4d6e-bf9e-e9f07aa35f1a
## Usage
```javascript
Stampery = require('stampery');
// Sign up and get your secret token at https://api-dashboard.stampery.com
stampery = new Stampery('yourSecretToken')

@@ -34,2 +47,3 @@

# Sign up and get your secret token at https://api-dashboard.stampery.com
stampery = new Stampery 'yourSecretToken'

@@ -48,56 +62,31 @@

# Intro
## Client libraries for other platforms
- [NodeJS](https://github.com/stampery/node)
- [PHP](https://github.com/stampery/php)
- [Ruby](https://github.com/stampery/ruby)
- [Python](https://github.com/stampery/python)
- [Java](https://github.com/stampery/java)
- [Go](https://github.com/stampery/go)
Stampery replaces **human trust** with **mathematical truth**. To do this, we create **immutable proofs of existence, integrity and attribution** of any data set, using the **Ethereum & Bitcoin blockchains**.
These proofs are:
## Feedback
- Automatically generated
- Impossible to modify, damage or destroy, because they’re embedded in the blockchain
- Valid globally, forever, even if we disappear
To see a quick example of how a proof looks like, here’s one:
[5,"0989551C2CCE109F40BE2C8AD711E23A539445C93547DFC13D25F9E8147886B8D0E71A16FF4DED1CB4BC6AC2E4BBB5722F0996B24F79FC849531FE70BB2DE800",[],[2,"0x5dfd1a08ed51f234be3f7ef13a238e166ec8330895fdc940226cc39866da1a28"]]
**A proof is all you need to verify that a data set has been stamped** at a given point in time.
# Hashing
We are privacy lovers and we don’t go into the content of what’s being stamped. So **our API only takes hashes**. That way, we get out of the data format: no matter if you use JSON, XML or MsgPack, hash it with SHA3–512 and you can use our API.
# Stamping process
Once your hash hits our API, we do our magic, embed your hash into a cryptographic tree, settle that tree with the Ethereum blockchain, then in the Bitcoin blockchain, and finally give you the proof back.
**The Bitcoin blockchain is the most secure one** in terms of reversibility, and that’s great for strong, trustless timestamping, but it takes around ~10mins for a set of transactions to settle.
So we also use the Ethereum blockchain, which is less secure in terms of reversibility (it has less computing power committed to it), but way faster (only 12 seconds to settle), so you can have a **first proof in just seconds**.
Wrapping up: you call our API with your hash, we do our magic and give you the proof back. The first proof is the Ethereum one, the second is Bitcoin’s. Ethereum’s proof is a subset of Bitcoin’s, so in the end, the final proof = 1st proof + 2nd proof.
# TCP + MsgPack + RPC
For the API calls, we use TCP as the transport layer, MsgPack for the encoding of the messages, and RPC as the communication protocol. There are multiple implementations for this, so probably you don’t have to do the work of implementing this yourself. [Check some of them](https://github.com/msgpack-rpc/msgpack-rpc#implementations).
# AMQP
**We use queues as a reliable way of giving your proofs back**. We give you a AMQP server to connect to.
After calling the API with your hash, You will have to **consume**** a queue which name is the hash** you sent: both the Ethereum and Bitcoin proofs will be sent there.
# Implementation details
1. Connect to the API endpoint over TCP and connect to our AMQP server
2. Call the “auth” RPC method, with your “clientId” and your “clientSecret” as the params
3. After you’re authed, just call “stamp” with your hash as a param
4. Then, subscribe to the queue “{yourhash}-clnt”
5. When the final proofs are delivered, that’s it!
<<<<<<< HEAD
Ping us at [support@stampery.com](mailto:support@stampery.com) and we will more than happy to help you! 😃
=======
# Official implementations
- [NodeJS](https://github.com/stampery/node)
- [PHP](https://github.com/stampery/php)
- [ruby](https://github.com/stampery/ruby)
- [Python](https://github.com/stampery/python)
- [Elixir](https://github.com/stampery/elixir)
- [Java](https://github.com/stampery/java)
- [Go](https://github.com/stampery/go)
>>>>>>> b04e57f62f8c9d1235361dbc116eb314e6383ba9
# Verifying a proof
In order to verify a hash has been timestamped, you need both the hash and its proof.
The process is the following:
1. Get the hash, and sum it to the first sibling. While summing, sort them so the first is the lower value and the second the bigger. Hash that sum, and repeat the process with the next siblings. You should get the root
2. With the root, go to the corresponding Ethereum/Bitcoin transaction. The hash in their data field should contain the root you obtained
# Feedback
## License
Ping us at support@stampery.com and we’ll help you! 😃
Code released under
[the MIT license](https://github.com/stampery/node/blob/master/LICENSE).
Copyright 2015-2016 Stampery, Inc.

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc