UNPKG

@machinemode/cryptopia

Version:

Node wrapper for Cryptopia's CLient API

24 lines 907 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var crypto = require('crypto'); var Amx = (function () { function Amx(baseUri, key, secret) { this.baseUri = baseUri; this.key = key; this.secret = secret; } Amx.prototype.makeToken = function (path, params) { var uri = encodeURIComponent("" + this.baseUri + path).toLowerCase(); var nonce = Math.floor(Date.now()); var hashedParams = crypto.createHash('md5') .update(JSON.stringify(params)) .digest('base64'); var signature = crypto.createHmac('sha256', new Buffer(this.secret, 'base64')) .update(this.key + "POST" + uri + nonce + hashedParams) .digest('base64'); return "amx " + this.key + ":" + signature + ":" + nonce; }; return Amx; }()); exports.default = Amx; //# sourceMappingURL=Amx.js.map