Socket
Socket
Sign inDemoInstall

@taquito/utils

Package Overview
Dependencies
Maintainers
3
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/utils - npm Package Compare versions

Comparing version 12.0.3 to 12.1.0-beta-RC.0

25

dist/lib/constants.js

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

Prefix["TZ3"] = "tz3";
Prefix["TZ4"] = "tz4";
Prefix["KT"] = "KT";

@@ -38,2 +39,10 @@ Prefix["KT1"] = "KT1";

Prefix["VH"] = "vh";
//rollups
Prefix["TXR1"] = "txr1";
Prefix["TXI"] = "txi";
Prefix["TXM"] = "txm";
Prefix["TXC"] = "txc";
Prefix["TXMR"] = "txmr";
Prefix["TXRL"] = "txM";
Prefix["TXW"] = "txw";
})(Prefix = exports.Prefix || (exports.Prefix = {}));

@@ -44,2 +53,3 @@ exports.prefix = {

[Prefix.TZ3]: new Uint8Array([6, 161, 164]),
[Prefix.TZ4]: new Uint8Array([6, 161, 166]),
[Prefix.KT]: new Uint8Array([2, 90, 121]),

@@ -74,2 +84,9 @@ [Prefix.KT1]: new Uint8Array([2, 90, 121]),

[Prefix.VH]: new Uint8Array([1, 106, 242]),
[Prefix.TXR1]: new Uint8Array([1, 128, 120, 31]),
[Prefix.TXI]: new Uint8Array([79, 148, 196]),
[Prefix.TXM]: new Uint8Array([79, 149, 30]),
[Prefix.TXC]: new Uint8Array([79, 148, 17]),
[Prefix.TXMR]: new Uint8Array([18, 7, 206, 87]),
[Prefix.TXRL]: new Uint8Array([79, 146, 82]),
[Prefix.TXW]: new Uint8Array([79, 150, 72]),
};

@@ -80,2 +97,3 @@ exports.prefixLength = {

[Prefix.TZ3]: 20,
[Prefix.TZ4]: 20,
[Prefix.KT]: 20,

@@ -95,3 +113,10 @@ [Prefix.KT1]: 20,

[Prefix.VH]: 32,
[Prefix.TXR1]: 20,
[Prefix.TXI]: 32,
[Prefix.TXM]: 32,
[Prefix.TXC]: 32,
[Prefix.TXMR]: 32,
[Prefix.TXRL]: 32,
[Prefix.TXW]: 32,
};
//# sourceMappingURL=constants.js.map

165

dist/lib/errors.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidOperationHashError = exports.InvalidProtocolHashError = exports.InvalidBlockHashError = exports.InvalidKeyHashError = exports.InvalidAddressError = exports.InvalidContractAddressError = exports.InvalidMessageError = exports.InvalidSignatureError = exports.InvalidPublicKeyError = void 0;
exports.ValueConversionError = exports.ProhibitedActionError = exports.DeprecationError = exports.InvalidOperationKindError = exports.InvalidOperationHashError = exports.InvalidProtocolHashError = exports.InvalidBlockHashError = exports.InvalidKeyHashError = exports.InvalidChainIdError = exports.InvalidAddressError = exports.InvalidContractAddressError = exports.InvalidMessageError = exports.InvalidSignatureError = exports.InvalidPublicKeyError = exports.InvalidKeyError = void 0;
/**
* @category Error
* @description Error that indicates an invalid key being passed or used
*/
class InvalidKeyError extends Error {
constructor(key, errorDetail) {
super(`The key ${key} is invalid. ${errorDetail}`);
this.key = key;
this.errorDetail = errorDetail;
this.name = 'InvalidKeyError';
}
}
exports.InvalidKeyError = InvalidKeyError;
/**
* @category Error
* @description Error that indicates an Invalid Public Key being passed or used
*/
class InvalidPublicKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(publicKey, errorDetail) {
super(`The public key '${publicKey}' is invalid. ${errorDetail}`);
this.publicKey = publicKey;
this.name = 'InvalidPublicKeyError';

@@ -12,6 +29,10 @@ }

exports.InvalidPublicKeyError = InvalidPublicKeyError;
/**
* @category Error
* @description Error that indicates an invalid signature being passed or used
*/
class InvalidSignatureError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(signature, errorDetail) {
super(`The signature '${signature}' is invalid (${errorDetail})`);
this.signature = signature;
this.name = 'InvalidSignatureError';

@@ -21,6 +42,11 @@ }

exports.InvalidSignatureError = InvalidSignatureError;
/**
* @category Error
* @description Error that indicates an invalid message being passed or used
*/
class InvalidMessageError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(msg, errorDetail) {
super(`The message '${msg}' is invalid. ${errorDetail}`);
this.msg = msg;
this.errorDetail = errorDetail;
this.name = 'InvalidMessageError';

@@ -30,6 +56,10 @@ }

exports.InvalidMessageError = InvalidMessageError;
/**
* @category Error
* @description Error that indicates an invalid contract address being passed or used
*/
class InvalidContractAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(contractAddress) {
super(`The contract address '${contractAddress}' is invalid`);
this.contractAddress = contractAddress;
this.name = 'InvalidContractAddressError';

@@ -39,6 +69,10 @@ }

