Socket
Socket
Sign inDemoInstall

stampery

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stampery - npm Package Compare versions

Comparing version 3.4.3 to 3.5.0

9

example.js

@@ -16,3 +16,3 @@ // Generated by IcedCoffeeScript 108.0.11

___iced_passed_deferral = iced.findDeferral(arguments);
console.log("Received proof for " + hash, proof);
console.log("\nReceived proof for\n" + hash + "\n", JSON.stringify(proof, null, 2));
(function(_this) {

@@ -22,3 +22,3 @@ return (function(__iced_k) {

parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Desarrollo/Stampery/node/example.iced"
filename: "/home/johann/Workspace/Stampery/node/example.iced"
});

@@ -50,3 +50,2 @@ stampery.prove(hash, proof, __iced_deferrals.defer({

___iced_passed_deferral = iced.findDeferral(arguments);
stampery.receiveMissedProofs();
random = Math.random().toString(36).slice(2);

@@ -57,3 +56,3 @@ (function(_this) {

parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Desarrollo/Stampery/node/example.iced"
filename: "/home/johann/Workspace/Stampery/node/example.iced"
});

@@ -66,3 +65,3 @@ stampery.hash("The piano has been drinking " + random, __iced_deferrals.defer({

})(),
lineno: 16
lineno: 15
}));

@@ -69,0 +68,0 @@ __iced_deferrals._fulfill();

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

// Generated by IcedCoffeeScript 108.0.11
(function() {

@@ -46,6 +47,7 @@ var EventEmitter, MsgpackRPC, RockSolidSocket, SHA3, Stampery, amqp, amqpDomain, crypto, domain, iced, msgpack, pjson, request, stream, util, __iced_k, __iced_k_noop,

function Stampery(clientSecret, beta) {
var host, sock;
var host, sock, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
this.clientSecret = clientSecret;
this.beta = beta;
this.receiveMissedProofs = __bind(this.receiveMissedProofs, this);
this.checkRootInChain = __bind(this.checkRootInChain, this);

@@ -55,7 +57,7 @@ this.checkSiblings = __bind(this.checkSiblings, this);

this._merkleMixer = __bind(this._merkleMixer, this);
this._convertSiblingArray = __bind(this._convertSiblingArray, this);
this._processProof = __bind(this._processProof, this);
this._handleQueueConsumingForHash = __bind(this._handleQueueConsumingForHash, this);
this._auth = __bind(this._auth, this);
this._connectRabbit = __bind(this._connectRabbit, this);
this._recursiveConvert = __bind(this._recursiveConvert, this);
this._convertSiblingArray = __bind(this._convertSiblingArray, this);
this.clientId = crypto.createHash('md5').update(this.clientSecret).digest('hex').substring(0, 15);

@@ -69,27 +71,27 @@ if (this.beta) {

this.rpc = new MsgpackRPC('stampery.3', sock);
this._connectRabbit();
}
Stampery.prototype._convertSiblingArray = function(siblings) {
if (siblings === '') {
return [];
} else {
return siblings.map(function(v, i) {
return v.toString();
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery"
});
_this._auth(__iced_deferrals.defer({
assign_fn: (function(__slot_1) {
return function() {
return __slot_1.authed = arguments[0];
};
})(_this),
lineno: 37
}));
__iced_deferrals._fulfill();
});
}
};
Stampery.prototype._recursiveConvert = function(proof) {
return proof.map((function(_this) {
return function(e) {
if (e instanceof Buffer) {
e = e.toString('utf8');
} else if (e instanceof Array) {
e = _this._recursiveConvert(e);
})(this)((function(_this) {
return function() {
if (_this.authed) {
return _this._connectRabbit();
}
return e;
};
})(this));
};
}

@@ -106,3 +108,3 @@ Stampery.prototype._connectRabbit = function() {

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery._connectRabbit"

@@ -117,3 +119,3 @@ });

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

@@ -126,3 +128,3 @@ __iced_deferrals._fulfill();

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery._connectRabbit"

@@ -137,3 +139,3 @@ });

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

@@ -149,9 +151,12 @@ __iced_deferrals._fulfill();

}
console.log('[QUEUE] Connected to Rabbit!');
_this.emit('ready');
amqpDomain.add(_this.rabbit);
return _this.rabbit.on('error', function(err) {
_this.emit('error', err);
return _this._connectRabbit;
});
if (_this.rabbit) {
console.log('[QUEUE] Connected to Rabbit!');
_this.emit('ready');
amqpDomain.add(_this.rabbit);
_this._handleQueueConsumingForHash(_this.clientId);
return _this.rabbit.on('error', function(err) {
_this.emit('error', err);
return _this._connectRabbit;
});
}
};

@@ -161,4 +166,4 @@ })(this));

