New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vostokplatform/signature-generator

Package Overview
Dependencies
Maintainers
12
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vostokplatform/signature-generator - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2-NM

815

dist/byteProcessor/ByteProcessor.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -24,47 +11,13 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var data_entities_1 = require("@waves/data-entities");
var base64_js_1 = require("base64-js");
var base58_1 = require("../libs/base58");
var convert_1 = require("../utils/convert");
var concat_1 = require("../utils/concat");
var constants_1 = require("../constants");
var __1 = require("..");
var constants_2 = require("../constants");
var constants_3 = require("../constants");
var converters_1 = require("../libs/converters");
const data_entities_1 = require("@waves/data-entities");
const base64_js_1 = require("base64-js");
const base58_1 = require("../libs/base58");
const convert_1 = require("../utils/convert");
const concat_1 = require("../utils/concat");
const constants_1 = require("../constants");
const __1 = require("..");
const constants_2 = require("../constants");
const constants_3 = require("../constants");
const converters_1 = require("../libs/converters");
// NOTE : Waves asset ID in blockchain transactions equals to an empty string

@@ -77,15 +30,15 @@ function blockchainifyAssetId(assetId) {

function getAliasBytes(alias) {
var aliasBytes = convert_1.default.stringToByteArrayWithSize(alias);
return __spreadArrays([constants_2.ALIAS_VERSION, __1.config.getNetworkByte()], aliasBytes);
const aliasBytes = convert_1.default.stringToByteArrayWithSize(alias);
return [constants_2.ALIAS_VERSION, __1.config.getNetworkByte(), ...aliasBytes];
}
// ABSTRACT PARENT
var ByteProcessor = /** @class */ (function () {
function ByteProcessor(required) {
class ByteProcessor {
constructor(required) {
this.required = required;
this.allowNull = false;
}
ByteProcessor.prototype.getValidationError = function (val) {
getValidationError(val) {
return null;
};
ByteProcessor.prototype.getError = function (val) {
}
getError(val) {
if (this.required && typeof val === 'undefined') {

@@ -98,91 +51,77 @@ return 'field is required';

return this.getValidationError(val);
};
ByteProcessor.prototype.isValid = function (val) {
}
isValid(val) {
return !this.getError(val);
};
return ByteProcessor;
}());
}
}
exports.ByteProcessor = ByteProcessor;
// BASIC
var TxType = /** @class */ (function (_super) {
__extends(TxType, _super);
function TxType(required, type) {
var _this = _super.call(this, required) || this;
_this.type = type;
return _this;
class TxType extends ByteProcessor {
constructor(required, type) {
super(required);
this.type = type;
}
TxType.prototype.getBytes = function (val) {
getBytes(val) {
return Promise.resolve(Uint8Array.from([this.type]));
};
return TxType;
}(ByteProcessor));
}
}
exports.TxType = TxType;
var TxVersion = /** @class */ (function (_super) {
__extends(TxVersion, _super);
function TxVersion(required, version) {
var _this = _super.call(this, required) || this;
_this.version = version;
return _this;
class TxVersion extends ByteProcessor {
constructor(required, version) {
super(required);
this.version = version;
}
TxVersion.prototype.getBytes = function (val) {
getBytes(val) {
return Promise.resolve(Uint8Array.from([this.version]));
};
return TxVersion;
}(ByteProcessor));
}
}
exports.TxVersion = TxVersion;
// SIMPLE
var Base58 = /** @class */ (function (_super) {
__extends(Base58, _super);
function Base58(required, limit) {
var _this = _super.call(this, required) || this;
class Base58 extends ByteProcessor {
constructor(required, limit) {
super(required);
if (limit) {
_this.limit = limit;
this.limit = limit;
}
return _this;
}
Base58.prototype.getValidationError = function (value) {
var bytes = base58_1.default.decode(value);
getValidationError(value) {
const bytes = base58_1.default.decode(value);
if (this.limit && bytes.length > this.limit) {
return "Maximum length is exceeded: " + this.limit;
return `Maximum length is exceeded: ${this.limit}`;
}
return null;
};
Base58.prototype.getBytes = function (value) {
var bytes = base58_1.default.decode(value);
}
getBytes(value) {
const bytes = base58_1.default.decode(value);
return Promise.resolve(bytes);
};
return Base58;
}(ByteProcessor));
}
}
exports.Base58 = Base58;
var Base58WithLength = /** @class */ (function (_super) {
__extends(Base58WithLength, _super);
function Base58WithLength(required, limit) {
var _this = _super.call(this, required) || this;
class Base58WithLength extends ByteProcessor {
constructor(required, limit) {
super(required);
if (limit) {
_this.limit = limit;
this.limit = limit;
}
return _this;
}
Base58WithLength.prototype.getValidationError = function (value) {
var bytes = base58_1.default.decode(value);
getValidationError(value) {
const bytes = base58_1.default.decode(value);
if (this.limit && bytes.length > this.limit) {
return "Maximum length is exceeded: " + this.limit;
return `Maximum length is exceeded: ${this.limit}`;
}
return null;
};
Base58WithLength.prototype.getBytes = function (value) {
var bytes = Array.from(base58_1.default.decode(value));
var lengthBytes = converters_1.default.int16ToBytes(bytes.length, true);
var result = Uint8Array.from(__spreadArrays(lengthBytes, bytes));
}
getBytes(value) {
const bytes = Array.from(base58_1.default.decode(value));
const lengthBytes = converters_1.default.int16ToBytes(bytes.length, true);
const result = Uint8Array.from([...lengthBytes, ...bytes]);
return Promise.resolve(result);
};
return Base58WithLength;
}(ByteProcessor));
}
}
exports.Base58WithLength = Base58WithLength;
var Base64 = /** @class */ (function (_super) {
__extends(Base64, _super);
function Base64(required) {
return _super.call(this, required) || this;
class Base64 extends ByteProcessor {
constructor(required) {
super(required);
}
Base64.prototype.getValidationError = function (val) {
getValidationError(val) {
if (typeof val !== 'string')

@@ -193,8 +132,7 @@ return 'You should pass a string to BinaryDataEntry constructor';

return null;
};
Base64.prototype.getBytes = function (value, byteLength) {
if (byteLength === void 0) { byteLength = 2; }
var b64 = value.slice(7); // Getting the string payload
var bytes = Uint8Array.from(base64_js_1.toByteArray(b64));
var lengthBytes;
}
getBytes(value, byteLength = 2) {
const b64 = value.slice(7); // Getting the string payload
const bytes = Uint8Array.from(base64_js_1.toByteArray(b64));
let lengthBytes;
if (byteLength === 4) {

@@ -208,24 +146,20 @@ lengthBytes = Uint8Array.from(converters_1.default.int32ToBytes(bytes.length, true));

return Promise.resolve(concat_1.concatUint8Arrays(lengthBytes, bytes));
};
return Base64;
}(ByteProcessor));
}
}
exports.Base64 = Base64;
var Bool = /** @class */ (function (_super) {
__extends(Bool, _super);
function Bool(required) {
return _super.call(this, required) || this;
class Bool extends ByteProcessor {
constructor(required) {
super(required);
}
Bool.prototype.getBytes = function (value) {
var bytes = convert_1.default.booleanToBytes(value);
getBytes(value) {
const bytes = convert_1.default.booleanToBytes(value);
return Promise.resolve(Uint8Array.from(bytes));
};
return Bool;
}(ByteProcessor));
}
}
exports.Bool = Bool;
var Byte = /** @class */ (function (_super) {
__extends(Byte, _super);
function Byte(required) {
return _super.call(this, required) || this;
class Byte extends ByteProcessor {
constructor(required) {
super(required);
}
Byte.prototype.getValidationError = function (val) {
getValidationError(val) {
if (typeof val !== 'number')

@@ -236,26 +170,22 @@ return 'You should pass a number to Byte constructor';

return null;
};
Byte.prototype.getBytes = function (value) {
}
getBytes(value) {
return Promise.resolve(Uint8Array.from([value]));
};
return Byte;
}(ByteProcessor));
}
}
exports.Byte = Byte;
var Long = /** @class */ (function (_super) {
__extends(Long, _super);
function Long(required) {
return _super.call(this, required) || this;
class Long extends ByteProcessor {
constructor(required) {
super(required);
}
Long.prototype.getBytes = function (value) {
getBytes(value) {
return Promise.resolve(Uint8Array.from(convert_1.default.bigNumberToByteArray(new data_entities_1.BigNumber(value))));
};
return Long;
}(ByteProcessor));
}
}
exports.Long = Long;
var Short = /** @class */ (function (_super) {
__extends(Short, _super);
function Short(required) {
return _super.call(this, required) || this;
class Short extends ByteProcessor {
constructor(required) {
super(required);
}
Short.prototype.getValidationError = function (val) {
getValidationError(val) {
if (typeof val !== 'number')

@@ -266,15 +196,13 @@ return 'You should pass a number to Short constructor';

return null;
};
Short.prototype.getBytes = function (value) {
}
getBytes(value) {
return Promise.resolve(Uint8Array.from(convert_1.default.shortToByteArray(value)));
};
return Short;
}(ByteProcessor));
}
}
exports.Short = Short;
var Integer = /** @class */ (function (_super) {
__extends(Integer, _super);
function Integer(required) {
return _super.call(this, required) || this;
class Integer extends ByteProcessor {
constructor(required) {
super(required);
}
Integer.prototype.getValidationError = function (value) {
getValidationError(value) {
if (typeof value !== 'number')

@@ -285,19 +213,16 @@ return 'You should pass a number to Integer constructor';

return null;
};
Integer.prototype.getBytes = function (value) {
}
getBytes(value) {
return Promise.resolve(Uint8Array.from(convert_1.default.IntToByteArray(value)));
};
return Integer;
}(ByteProcessor));
}
}
exports.Integer = Integer;
var ByteArrayWithSize = /** @class */ (function (_super) {
__extends(ByteArrayWithSize, _super);
function ByteArrayWithSize(required, limit) {
var _this = _super.call(this, required) || this;
class ByteArrayWithSize extends ByteProcessor {
constructor(required, limit) {
super(required);
if (limit) {
_this.limit = limit;
this.limit = limit;
}
return _this;
}
ByteArrayWithSize.prototype.getValidationError = function (value) {
getValidationError(value) {
if (typeof value === 'string') {

@@ -307,35 +232,30 @@ value = Uint8Array.from(convert_1.default.stringToByteArray(value));

if (this.limit && value.length > this.limit) {
return "Maximum length is exceeded: " + this.limit;
return `Maximum length is exceeded: ${this.limit}`;
}
return null;
};
ByteArrayWithSize.prototype.getBytes = function (value) {
}
getBytes(value) {
if (typeof value === 'string') {
value = Uint8Array.from(convert_1.default.stringToByteArray(value));
}
var valueWithLength = convert_1.default.bytesToByteArrayWithSize(value);
const valueWithLength = convert_1.default.bytesToByteArrayWithSize(value);
return Promise.resolve(Uint8Array.from(valueWithLength));
};
return ByteArrayWithSize;
}(ByteProcessor));
}
}
exports.ByteArrayWithSize = ByteArrayWithSize;
var StringWithLength = /** @class */ (function (_super) {
__extends(StringWithLength, _super);
function StringWithLength(required) {
return _super.call(this, required) || this;
class StringWithLength extends ByteProcessor {
constructor(required) {
super(required);
}
StringWithLength.prototype.getBytes = function (value, byteLength) {
if (byteLength === void 0) { byteLength = 2; }
var bytesWithLength = convert_1.default.stringToByteArrayWithSize(value, byteLength);
getBytes(value, byteLength = 2) {
const bytesWithLength = convert_1.default.stringToByteArrayWithSize(value, byteLength);
return Promise.resolve(Uint8Array.from(bytesWithLength));
};
return StringWithLength;
}(ByteProcessor));
}
}
exports.StringWithLength = StringWithLength;
var Attachment = /** @class */ (function (_super) {
__extends(Attachment, _super);
function Attachment(required) {
return _super.call(this, required) || this;
class Attachment extends ByteProcessor {
constructor(required) {
super(required);
}
Attachment.prototype.getValidationError = function (value) {
getValidationError(value) {
if (typeof value === 'string') {

@@ -348,57 +268,49 @@ value = Uint8Array.from(convert_1.default.stringToByteArray(value));

return null;
};
Attachment.prototype.getBytes = function (value) {
}
getBytes(value) {
if (typeof value === 'string') {
value = Uint8Array.from(convert_1.default.stringToByteArray(value));
}
var valueWithLength = convert_1.default.bytesToByteArrayWithSize(value);
const valueWithLength = convert_1.default.bytesToByteArrayWithSize(value);
return Promise.resolve(Uint8Array.from(valueWithLength));
};
return Attachment;
}(ByteProcessor));
}
}
exports.Attachment = Attachment;
// COMPLEX
var Alias = /** @class */ (function (_super) {
__extends(Alias, _super);
function Alias(required) {
return _super.call(this, required) || this;
class Alias extends ByteProcessor {
constructor(required) {
super(required);
}
Alias.prototype.getBytes = function (value) {
var aliasBytes = getAliasBytes(value);
var aliasBytesWithLength = convert_1.default.bytesToByteArrayWithSize(aliasBytes);
getBytes(value) {
const aliasBytes = getAliasBytes(value);
const aliasBytesWithLength = convert_1.default.bytesToByteArrayWithSize(aliasBytes);
return Promise.resolve(Uint8Array.from(aliasBytesWithLength));
};
return Alias;
}(ByteProcessor));
}
}
exports.Alias = Alias;
var AssetId = /** @class */ (function (_super) {
__extends(AssetId, _super);
function AssetId(required) {
return _super.call(this, required) || this;
class AssetId extends ByteProcessor {
constructor(required) {
super(required);
}
AssetId.prototype.getBytes = function (value) {
getBytes(value) {
value = blockchainifyAssetId(value);
return Promise.resolve(base58_1.default.decode(value));
};
return AssetId;
}(ByteProcessor));
}
}
exports.AssetId = AssetId;
var MandatoryAssetId = /** @class */ (function (_super) {
__extends(MandatoryAssetId, _super);
function MandatoryAssetId(required) {
return _super.call(this, required) || this;
class MandatoryAssetId extends ByteProcessor {
constructor(required) {
super(required);
}
MandatoryAssetId.prototype.getBytes = function (value) {
getBytes(value) {
value = blockchainifyAssetId(value);
return Promise.resolve(base58_1.default.decode(value));
};
return MandatoryAssetId;
}(ByteProcessor));
}
}
exports.MandatoryAssetId = MandatoryAssetId;
var OrderType = /** @class */ (function (_super) {
__extends(OrderType, _super);
function OrderType(required) {
return _super.call(this, required) || this;
class OrderType extends ByteProcessor {
constructor(required) {
super(required);
}
OrderType.prototype.getValidationError = function (value) {
getValidationError(value) {
if (value !== 'buy' && value !== 'sell') {

@@ -408,4 +320,4 @@ return 'There are no other order types besides "buy" and "sell"';

return null;
};
OrderType.prototype.getBytes = function (value) {
}
getBytes(value) {
if (value === 'buy') {

@@ -417,66 +329,58 @@ return Bool.prototype.getBytes.call(this, false);

}
};
return OrderType;
}(ByteProcessor));
}
}
exports.OrderType = OrderType;
var Recipient = /** @class */ (function (_super) {
__extends(Recipient, _super);
function Recipient(required) {
return _super.call(this, required) || this;
class Recipient extends ByteProcessor {
constructor(required) {
super(required);
}
Recipient.prototype.getBytes = function (value) {
getBytes(value) {
if (/alias:.:/i.test(value)) {
var aliasBytes = getAliasBytes(value.split(':').pop());
const aliasBytes = getAliasBytes(value.split(':').pop());
return Promise.resolve(Uint8Array.from(aliasBytes));
}
else {
var addressBytes = base58_1.default.decode(value);
const addressBytes = base58_1.default.decode(value);
return Promise.resolve(Uint8Array.from(addressBytes));
}
};
return Recipient;
}(ByteProcessor));
}
}
exports.Recipient = Recipient;
var Transfers = /** @class */ (function (_super) {
__extends(Transfers, _super);
function Transfers(required) {
return _super.call(this, required) || this;
class Transfers extends ByteProcessor {
constructor(required) {
super(required);
}
Transfers.prototype.getBytes = function (values) {
var recipientProcessor = new Recipient(true);
var amountProcessor = new Long(true);
var promises = [];
for (var i = 0; i < values.length; i++) {
getBytes(values) {
const recipientProcessor = new Recipient(true);
const amountProcessor = new Long(true);
const promises = [];
for (let i = 0; i < values.length; i++) {
promises.push(recipientProcessor.getBytes(values[i].recipient));
promises.push(amountProcessor.getBytes(values[i].amount));
}
return Promise.all(promises).then(function (elements) {
var length = convert_1.default.shortToByteArray(values.length);
var lengthBytes = Uint8Array.from(length);
return concat_1.concatUint8Arrays.apply(void 0, __spreadArrays([lengthBytes], elements));
return Promise.all(promises).then((elements) => {
const length = convert_1.default.shortToByteArray(values.length);
const lengthBytes = Uint8Array.from(length);
return concat_1.concatUint8Arrays(lengthBytes, ...elements);
});
};
return Transfers;
}(ByteProcessor));
}
}
exports.Transfers = Transfers;
// PERMISSIONS
var PermissionTarget = /** @class */ (function (_super) {
__extends(PermissionTarget, _super);
function PermissionTarget(required) {
return _super.call(this, required) || this;
class PermissionTarget extends ByteProcessor {
constructor(required) {
super(required);
}
PermissionTarget.prototype.getBytes = function (value) {
var addressBytes = base58_1.default.decode(value);
getBytes(value) {
const addressBytes = base58_1.default.decode(value);
return Promise.resolve(Uint8Array.from(addressBytes));
};
return PermissionTarget;
}(ByteProcessor));
}
}
exports.PermissionTarget = PermissionTarget;
// opType: "a" or "r" (byte)
var PermissionOpType = /** @class */ (function (_super) {
__extends(PermissionOpType, _super);
function PermissionOpType(required) {
return _super.call(this, required) || this;
class PermissionOpType extends ByteProcessor {
constructor(required) {
super(required);
}
PermissionOpType.prototype.getValidationError = function (value) {
getValidationError(value) {
if (value === "add" /* ADD */ || value === "remove" /* REMOVE */) {

@@ -486,7 +390,7 @@ return null;

else {
return "Unknown permission operation type: " + value;
return `Unknown permission operation type: ${value}`;
}
};
PermissionOpType.prototype.getBytes = function (value) {
var opByte;
}
getBytes(value) {
let opByte;
if (value === "add" /* ADD */) {

@@ -499,44 +403,39 @@ opByte = constants_3.PERMISSION_TRANSACTION_OPERATION_TYPE_BYTE.ADD;

return Promise.resolve(Uint8Array.from([opByte]));
};
return PermissionOpType;
}(ByteProcessor));
}
}
exports.PermissionOpType = PermissionOpType;
// role: 1-6 (byte)
var PermissionRole = /** @class */ (function (_super) {
__extends(PermissionRole, _super);
function PermissionRole(required) {
return _super.call(this, required) || this;
class PermissionRole extends ByteProcessor {
constructor(required) {
super(required);
}
PermissionRole.prototype.getValidationError = function (value) {
var roleKey = Object.keys(constants_3.PERMISSION_TRANSACTION_ROLE)
.find(function (k) { return constants_3.PERMISSION_TRANSACTION_ROLE[k] === value; });
getValidationError(value) {
const roleKey = Object.keys(constants_3.PERMISSION_TRANSACTION_ROLE)
.find(k => constants_3.PERMISSION_TRANSACTION_ROLE[k] === value);
if (!roleKey) {
return "Permission role " + value + " not found";
return `Permission role ${value} not found`;
}
return null;
};
PermissionRole.prototype.getBytes = function (value) {
var roleKey = Object.keys(constants_3.PERMISSION_TRANSACTION_ROLE)
.find(function (k) { return constants_3.PERMISSION_TRANSACTION_ROLE[k] === value; });
var roleByte = constants_3.PERMISSION_TRANSACTION_ROLE_BYTE[roleKey];
}
getBytes(value) {
const roleKey = Object.keys(constants_3.PERMISSION_TRANSACTION_ROLE)
.find(k => constants_3.PERMISSION_TRANSACTION_ROLE[k] === value);
const roleByte = constants_3.PERMISSION_TRANSACTION_ROLE_BYTE[roleKey];
return Promise.resolve(Uint8Array.from([roleByte]));
};
return PermissionRole;
}(ByteProcessor));
}
}
exports.PermissionRole = PermissionRole;
// dueTimestamp: 0 + 0 * sizeOfLong | 1 + dueTimestamp.toBytes
var PermissionDueTimestamp = /** @class */ (function (_super) {
__extends(PermissionDueTimestamp, _super);
function PermissionDueTimestamp(required) {
var _this = _super.call(this, required) || this;
_this.allowNull = true;
return _this;
class PermissionDueTimestamp extends ByteProcessor {
constructor(required) {
super(required);
this.allowNull = true;
}
PermissionDueTimestamp.prototype.getBytes = function (value) {
getBytes(value) {
// no due timestamp specified
if (!+value || isNaN(+value)) {
var emptyDueTimestamp = Uint8Array.from(new Array(9).fill(0));
const emptyDueTimestamp = Uint8Array.from(new Array(9).fill(0));
return Promise.resolve(emptyDueTimestamp);
}
var bytes;
let bytes;
if (typeof value === 'number') {

@@ -551,13 +450,11 @@ bytes = convert_1.default.longToByteArray(value);

}
return Promise.resolve(Uint8Array.from(__spreadArrays([1], bytes)));
};
return PermissionDueTimestamp;
}(ByteProcessor));
return Promise.resolve(Uint8Array.from([1, ...bytes]));
}
}
exports.PermissionDueTimestamp = PermissionDueTimestamp;
var PermissionOptions = /** @class */ (function (_super) {
__extends(PermissionOptions, _super);
function PermissionOptions(required) {
return _super.call(this, required) || this;
class PermissionOptions extends ByteProcessor {
constructor(required) {
super(required);
}
PermissionOptions.prototype.getValidationError = function (value) {
getValidationError(value) {
return (new PermissionOpType(true)).getValidationError(value.opType)

@@ -567,125 +464,103 @@ || (new PermissionRole(true)).getValidationError(value.role)

|| (new Long(true)).getValidationError(value.timestamp);
};
PermissionOptions.prototype.getBytes = function (value) {
return __awaiter(this, void 0, void 0, function () {
var multipleDataBytes;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all([
(new PermissionOpType(true)).getBytes(value.opType),
(new PermissionRole(true)).getBytes(value.role),
(new Long(true)).getBytes(value.timestamp),
(new PermissionDueTimestamp(false)).getBytes(value.dueTimestamp),
])];
case 1:
multipleDataBytes = _a.sent();
return [2 /*return*/, concat_1.concatUint8Arrays.apply(void 0, multipleDataBytes)];
}
});
}
getBytes(value) {
return __awaiter(this, void 0, void 0, function* () {
const multipleDataBytes = yield Promise.all([
(new PermissionOpType(true)).getBytes(value.opType),
(new PermissionRole(true)).getBytes(value.role),
(new Long(true)).getBytes(value.timestamp),
(new PermissionDueTimestamp(false)).getBytes(value.dueTimestamp),
]);
return concat_1.concatUint8Arrays(...multipleDataBytes);
});
};
return PermissionOptions;
}(ByteProcessor));
}
}
exports.PermissionOptions = PermissionOptions;
// DATA TRANSACTIONS ONLY
var INTEGER_DATA_TYPE = 0;
var BOOLEAN_DATA_TYPE = 1;
var BINARY_DATA_TYPE = 2;
var STRING_DATA_TYPE = 3;
var IntegerDataEntry = /** @class */ (function (_super) {
__extends(IntegerDataEntry, _super);
function IntegerDataEntry(required) {
return _super.call(this, required) || this;
const INTEGER_DATA_TYPE = 0;
const BOOLEAN_DATA_TYPE = 1;
const BINARY_DATA_TYPE = 2;
const STRING_DATA_TYPE = 3;
class IntegerDataEntry extends ByteProcessor {
constructor(required) {
super(required);
}
IntegerDataEntry.prototype.getBytes = function (value) {
return Long.prototype.getBytes.call(this, value).then(function (longBytes) {
var typeByte = Uint8Array.from([INTEGER_DATA_TYPE]);
getBytes(value) {
return Long.prototype.getBytes.call(this, value).then((longBytes) => {
const typeByte = Uint8Array.from([INTEGER_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, longBytes);
});
};
return IntegerDataEntry;
}(ByteProcessor));
}
}
exports.IntegerDataEntry = IntegerDataEntry;
var BooleanDataEntry = /** @class */ (function (_super) {
__extends(BooleanDataEntry, _super);
function BooleanDataEntry(required) {
return _super.call(this, required) || this;
class BooleanDataEntry extends ByteProcessor {
constructor(required) {
super(required);
}
BooleanDataEntry.prototype.getBytes = function (value) {
return Bool.prototype.getBytes.call(this, value).then(function (boolByte) {
var typeByte = Uint8Array.from([BOOLEAN_DATA_TYPE]);
getBytes(value) {
return Bool.prototype.getBytes.call(this, value).then((boolByte) => {
const typeByte = Uint8Array.from([BOOLEAN_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, boolByte);
});
};
return BooleanDataEntry;
}(ByteProcessor));
}
}
exports.BooleanDataEntry = BooleanDataEntry;
var BinaryDataEntry = /** @class */ (function (_super) {
__extends(BinaryDataEntry, _super);
function BinaryDataEntry(required) {
return _super.call(this, required) || this;
class BinaryDataEntry extends ByteProcessor {
constructor(required) {
super(required);
}
BinaryDataEntry.prototype.getBytes = function (value) {
return Base64.prototype.getBytes.call(this, value).then(function (binaryBytes) {
var typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
getBytes(value) {
return Base64.prototype.getBytes.call(this, value).then((binaryBytes) => {
const typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
return Promise.resolve(concat_1.concatUint8Arrays(typeByte, binaryBytes));
});
};
return BinaryDataEntry;
}(ByteProcessor));
}
}
exports.BinaryDataEntry = BinaryDataEntry;
var StringDataEntry = /** @class */ (function (_super) {
__extends(StringDataEntry, _super);
function StringDataEntry(required) {
return _super.call(this, required) || this;
class StringDataEntry extends ByteProcessor {
constructor(required) {
super(required);
}
StringDataEntry.prototype.getBytes = function (value) {
return StringWithLength.prototype.getBytes.call(this, value).then(function (stringBytes) {
var typeByte = Uint8Array.from([STRING_DATA_TYPE]);
getBytes(value) {
return StringWithLength.prototype.getBytes.call(this, value).then((stringBytes) => {
const typeByte = Uint8Array.from([STRING_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, stringBytes);
});
};
return StringDataEntry;
}(ByteProcessor));
}
}
exports.StringDataEntry = StringDataEntry;
var BinaryDockerParamEntry = /** @class */ (function (_super) {
__extends(BinaryDockerParamEntry, _super);
function BinaryDockerParamEntry(required) {
return _super.call(this, required) || this;
class BinaryDockerParamEntry extends ByteProcessor {
constructor(required) {
super(required);
}
BinaryDockerParamEntry.prototype.getBytes = function (value) {
return Base64.prototype.getBytes.call(this, value, 4).then(function (binaryBytes) {
var typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
getBytes(value) {
return Base64.prototype.getBytes.call(this, value, 4).then((binaryBytes) => {
const typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
return Promise.resolve(concat_1.concatUint8Arrays(typeByte, binaryBytes));
});
};
return BinaryDockerParamEntry;
}(ByteProcessor));
}
}
exports.BinaryDockerParamEntry = BinaryDockerParamEntry;
var StringDockerParamEntry = /** @class */ (function (_super) {
__extends(StringDockerParamEntry, _super);
function StringDockerParamEntry(required) {
return _super.call(this, required) || this;
class StringDockerParamEntry extends ByteProcessor {
constructor(required) {
super(required);
}
StringDockerParamEntry.prototype.getBytes = function (value) {
return StringWithLength.prototype.getBytes.call(this, value, 4).then(function (stringBytes) {
var typeByte = Uint8Array.from([STRING_DATA_TYPE]);
getBytes(value) {
return StringWithLength.prototype.getBytes.call(this, value, 4).then((stringBytes) => {
const typeByte = Uint8Array.from([STRING_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, stringBytes);
});
};
return StringDockerParamEntry;
}(ByteProcessor));
}
}
exports.StringDockerParamEntry = StringDockerParamEntry;
var DataEntries = /** @class */ (function (_super) {
__extends(DataEntries, _super);
function DataEntries(required) {
return _super.call(this, required) || this;
class DataEntries extends ByteProcessor {
constructor(required) {
super(required);
}
DataEntries.prototype.getBytes = function (entries) {
var _this = this;
var lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(entries.length));
getBytes(entries) {
const lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(entries.length));
if (entries.length) {
return Promise.all(entries.map(function (entry) {
var prependKeyBytes = function (valueBytes) {
return StringWithLength.prototype.getBytes.call(_this, entry.key).then(function (keyBytes) {
return Promise.all(entries.map((entry) => {
const prependKeyBytes = (valueBytes) => {
return StringWithLength.prototype.getBytes.call(this, entry.key).then((keyBytes) => {
return concat_1.concatUint8Arrays(keyBytes, valueBytes);

@@ -696,14 +571,14 @@ });

case 'integer':
return IntegerDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return IntegerDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
case 'boolean':
return BooleanDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return BooleanDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
case 'binary':
return BinaryDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return BinaryDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
case 'string':
return StringDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return StringDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
default:
throw new Error("There is no data type \"" + entry.type + "\"");
throw new Error(`There is no data type "${entry.type}"`);
}
})).then(function (entriesBytes) {
var bytes = concat_1.concatUint8Arrays.apply(void 0, __spreadArrays([lengthBytes], entriesBytes));
})).then((entriesBytes) => {
const bytes = concat_1.concatUint8Arrays(lengthBytes, ...entriesBytes);
if (bytes.length > constants_1.DATA_ENTRIES_BYTE_LIMIT)

@@ -717,5 +592,4 @@ throw new Error('Data transaction is too large (140KB max)');

}
};
return DataEntries;
}(ByteProcessor));
}
}
exports.DataEntries = DataEntries;

@@ -726,14 +600,12 @@ /*

/* todo rename to DockerParamsEntries*/
var DockerCreateParamsEntries = /** @class */ (function (_super) {
__extends(DockerCreateParamsEntries, _super);
function DockerCreateParamsEntries(required) {
return _super.call(this, required) || this;
class DockerCreateParamsEntries extends ByteProcessor {
constructor(required) {
super(required);
}
DockerCreateParamsEntries.prototype.getBytes = function (entries) {
var _this = this;
var lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(entries.length));
getBytes(entries) {
const lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(entries.length));
if (entries.length) {
return Promise.all(entries.map(function (entry) {
var prependKeyBytes = function (valueBytes) {
return StringWithLength.prototype.getBytes.call(_this, entry.key).then(function (keyBytes) {
return Promise.all(entries.map((entry) => {
const prependKeyBytes = (valueBytes) => {
return StringWithLength.prototype.getBytes.call(this, entry.key).then((keyBytes) => {
return concat_1.concatUint8Arrays(keyBytes, valueBytes);

@@ -744,15 +616,15 @@ });

case 'integer':
return IntegerDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return IntegerDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
case 'boolean':
return BooleanDataEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return BooleanDataEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
// for docker tx data entries string and binary types have 4 byte length
case 'binary':
return BinaryDockerParamEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return BinaryDockerParamEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
case 'string':
return StringDockerParamEntry.prototype.getBytes.call(_this, entry.value).then(prependKeyBytes);
return StringDockerParamEntry.prototype.getBytes.call(this, entry.value).then(prependKeyBytes);
default:
throw new Error("There is no data type \"" + entry.type + "\"");
throw new Error(`There is no data type "${entry.type}"`);
}
})).then(function (entriesBytes) {
var bytes = concat_1.concatUint8Arrays.apply(void 0, __spreadArrays([lengthBytes], entriesBytes));
})).then((entriesBytes) => {
const bytes = concat_1.concatUint8Arrays(lengthBytes, ...entriesBytes);
if (bytes.length > constants_1.DATA_ENTRIES_BYTE_LIMIT)

@@ -766,29 +638,26 @@ throw new Error('Data transaction is too large (140KB max)');

}
};
return DockerCreateParamsEntries;
}(ByteProcessor));
}
}
exports.DockerCreateParamsEntries = DockerCreateParamsEntries;
var ArrayOfStringsWithLength = /** @class */ (function (_super) {
__extends(ArrayOfStringsWithLength, _super);
function ArrayOfStringsWithLength(required) {
return _super.call(this, required) || this;
class ArrayOfStringsWithLength extends ByteProcessor {
constructor(required) {
super(required);
}
ArrayOfStringsWithLength.prototype.getBytes = function (values) {
var recipientProcessor = new Recipient(true);
var promises = [];
for (var i = 0; i < values.length; i++) {
getBytes(values) {
const recipientProcessor = new Recipient(true);
const promises = [];
for (let i = 0; i < values.length; i++) {
promises.push(recipientProcessor.getBytes(values[i]));
}
return Promise.all(promises).then(function (elements) {
return Promise.all(promises).then((elements) => {
if (values.length === 0) {
return Uint8Array.from([0, 0, 0, 0]);
}
var length = convert_1.default.IntToByteArray(values.length);
var lengthBytes = Uint8Array.from(length);
return concat_1.concatUint8Arrays.apply(void 0, __spreadArrays([lengthBytes], elements));
const length = convert_1.default.IntToByteArray(values.length);
const lengthBytes = Uint8Array.from(length);
return concat_1.concatUint8Arrays(lengthBytes, ...elements);
});
};
return ArrayOfStringsWithLength;
}(ByteProcessor));
}
}
exports.ArrayOfStringsWithLength = ArrayOfStringsWithLength;
//# sourceMappingURL=ByteProcessor.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var __1 = require("../");
var DEFAULT_CONFIG = {
const __1 = require("../");
const DEFAULT_CONFIG = {
networkByte: __1.MAINNET_BYTE,

@@ -10,30 +10,29 @@ logLevel: 'warning',

};
var Config = /** @class */ (function () {
function Config() {
class Config {
constructor() {
this.props = Object.assign(Object.create(null), DEFAULT_CONFIG);
}
Config.prototype.getNetworkByte = function () {
getNetworkByte() {
return this.props.networkByte;
};
Config.prototype.getLogLevel = function () {
}
getLogLevel() {
return this.props.logLevel;
};
Config.prototype.getCrypto = function () {
}
getCrypto() {
return this.props.crypto;
};
Config.prototype.isCryptoGost = function () {
}
isCryptoGost() {
return this.props.crypto === 'gost';
};
Config.prototype.set = function (config) {
}
set(config) {
Object.assign(this.props, config);
};
Config.prototype.get = function (key) {
}
get(key) {
return this.props[key];
};
Config.prototype.clear = function () {
}
clear() {
this.props = Object.assign(Object.create(null), DEFAULT_CONFIG);
};
return Config;
}());
}
}
exports.config = new Config();
//# sourceMappingURL=Config.js.map

@@ -23,4 +23,4 @@ "use strict";

};
var PERMISSION_TRANSACTION_OPERATION_TYPE_ADD_BYTE = 'a'.charCodeAt(0);
var PERMISSION_TRANSACTION_OPERATION_TYPE_REMOVE_BYTE = 'r'.charCodeAt(0);
const PERMISSION_TRANSACTION_OPERATION_TYPE_ADD_BYTE = 'a'.charCodeAt(0);
const PERMISSION_TRANSACTION_OPERATION_TYPE_REMOVE_BYTE = 'r'.charCodeAt(0);
exports.PERMISSION_TRANSACTION_OPERATION_TYPE_BYTE = {

@@ -27,0 +27,0 @@ ADD: PERMISSION_TRANSACTION_OPERATION_TYPE_ADD_BYTE,

@@ -13,19 +13,19 @@ "use strict";

exports.BigNumber = data_entities_1.BigNumber;
var base58_1 = require("./libs/base58");
var converters_1 = require("./libs/converters");
var axlsign_1 = require("./libs/axlsign");
var blake2b = require("./libs/blake2b");
var sha3_1 = require("./libs/sha3");
var secure_random_1 = require("./libs/secure-random");
var base64 = require("base64-js");
var concat_1 = require("./utils/concat");
var convert_1 = require("./utils/convert");
var crypto_1 = require("./utils/crypto");
var cryptoGost_1 = require("./utils/cryptoGost");
const base58_1 = require("./libs/base58");
const converters_1 = require("./libs/converters");
const axlsign_1 = require("./libs/axlsign");
const blake2b = require("./libs/blake2b");
const sha3_1 = require("./libs/sha3");
const secure_random_1 = require("./libs/secure-random");
const base64 = require("base64-js");
const concat_1 = require("./utils/concat");
const convert_1 = require("./utils/convert");
const crypto_1 = require("./utils/crypto");
const cryptoGost_1 = require("./utils/cryptoGost");
exports.libs = {
base64: base64,
base64,
base58: base58_1.default,
converters: converters_1.default,
axlsign: axlsign_1.default,
blake2b: blake2b,
blake2b,
secureRandom: secure_random_1.default,

@@ -32,0 +32,0 @@ keccak256: sha3_1.keccak256

@@ -16,5 +16,5 @@ "use strict";

// See for details: http://tweetnacl.cr.yp.to/
var axlsign = Object.create(null);
var gf = function (init) {
var i, r = new Float64Array(16);
const axlsign = Object.create(null);
const gf = function (init) {
let i, r = new Float64Array(16);
if (init)

@@ -25,6 +25,6 @@ for (i = 0; i < init.length; i++)

};
var _0 = new Uint8Array(16);
var _9 = new Uint8Array(32);
const _0 = new Uint8Array(16);
const _9 = new Uint8Array(32);
_9[0] = 9;
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([0xdb41, 1]), D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]), D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]), X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]), Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]), I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
const gf0 = gf(), gf1 = gf([1]), _121665 = gf([0xdb41, 1]), D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]), D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]), X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]), Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]), I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
function ts64(x, i, h, l) {

@@ -41,3 +41,3 @@ x[i] = (h >> 24) & 0xff;

function vn(x, xi, y, yi, n) {
var i, d = 0;
let i, d = 0;
for (i = 0; i < n; i++)

@@ -51,7 +51,7 @@ d |= x[xi + i] ^ y[yi + i];

function set25519(r, a) {
for (var i = 0; i < 16; i++)
for (let i = 0; i < 16; i++)
r[i] = a[i] | 0;
}
function car25519(o) {
var i, v, c = 1;
let i, v, c = 1;
for (i = 0; i < 16; i++) {

@@ -65,4 +65,4 @@ v = o[i] + c + 65535;

function sel25519(p, q, b) {
var t, c = ~(b - 1);
for (var i = 0; i < 16; i++) {
let t, c = ~(b - 1);
for (let i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]);

@@ -74,4 +74,4 @@ p[i] ^= t;

function pack25519(o, n) {
var i, j, b;
var m = gf(), t = gf();
let i, j, b;
const m = gf(), t = gf();
for (i = 0; i < 16; i++)

@@ -99,3 +99,3 @@ t[i] = n[i];

function neq25519(a, b) {
var c = new Uint8Array(32), d = new Uint8Array(32);
const c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a);

@@ -106,3 +106,3 @@ pack25519(d, b);

function par25519(a) {
var d = new Uint8Array(32);
const d = new Uint8Array(32);
pack25519(d, a);

@@ -112,3 +112,3 @@ return d[0] & 1;

function unpack25519(o, n) {
for (var i = 0; i < 16; i++)
for (let i = 0; i < 16; i++)
o[i] = n[2 * i] + (n[2 * i + 1] << 8);

@@ -118,11 +118,11 @@ o[15] &= 0x7fff;

function A(o, a, b) {
for (var i = 0; i < 16; i++)
for (let i = 0; i < 16; i++)
o[i] = a[i] + b[i];
}
function Z(o, a, b) {
for (var i = 0; i < 16; i++)
for (let i = 0; i < 16; i++)
o[i] = a[i] - b[i];
}
function M(o, a, b) {
var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
let v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
v = a[0];

@@ -539,4 +539,4 @@ t0 += v * b0;

function inv25519(o, i) {
var c = gf();
var a;
const c = gf();
let a;
for (a = 0; a < 16; a++)

@@ -553,4 +553,4 @@ c[a] = i[a];

function pow2523(o, i) {
var c = gf();
var a;
const c = gf();
let a;
for (a = 0; a < 16; a++)

@@ -567,6 +567,6 @@ c[a] = i[a];

function crypto_scalarmult(q, n, p) {
var z = new Uint8Array(32);
var x = new Float64Array(80);
var r, i;
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf();
const z = new Uint8Array(32);
const x = new Float64Array(80);
let r, i;
const a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf();
for (i = 0; i < 31; i++)

@@ -613,4 +613,4 @@ z[i] = n[i];

}
var x32 = x.subarray(32);
var x16 = x.subarray(16);
const x32 = x.subarray(32);
const x16 = x.subarray(16);
inv25519(x32, x32);

@@ -624,3 +624,3 @@ M(x16, x16, x32);

}
var K = [
const K = [
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,

@@ -668,6 +668,6 @@ 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,

function crypto_hashblocks_hl(hh, hl, m, n) {
var wh = new Int32Array(16), wl = new Int32Array(16);
var bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
var pos = 0;
const wh = new Int32Array(16), wl = new Int32Array(16);
let bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
let ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
let pos = 0;
while (n >= 128) {

@@ -980,6 +980,6 @@ for (i = 0; i < 16; i++) {

function crypto_hash(out, m, n) {
var hh = new Int32Array(8);
var hl = new Int32Array(8);
var x = new Uint8Array(256);
var i, b = n;
const hh = new Int32Array(8);
const hl = new Int32Array(8);
const x = new Uint8Array(256);
let i, b = n;
hh[0] = 0x6a09e667;

@@ -1015,3 +1015,3 @@ hh[1] = 0xbb67ae85;

function add(p, q) {
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
const a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
Z(a, p[1], p[0]);

@@ -1037,3 +1037,3 @@ Z(t, q[1], q[0]);

function cswap(p, q, b) {
for (var i = 0; i < 4; i++) {
for (let i = 0; i < 4; i++) {
sel25519(p[i], q[i], b);

@@ -1043,3 +1043,3 @@ }

function pack(r, p) {
var tx = gf(), ty = gf(), zi = gf();
const tx = gf(), ty = gf(), zi = gf();
inv25519(zi, p[2]);

@@ -1052,3 +1052,3 @@ M(tx, p[0], zi);

function scalarmult(p, q, s) {
var b, i;
let b, i;
set25519(p[0], gf0);

@@ -1067,3 +1067,3 @@ set25519(p[1], gf1);

function scalarbase(p, s) {
var q = [gf(), gf(), gf(), gf()];
const q = [gf(), gf(), gf(), gf()];
set25519(q[0], X);

@@ -1075,5 +1075,5 @@ set25519(q[1], Y);

}
var L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
const L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
function modL(r, x) {
var carry, i, j, k;
let carry, i, j, k;
for (i = 63; i >= 32; --i) {

@@ -1103,4 +1103,4 @@ carry = 0;

function reduce(r) {
var x = new Float64Array(64);
var i;
const x = new Float64Array(64);
let i;
for (i = 0; i < 64; i++)

@@ -1114,6 +1114,6 @@ x[i] = r[i];

function crypto_sign_direct(sm, m, n, sk) {
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
var x = new Float64Array(64);
var p = [gf(), gf(), gf(), gf()];
var i, j;
const d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
const x = new Float64Array(64);
const p = [gf(), gf(), gf(), gf()];
let i, j;
for (i = 0; i < n; i++)

@@ -1145,6 +1145,6 @@ sm[64 + i] = m[i];

function crypto_sign_direct_rnd(sm, m, n, sk, rnd) {
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
var x = new Float64Array(64);
var p = [gf(), gf(), gf(), gf()];
var i, j;
const d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
const x = new Float64Array(64);
const p = [gf(), gf(), gf(), gf()];
let i, j;
// Hash separation.

@@ -1190,5 +1190,5 @@ sm[0] = 0xfe;

// Convert Curve25519 secret key into Ed25519 secret key (includes pub key).
var edsk = new Uint8Array(64);
var p = [gf(), gf(), gf(), gf()];
for (var i = 0; i < 32; i++)
const edsk = new Uint8Array(64);
const p = [gf(), gf(), gf(), gf()];
for (let i = 0; i < 32; i++)
edsk[i] = sk[i];

@@ -1202,4 +1202,4 @@ // Ensure private key is in the correct format.

// Remember sign bit.
var signBit = edsk[63] & 128;
var smlen;
const signBit = edsk[63] & 128;
let smlen;
if (opt_rnd) {

@@ -1216,3 +1216,3 @@ smlen = crypto_sign_direct_rnd(sm, m, n, edsk, opt_rnd);

function unpackneg(r, p) {
var t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
const t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
set25519(r[2], gf1);

@@ -1248,5 +1248,5 @@ unpack25519(r[1], p);

function crypto_sign_open(m, sm, n, pk) {
var i, mlen;
var t = new Uint8Array(32), h = new Uint8Array(64);
var p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
let i, mlen;
const t = new Uint8Array(32), h = new Uint8Array(64);
const p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
mlen = -1;

@@ -1281,3 +1281,3 @@ if (n < 64)

function convertPublicKey(pk) {
var z = new Uint8Array(32), x = gf(), a = gf(), b = gf();
const z = new Uint8Array(32), x = gf(), a = gf(), b = gf();
unpack25519(x, pk);

@@ -1293,3 +1293,3 @@ A(a, x, gf1);

// Convert Curve25519 public key into Ed25519 public key.
var edpk = convertPublicKey(pk);
const edpk = convertPublicKey(pk);
// Restore sign bit from signature.

@@ -1303,8 +1303,4 @@ edpk[31] |= sm[63] & 128;

/* High-level API */
function checkArrayTypes() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var t, i;
function checkArrayTypes(...args) {
let t, i;
for (i = 0; i < arguments.length; i++) {

@@ -1321,3 +1317,3 @@ if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')

throw new Error('wrong secret key length');
var sharedKey = new Uint8Array(32);
const sharedKey = new Uint8Array(32);
crypto_scalarmult(sharedKey, secretKey, publicKey);

@@ -1334,3 +1330,3 @@ return sharedKey;

throw new Error('wrong random data length');
var buf = new Uint8Array(128 + msg.length);
const buf = new Uint8Array(128 + msg.length);
curve25519_sign(buf, msg, msg.length, secretKey, opt_random);

@@ -1340,3 +1336,3 @@ return new Uint8Array(buf.subarray(0, 64 + msg.length));

else {
var signedMsg = new Uint8Array(64 + msg.length);
const signedMsg = new Uint8Array(64 + msg.length);
curve25519_sign(signedMsg, msg, msg.length, secretKey);

@@ -1350,8 +1346,8 @@ return signedMsg;

throw new Error('wrong public key length');
var tmp = new Uint8Array(signedMsg.length);
var mlen = curve25519_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
const tmp = new Uint8Array(signedMsg.length);
const mlen = curve25519_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
if (mlen < 0)
return null;
var m = new Uint8Array(mlen);
for (var i = 0; i < m.length; i++)
const m = new Uint8Array(mlen);
for (let i = 0; i < m.length; i++)
m[i] = tmp[i];

@@ -1369,6 +1365,6 @@ return m;

}
var buf = new Uint8Array((opt_random ? 128 : 64) + msg.length);
const buf = new Uint8Array((opt_random ? 128 : 64) + msg.length);
curve25519_sign(buf, msg, msg.length, secretKey, opt_random);
var signature = new Uint8Array(64);
for (var i = 0; i < signature.length; i++)
const signature = new Uint8Array(64);
for (let i = 0; i < signature.length; i++)
signature[i] = buf[i];

@@ -1383,5 +1379,5 @@ return signature;

throw new Error('wrong public key length');
var sm = new Uint8Array(64 + msg.length);
var m = new Uint8Array(64 + msg.length);
var i;
const sm = new Uint8Array(64 + msg.length);
const m = new Uint8Array(64 + msg.length);
let i;
for (i = 0; i < 64; i++)

@@ -1397,5 +1393,5 @@ sm[i] = signature[i];

throw new Error('wrong seed length');
var sk = new Uint8Array(32);
var pk = new Uint8Array(32);
for (var i = 0; i < 32; i++)
const sk = new Uint8Array(32);
const pk = new Uint8Array(32);
for (let i = 0; i < 32; i++)
sk[i] = seed[i];

@@ -1402,0 +1398,0 @@ crypto_scalarmult_base(pk, sk);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
var ALPHABET_MAP = ALPHABET.split('').reduce(function (map, c, i) {
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const ALPHABET_MAP = ALPHABET.split('').reduce((map, c, i) => {
map[c] = i;

@@ -9,13 +9,13 @@ return map;

exports.default = {
encode: function (buffer) {
encode(buffer) {
if (!buffer.length)
return '';
var digits = [0];
for (var i = 0; i < buffer.length; i++) {
for (var j = 0; j < digits.length; j++) {
const digits = [0];
for (let i = 0; i < buffer.length; i++) {
for (let j = 0; j < digits.length; j++) {
digits[j] <<= 8;
}
digits[0] += buffer[i];
var carry = 0;
for (var k = 0; k < digits.length; k++) {
let carry = 0;
for (let k = 0; k < digits.length; k++) {
digits[k] += carry;

@@ -30,3 +30,3 @@ carry = (digits[k] / 58) | 0;

}
for (var i = 0; buffer[i] === 0 && i < buffer.length - 1; i++) {
for (let i = 0; buffer[i] === 0 && i < buffer.length - 1; i++) {
digits.push(0);

@@ -38,18 +38,17 @@ }

},
decode: function (string) {
if (string === void 0) { string = ''; }
decode(string = '') {
if (!string.length)
return new Uint8Array(0);
var bytes = [0];
for (var i = 0; i < string.length; i++) {
var c = string[i];
const bytes = [0];
for (let i = 0; i < string.length; i++) {
const c = string[i];
if (!(c in ALPHABET_MAP)) {
throw "There is no character \"" + c + "\" in the Base58 sequence!";
throw `There is no character "${c}" in the Base58 sequence!`;
}
for (var j = 0; j < bytes.length; j++) {
for (let j = 0; j < bytes.length; j++) {
bytes[j] *= 58;
}
bytes[0] += ALPHABET_MAP[c];
var carry = 0;
for (var j = 0; j < bytes.length; j++) {
let carry = 0;
for (let j = 0; j < bytes.length; j++) {
bytes[j] += carry;

@@ -64,3 +63,3 @@ carry = bytes[j] >> 8;

}
for (var i = 0; string[i] === '1' && i < string.length - 1; i++) {
for (let i = 0; string[i] === '1' && i < string.length - 1; i++) {
bytes.push(0);

@@ -67,0 +66,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CryptoJS = require("crypto-js");
const CryptoJS = require("crypto-js");
/** START OF THE LICENSED CODE */

@@ -20,8 +20,8 @@ /******************************************************************************

******************************************************************************/
var converters = function () {
var charToNibble = {};
var nibbleToChar = [];
var i;
let converters = function () {
let charToNibble = {};
let nibbleToChar = [];
let i;
for (i = 0; i <= 9; ++i) {
var character = i.toString();
let character = i.toString();
charToNibble[character] = i;

@@ -31,4 +31,4 @@ nibbleToChar.push(character);

for (i = 10; i <= 15; ++i) {
var lowerChar = String.fromCharCode('a'.charCodeAt(0) + i - 10);
var upperChar = String.fromCharCode('A'.charCodeAt(0) + i - 10);
let lowerChar = String.fromCharCode('a'.charCodeAt(0) + i - 10);
let upperChar = String.fromCharCode('A'.charCodeAt(0) + i - 10);
charToNibble[lowerChar] = i;

@@ -40,8 +40,8 @@ charToNibble[upperChar] = i;

byteArrayToHexString: function (bytes) {
var str = '';
for (var i_1 = 0; i_1 < bytes.length; ++i_1) {
if (bytes[i_1] < 0) {
bytes[i_1] += 256;
let str = '';
for (let i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {
bytes[i] += 256;
}
str += nibbleToChar[bytes[i_1] >> 4] + nibbleToChar[bytes[i_1] & 0x0F];
str += nibbleToChar[bytes[i] >> 4] + nibbleToChar[bytes[i] & 0x0F];
}

@@ -52,10 +52,10 @@ return str;

str = unescape(encodeURIComponent(str));
var bytes = new Array(str.length);
for (var i_2 = 0; i_2 < str.length; ++i_2)
bytes[i_2] = str.charCodeAt(i_2);
let bytes = new Array(str.length);
for (let i = 0; i < str.length; ++i)
bytes[i] = str.charCodeAt(i);
return bytes;
},
hexStringToByteArray: function (str) {
var bytes = [];
var i = 0;
let bytes = [];
let i = 0;
if (0 !== str.length % 2) {

@@ -76,3 +76,3 @@ bytes.push(charToNibble[str.charAt(0)]);

checkBytesToIntInput: function (bytes, numBytes, opt_startIndex) {
var startIndex = opt_startIndex || 0;
let startIndex = opt_startIndex || 0;
if (startIndex < 0) {

@@ -87,4 +87,4 @@ throw new Error('Start index should not be negative');

byteArrayToSignedShort: function (bytes, opt_startIndex) {
var index = this.checkBytesToIntInput(bytes, 2, opt_startIndex);
var value = bytes[index];
let index = this.checkBytesToIntInput(bytes, 2, opt_startIndex);
let value = bytes[index];
value += bytes[index + 1] << 8;

@@ -94,4 +94,4 @@ return value;

byteArrayToSignedInt32: function (bytes, opt_startIndex) {
var index = this.checkBytesToIntInput(bytes, 4, opt_startIndex);
var value = bytes[index];
let index = this.checkBytesToIntInput(bytes, 4, opt_startIndex);
let value = bytes[index];
value += bytes[index + 1] << 8;

@@ -103,8 +103,8 @@ value += bytes[index + 2] << 16;

byteArrayToBigInteger: function (bytes, opt_startIndex) {
var index = this.checkBytesToIntInput(bytes, 8, opt_startIndex);
var value = new BigInteger('0', 10);
var temp1, temp2;
for (var i_3 = 7; i_3 >= 0; i_3--) {
let index = this.checkBytesToIntInput(bytes, 8, opt_startIndex);
let value = new BigInteger('0', 10);
let temp1, temp2;
for (let i = 7; i >= 0; i--) {
temp1 = value.multiply(new BigInteger('256', 10));
temp2 = temp1.add(new BigInteger(bytes[opt_startIndex + i_3].toString(10), 10));
temp2 = temp1.add(new BigInteger(bytes[opt_startIndex + i].toString(10), 10));
value = temp2;

@@ -116,4 +116,4 @@ }

byteArrayToWordArray: function (byteArray) {
var i = 0, offset = 0, word = 0, len = byteArray.length;
var words = new Uint32Array(((len / 4) | 0) + (len % 4 == 0 ? 0 : 1));
let i = 0, offset = 0, word = 0, len = byteArray.length;
let words = new Uint32Array(((len / 4) | 0) + (len % 4 == 0 ? 0 : 1));
while (i < (len - (len % 4))) {

@@ -132,3 +132,3 @@ words[offset++] = (byteArray[i++] << 24) | (byteArray[i++] << 16) | (byteArray[i++] << 8) | (byteArray[i++]);

}
var wordArray = new Object();
let wordArray = new Object();
wordArray.sigBytes = len;

@@ -143,8 +143,8 @@ wordArray.words = words;

wordArrayToByteArrayImpl: function (wordArray, isFirstByteHasSign) {
var len = wordArray.words.length;
let len = wordArray.words.length;
if (len == 0) {
return new Array(0);
}
var byteArray = new Array(wordArray.sigBytes);
var offset = 0, word, i;
let byteArray = new Array(wordArray.sigBytes);
let offset = 0, word, i;
for (i = 0; i < len - 1; i++) {

@@ -177,3 +177,3 @@ word = wordArray.words[i];

if (opt_startIndex && length) {
var index = this.checkBytesToIntInput(bytes, parseInt(length, 10), parseInt(opt_startIndex, 10));
let index = this.checkBytesToIntInput(bytes, parseInt(length, 10), parseInt(opt_startIndex, 10));
bytes = bytes.slice(opt_startIndex, opt_startIndex + length);

@@ -184,4 +184,4 @@ }

byteArrayToShortArray: function (byteArray) {
var shortArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var i;
let shortArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let i;
for (i = 0; i < 16; i++) {

@@ -193,4 +193,4 @@ shortArray[i] = byteArray[i * 2] | byteArray[i * 2 + 1] << 8;

shortArrayToByteArray: function (shortArray) {
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var i;
let byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let i;
for (i = 0; i < 16; i++) {

@@ -203,5 +203,5 @@ byteArray[2 * i] = shortArray[i] & 0xff;

shortArrayToHexString: function (ary) {
var res = '';
for (var i_4 = 0; i_4 < ary.length; i_4++) {
res += nibbleToChar[(ary[i_4] >> 4) & 0x0f] + nibbleToChar[ary[i_4] & 0x0f] + nibbleToChar[(ary[i_4] >> 12) & 0x0f] + nibbleToChar[(ary[i_4] >> 8) & 0x0f];
let res = '';
for (let i = 0; i < ary.length; i++) {
res += nibbleToChar[(ary[i] >> 4) & 0x0f] + nibbleToChar[ary[i] & 0x0f] + nibbleToChar[(ary[i] >> 12) & 0x0f] + nibbleToChar[(ary[i] >> 8) & 0x0f];
}

@@ -217,12 +217,12 @@ return res;

intToBytes_: function (x, numBytes, unsignedMax, opt_bigEndian) {
var signedMax = Math.floor(unsignedMax / 2);
var negativeMax = (signedMax + 1) * -1;
let signedMax = Math.floor(unsignedMax / 2);
let negativeMax = (signedMax + 1) * -1;
if (x != Math.floor(x) || x < negativeMax || x > unsignedMax) {
throw new Error(x + ' is not a ' + (numBytes * 8) + ' bit integer');
}
var bytes = [];
var current;
let bytes = [];
let current;
// Number type 0 is in the positive int range, 1 is larger than signed int,
// and 2 is negative int.
var numberType = x >= 0 && x <= signedMax ? 0 :
let numberType = x >= 0 && x <= signedMax ? 0 :
x > signedMax && x <= unsignedMax ? 1 : 2;

@@ -232,3 +232,3 @@ if (numberType == 2) {

}
for (var i_5 = 0; i_5 < numBytes; i_5++) {
for (let i = 0; i < numBytes; i++) {
if (numberType == 2) {

@@ -269,9 +269,9 @@ current = 255 - (x % 256);

// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
let words = wordArray.words;
let sigBytes = wordArray.sigBytes;
// Convert
var u8 = new Uint8Array(sigBytes);
for (var i_6 = 0; i_6 < sigBytes; i_6++) {
var byte = (words[i_6 >>> 2] >>> (24 - (i_6 % 4) * 8)) & 0xff;
u8[i_6] = byte;
let u8 = new Uint8Array(sigBytes);
for (let i = 0; i < sigBytes; i++) {
let byte = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
u8[i] = byte;
}

@@ -287,7 +287,7 @@ return u8;

// Shortcut
var len = u8arr.length;
let len = u8arr.length;
// Convert
var words = [];
for (var i_7 = 0; i_7 < len; i_7++) {
words[i_7 >>> 2] |= (u8arr[i_7] & 0xff) << (24 - (i_7 % 4) * 8);
let words = [];
for (let i = 0; i < len; i++) {
words[i >>> 2] |= (u8arr[i] & 0xff) << (24 - (i % 4) * 8);
}

@@ -294,0 +294,0 @@ return CryptoJS.lib.WordArray.create(words, len);

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var converters_1 = require("../libs/converters");
var CryptoGost_1 = require("@vostokplatform/crypto-gost-js/dist/CryptoGost");
var coding = CryptoGost_1.CryptoGost.coding;
var algoritmKey = {
const converters_1 = require("../libs/converters");
const CryptoGost_1 = require("@vostokplatform/crypto-gost-js/dist/CryptoGost");
const { coding } = CryptoGost_1.CryptoGost;
const algoritmKey = {
keySize: 32,

@@ -25,3 +14,3 @@ length: 256,

};
var algorithmGostSign = {
const algorithmGostSign = {
name: 'GOST R 34.10',

@@ -45,7 +34,7 @@ version: 2012,

exports.default = {
streebog256: function (data) {
streebog256(data) {
if (typeof data === 'string') {
data = Uint8Array.from(converters_1.default.stringToByteArray(data));
}
var GostDigest = CryptoGost_1.GostEngine.getGostDigest({
const GostDigest = CryptoGost_1.GostEngine.getGostDigest({
name: 'GOST R 34.11'

@@ -55,7 +44,7 @@ });

},
generateKey: function (ukm) {
var GostSign = CryptoGost_1.GostEngine.getGostSign(__assign(__assign({}, algorithmGostSign), { ukm: ukm }));
var keys = GostSign.generateKey();
var privateKeyObject = convertKey(algoritmKey, false, null, keys.privateKey, 'private');
var publicKeyObject = convertKey(algoritmKey, false, null, keys.publicKey, 'public');
generateKey(ukm) {
const GostSign = CryptoGost_1.GostEngine.getGostSign(Object.assign(Object.assign({}, algorithmGostSign), { ukm }));
const keys = GostSign.generateKey();
const privateKeyObject = convertKey(algoritmKey, false, null, keys.privateKey, 'private');
const publicKeyObject = convertKey(algoritmKey, false, null, keys.publicKey, 'public');
return {

@@ -66,5 +55,5 @@ publicKey: this.exportKey('raw', publicKeyObject),

},
sign: function (privateKey, dataBytes) {
var GostSign = CryptoGost_1.GostEngine.getGostSign(__assign({}, algorithmGostSign));
var signature = GostSign.sign(privateKey.buffer, dataBytes);
sign(privateKey, dataBytes) {
const GostSign = CryptoGost_1.GostEngine.getGostSign(Object.assign({}, algorithmGostSign));
const signature = GostSign.sign(privateKey.buffer, dataBytes);
if (signature instanceof ArrayBuffer) {

@@ -77,4 +66,4 @@ return new Uint8Array(signature);

},
importKey: function (format, key, type) {
var decodeKey = null;
importKey(format, key, type) {
let decodeKey = null;
switch (format) {

@@ -98,4 +87,4 @@ case 'spki':

},
exportKey: function (format, key) {
var encodeKey = null;
exportKey(format, key) {
let encodeKey = null;
switch (format) {

@@ -119,10 +108,10 @@ case 'spki':

},
verify: function (publicKey, signature, data) {
var GostSign = CryptoGost_1.GostEngine.getGostSign(__assign({}, algorithmGostSign));
verify(publicKey, signature, data) {
const GostSign = CryptoGost_1.GostEngine.getGostSign(Object.assign({}, algorithmGostSign));
return GostSign.verify(publicKey, signature, data);
},
encrypt: function (password, seed, address) {
var baseKey = getBaseKeyForDerivation(password, address);
encrypt(password, seed, address) {
const baseKey = getBaseKeyForDerivation(password, address);
if (baseKey instanceof ArrayBuffer) {
var GostCipher = CryptoGost_1.GostEngine.getGostCipher({
const GostCipher = CryptoGost_1.GostEngine.getGostCipher({
name: 'GOST R 34.12',

@@ -132,4 +121,4 @@ version: 2015,

});
var seedBytes = this.decodeChars(seed);
var encryptedSeedBytes = GostCipher.encrypt(baseKey, seedBytes);
const seedBytes = this.decodeChars(seed);
const encryptedSeedBytes = GostCipher.encrypt(baseKey, seedBytes);
return this.encodeHex(encryptedSeedBytes);

@@ -141,6 +130,6 @@ }

},
decrypt: function (password, encryptedSeed, address) {
var baseKey = getBaseKeyForDerivation(password, address);
decrypt(password, encryptedSeed, address) {
const baseKey = getBaseKeyForDerivation(password, address);
if (baseKey instanceof ArrayBuffer) {
var GostCipher = CryptoGost_1.GostEngine.getGostCipher({
const GostCipher = CryptoGost_1.GostEngine.getGostCipher({
name: 'GOST R 34.12',

@@ -150,4 +139,4 @@ version: 2015,

});
var encryptedSeedBytes = this.decodeHex(encryptedSeed);
var decryptedSeedBytes = GostCipher.decrypt(baseKey, encryptedSeedBytes);
const encryptedSeedBytes = this.decodeHex(encryptedSeed);
const decryptedSeedBytes = GostCipher.decrypt(baseKey, encryptedSeedBytes);
return this.encodeChars(decryptedSeedBytes).replace(/[^\x20-\x7E]/g, '');

@@ -159,14 +148,12 @@ }

},
decodeHex: function (input) {
decodeHex(input) {
return coding.Hex.decode(input);
},
encodeHex: function (input) {
encodeHex(input) {
return coding.Hex.encode(input);
},
decodeChars: function (input, charset) {
if (charset === void 0) { charset = 'utf-8'; }
decodeChars(input, charset = 'utf-8') {
return coding.Chars.decode(input, charset);
},
encodeChars: function (input, charset) {
if (charset === void 0) { charset = 'utf-8'; }
encodeChars(input, charset = 'utf-8') {
return coding.Chars.encode(input, charset);

@@ -185,4 +172,4 @@ }

function getBaseKeyForDerivation(password, salt) {
var saltBytes = coding.Chars.decode(salt, 'utf-8');
var GostDigest = CryptoGost_1.GostEngine.getGostDigest({
const saltBytes = coding.Chars.decode(salt, 'utf-8');
const GostDigest = CryptoGost_1.GostEngine.getGostDigest({
name: 'GOST R 34.11',

@@ -192,5 +179,5 @@ mode: 'CPKDF',

});
var passwordBytes = coding.Chars.decode(password, 'utf-8');
const passwordBytes = coding.Chars.decode(password, 'utf-8');
return GostDigest.deriveKey(passwordBytes);
}
//# sourceMappingURL=gost.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function nodeRandom(count, options) {
var crypto = require('crypto');
var buf = crypto.randomBytes(count);
const crypto = require('crypto');
const buf = crypto.randomBytes(count);
switch (options.type) {

@@ -12,4 +12,4 @@ case 'Array':

case 'Uint8Array':
var arr = new Uint8Array(count);
for (var i = 0; i < count; ++i) {
const arr = new Uint8Array(count);
for (let i = 0; i < count; ++i) {
arr[i] = buf.readUInt8(i);

@@ -23,4 +23,4 @@ }

function browserRandom(count, options) {
var nativeArr = new Uint8Array(count);
var crypto = self.crypto || self.msCrypto;
const nativeArr = new Uint8Array(count);
const crypto = self.crypto || self.msCrypto;
crypto.getRandomValues(nativeArr);

@@ -32,3 +32,3 @@ switch (options.type) {

try {
var b = new Buffer(1);
const b = new Buffer(1);
}

@@ -59,9 +59,9 @@ catch (e) {

secureRandom: secureRandom,
randomArray: function (byteCount) {
randomArray(byteCount) {
return secureRandom(byteCount, { type: 'Array' });
},
randomUint8Array: function (byteCount) {
randomUint8Array(byteCount) {
return secureRandom(byteCount, { type: 'Uint8Array' });
},
randomBuffer: function (byteCount) {
randomBuffer(byteCount) {
return secureRandom(byteCount, { type: 'Buffer' });

@@ -68,0 +68,0 @@ }

@@ -11,9 +11,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var sha3 = {};
var HEX_CHARS = '0123456789abcdef'.split('');
var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
var KECCAK_PADDING = [1, 256, 65536, 16777216];
var PADDING = [6, 1536, 393216, 100663296];
var SHIFT = [0, 8, 16, 24];
var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
const sha3 = {};
const HEX_CHARS = '0123456789abcdef'.split('');
const SHAKE_PADDING = [31, 7936, 2031616, 520093696];
const KECCAK_PADDING = [1, 256, 65536, 16777216];
const PADDING = [6, 1536, 393216, 100663296];
const SHIFT = [0, 8, 16, 24];
const RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,

@@ -23,6 +23,6 @@ 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,

2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
var BITS = [224, 256, 384, 512];
var SHAKE_BITS = [128, 256];
var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
var createOutputMethod = function (bits, padding, outputType) {
const BITS = [224, 256, 384, 512];
const SHAKE_BITS = [128, 256];
const OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
const createOutputMethod = function (bits, padding, outputType) {
return function (message) {

@@ -32,3 +32,3 @@ return new Keccak(bits, padding, bits).update(message)[outputType]();

};
var createShakeOutputMethod = function (bits, padding, outputType) {
const createShakeOutputMethod = function (bits, padding, outputType) {
return function (message, outputBits) {

@@ -38,4 +38,4 @@ return new Keccak(bits, padding, outputBits).update(message)[outputType]();

};
var createMethod = function (bits, padding) {
var method = createOutputMethod(bits, padding, 'hex');
const createMethod = function (bits, padding) {
const method = createOutputMethod(bits, padding, 'hex');
method.create = function () {

@@ -47,4 +47,4 @@ return new Keccak(bits, padding, bits);

};
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
for (let i = 0; i < OUTPUT_TYPES.length; ++i) {
const type = OUTPUT_TYPES[i];
method[type] = createOutputMethod(bits, padding, type);

@@ -54,4 +54,4 @@ }

};
var createShakeMethod = function (bits, padding) {
var method = createShakeOutputMethod(bits, padding, 'hex');
const createShakeMethod = function (bits, padding) {
const method = createShakeOutputMethod(bits, padding, 'hex');
method.create = function (outputBits) {

@@ -63,4 +63,4 @@ return new Keccak(bits, padding, outputBits);

};
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
for (let i = 0; i < OUTPUT_TYPES.length; ++i) {
const type = OUTPUT_TYPES[i];
method[type] = createShakeOutputMethod(bits, padding, type);

@@ -70,3 +70,3 @@ }

};
var algorithms = [
const algorithms = [
{ name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },

@@ -76,8 +76,8 @@ { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },

];
var methods = {}, methodNames = [];
for (var i = 0; i < algorithms.length; ++i) {
var algorithm = algorithms[i];
var bits = algorithm.bits;
for (var j = 0; j < bits.length; ++j) {
var methodName = algorithm.name + '_' + bits[j];
const methods = {}, methodNames = [];
for (let i = 0; i < algorithms.length; ++i) {
const algorithm = algorithms[i];
const bits = algorithm.bits;
for (let j = 0; j < bits.length; ++j) {
const methodName = algorithm.name + '_' + bits[j];
methodNames.push(methodName);

@@ -99,3 +99,3 @@ methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);

this.extraBytes = (outputBits & 31) >> 3;
for (var i = 0; i < 50; ++i) {
for (let i = 0; i < 50; ++i) {
this.s[i] = 0;

@@ -105,8 +105,8 @@ }

Keccak.prototype.update = function (message) {
var notString = typeof message !== 'string';
const notString = typeof message !== 'string';
if (notString && message.constructor === ArrayBuffer) {
message = new Uint8Array(message);
}
var length = message.length, blocks = this.blocks, byteCount = this.byteCount;
var blockCount = this.blockCount, index = 0, s = this.s, i, code;
const length = message.length, blocks = this.blocks, byteCount = this.byteCount;
let blockCount = this.blockCount, index = 0, s = this.s, i, code;
while (index < length) {

@@ -166,4 +166,4 @@ if (this.reset) {

Keccak.prototype.finalize = function () {
var blocks = this.blocks;
var i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
const blocks = this.blocks;
let i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
blocks[i >> 2] |= this.padding[i & 3];

@@ -184,5 +184,5 @@ if (this.lastByteIndex === this.byteCount) {

this.finalize();
var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
var extraBytes = this.extraBytes, i = 0, j = 0;
var hex = '', block;
const blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
let extraBytes = this.extraBytes, i = 0, j = 0;
let hex = '', block;
while (j < outputBlocks) {

@@ -217,6 +217,6 @@ for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {

this.finalize();
var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
var extraBytes = this.extraBytes, i = 0, j = 0;
var bytes = this.outputBits >> 3;
var buffer;
const blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
let extraBytes = this.extraBytes, i = 0, j = 0;
const bytes = this.outputBits >> 3;
let buffer;
if (extraBytes) {

@@ -228,3 +228,3 @@ buffer = new ArrayBuffer((outputBlocks + 1) << 2);

}
var array = new Uint32Array(buffer);
const array = new Uint32Array(buffer);
while (j < outputBlocks) {

@@ -247,6 +247,6 @@ for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {

this.finalize();
var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
var extraBytes = this.extraBytes, i = 0, j = 0;
var array = [];
var offset, block;
const blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks;
let extraBytes = this.extraBytes, i = 0, j = 0;
const array = [];
let offset, block;
while (j < outputBlocks) {

@@ -280,4 +280,4 @@ for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {

};
var f = function (s) {
var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
const f = function (s) {
let h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
for (n = 0; n < 48; n += 2) {

@@ -284,0 +284,0 @@ c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Config_1 = require("./config/Config");
var index_1 = require("./index");
var dictionary_1 = require("./dictionary");
var Seed = /** @class */ (function () {
function Seed(phrase) {
const Config_1 = require("./config/Config");
const index_1 = require("./index");
const dictionary_1 = require("./dictionary");
class Seed {
constructor(phrase) {
if (phrase.length < Config_1.config.get('minimalSeedLength')) {
throw new Error('Your seed length is less than allowed in config');
}
var keys = Config_1.config.isCryptoGost() ? index_1.utils.cryptoGost.buildKeyPair(phrase) : index_1.utils.crypto.buildKeyPair(phrase);
const keys = Config_1.config.isCryptoGost() ? index_1.utils.cryptoGost.buildKeyPair(phrase) : index_1.utils.crypto.buildKeyPair(phrase);
this.phrase = phrase;

@@ -21,7 +21,6 @@ this.address = Config_1.config.isCryptoGost() ? index_1.utils.cryptoGost.buildRawAddress(keys.publicKey) : index_1.utils.crypto.buildRawAddress(keys.publicKey);

}
Seed.prototype.encrypt = function (password, encryptionRounds) {
encrypt(password, encryptionRounds) {
return Seed.encryptSeedPhrase(this.phrase, password, this.address, this.isGost);
};
Seed.encryptSeedPhrase = function (seedPhrase, password, address, isGost) {
if (isGost === void 0) { isGost = false; }
}
static encryptSeedPhrase(seedPhrase, password, address, isGost = false) {
if (password && password.length < 8) {

@@ -35,6 +34,6 @@ // logger.warn('Your password may be too weak');

return index_1.utils.crypto.encryptSeed(seedPhrase, password);
};
Seed.decryptSeedPhrase = function (encryptedSeedPhrase, password, address) {
var wrongPasswordMessage = 'The password is wrong';
var phrase;
}
static decryptSeedPhrase(encryptedSeedPhrase, password, address) {
const wrongPasswordMessage = 'The password is wrong';
let phrase;
try {

@@ -51,27 +50,26 @@ // phrase = config.isCryptoGost() ? utils.cryptoGost.decryptSeed(encryptedSeedPhrase, password, address) : utils.crypto.decryptSeed(encryptedSeedPhrase, password);

return phrase;
};
Seed.create = function (words) {
if (words === void 0) { words = 15; }
var phrase = Seed._generateNewSeed(words);
var minimumSeedLength = Config_1.config.get('minimalSeedLength');
}
static create(words = 15) {
const phrase = Seed._generateNewSeed(words);
const minimumSeedLength = Config_1.config.get('minimalSeedLength');
if (phrase.length < minimumSeedLength) {
// If you see that error you should increase the number of words in the generated seed
throw new Error("The resulted seed length is less than the minimum length (" + minimumSeedLength + ")");
throw new Error(`The resulted seed length is less than the minimum length (${minimumSeedLength})`);
}
return new Seed(phrase);
};
Seed.fromExistingPhrase = function (phrase) {
var minimumSeedLength = Config_1.config.get('minimalSeedLength');
}
static fromExistingPhrase(phrase) {
const minimumSeedLength = Config_1.config.get('minimalSeedLength');
if (phrase.length < minimumSeedLength) {
// If you see that error you should increase the number of words or set it lower in the config
throw new Error("The resulted seed length is less than the minimum length (" + minimumSeedLength + ")");
throw new Error(`The resulted seed length is less than the minimum length (${minimumSeedLength})`);
}
return new Seed(phrase);
};
Seed._generateNewSeed = function (length) {
var random = Config_1.config.isCryptoGost() ? index_1.utils.cryptoGost.generateRandomUint32Array(length) : index_1.utils.crypto.generateRandomUint32Array(length);
var wordCount = dictionary_1.default.length;
var phrase = [];
for (var i = 0; i < length; i++) {
var wordIndex = random[i] % wordCount;
}
static _generateNewSeed(length) {
const random = Config_1.config.isCryptoGost() ? index_1.utils.cryptoGost.generateRandomUint32Array(length) : index_1.utils.crypto.generateRandomUint32Array(length);
const wordCount = dictionary_1.default.length;
const phrase = [];
for (let i = 0; i < length; i++) {
const wordIndex = random[i] % wordCount;
phrase.push(dictionary_1.default[wordIndex]);

@@ -81,6 +79,5 @@ }

return phrase.join(' ');
};
return Seed;
}());
}
}
exports.Seed = Seed;
//# sourceMappingURL=Seed.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function concatUint8Arrays() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
function concatUint8Arrays(...args) {
if (args.length < 2) {
throw new Error('Two or more Uint8Array are expected');
}
if (!(args.every(function (arg) { return arg instanceof Uint8Array; }))) {
if (!(args.every((arg) => arg instanceof Uint8Array))) {
throw new Error('One of arguments is not a Uint8Array');
}
var count = args.length;
var sumLength = args.reduce(function (sum, arr) { return sum + arr.length; }, 0);
var result = new Uint8Array(sumLength);
var curLength = 0;
for (var i = 0; i < count; i++) {
const count = args.length;
const sumLength = args.reduce((sum, arr) => sum + arr.length, 0);
const result = new Uint8Array(sumLength);
let curLength = 0;
for (let i = 0; i < count; i++) {
result.set(args[i], curLength);

@@ -20,0 +16,0 @@ curLength += args[i].length;

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var converters_1 = require("../libs/converters");
var data_entities_1 = require("@waves/data-entities");
const converters_1 = require("../libs/converters");
const data_entities_1 = require("@waves/data-entities");
function performBitwiseAnd(a, b) {
var sa = a.toString(2).split('.')[0];
var sb = b.toString(2).split('.')[0];
var len = Math.min(sa.length, sb.length);
var s1 = sa.slice(sa.length - len);
var s2 = sb.slice(sb.length - len);
var result = new Array(len);
for (var i = len - 1; i >= 0; i--) {
const sa = a.toString(2).split('.')[0];
const sb = b.toString(2).split('.')[0];
const len = Math.min(sa.length, sb.length);
const s1 = sa.slice(sa.length - len);
const s2 = sb.slice(sb.length - len);
let result = new Array(len);
for (let i = len - 1; i >= 0; i--) {
result[i] = (s1[i] === '1' && s2[i] === '1') ? '1' : '0';

@@ -25,3 +18,3 @@ }

exports.default = {
booleanToBytes: function (input) {
booleanToBytes(input) {
if (typeof input !== 'boolean') {

@@ -32,3 +25,3 @@ throw new Error('Boolean input is expected');

},
shortToByteArray: function (input) {
shortToByteArray(input) {
if (typeof input !== 'number') {

@@ -39,3 +32,3 @@ throw new Error('Numeric input is expected');

},
IntToByteArray: function (input) {
IntToByteArray(input) {
if (typeof input !== 'number') {

@@ -46,7 +39,7 @@ throw new Error('Numeric input is expected');

},
bytesToByteArrayWithSize: function (input) {
bytesToByteArrayWithSize(input) {
if (!(input instanceof Array || input instanceof Uint8Array)) {
throw new Error('Byte array or Uint8Array input is expected');
}
else if (input instanceof Array && !(input.every(function (n) { return typeof n === 'number'; }))) {
else if (input instanceof Array && !(input.every((n) => typeof n === 'number'))) {
throw new Error('Byte array contains non-numeric elements');

@@ -57,11 +50,11 @@ }

}
var lengthBytes = converters_1.default.int16ToBytes(input.length, true);
return __spreadArrays(lengthBytes, input);
const lengthBytes = converters_1.default.int16ToBytes(input.length, true);
return [...lengthBytes, ...input];
},
longToByteArray: function (input) {
longToByteArray(input) {
if (typeof input !== 'number') {
throw new Error('Numeric input is expected');
}
var bytes = new Array(7);
for (var k = 7; k >= 0; k--) {
const bytes = new Array(7);
for (let k = 7; k >= 0; k--) {
bytes[k] = input & (255);

@@ -72,13 +65,13 @@ input = input / 256;

},
bigNumberToByteArray: function (input) {
if (!(input instanceof data_entities_1.BigNumber)) {
bigNumberToByteArray(input) {
if (!(input.constructor && input.constructor.name === 'BigNumber')) {
throw new Error('BigNumber input is expected');
}
var isMinus = input.lt(new data_entities_1.BigNumber(0));
var performBitwiseAnd255 = performBitwiseAnd.bind(null, new data_entities_1.BigNumber(255));
const isMinus = input.lt(new data_entities_1.BigNumber(0));
const performBitwiseAnd255 = performBitwiseAnd.bind(null, new data_entities_1.BigNumber(255));
if (isMinus) {
input = input.plus(1, 10);
}
var bytes = new Array(8);
for (var k = 7; k >= 0; k--) {
const bytes = new Array(8);
for (let k = 7; k >= 0; k--) {
bytes[k] = performBitwiseAnd255(input);

@@ -92,3 +85,3 @@ if (isMinus) {

},
stringToByteArray: function (input) {
stringToByteArray(input) {
if (typeof input !== 'string') {

@@ -99,9 +92,8 @@ throw new Error('String input is expected');

},
stringToByteArrayWithSize: function (input, maxLengthBytesCount) {
if (maxLengthBytesCount === void 0) { maxLengthBytesCount = 2; }
stringToByteArrayWithSize(input, maxLengthBytesCount = 2) {
if (typeof input !== 'string') {
throw new Error('String input is expected ' + input);
}
var stringBytes = converters_1.default.stringToByteArray(input);
var lengthBytes;
const stringBytes = converters_1.default.stringToByteArray(input);
let lengthBytes;
switch (maxLengthBytesCount) {

@@ -115,5 +107,5 @@ // binary and string data entries of docker create tx have 4 bytes length

}
return __spreadArrays(lengthBytes, stringBytes);
return [...lengthBytes, ...stringBytes];
}
};
//# sourceMappingURL=convert.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CryptoJS = require("crypto-js");
var axlsign_1 = require("../libs/axlsign");
var base58_1 = require("../libs/base58");
var blake = require("../libs/blake2b");
var converters_1 = require("../libs/converters");
var secure_random_1 = require("../libs/secure-random");
var sha3_1 = require("../libs/sha3");
var concat_1 = require("./concat");
var __1 = require("../");
var constants_1 = require("../constants");
const CryptoJS = require("crypto-js");
const axlsign_1 = require("../libs/axlsign");
const base58_1 = require("../libs/base58");
const blake = require("../libs/blake2b");
const converters_1 = require("../libs/converters");
const secure_random_1 = require("../libs/secure-random");
const sha3_1 = require("../libs/sha3");
const concat_1 = require("./concat");
const __1 = require("../");
const constants_1 = require("../constants");
function sha256(input) {
var bytes;
let bytes;
if (typeof input === 'string') {

@@ -21,4 +21,4 @@ bytes = converters_1.default.stringToByteArray(input);

}
var wordArray = converters_1.default.byteArrayToWordArrayEx(Uint8Array.from(bytes));
var resultWordArray = CryptoJS.SHA256(wordArray);
const wordArray = converters_1.default.byteArrayToWordArrayEx(Uint8Array.from(bytes));
const resultWordArray = CryptoJS.SHA256(wordArray);
return converters_1.default.wordArrayToByteArrayEx(resultWordArray);

@@ -36,9 +36,8 @@ }

function buildSeedHash(seedBytes) {
var nonce = new Uint8Array(converters_1.default.int32ToBytes(constants_1.INITIAL_NONCE, true));
var seedBytesWithNonce = concat_1.concatUint8Arrays(nonce, seedBytes);
var seedHash = hashChain(seedBytesWithNonce);
const nonce = new Uint8Array(converters_1.default.int32ToBytes(constants_1.INITIAL_NONCE, true));
const seedBytesWithNonce = concat_1.concatUint8Arrays(nonce, seedBytes);
const seedHash = hashChain(seedBytesWithNonce);
return sha256(seedHash);
}
function strengthenPassword(password, rounds) {
if (rounds === void 0) { rounds = 5000; }
function strengthenPassword(password, rounds = 5000) {
while (rounds--)

@@ -49,3 +48,3 @@ password = converters_1.default.byteArrayToHexString(sha256(password));

exports.default = {
buildTransactionSignature: function (dataBytes, privateKey) {
buildTransactionSignature(dataBytes, privateKey) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {

@@ -57,10 +56,10 @@ throw new Error('Missing or invalid data');

}
var privateKeyBytes = base58_1.default.decode(privateKey);
const privateKeyBytes = base58_1.default.decode(privateKey);
if (privateKeyBytes.length !== constants_1.PRIVATE_KEY_LENGTH) {
throw new Error('Invalid public key');
}
var signature = axlsign_1.default.sign(privateKeyBytes, dataBytes, secure_random_1.default.randomUint8Array(64));
const signature = axlsign_1.default.sign(privateKeyBytes, dataBytes, secure_random_1.default.randomUint8Array(64));
return base58_1.default.encode(signature);
},
isValidSignature: function (dataBytes, signature, publicKey) {
isValidSignature(dataBytes, signature, publicKey) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {

@@ -75,4 +74,4 @@ throw new Error('Missing or invalid data');

}
var signatureBytes = base58_1.default.decode(signature);
var publicKeyBytes = base58_1.default.decode(publicKey);
const signatureBytes = base58_1.default.decode(signature);
const publicKeyBytes = base58_1.default.decode(publicKey);
if (publicKeyBytes.length !== constants_1.PUBLIC_KEY_LENGTH) {

@@ -83,16 +82,16 @@ throw new Error('Invalid public key');

},
buildTransactionId: function (dataBytes) {
buildTransactionId(dataBytes) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {
throw new Error('Missing or invalid data');
}
var hash = blake2b(dataBytes);
const hash = blake2b(dataBytes);
return base58_1.default.encode(hash);
},
buildKeyPair: function (seed) {
buildKeyPair(seed) {
if (!seed || typeof seed !== 'string') {
throw new Error('Missing or invalid seed phrase');
}
var seedBytes = Uint8Array.from(converters_1.default.stringToByteArray(seed));
var seedHash = buildSeedHash(seedBytes);
var keys = axlsign_1.default.generateKeyPair(seedHash);
const seedBytes = Uint8Array.from(converters_1.default.stringToByteArray(seed));
const seedHash = buildSeedHash(seedBytes);
const keys = axlsign_1.default.generateKeyPair(seedHash);
return {

@@ -103,14 +102,14 @@ privateKey: keys.private,

},
isValidAddress: function (address) {
isValidAddress(address) {
if (!address || typeof address !== 'string') {
throw new Error('Missing or invalid address');
}
var addressBytes = base58_1.default.decode(address);
const addressBytes = base58_1.default.decode(address);
if (addressBytes[0] !== 1 || addressBytes[1] !== __1.config.getNetworkByte()) {
return false;
}
var key = addressBytes.slice(0, 22);
var check = addressBytes.slice(22, 26);
var keyHash = hashChain(key).slice(0, 4);
for (var i = 0; i < 4; i++) {
const key = addressBytes.slice(0, 22);
const check = addressBytes.slice(22, 26);
const keyHash = hashChain(key).slice(0, 4);
for (let i = 0; i < 4; i++) {
if (check[i] !== keyHash[i]) {

@@ -122,13 +121,13 @@ return false;

},
buildRawAddress: function (publicKeyBytes) {
buildRawAddress(publicKeyBytes) {
if (!publicKeyBytes || publicKeyBytes.length !== constants_1.PUBLIC_KEY_LENGTH || !(publicKeyBytes instanceof Uint8Array)) {
throw new Error('Missing or invalid public key');
}
var prefix = Uint8Array.from([constants_1.ADDRESS_VERSION, __1.config.getNetworkByte()]);
var publicKeyHashPart = Uint8Array.from(hashChain(publicKeyBytes).slice(0, 20));
var rawAddress = concat_1.concatUint8Arrays(prefix, publicKeyHashPart);
var addressHash = Uint8Array.from(hashChain(rawAddress).slice(0, 4));
const prefix = Uint8Array.from([constants_1.ADDRESS_VERSION, __1.config.getNetworkByte()]);
const publicKeyHashPart = Uint8Array.from(hashChain(publicKeyBytes).slice(0, 20));
const rawAddress = concat_1.concatUint8Arrays(prefix, publicKeyHashPart);
const addressHash = Uint8Array.from(hashChain(rawAddress).slice(0, 4));
return base58_1.default.encode(concat_1.concatUint8Arrays(rawAddress, addressHash));
},
encryptSeed: function (seed, password, encryptionRounds) {
encryptSeed(seed, password, encryptionRounds) {
if (!seed || typeof seed !== 'string') {

@@ -143,3 +142,3 @@ throw new Error('Seed is required');

},
decryptSeed: function (encryptedSeed, password, encryptionRounds) {
decryptSeed(encryptedSeed, password, encryptionRounds) {
if (!encryptedSeed || typeof encryptedSeed !== 'string') {

@@ -152,15 +151,15 @@ throw new Error('Encrypted seed is required');

password = strengthenPassword(password, encryptionRounds);
var hexSeed = CryptoJS.AES.decrypt(encryptedSeed, password);
const hexSeed = CryptoJS.AES.decrypt(encryptedSeed, password);
return converters_1.default.hexStringToString(hexSeed.toString());
},
generateRandomUint32Array: function (length) {
generateRandomUint32Array(length) {
if (!length || length < 0) {
throw new Error('Missing or invalid array length');
}
var a = secure_random_1.default.randomUint8Array(length);
var b = secure_random_1.default.randomUint8Array(length);
var result = new Uint32Array(length);
for (var i = 0; i < length; i++) {
var hash = converters_1.default.byteArrayToHexString(sha256("" + a[i] + b[i]));
var randomValue = parseInt(hash.slice(0, 13), 16);
const a = secure_random_1.default.randomUint8Array(length);
const b = secure_random_1.default.randomUint8Array(length);
const result = new Uint32Array(length);
for (let i = 0; i < length; i++) {
const hash = converters_1.default.byteArrayToHexString(sha256(`${a[i]}${b[i]}`));
const randomValue = parseInt(hash.slice(0, 13), 16);
result.set([randomValue], i);

@@ -167,0 +166,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var base58_1 = require("../libs/base58");
var converters_1 = require("../libs/converters");
var secure_random_1 = require("../libs/secure-random");
var concat_1 = require("./concat");
var __1 = require("../");
var constants_1 = require("../constants");
var gost_1 = require("../libs/gost");
const base58_1 = require("../libs/base58");
const converters_1 = require("../libs/converters");
const secure_random_1 = require("../libs/secure-random");
const concat_1 = require("./concat");
const __1 = require("../");
const constants_1 = require("../constants");
const gost_1 = require("../libs/gost");
function buildSeedHash(seedBytes) {
var nonce = new Uint8Array(converters_1.default.int32ToBytes(constants_1.INITIAL_NONCE, true));
var seedBytesWithNonce = concat_1.concatUint8Arrays(nonce, seedBytes);
const nonce = new Uint8Array(converters_1.default.int32ToBytes(constants_1.INITIAL_NONCE, true));
const seedBytesWithNonce = concat_1.concatUint8Arrays(nonce, seedBytes);
return gost_1.default.streebog256(seedBytesWithNonce);
}
exports.default = {
buildTransactionSignature: function (dataBytes, privateKey) {
buildTransactionSignature(dataBytes, privateKey) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {

@@ -23,7 +23,7 @@ throw new Error('Missing or invalid data');

}
var privateKeyBytes = base58_1.default.decode(privateKey);
var signature = gost_1.default.sign(privateKeyBytes, dataBytes);
const privateKeyBytes = base58_1.default.decode(privateKey);
const signature = gost_1.default.sign(privateKeyBytes, dataBytes);
return base58_1.default.encode(signature);
},
verifySignature: function (publicKey, signature, dataBytes) {
verifySignature(publicKey, signature, dataBytes) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {

@@ -35,39 +35,39 @@ throw new Error('Missing or invalid data');

}
var publicKeyBytes = base58_1.default.decode(publicKey);
var signatureBytes = base58_1.default.decode(signature);
const publicKeyBytes = base58_1.default.decode(publicKey);
const signatureBytes = base58_1.default.decode(signature);
return gost_1.default.verify(publicKeyBytes, signatureBytes, dataBytes);
},
buildTransactionId: function (dataBytes) {
buildTransactionId(dataBytes) {
if (!dataBytes || !(dataBytes instanceof Uint8Array)) {
throw new Error('Missing or invalid data');
}
var hash = gost_1.default.streebog256(dataBytes);
const hash = gost_1.default.streebog256(dataBytes);
return base58_1.default.encode(hash);
},
buildKeyPair: function (seed) {
buildKeyPair(seed) {
if (!seed || typeof seed !== 'string') {
throw new Error('Missing or invalid seed phrase');
}
var seedBytes = Uint8Array.from(converters_1.default.stringToByteArray(seed));
var seedHash = buildSeedHash(seedBytes);
var keys = gost_1.default.generateKey(seedHash);
var publicKey = new Uint8Array(keys.publicKey);
var privateKey = new Uint8Array(keys.privateKey);
const seedBytes = Uint8Array.from(converters_1.default.stringToByteArray(seed));
const seedHash = buildSeedHash(seedBytes);
const keys = gost_1.default.generateKey(seedHash);
const publicKey = new Uint8Array(keys.publicKey);
const privateKey = new Uint8Array(keys.privateKey);
return {
publicKey: publicKey,
privateKey: privateKey
publicKey,
privateKey
};
},
isValidAddress: function (address) {
isValidAddress(address) {
if (!address || typeof address !== 'string') {
throw new Error('Missing or invalid address');
}
var addressBytes = base58_1.default.decode(address);
const addressBytes = base58_1.default.decode(address);
if (addressBytes[0] !== 1 || addressBytes[1] !== __1.config.getNetworkByte()) {
return false;
}
var key = addressBytes.slice(0, 22);
var check = addressBytes.slice(22, 26);
var keyHash = gost_1.default.streebog256(key).slice(0, 4);
for (var i = 0; i < 4; i++) {
const key = addressBytes.slice(0, 22);
const check = addressBytes.slice(22, 26);
const keyHash = gost_1.default.streebog256(key).slice(0, 4);
for (let i = 0; i < 4; i++) {
if (check[i] !== keyHash[i]) {

@@ -79,3 +79,3 @@ return false;

},
buildRawAddress: function (publicKeyBytes) {
buildRawAddress(publicKeyBytes) {
if (publicKeyBytes instanceof ArrayBuffer) {

@@ -87,9 +87,9 @@ publicKeyBytes = new Uint8Array(publicKeyBytes);

}
var prefix = Uint8Array.from([constants_1.ADDRESS_VERSION, __1.config.getNetworkByte()]);
var publicKeyHashPart = gost_1.default.streebog256(publicKeyBytes).slice(0, 20);
var rawAddress = concat_1.concatUint8Arrays(prefix, publicKeyHashPart);
var addressHash = gost_1.default.streebog256(rawAddress).slice(0, 4);
const prefix = Uint8Array.from([constants_1.ADDRESS_VERSION, __1.config.getNetworkByte()]);
const publicKeyHashPart = gost_1.default.streebog256(publicKeyBytes).slice(0, 20);
const rawAddress = concat_1.concatUint8Arrays(prefix, publicKeyHashPart);
const addressHash = gost_1.default.streebog256(rawAddress).slice(0, 4);
return base58_1.default.encode(concat_1.concatUint8Arrays(rawAddress, addressHash));
},
encryptSeed: function (seed, password, address) {
encryptSeed(seed, password, address) {
if (!seed || typeof seed !== 'string') {

@@ -106,3 +106,3 @@ throw new Error('Seed is required');

},
decryptSeed: function (encryptedSeed, password, address) {
decryptSeed(encryptedSeed, password, address) {
if (!encryptedSeed || typeof encryptedSeed !== 'string') {

@@ -116,13 +116,13 @@ throw new Error('Encrypted seed is required');

},
generateRandomUint32Array: function (length) {
generateRandomUint32Array(length) {
if (!length || length < 0) {
throw new Error('Missing or invalid array length');
}
var a = secure_random_1.default.randomUint8Array(length);
var b = secure_random_1.default.randomUint8Array(length);
var result = new Uint32Array(length);
for (var i = 0; i < length; i++) {
var data = (gost_1.default.streebog256("" + a[i] + b[i]));
var hash = gost_1.default.encodeHex(data.buffer);
var randomValue = parseInt(hash.slice(0, 13), 16);
const a = secure_random_1.default.randomUint8Array(length);
const b = secure_random_1.default.randomUint8Array(length);
const result = new Uint32Array(length);
for (let i = 0; i < length; i++) {
const data = (gost_1.default.streebog256(`${a[i]}${b[i]}`));
const hash = gost_1.default.encodeHex(data.buffer);
const randomValue = parseInt(hash.slice(0, 13), 16);
result.set([randomValue], i);

@@ -129,0 +129,0 @@ }

{
"name": "@vostokplatform/signature-generator",
"version": "2.0.1",
"version": "2.0.2-NM",
"main": "dist/index.js",

@@ -28,3 +28,3 @@ "files": [

"build-partial": "node_modules/.bin/browserify dist/index.js -u @waves/data-entities --node -s wavesSignatureGenerator -o dist/signature-generator.partial.js",
"build": "npm run compile && npm run build-full && npm run build-partial && npm run uglify"
"build": "npm run compile && npm run build-full && npm run build-partial"
},

@@ -31,0 +31,0 @@ "devDependencies": {

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

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

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

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 too big to display

Sorry, the diff of this file is too big to display

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

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