exports.InvalidContractAddressError = InvalidContractAddressError;
/**
* @category Error
* @description Error that indicates an invalid address being passed or used (both contract and implicit)
*/
class InvalidAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(address) {
super(`The address '${address}' is invalid`);
this.address = address;
this.name = 'InvalidAddressError';

@@ -48,6 +82,22 @@ }

exports.InvalidAddressError = InvalidAddressError;
/**
* @category Error
* @description Error that indicates an invalid chain id being passed or used
*/
class InvalidChainIdError extends Error {
constructor(chainId) {
super(`The chain id '${chainId}' is invalid`);
this.chainId = chainId;
this.name = 'InvalidChainIdError';
}
}
exports.InvalidChainIdError = InvalidChainIdError;
/**
* @category Error
* @description Error that indicates an invalid key hash being passed or used
*/
class InvalidKeyHashError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(keyHash) {
super(`The public key hash '${keyHash}' is invalid`);
this.keyHash = keyHash;
this.name = 'InvalidKeyHashError';

@@ -57,6 +107,9 @@ }

exports.InvalidKeyHashError = InvalidKeyHashError;
class InvalidBlockHashError extends Error {
constructor(message) {
super(message);
this.message = message;
/**
* @category Error
* @description Error that indicates an invalid block hash being passed or used
*/ class InvalidBlockHashError extends Error {
constructor(blockHash) {
super(`The block hash '${blockHash}' is invalid`);
this.blockHash = blockHash;
this.name = 'InvalidBlockHashError';

@@ -66,18 +119,74 @@ }

exports.InvalidBlockHashError = InvalidBlockHashError;
/**
* @category Error
* @description Error that indicates invalid protocol hash being passed or used
*/
class InvalidProtocolHashError extends Error {
constructor(protocolHash) {
super(`The protocol hash '${protocolHash}' is invalid`);
this.protocolHash = protocolHash;
this.name = 'InvalidProtocolHashError';
}
}
exports.InvalidProtocolHashError = InvalidProtocolHashError;
/**
* @category Error
* @description Error that indicates an invalid operation hash being passed or used
*/ class InvalidOperationHashError extends Error {
constructor(operationHash) {
super(`The operation hash '${operationHash}' is invalid`);
this.operationHash = operationHash;
this.name = 'InvalidOperationHashError';
}
}
exports.InvalidOperationHashError = InvalidOperationHashError;
/**
* @category Error
* @description Error that indicates an invalid operation kind being passed or used
*/
class InvalidOperationKindError extends Error {
constructor(operationKind) {
super(`The operation kind '${operationKind}' is unsupported`);
this.operationKind = operationKind;
this.name = 'InvalidOperationKindError';
}
}
exports.InvalidOperationKindError = InvalidOperationKindError;
/**
* @category Error
* @description General error that indicates something is no longer supported and/or deprecated
*/
class DeprecationError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidProtocolHashError';
this.name = 'DeprecationError';
}
}
exports.InvalidProtocolHashError = InvalidProtocolHashError;
class InvalidOperationHashError extends Error {
exports.DeprecationError = DeprecationError;
/**
* @category Error
* @description General error that indicates an action is prohibited or not allowed
*/
class ProhibitedActionError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidOperationHashError';
this.name = 'ProhibitedActionError';
}
}
exports.InvalidOperationHashError = InvalidOperationHashError;
exports.ProhibitedActionError = ProhibitedActionError;
/**
* @category Error
* @description General error that indicates a failure when trying to convert data from one type to another
*/
class ValueConversionError extends Error {
constructor(value, desiredType) {
super(`Unable to convert ${value} to a ${desiredType}`);
this.value = value;
this.desiredType = desiredType;
this.name = 'ValueConversionError';
}
}
exports.ValueConversionError = ValueConversionError;
//# sourceMappingURL=errors.js.map

3

dist/lib/taquito-utils.js

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

const bs58check_1 = require("bs58check");
const errors_1 = require("./errors");
__exportStar(require("./validators"), exports);

@@ -175,3 +176,3 @@ var version_1 = require("./version");

else {
throw new Error(`Unable to convert ${hex} to a Uint8Array`);
throw new errors_1.ValueConversionError(hex, 'Uint8Array');
}

@@ -178,0 +179,0 @@ };

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

}
const implicitPrefix = [constants_1.Prefix.TZ1, constants_1.Prefix.TZ2, constants_1.Prefix.TZ3];
const contractPrefix = [constants_1.Prefix.KT1];
const implicitPrefix = [constants_1.Prefix.TZ1, constants_1.Prefix.TZ2, constants_1.Prefix.TZ3, constants_1.Prefix.TZ4];
const contractPrefix = [constants_1.Prefix.KT1, constants_1.Prefix.TXR1];
const signaturePrefix = [constants_1.Prefix.EDSIG, constants_1.Prefix.P2SIG, constants_1.Prefix.SPSIG, constants_1.Prefix.SIG];

@@ -59,0 +59,0 @@ const pkPrefix = [constants_1.Prefix.EDPK, constants_1.Prefix.SPPK, constants_1.Prefix.P2PK];

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

if (message === '') {
throw new errors_1.InvalidMessageError(`The message provided for verifying signature cannot be empty.`);
throw new errors_1.InvalidMessageError(message, 'The message provided for verifying signature cannot be empty.');
}