Stampery.prototype._sha3Hash = function(stringToHash, cb) {
return cb(SHA3.sha3_512(stringToHash));
Stampery.prototype._sha3Hash = function(string, cb) {
return cb(SHA3.sha3_512(string).toUpperCase());
};

@@ -185,3 +190,3 @@

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery._auth"

@@ -196,3 +201,3 @@ });

})(),
lineno: 80
lineno: 69
}));

@@ -203,5 +208,6 @@ __iced_deferrals._fulfill();

return function() {
console.log("[RPC] Auth: ", err, res);
if (err) {
return _this.emit('error', err);
_this.auth = false;
_this.emit('error', "Couldn't authenticate");
process.exit();
}

@@ -217,44 +223,58 @@ return cb(true);

___iced_passed_deferral = iced.findDeferral(arguments);
if (this.rabbit) {
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "./index.iced",
funcname: "Stampery._handleQueueConsumingForHash"
});
_this.rabbit.createChannel(__iced_deferrals.defer({
assign_fn: (function(__slot_1) {
return function() {
err = arguments[0];
return __slot_1.channel = arguments[1];
};
})(_this),
lineno: 87
}));
__iced_deferrals._fulfill();
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery._handleQueueConsumingForHash"
});
})(this)((function(_this) {
return function() {
console.log("[QUEUE] Bound to " + queue + "-clnt", err);
return __iced_k(_this.channel.consume("" + queue + "-clnt", function(queueMsg) {
_this.rabbit.createChannel(__iced_deferrals.defer({
assign_fn: (function(__slot_1) {
return function() {
err = arguments[0];
return __slot_1.channel = arguments[1];
};
})(_this),
lineno: 77
}));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
if (!err) {
return _this.channel.consume("" + queue + "-clnt", function(queueMsg) {
var hash, niceProof, unpackedMsg;
console.log("[QUEUE] Received data!");
unpackedMsg = msgpack.unpack(queueMsg.content);
hash = queueMsg.fields.routingKey;
if (unpackedMsg[3][0] === 1 || unpackedMsg[3][0] === -1) {
console.log('[QUEUE] Received BTC proof for ' + hash);
unpackedMsg[1] = (_this.ethSiblings[hash] || []).concat(unpackedMsg[1] || []);
} else if (unpackedMsg[3][0] === 2 || unpackedMsg[3][0] === -2) {
console.log('[QUEUE] Received ETH proof for ' + hash);
_this.ethSiblings[hash] = _this._convertSiblingArray(unpackedMsg[1]);
}
_this.channel.ack(queueMsg);
niceProof = _this._recursiveConvert(unpackedMsg);
niceProof = _this._processProof(hash, unpackedMsg);
return _this.emit('proof', hash, niceProof);
}));
};
})(this));
});
} else {
return _this.emit('error', "Error " + err);
}
};
})(this));
};
Stampery.prototype._processProof = function(hash, raw_proof) {
return {
'hash': hash,
'version': raw_proof[0],
'siblings': this._convertSiblingArray(raw_proof[1]),
'root': raw_proof[2].toString('utf8'),
'anchor': {
'chain': raw_proof[3][0],
'tx': raw_proof[3][1].toString('utf8')
}
};
};
Stampery.prototype._convertSiblingArray = function(siblings) {
if (siblings === '') {
return [];
} else {
return __iced_k(this.emit('error', "Error binding to " + hash + "-clnt"));
return siblings.map(function(v, i) {
return v.toString();
});
}

@@ -264,8 +284,6 @@ };

