Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vostokplatform/signature-generator

Package Overview
Dependencies
Maintainers
9
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 1.3.24 to 1.3.30

77

dist/byteProcessor/ByteProcessor.js

@@ -25,2 +25,3 @@ "use strict";

var constants_3 = require("../constants");
var converters_1 = require("../libs/converters");
// NOTE : Waves asset ID in blockchain transactions equals to an empty string

@@ -57,2 +58,16 @@ function blockchainifyAssetId(assetId) {

exports.Base58 = Base58;
var Base58WithLength = /** @class */ (function (_super) {
__extends(Base58WithLength, _super);
function Base58WithLength() {
return _super !== null && _super.apply(this, arguments) || this;
}
Base58WithLength.prototype.process = function (value) {
var bytes = Array.from(base58_1.default.decode(value));
var lengthBytes = converters_1.default.int16ToBytes(bytes.length, true);
var result = Uint8Array.from(lengthBytes.concat(bytes));
return Promise.resolve(result);
};
return Base58WithLength;
}(ByteProcessor));
exports.Base58WithLength = Base58WithLength;
var Base64 = /** @class */ (function (_super) {

@@ -63,3 +78,4 @@ __extends(Base64, _super);

}
Base64.prototype.process = function (value) {
Base64.prototype.process = function (value, byteLength) {
if (byteLength === void 0) { byteLength = 2; }
if (typeof value !== 'string')

@@ -71,3 +87,10 @@ throw new Error('You should pass a string to BinaryDataEntry constructor');

var bytes = Uint8Array.from(base64_js_1.toByteArray(b64));
var lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(bytes.length));
var lengthBytes;
if (byteLength === 4) {
lengthBytes = Uint8Array.from(converters_1.default.int32ToBytes(bytes.length, true));
}
else {
// 2 bytes for the length otherwise
lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(bytes.length));
}
return Promise.resolve(concat_1.concatUint8Arrays(lengthBytes, bytes));

@@ -412,2 +435,30 @@ };

exports.StringDataEntry = StringDataEntry;
var BinaryDockerParamEntry = /** @class */ (function (_super) {
__extends(BinaryDockerParamEntry, _super);
function BinaryDockerParamEntry() {
return _super !== null && _super.apply(this, arguments) || this;
}
BinaryDockerParamEntry.prototype.process = function (value) {
return Base64.prototype.process.call(this, value, 4).then(function (binaryBytes) {
var 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() {
return _super !== null && _super.apply(this, arguments) || this;
}
StringDockerParamEntry.prototype.process = function (value) {
return StringWithLength.prototype.process.call(this, value, 4).then(function (stringBytes) {
var typeByte = Uint8Array.from([STRING_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, stringBytes);
});
};
return StringDockerParamEntry;
}(ByteProcessor));
exports.StringDockerParamEntry = StringDockerParamEntry;
var DataEntries = /** @class */ (function (_super) {

@@ -468,12 +519,12 @@ __extends(DataEntries, _super);

return Promise.all(entries.map(function (entry) {
// for docker tx data entries string and binary types have 4 byte length
var byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4;
}
else {
byteLength = 2;
}
var prependKeyBytes = function (valueBytes) {
// for docker tx data entries string and binary types have 4 byte length
var byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4;
}
else {
byteLength = 2;
}
return StringWithLength.prototype.process.call(_this, entry.key, byteLength).then(function (keyBytes) {
return StringWithLength.prototype.process.call(_this, entry.key).then(function (keyBytes) {
return concat_1.concatUint8Arrays(keyBytes, valueBytes);

@@ -488,5 +539,5 @@ });

case 'binary':
return BinaryDataEntry.prototype.process.call(_this, entry.value).then(prependKeyBytes);
return BinaryDockerParamEntry.prototype.process.call(_this, entry.value).then(prependKeyBytes);
case 'string':
return StringDataEntry.prototype.process.call(_this, entry.value).then(prependKeyBytes);
return StringDockerParamEntry.prototype.process.call(_this, entry.value).then(prependKeyBytes);
default:

@@ -493,0 +544,0 @@ throw new Error("There is no data type \"" + entry.type + "\"");

@@ -37,2 +37,3 @@ "use strict";

decode: function (string) {
if (string === void 0) { string = ''; }
if (!string.length)

@@ -39,0 +40,0 @@ return new Uint8Array(0);

7

dist/signatureFactory/SignatureFactory.js

@@ -299,7 +299,6 @@ "use strict";

var DOCKER_CALL = generate([
103 /* DOCKER_CREATE */,
1 /* DOCKER_CREATE */,
104 /* DOCKER_CALL */,
1 /* DOCKER_CALL */,
new __1.Base58('senderPublicKey'),
new __1.Base58('authorPublicKey'),
new __1.StringWithLength('contractId'),
new __1.Base58WithLength('contractId'),
new __1.DockerCreateParamsEntries('params'),

@@ -306,0 +305,0 @@ new __1.Long('fee'),

@@ -91,3 +91,4 @@ "use strict";

break;
case 2: lengthBytes = converters_1.default.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
case 2:
lengthBytes = converters_1.default.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
}

@@ -94,0 +95,0 @@ return lengthBytes.concat(stringBytes);

{
"name": "@vostokplatform/signature-generator",
"version": "1.3.24",
"version": "1.3.30",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "files": [

@@ -12,2 +12,3 @@ "use strict";

const constants_3 = require("../constants");
const converters_1 = require("../libs/converters");
// NOTE : Waves asset ID in blockchain transactions equals to an empty string

@@ -38,4 +39,13 @@ function blockchainifyAssetId(assetId) {

exports.Base58 = Base58;
class Base58WithLength extends ByteProcessor {
process(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);
}
}
exports.Base58WithLength = Base58WithLength;
class Base64 extends ByteProcessor {
process(value) {
process(value, byteLength = 2) {
if (typeof value !== 'string')

@@ -47,3 +57,10 @@ throw new Error('You should pass a string to BinaryDataEntry constructor');

const bytes = Uint8Array.from(base64_js_1.toByteArray(b64));
const lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(bytes.length));
let lengthBytes;
if (byteLength === 4) {
lengthBytes = Uint8Array.from(converters_1.default.int32ToBytes(bytes.length, true));
}
else {
// 2 bytes for the length otherwise
lengthBytes = Uint8Array.from(convert_1.default.shortToByteArray(bytes.length));
}
return Promise.resolve(concat_1.concatUint8Arrays(lengthBytes, bytes));

@@ -286,2 +303,20 @@ }

exports.StringDataEntry = StringDataEntry;
class BinaryDockerParamEntry extends ByteProcessor {
process(value) {
return Base64.prototype.process.call(this, value, 4).then((binaryBytes) => {
const typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
return Promise.resolve(concat_1.concatUint8Arrays(typeByte, binaryBytes));
});
}
}
exports.BinaryDockerParamEntry = BinaryDockerParamEntry;
class StringDockerParamEntry extends ByteProcessor {
process(value) {
return StringWithLength.prototype.process.call(this, value, 4).then((stringBytes) => {
const typeByte = Uint8Array.from([STRING_DATA_TYPE]);
return concat_1.concatUint8Arrays(typeByte, stringBytes);
});
}
}
exports.StringDockerParamEntry = StringDockerParamEntry;
class DataEntries extends ByteProcessor {

@@ -331,12 +366,12 @@ process(entries) {

return Promise.all(entries.map((entry) => {
// for docker tx data entries string and binary types have 4 byte length
let byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4;
}
else {
byteLength = 2;
}
const prependKeyBytes = (valueBytes) => {
// for docker tx data entries string and binary types have 4 byte length
let byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4;
}
else {
byteLength = 2;
}
return StringWithLength.prototype.process.call(this, entry.key, byteLength).then((keyBytes) => {
return StringWithLength.prototype.process.call(this, entry.key).then((keyBytes) => {
return concat_1.concatUint8Arrays(keyBytes, valueBytes);

@@ -351,5 +386,5 @@ });

case 'binary':
return BinaryDataEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
return BinaryDockerParamEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
case 'string':
return StringDataEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
return StringDockerParamEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
default:

@@ -356,0 +391,0 @@ throw new Error(`There is no data type "${entry.type}"`);

@@ -15,2 +15,3 @@ import {BigNumber} from '@waves/data-entities';

} from '../constants';
import converters from "../libs/converters";

@@ -50,4 +51,16 @@ // NOTE : Waves asset ID in blockchain transactions equals to an empty string

export class Base58WithLength extends ByteProcessor {
public process(value: string) {
const bytes = Array.from(base58.decode(value));
const lengthBytes = converters.int16ToBytes(bytes.length, true);
const result = Uint8Array.from([...lengthBytes, ...bytes]);
return Promise.resolve(result);
}
}
export class Base64 extends ByteProcessor {
public process(value: string) {
public process(value: string, byteLength: number = 2) {
if (typeof value !== 'string') throw new Error('You should pass a string to BinaryDataEntry constructor');

@@ -57,3 +70,10 @@ if (value.slice(0, 7) !== 'base64:') throw new Error('Blob should be encoded in base64 and prefixed with "base64:"');

const bytes = Uint8Array.from(toByteArray(b64));
const lengthBytes = Uint8Array.from(convert.shortToByteArray(bytes.length));
let lengthBytes;
if (byteLength === 4) {
lengthBytes = Uint8Array.from(converters.int32ToBytes(bytes.length, true));
} else {
// 2 bytes for the length otherwise
lengthBytes = Uint8Array.from(convert.shortToByteArray(bytes.length));
}
return Promise.resolve(concatUint8Arrays(lengthBytes, bytes));

@@ -302,2 +322,20 @@ }

export class BinaryDockerParamEntry extends ByteProcessor {
public process(value: string) {
return Base64.prototype.process.call(this, value, 4).then((binaryBytes) => {
const typeByte = Uint8Array.from([BINARY_DATA_TYPE]);
return Promise.resolve(concatUint8Arrays(typeByte, binaryBytes));
});
}
}
export class StringDockerParamEntry extends ByteProcessor {
public process(value: string) {
return StringWithLength.prototype.process.call(this, value, 4).then((stringBytes) => {
const typeByte = Uint8Array.from([STRING_DATA_TYPE]);
return concatUint8Arrays(typeByte, stringBytes);
});
}
}
export class DataEntries extends ByteProcessor {

@@ -341,2 +379,3 @@ public process(entries: any[]) {

* */
/* todo rename to DockerParamsEntries*/

@@ -348,13 +387,12 @@ export class DockerCreateParamsEntries extends ByteProcessor {

return Promise.all(entries.map((entry) => {
// for docker tx data entries string and binary types have 4 byte length
let byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4
} else {
byteLength = 2;
}
const prependKeyBytes = (valueBytes) => {
// for docker tx data entries string and binary types have 4 byte length
let byteLength;
if (entry.type === 'string' || entry.type === 'binary') {
byteLength = 4
} else {
byteLength = 2;
}
return StringWithLength.prototype.process.call(this, entry.key, byteLength).then((keyBytes) => {
return StringWithLength.prototype.process.call(this, entry.key).then((keyBytes) => {
return concatUint8Arrays(keyBytes, valueBytes);

@@ -370,5 +408,5 @@ });

case 'binary':
return BinaryDataEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
return BinaryDockerParamEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
case 'string':
return StringDataEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
return StringDockerParamEntry.prototype.process.call(this, entry.value).then(prependKeyBytes);
default:

@@ -375,0 +413,0 @@ throw new Error(`There is no data type "${entry.type}"`);

@@ -36,3 +36,3 @@ "use strict";

},
decode(string) {
decode(string = '') {
if (!string.length)

@@ -39,0 +39,0 @@ return new Uint8Array(0);

@@ -51,3 +51,3 @@ import { TBuffer } from '../interface';

decode(string): Uint8Array {
decode(string = ''): Uint8Array {

@@ -54,0 +54,0 @@ if (!string.length) return new Uint8Array(0);

@@ -294,7 +294,6 @@ "use strict";

const DOCKER_CALL = generate([
103 /* DOCKER_CREATE */,
1 /* DOCKER_CREATE */,
104 /* DOCKER_CALL */,
1 /* DOCKER_CALL */,
new __1.Base58('senderPublicKey'),
new __1.Base58('authorPublicKey'),
new __1.StringWithLength('contractId'),
new __1.Base58WithLength('contractId'),
new __1.DockerCreateParamsEntries('params'),

@@ -301,0 +300,0 @@ new __1.Long('fee'),

@@ -6,2 +6,3 @@ import {

Base58,
Base58WithLength,
Base64,

@@ -43,4 +44,4 @@ Bool,

import * as constants from '../constants';
import base58 from '../libs/base58';
export function generate<T>(fields: Array<ByteProcessor | number>): ISignatureGeneratorConstructor<T> {

@@ -377,7 +378,6 @@

const DOCKER_CALL = generate<IDOCKERCALL_PROPS>([
constants.TRANSACTION_TYPE_NUMBER.DOCKER_CREATE,
constants.TRANSACTION_TYPE_VERSION.DOCKER_CREATE,
constants.TRANSACTION_TYPE_NUMBER.DOCKER_CALL,
constants.TRANSACTION_TYPE_VERSION.DOCKER_CALL,
new Base58('senderPublicKey'),
new Base58('authorPublicKey'),
new StringWithLength('contractId'),
new Base58WithLength('contractId'),
new DockerCreateParamsEntries('params'),

@@ -384,0 +384,0 @@ new Long('fee'),

@@ -90,3 +90,4 @@ "use strict";

break;
case 2: lengthBytes = converters_1.default.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
case 2:
lengthBytes = converters_1.default.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
}

@@ -93,0 +94,0 @@ return [...lengthBytes, ...stringBytes];

@@ -114,3 +114,2 @@ import {TBuffer} from '../interface';

stringToByteArrayWithSize(input: string, maxLengthBytesCount = 2): number[] {
if (typeof input !== 'string') {

@@ -126,5 +125,7 @@ throw new Error('String input is expected');

// binary and string data entries of docker create tx have 4 bytes length
case 4: lengthBytes = converters.int32ToBytes(stringBytes.length, true);
break;
case 2: lengthBytes = converters.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
case 4:
lengthBytes = converters.int32ToBytes(stringBytes.length, true);
break;
case 2:
lengthBytes = converters.int16ToBytes(stringBytes.length, true); // 2 or anything but 4
}

@@ -131,0 +132,0 @@

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 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

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