@@ -58,3 +58,3 @@ return message;

if (publicKey === '') {
throw new errors_1.InvalidPublicKeyError(`The public key provided cannot be empty.`);
throw new errors_1.InvalidPublicKeyError(publicKey, 'Public key cannot be empty');
}

@@ -65,9 +65,9 @@ const pkPrefix = publicKey.substring(0, 4);

if (validation === taquito_utils_1.ValidationResult.INVALID_CHECKSUM) {
throw new errors_1.InvalidPublicKeyError(`The public key provided has an invalid checksum: ${publicKey}`);
throw new errors_1.InvalidPublicKeyError(publicKey, 'The public key provided has an invalid checksum');
}
else if (validation === taquito_utils_1.ValidationResult.INVALID_LENGTH) {
throw new errors_1.InvalidPublicKeyError(`The public key provided has an invalid length: ${publicKey}`);
throw new errors_1.InvalidPublicKeyError(publicKey, 'The public key provided has an invalid length');
}
else if (validation === taquito_utils_1.ValidationResult.NO_PREFIX_MATCHED) {
throw new errors_1.InvalidPublicKeyError(`The public key provided has an unsupported prefix: ${pkPrefix}`);
throw new errors_1.InvalidPublicKeyError(publicKey, `The public key provided has an unsupported prefix: ${pkPrefix}`);
}

@@ -79,13 +79,15 @@ }

function validateSigAndExtractPrefix(signature) {
const signaturePrefix = signature.startsWith('sig') ? signature.substr(0, 3) : signature.substr(0, 5);
const signaturePrefix = signature.startsWith('sig')
? signature.substr(0, 3)
: signature.substr(0, 5);
const validation = taquito_utils_1.validateSignature(signature);
if (validation !== taquito_utils_1.ValidationResult.VALID) {
if (validation === taquito_utils_1.ValidationResult.INVALID_CHECKSUM) {
throw new errors_1.InvalidSignatureError(`The signature provided has an invalid checksum: ${signature}`);
throw new errors_1.InvalidSignatureError(signature, `invalid checksum`);
}
else if (validation === taquito_utils_1.ValidationResult.INVALID_LENGTH) {
throw new errors_1.InvalidSignatureError(`The signature provided has an invalid length: ${signature}`);
throw new errors_1.InvalidSignatureError(signature, 'invalid length');
}
else if (validation === taquito_utils_1.ValidationResult.NO_PREFIX_MATCHED) {
throw new errors_1.InvalidSignatureError(`The signature provided has an unsupported prefix: ${signaturePrefix}`);
throw new errors_1.InvalidSignatureError(signaturePrefix, 'unsupported prefix');
}

@@ -92,0 +94,0 @@ }

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

exports.VERSION = {
"commitHash": "02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256",
"version": "12.0.3"
"commitHash": "e71912611826272f68d2bc1025eb8218417d28af",
"version": "12.1.0-beta-RC.0"
};
//# sourceMappingURL=version.js.map

@@ -14,2 +14,3 @@ import { Buffer } from 'buffer';

Prefix["TZ3"] = "tz3";
Prefix["TZ4"] = "tz4";
Prefix["KT"] = "KT";

@@ -43,2 +44,10 @@ Prefix["KT1"] = "KT1";

Prefix["VH"] = "vh";
//rollups
Prefix["TXR1"] = "txr1";
Prefix["TXI"] = "txi";
Prefix["TXM"] = "txm";
Prefix["TXC"] = "txc";
Prefix["TXMR"] = "txmr";
Prefix["TXRL"] = "txM";
Prefix["TXW"] = "txw";
})(Prefix || (Prefix = {}));

@@ -49,2 +58,3 @@ const prefix = {

[Prefix.TZ3]: new Uint8Array([6, 161, 164]),
[Prefix.TZ4]: new Uint8Array([6, 161, 166]),
[Prefix.KT]: new Uint8Array([2, 90, 121]),

@@ -79,2 +89,9 @@ [Prefix.KT1]: new Uint8Array([2, 90, 121]),

[Prefix.VH]: new Uint8Array([1, 106, 242]),
[Prefix.TXR1]: new Uint8Array([1, 128, 120, 31]),
[Prefix.TXI]: new Uint8Array([79, 148, 196]),
[Prefix.TXM]: new Uint8Array([79, 149, 30]),
[Prefix.TXC]: new Uint8Array([79, 148, 17]),
[Prefix.TXMR]: new Uint8Array([18, 7, 206, 87]),
[Prefix.TXRL]: new Uint8Array([79, 146, 82]),
[Prefix.TXW]: new Uint8Array([79, 150, 72]),
};