Stampery.prototype._merkleMixer = function(a, b, cb) {
var data, _ref;
if (b > a) {
_ref = [b, a], a = _ref[0], b = _ref[1];
}
data = a + b;
return this._sha3Hash(data, cb);
var buffer, commuted;
commuted = a > b ? a + b : b + a;
buffer = new Buffer(commuted, 'hex');
return this._sha3Hash(buffer, cb);
};

@@ -281,6 +299,6 @@

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery.prove"
});
_this.checkSiblings(hash, proof[1], proof[2], __iced_deferrals.defer({
_this.checkSiblings(hash, proof.siblings, proof.root, __iced_deferrals.defer({
assign_fn: (function() {

@@ -291,3 +309,3 @@ return function() {

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

@@ -311,3 +329,3 @@ __iced_deferrals._fulfill();

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery.checkDataIntegrity"

@@ -321,3 +339,3 @@ });

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

@@ -334,3 +352,3 @@ __iced_deferrals._fulfill();

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

@@ -353,3 +371,3 @@ return cb(valid);

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery.checkSiblings"

@@ -363,3 +381,3 @@ });

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

@@ -370,12 +388,9 @@ __iced_deferrals._fulfill();

return function() {
console.log('Resulting in', hash);
(function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery.checkSiblings"
});
_this.checkSiblings(hash, tail, root, function(res) {
return cb(res);
});
_this.checkSiblings(hash, tail, root, cb);
__iced_deferrals._fulfill();

@@ -386,4 +401,2 @@ })(__iced_k);

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

@@ -405,3 +418,3 @@ }

parent: ___iced_passed_deferral,
filename: "./index.iced",
filename: "/home/adansdpc/Stampery/Desarrollo/client-libraries/node/index.iced",
funcname: "Stampery.checkRootInChain"

@@ -415,3 +428,3 @@ });

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

@@ -427,67 +440,11 @@ __iced_deferrals._fulfill();

Stampery.prototype.receiveMissedProofs = function() {
return this._handleQueueConsumingForHash(this.clientId);
};
Stampery.prototype.stamp = function(hash) {
var err, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
console.log("Stamping " + hash);
(function(_this) {
return (function(__iced_k) {
if (!_this.authed) {
(function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "./index.iced",
funcname: "Stampery.stamp"
});
_this._auth(__iced_deferrals.defer({
assign_fn: (function(__slot_1) {
return function() {
return __slot_1.authed = arguments[0];
};
})(_this),
lineno: 153
}));
__iced_deferrals._fulfill();
})(__iced_k);
} else {
return __iced_k();
console.log("\nStamping \n" + hash);
hash = hash.toUpperCase();
return this.rpc.invoke('stamp', [hash], (function(_this) {
return function(err, res) {
if (err) {
console.log("[RPC] Error: " + err);
return _this.emit('error', err);
}
});
})(this)((function(_this) {
return function() {
hash = hash.toUpperCase();
console.log("Let's stamp " + hash);
if (!_this.rabbit) {
return setTimeout(_this.stamp.bind(_this, hash), 500);
}
(function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "./index.iced",
funcname: "Stampery.stamp"
});
_this.rpc.invoke('stamp', [hash], __iced_deferrals.defer({
assign_fn: (function() {
return function() {
err = arguments[0];
return res = arguments[1];
};
})(),
lineno: 157
}));
__iced_deferrals._fulfill();
})(function() {
if (!_this.authed) {
return _this.emit('error', 'Not authenticated');
}
console.log("[API] Received response: ", res);
if (err) {
console.log("[RPC] Error: " + err);
return _this.emit('error', err);
}
});
};

@@ -494,0 +451,0 @@ })(this));

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