@@ -85,2 +102,3 @@ const prefixLength = {

[Prefix.TZ3]: 20,
[Prefix.TZ4]: 20,
[Prefix.KT]: 20,

@@ -100,67 +118,177 @@ [Prefix.KT1]: 20,

[Prefix.VH]: 32,
[Prefix.TXR1]: 20,
[Prefix.TXI]: 32,
[Prefix.TXM]: 32,
[Prefix.TXC]: 32,
[Prefix.TXMR]: 32,
[Prefix.TXRL]: 32,
[Prefix.TXW]: 32,
};
/**
* @category Error
* @description Error that indicates an invalid key being passed or used
*/
class InvalidKeyError extends Error {
constructor(key, errorDetail) {
super(`The key ${key} is invalid. ${errorDetail}`);
this.key = key;
this.errorDetail = errorDetail;
this.name = 'InvalidKeyError';
}
}
/**
* @category Error
* @description Error that indicates an Invalid Public Key being passed or used
*/
class InvalidPublicKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(publicKey, errorDetail) {
super(`The public key '${publicKey}' is invalid. ${errorDetail}`);
this.publicKey = publicKey;
this.name = 'InvalidPublicKeyError';
}
}
/**
* @category Error
* @description Error that indicates an invalid signature being passed or used
*/
class InvalidSignatureError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(signature, errorDetail) {
super(`The signature '${signature}' is invalid (${errorDetail})`);
this.signature = signature;
this.name = 'InvalidSignatureError';
}
}
/**
* @category Error
* @description Error that indicates an invalid message being passed or used
*/
class InvalidMessageError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(msg, errorDetail) {
super(`The message '${msg}' is invalid. ${errorDetail}`);
this.msg = msg;
this.errorDetail = errorDetail;
this.name = 'InvalidMessageError';
}
}
/**
* @category Error
* @description Error that indicates an invalid contract address being passed or used
*/
class InvalidContractAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(contractAddress) {
super(`The contract address '${contractAddress}' is invalid`);
this.contractAddress = contractAddress;
this.name = 'InvalidContractAddressError';
}
}
/**
* @category Error
* @description Error that indicates an invalid address being passed or used (both contract and implicit)
*/
class InvalidAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(address) {
super(`The address '${address}' is invalid`);
this.address = address;
this.name = 'InvalidAddressError';
}
}
/**
* @category Error
* @description Error that indicates an invalid chain id being passed or used
*/
class InvalidChainIdError extends Error {
constructor(chainId) {
super(`The chain id '${chainId}' is invalid`);
this.chainId = chainId;
this.name = 'InvalidChainIdError';
}
}
/**
* @category Error
* @description Error that indicates an invalid key hash being passed or used
*/
class InvalidKeyHashError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(keyHash) {
super(`The public key hash '${keyHash}' is invalid`);
this.keyHash = keyHash;
this.name = 'InvalidKeyHashError';
}
}
class InvalidBlockHashError extends Error {
constructor(message) {
super(message);
this.message = message;
/**
* @category Error
* @description Error that indicates an invalid block hash being passed or used
*/ class InvalidBlockHashError extends Error {
constructor(blockHash) {
super(`The block hash '${blockHash}' is invalid`);
this.blockHash = blockHash;
this.name = 'InvalidBlockHashError';
}
}
/**
* @category Error
* @description Error that indicates invalid protocol hash being passed or used
*/
class InvalidProtocolHashError extends Error {
constructor(protocolHash) {
super(`The protocol hash '${protocolHash}' is invalid`);
this.protocolHash = protocolHash;
this.name = 'InvalidProtocolHashError';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation hash being passed or used
*/ class InvalidOperationHashError extends Error {
constructor(operationHash) {
super(`The operation hash '${operationHash}' is invalid`);
this.operationHash = operationHash;
this.name = 'InvalidOperationHashError';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation kind being passed or used
*/
class InvalidOperationKindError extends Error {
constructor(operationKind) {
super(`The operation kind '${operationKind}' is unsupported`);
this.operationKind = operationKind;
this.name = 'InvalidOperationKindError';
}
}
/**
* @category Error
* @description General error that indicates something is no longer supported and/or deprecated
*/
class DeprecationError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidProtocolHashError';
this.name = 'DeprecationError';
}
}
class InvalidOperationHashError extends Error {
/**
* @category Error
* @description General error that indicates an action is prohibited or not allowed
*/
class ProhibitedActionError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidOperationHashError';
this.name = 'ProhibitedActionError';
}
}
/**
* @category Error
* @description General error that indicates a failure when trying to convert data from one type to another
*/
class ValueConversionError extends Error {
constructor(value, desiredType) {
super(`Unable to convert ${value} to a ${desiredType}`);
this.value = value;
this.desiredType = desiredType;
this.name = 'ValueConversionError';
}
}

@@ -207,3 +335,3 @@ /**

if (message === '') {
throw new InvalidMessageError(`The message provided for verifying signature cannot be empty.`);
throw new InvalidMessageError(message, 'The message provided for verifying signature cannot be empty.');
}

@@ -214,3 +342,3 @@ return message;

if (publicKey === '') {
throw new InvalidPublicKeyError(`The public key provided cannot be empty.`);
throw new InvalidPublicKeyError(publicKey, 'Public key cannot be empty');
}

@@ -221,9 +349,9 @@ const pkPrefix = publicKey.substring(0, 4);

if (validation === ValidationResult.INVALID_CHECKSUM) {
throw new InvalidPublicKeyError(`The public key provided has an invalid checksum: ${publicKey}`);
throw new InvalidPublicKeyError(publicKey, 'The public key provided has an invalid checksum');
}
else if (validation === ValidationResult.INVALID_LENGTH) {
throw new InvalidPublicKeyError(`The public key provided has an invalid length: ${publicKey}`);
throw new InvalidPublicKeyError(publicKey, 'The public key provided has an invalid length');
}
else if (validation === ValidationResult.NO_PREFIX_MATCHED) {
throw new InvalidPublicKeyError(`The public key provided has an unsupported prefix: ${pkPrefix}`);
throw new InvalidPublicKeyError(publicKey, `The public key provided has an unsupported prefix: ${pkPrefix}`);
}

@@ -234,13 +362,15 @@ }

function validateSigAndExtractPrefix(signature) {
const signaturePrefix = signature.startsWith('sig') ? signature.substr(0, 3) : signature.substr(0, 5);
const signaturePrefix = signature.startsWith('sig')
? signature.substr(0, 3)
: signature.substr(0, 5);
const validation = validateSignature(signature);
if (validation !== ValidationResult.VALID) {
if (validation === ValidationResult.INVALID_CHECKSUM) {
throw new InvalidSignatureError(`The signature provided has an invalid checksum: ${signature}`);
throw new InvalidSignatureError(signature, `invalid checksum`);
}
else if (validation === ValidationResult.INVALID_LENGTH) {
throw new InvalidSignatureError(`The signature provided has an invalid length: ${signature}`);
throw new InvalidSignatureError(signature, 'invalid length');
}
else if (validation === ValidationResult.NO_PREFIX_MATCHED) {
throw new InvalidSignatureError(`The signature provided has an unsupported prefix: ${signaturePrefix}`);
throw new InvalidSignatureError(signaturePrefix, 'unsupported prefix');
}

@@ -329,4 +459,4 @@ }

}
const implicitPrefix = [Prefix.TZ1, Prefix.TZ2, Prefix.TZ3];
const contractPrefix = [Prefix.KT1];
const implicitPrefix = [Prefix.TZ1, Prefix.TZ2, Prefix.TZ3, Prefix.TZ4];
const contractPrefix = [Prefix.KT1, Prefix.TXR1];
const signaturePrefix = [Prefix.EDSIG, Prefix.P2SIG, Prefix.SPSIG, Prefix.SIG];

@@ -502,4 +632,4 @@ const pkPrefix = [Prefix.EDPK, Prefix.SPPK, Prefix.P2PK];

const VERSION = {
"commitHash": "02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256",
"version": "12.0.3"
"commitHash": "e71912611826272f68d2bc1025eb8218417d28af",
"version": "12.1.0-beta-RC.0"
};

@@ -637,3 +767,3 @@

else {
throw new Error(`Unable to convert ${hex} to a Uint8Array`);
throw new ValueConversionError(hex, 'Uint8Array');
}

@@ -775,3 +905,3 @@ };

export { InvalidAddressError, InvalidBlockHashError, InvalidContractAddressError, InvalidKeyHashError, InvalidMessageError, InvalidOperationHashError, InvalidProtocolHashError, InvalidPublicKeyError, InvalidSignatureError, Prefix, VERSION, ValidationResult, b58cdecode, b58cencode, b58decode, buf2hex, bytes2Char, char2Bytes, encodeExpr, encodeKey, encodeKeyHash, encodeOpHash, encodePubKey, getPkhfromPk, hex2buf, isValidPrefix, mergebuf, mic2arr, prefix, prefixLength, validateAddress, validateBlock, validateChain, validateContractAddress, validateKeyHash, validateOperation, validatePkAndExtractPrefix, validateProtocol, validatePublicKey, validateSignature, verifySignature };
export { DeprecationError, InvalidAddressError, InvalidBlockHashError, InvalidChainIdError, InvalidContractAddressError, InvalidKeyError, InvalidKeyHashError, InvalidMessageError, InvalidOperationHashError, InvalidOperationKindError, InvalidProtocolHashError, InvalidPublicKeyError, InvalidSignatureError, Prefix, ProhibitedActionError, VERSION, ValidationResult, ValueConversionError, b58cdecode, b58cencode, b58decode, buf2hex, bytes2Char, char2Bytes, encodeExpr, encodeKey, encodeKeyHash, encodeOpHash, encodePubKey, getPkhfromPk, hex2buf, isValidPrefix, mergebuf, mic2arr, prefix, prefixLength, validateAddress, validateBlock, validateChain, validateContractAddress, validateKeyHash, validateOperation, validatePkAndExtractPrefix, validateProtocol, validatePublicKey, validateSignature, verifySignature };
//# sourceMappingURL=taquito-utils.es6.js.map

@@ -19,2 +19,3 @@ (function (global, factory) {

Prefix["TZ3"] = "tz3";
Prefix["TZ4"] = "tz4";
Prefix["KT"] = "KT";

@@ -48,2 +49,10 @@ Prefix["KT1"] = "KT1";

Prefix["VH"] = "vh";
//rollups
Prefix["TXR1"] = "txr1";
Prefix["TXI"] = "txi";
Prefix["TXM"] = "txm";
Prefix["TXC"] = "txc";
Prefix["TXMR"] = "txmr";
Prefix["TXRL"] = "txM";
Prefix["TXW"] = "txw";
})(exports.Prefix || (exports.Prefix = {}));

@@ -54,2 +63,3 @@ const prefix = {

[exports.Prefix.TZ3]: new Uint8Array([6, 161, 164]),
[exports.Prefix.TZ4]: new Uint8Array([6, 161, 166]),
[exports.Prefix.KT]: new Uint8Array([2, 90, 121]),

@@ -84,2 +94,9 @@ [exports.Prefix.KT1]: new Uint8Array([2, 90, 121]),

[exports.Prefix.VH]: new Uint8Array([1, 106, 242]),
[exports.Prefix.TXR1]: new Uint8Array([1, 128, 120, 31]),
[exports.Prefix.TXI]: new Uint8Array([79, 148, 196]),
[exports.Prefix.TXM]: new Uint8Array([79, 149, 30]),
[exports.Prefix.TXC]: new Uint8Array([79, 148, 17]),
[exports.Prefix.TXMR]: new Uint8Array([18, 7, 206, 87]),
[exports.Prefix.TXRL]: new Uint8Array([79, 146, 82]),
[exports.Prefix.TXW]: new Uint8Array([79, 150, 72]),
};

@@ -90,2 +107,3 @@ const prefixLength = {

[exports.Prefix.TZ3]: 20,
[exports.Prefix.TZ4]: 20,
[exports.Prefix.KT]: 20,

@@ -105,67 +123,177 @@ [exports.Prefix.KT1]: 20,

[exports.Prefix.VH]: 32,
[exports.Prefix.TXR1]: 20,
[exports.Prefix.TXI]: 32,
[exports.Prefix.TXM]: 32,
[exports.Prefix.TXC]: 32,
[exports.Prefix.TXMR]: 32,
[exports.Prefix.TXRL]: 32,
[exports.Prefix.TXW]: 32,
};
/**
* @category Error
* @description Error that indicates an invalid key being passed or used
*/
class InvalidKeyError extends Error {
constructor(key, errorDetail) {
super(`The key ${key} is invalid. ${errorDetail}`);
this.key = key;
this.errorDetail = errorDetail;
this.name = 'InvalidKeyError';
}
}
/**
* @category Error
* @description Error that indicates an Invalid Public Key being passed or used
*/
class InvalidPublicKeyError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(publicKey, errorDetail) {
super(`The public key '${publicKey}' is invalid. ${errorDetail}`);
this.publicKey = publicKey;
this.name = 'InvalidPublicKeyError';
}
}
/**
* @category Error
* @description Error that indicates an invalid signature being passed or used
*/
class InvalidSignatureError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(signature, errorDetail) {
super(`The signature '${signature}' is invalid (${errorDetail})`);
this.signature = signature;
this.name = 'InvalidSignatureError';
}
}
/**
* @category Error
* @description Error that indicates an invalid message being passed or used
*/
class InvalidMessageError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(msg, errorDetail) {
super(`The message '${msg}' is invalid. ${errorDetail}`);
this.msg = msg;
this.errorDetail = errorDetail;
this.name = 'InvalidMessageError';
}
}
/**
* @category Error
* @description Error that indicates an invalid contract address being passed or used
*/
class InvalidContractAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(contractAddress) {
super(`The contract address '${contractAddress}' is invalid`);
this.contractAddress = contractAddress;
this.name = 'InvalidContractAddressError';
}
}
/**
* @category Error
* @description Error that indicates an invalid address being passed or used (both contract and implicit)
*/
class InvalidAddressError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(address) {
super(`The address '${address}' is invalid`);
this.address = address;
this.name = 'InvalidAddressError';
}
}
/**
* @category Error
* @description Error that indicates an invalid chain id being passed or used
*/
class InvalidChainIdError extends Error {
constructor(chainId) {
super(`The chain id '${chainId}' is invalid`);
this.chainId = chainId;
this.name = 'InvalidChainIdError';
}
}
/**
* @category Error
* @description Error that indicates an invalid key hash being passed or used
*/
class InvalidKeyHashError extends Error {
constructor(message) {
super(message);
this.message = message;
constructor(keyHash) {
super(`The public key hash '${keyHash}' is invalid`);
this.keyHash = keyHash;
this.name = 'InvalidKeyHashError';
}
}
class InvalidBlockHashError extends Error {
constructor(message) {
super(message);
this.message = message;
/**
* @category Error
* @description Error that indicates an invalid block hash being passed or used
*/ class InvalidBlockHashError extends Error {
constructor(blockHash) {
super(`The block hash '${blockHash}' is invalid`);
this.blockHash = blockHash;
this.name = 'InvalidBlockHashError';
}
}
/**
* @category Error
* @description Error that indicates invalid protocol hash being passed or used
*/
class InvalidProtocolHashError extends Error {
constructor(protocolHash) {
super(`The protocol hash '${protocolHash}' is invalid`);
this.protocolHash = protocolHash;
this.name = 'InvalidProtocolHashError';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation hash being passed or used
*/ class InvalidOperationHashError extends Error {
constructor(operationHash) {
super(`The operation hash '${operationHash}' is invalid`);
this.operationHash = operationHash;
this.name = 'InvalidOperationHashError';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation kind being passed or used
*/
class InvalidOperationKindError extends Error {
constructor(operationKind) {
super(`The operation kind '${operationKind}' is unsupported`);
this.operationKind = operationKind;
this.name = 'InvalidOperationKindError';
}
}
/**
* @category Error
* @description General error that indicates something is no longer supported and/or deprecated
*/
class DeprecationError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidProtocolHashError';
this.name = 'DeprecationError';
}
}
class InvalidOperationHashError extends Error {
/**
* @category Error
* @description General error that indicates an action is prohibited or not allowed
*/
class ProhibitedActionError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidOperationHashError';
this.name = 'ProhibitedActionError';
}
}
/**
* @category Error
* @description General error that indicates a failure when trying to convert data from one type to another
*/
class ValueConversionError extends Error {
constructor(value, desiredType) {
super(`Unable to convert ${value} to a ${desiredType}`);
this.value = value;
this.desiredType = desiredType;
this.name = 'ValueConversionError';
}
}

@@ -212,3 +340,3 @@ /**

if (message === '') {
throw new InvalidMessageError(`The message provided for verifying signature cannot be empty.`);
throw new InvalidMessageError(message, 'The message provided for verifying signature cannot be empty.');
}

@@ -219,3 +347,3 @@ return message;

if (publicKey === '') {
throw new InvalidPublicKeyError(`The public key provided cannot be empty.`);
throw new InvalidPublicKeyError(publicKey, 'Public key cannot be empty');
}

@@ -226,9 +354,9 @@ const pkPrefix = publicKey.substring(0, 4);

if (validation === exports.ValidationResult.INVALID_CHECKSUM) {
throw new InvalidPublicKeyError(`The public key provided has an invalid checksum: ${publicKey}`);
throw new InvalidPublicKeyError(publicKey, 'The public key provided has an invalid checksum');
}
else if (validation === exports.ValidationResult.INVALID_LENGTH) {
throw new InvalidPublicKeyError(`The public key provided has an invalid length: ${publicKey}`);
throw new InvalidPublicKeyError(publicKey, 'The public key provided has an invalid length');
}
else if (validation === exports.ValidationResult.NO_PREFIX_MATCHED) {
throw new InvalidPublicKeyError(`The public key provided has an unsupported prefix: ${pkPrefix}`);
throw new InvalidPublicKeyError(publicKey, `The public key provided has an unsupported prefix: ${pkPrefix}`);
}

@@ -239,13 +367,15 @@ }

function validateSigAndExtractPrefix(signature) {
const signaturePrefix = signature.startsWith('sig') ? signature.substr(0, 3) : signature.substr(0, 5);
const signaturePrefix = signature.startsWith('sig')
? signature.substr(0, 3)
: signature.substr(0, 5);
const validation = validateSignature(signature);
if (validation !== exports.ValidationResult.VALID) {
if (validation === exports.ValidationResult.INVALID_CHECKSUM) {
throw new InvalidSignatureError(`The signature provided has an invalid checksum: ${signature}`);
throw new InvalidSignatureError(signature, `invalid checksum`);
}
else if (validation === exports.ValidationResult.INVALID_LENGTH) {
throw new InvalidSignatureError(`The signature provided has an invalid length: ${signature}`);
throw new InvalidSignatureError(signature, 'invalid length');
}
else if (validation === exports.ValidationResult.NO_PREFIX_MATCHED) {
throw new InvalidSignatureError(`The signature provided has an unsupported prefix: ${signaturePrefix}`);
throw new InvalidSignatureError(signaturePrefix, 'unsupported prefix');
}

@@ -334,4 +464,4 @@ }

}
const implicitPrefix = [exports.Prefix.TZ1, exports.Prefix.TZ2, exports.Prefix.TZ3];
const contractPrefix = [exports.Prefix.KT1];
const implicitPrefix = [exports.Prefix.TZ1, exports.Prefix.TZ2, exports.Prefix.TZ3, exports.Prefix.TZ4];
const contractPrefix = [exports.Prefix.KT1, exports.Prefix.TXR1];
const signaturePrefix = [exports.Prefix.EDSIG, exports.Prefix.P2SIG, exports.Prefix.SPSIG, exports.Prefix.SIG];

@@ -507,4 +637,4 @@ const pkPrefix = [exports.Prefix.EDPK, exports.Prefix.SPPK, exports.Prefix.P2PK];

const VERSION = {
"commitHash": "02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256",
"version": "12.0.3"
"commitHash": "e71912611826272f68d2bc1025eb8218417d28af",
"version": "12.1.0-beta-RC.0"
};

@@ -642,3 +772,3 @@

else {
throw new Error(`Unable to convert ${hex} to a Uint8Array`);
throw new ValueConversionError(hex, 'Uint8Array');
}

@@ -780,12 +910,18 @@ };

exports.DeprecationError = DeprecationError;
exports.InvalidAddressError = InvalidAddressError;
exports.InvalidBlockHashError = InvalidBlockHashError;
exports.InvalidChainIdError = InvalidChainIdError;
exports.InvalidContractAddressError = InvalidContractAddressError;
exports.InvalidKeyError = InvalidKeyError;
exports.InvalidKeyHashError = InvalidKeyHashError;
exports.InvalidMessageError = InvalidMessageError;
exports.InvalidOperationHashError = InvalidOperationHashError;
exports.InvalidOperationKindError = InvalidOperationKindError;
exports.InvalidProtocolHashError = InvalidProtocolHashError;
exports.InvalidPublicKeyError = InvalidPublicKeyError;
exports.InvalidSignatureError = InvalidSignatureError;
exports.ProhibitedActionError = ProhibitedActionError;
exports.VERSION = VERSION;
exports.ValueConversionError = ValueConversionError;
exports.b58cdecode = b58cdecode;

@@ -792,0 +928,0 @@ exports.b58cencode = b58cencode;

@@ -5,2 +5,3 @@ export declare enum Prefix {

TZ3 = "tz3",
TZ4 = "tz4",
KT = "KT",

@@ -33,3 +34,10 @@ KT1 = "KT1",

TZ = "TZ",
VH = "vh"
VH = "vh",
TXR1 = "txr1",
TXI = "txi",
TXM = "txm",
TXC = "txc",
TXMR = "txmr",
TXRL = "txM",
TXW = "txw"
}

@@ -40,2 +48,3 @@ export declare const prefix: {

tz3: Uint8Array;
tz4: Uint8Array;
KT: Uint8Array;

@@ -69,2 +78,9 @@ KT1: Uint8Array;

vh: Uint8Array;
txr1: Uint8Array;
txi: Uint8Array;
txm: Uint8Array;
txc: Uint8Array;
txmr: Uint8Array;
txM: Uint8Array;
txw: Uint8Array;
};

@@ -71,0 +87,0 @@ export declare const prefixLength: {

@@ -0,37 +1,114 @@

/**
* @category Error
* @description Error that indicates an invalid key being passed or used
*/
export declare class InvalidKeyError extends Error {
key: string;
errorDetail?: string | undefined;
name: string;
constructor(key: string, errorDetail?: string | undefined);
}
/**
* @category Error
* @description Error that indicates an Invalid Public Key being passed or used
*/
export declare class InvalidPublicKeyError extends Error {
message: string;
publicKey: string;
name: string;
constructor(message: string);
constructor(publicKey: string, errorDetail?: string);
}
/**
* @category Error
* @description Error that indicates an invalid signature being passed or used
*/
export declare class InvalidSignatureError extends Error {
message: string;
signature: string;
name: string;
constructor(message: string);
constructor(signature: string, errorDetail?: string);
}
/**
* @category Error
* @description Error that indicates an invalid message being passed or used
*/
export declare class InvalidMessageError extends Error {
message: string;
msg: string;
errorDetail?: string | undefined;
name: string;
constructor(message: string);
constructor(msg: string, errorDetail?: string | undefined);
}
/**
* @category Error
* @description Error that indicates an invalid contract address being passed or used
*/
export declare class InvalidContractAddressError extends Error {
message: string;
contractAddress: string;
name: string;
constructor(message: string);
constructor(contractAddress: string);
}
/**
* @category Error
* @description Error that indicates an invalid address being passed or used (both contract and implicit)
*/
export declare class InvalidAddressError extends Error {
message: string;
address: string;
name: string;
constructor(message: string);
constructor(address: string);
}
/**
* @category Error
* @description Error that indicates an invalid chain id being passed or used
*/
export declare class InvalidChainIdError extends Error {
chainId: string;
name: string;
constructor(chainId: string);
}
/**
* @category Error
* @description Error that indicates an invalid key hash being passed or used
*/
export declare class InvalidKeyHashError extends Error {
message: string;
keyHash: string;
name: string;
constructor(message: string);
constructor(keyHash: string);
}
export declare class InvalidBlockHashError extends Error {
message: string;
/**
* @category Error
* @description Error that indicates an invalid block hash being passed or used
*/ export declare class InvalidBlockHashError extends Error {
blockHash: string;
name: string;
constructor(message: string);
constructor(blockHash: string);
}
/**
* @category Error
* @description Error that indicates invalid protocol hash being passed or used
*/
export declare class InvalidProtocolHashError extends Error {
protocolHash: string;
name: string;
constructor(protocolHash: string);
}
/**
* @category Error
* @description Error that indicates an invalid operation hash being passed or used
*/ export declare class InvalidOperationHashError extends Error {
operationHash: string;
name: string;
constructor(operationHash: string);
}
/**
* @category Error
* @description Error that indicates an invalid operation kind being passed or used
*/
export declare class InvalidOperationKindError extends Error {
operationKind: string;
name: string;
constructor(operationKind: string);
}
/**
* @category Error
* @description General error that indicates something is no longer supported and/or deprecated
*/
export declare class DeprecationError extends Error {
message: string;

@@ -41,3 +118,7 @@ name: string;

}
export declare class InvalidOperationHashError extends Error {
/**
* @category Error
* @description General error that indicates an action is prohibited or not allowed
*/
export declare class ProhibitedActionError extends Error {
message: string;

@@ -47,1 +128,11 @@ name: string;

}
/**
* @category Error
* @description General error that indicates a failure when trying to convert data from one type to another
*/
export declare class ValueConversionError extends Error {
value: string;
desiredType: string;
name: string;
constructor(value: string, desiredType: string);
}
{
"name": "@taquito/utils",
"version": "12.0.3",
"version": "12.1.0-beta-RC.0",
"description": "converts michelson data and types into convenient JS/TS objects",

@@ -105,3 +105,3 @@ "keywords": [

},
"gitHead": "b8cd241cd9e19a15c487ab56a149e92ac3713ee9"
"gitHead": "db5a5a1ec2fb4e9881303bf1e178dbe859204695"
}

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

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