/*! 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);
/*! stampery-node 2016-10-27 */
(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,g,i,k;k=q,g=j.findDeferral(arguments),this.clientSecret=a,this.beta=d,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._convertSiblingArray=r(this._convertSiblingArray,this),this._processProof=r(this._processProof,this),this._handleQueueConsumingForHash=r(this._handleQueueConsumingForHash,this),this._auth=r(this._auth,this),this._connectRabbit=r(this._connectRabbit,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),function(a){return function(b){i=new j.Deferrals(b,{parent:g,filename:"./index.iced",funcname:"Stampery"}),a._auth(i.defer({assign_fn:function(a){return function(){return a.authed=arguments[0]}}(a),lineno:37})),i._fulfill()}}(this)(function(a){return function(){if(a.authed)return a._connectRabbit()}}(this))}return a.prototype.ethSiblings={},a.prototype.authed=!1,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:43})),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:45})),c._fulfill()}(e)}}(this)(function(b){return function(){return a?console.log("[QUEUE] Error connecting "+a):b.rabbit?(console.log("[QUEUE] Connected to Rabbit!"),b.emit("ready"),g.add(b.rabbit),b._handleQueueConsumingForHash(b.clientId),b.rabbit.on("error",function(a){return b.emit("error",a),b._connectRabbit})):void 0}}(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:69})),e._fulfill()}}(this)(function(c){return function(){return b&&(c.auth=!1,c.emit("error","Couldn't authenticate"),process.exit()),a(!0)}}(this))},a.prototype._handleQueueConsumingForHash=function(a){var b,c,d,e;e=q,c=j.findDeferral(arguments),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:77})),d._fulfill()}}(this)(function(c){return function(){return b?c.emit("error","Error "+b):c.channel.consume(""+a+"-clnt",function(a){var b,d,e;return e=k.unpack(a.content),b=a.fields.routingKey,c.channel.ack(a),d=c._processProof(e),c.emit("proof",b,d)})}}(this))},a.prototype._processProof=function(a){return{version:a[0],siblings:this._convertSiblingArray(a[1]),root:a[2].toString("utf8"),anchor:{chain:a[3][0],tx:a[3][1].toString("utf8")}}},a.prototype._convertSiblingArray=function(a){return""===a?[]:a.map(function(a,b){return a.toString()})},a.prototype._merkleMixer=function(a,b,c){var d,e;return a>b&&(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.siblings,b.root,f.defer({assign_fn:function(){return function(){return d=arguments[0]}}(),lineno:117})),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:121})),g._fulfill()}}(this)(function(a){return function(){return a.prove(d,b,g.defer({assign_fn:function(){return function(){return e=arguments[0]}}(),lineno:122})),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:129})),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=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:139})),h._fulfill()}}(this)(function(b){return function(){return d(e.indexOf(a.toLowerCase())>=0)}}(this))},a.prototype.stamp=function(a){return console.log("\nStamping \n"+a),a=a.toUpperCase(),this.rpc.invoke("stamp",[a],function(a){return function(b,c){if(b)return console.log("[RPC] Error: "+b),a.emit("error",b)}}(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.3",
"version": "3.5.0",
"description": "Stampery API for NodeJS. Notarize all your data using the blockchain",

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

@@ -13,7 +13,11 @@ # Stampery

npm install --save stampery
```
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
```
2f6215c7-ad87-4d6e-bf9e-e9f07aa35f1a
```

@@ -26,3 +30,4 @@ ## Usage

// Sign up and get your secret token at https://api-dashboard.stampery.com
stampery = new Stampery('yourSecretToken')
// Please use 'beta' for testing and 'prod' for production
stampery = new Stampery('yourSecretToken', 'prod')

@@ -50,3 +55,4 @@ stampery.on('proof', function(hash, proof) {

# Sign up and get your secret token at https://api-dashboard.stampery.com
stampery = new Stampery 'yourSecretToken'
# Please use 'beta' for testing and 'prod' for production
stampery = new Stampery 'your-secret-token', 'prod'

@@ -76,16 +82,6 @@ stampery.on 'proof', (hash, proof) ->

## 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)
## License
Code released under
[the MIT license](https://github.com/stampery/node/blob/master/LICENSE).
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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc