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

@taquito/utils

Package Overview
Dependencies
Maintainers
2
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 6.3.0-wallet.4 to 6.3.1-beta.0

1

dist/lib/constants.js
"use strict";
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.prefixLength = exports.prefix = exports.Prefix = void 0;
var Prefix;

@@ -5,0 +6,0 @@ (function (Prefix) {

56

dist/lib/taquito-utils.js

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

*/
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.buf2hex = exports.ml2mic = exports.mic2arr = exports.sexp2mic = exports.mergebuf = exports.hex2buf = exports.encodeKeyHash = exports.encodeKey = exports.encodePubKey = exports.b58decode = exports.b58cdecode = exports.b58cencode = exports.encodeExpr = void 0;
var buffer_1 = require("buffer");

@@ -16,7 +24,13 @@ var constants_1 = require("./constants");

var bs58check = require('bs58check');
__export(require("./validators"));
__exportStar(require("./validators"), exports);
var constants_2 = require("./constants");
exports.prefix = constants_2.prefix;
exports.Prefix = constants_2.Prefix;
exports.prefixLength = constants_2.prefixLength;
Object.defineProperty(exports, "prefix", { enumerable: true, get: function () { return constants_2.prefix; } });
Object.defineProperty(exports, "Prefix", { enumerable: true, get: function () { return constants_2.Prefix; } });
Object.defineProperty(exports, "prefixLength", { enumerable: true, get: function () { return constants_2.prefixLength; } });
/**
*
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
*
* @param value Value in hex
*/
function encodeExpr(value) {

@@ -96,2 +110,8 @@ var blakeHash = blake.blake2b(exports.hex2buf(value), null, 32);

exports.encodePubKey = encodePubKey;
/**
*
* @description Base58 encode a key according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKey(value) {

@@ -108,2 +128,8 @@ if (value[0] === '0') {

exports.encodeKey = encodeKey;
/**
*
* @description Base58 encode a key hash according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKeyHash(value) {

@@ -131,16 +157,2 @@ if (value[0] === '0') {

*
* @description Generate a random hex nonce
*
* @param length length of the nonce
*/
exports.hexNonce = function (length) {
var chars = '0123456789abcedf';
var hex = '';
while (length--) {
hex += chars[(Math.random() * 16) | 0];
}
return hex;
};
/**
*
* @description Merge 2 buffers together

@@ -290,3 +302,3 @@ *

*
* @description Convert a michelson string to it's json representation
* @description Convert a michelson string to its json representation
*

@@ -293,0 +305,0 @@ * @param mi Michelson string to convert to json

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePublicKey = exports.validateSignature = exports.validateKeyHash = exports.validateContractAddress = exports.validateChain = exports.validateAddress = exports.isValidPrefix = exports.ValidationResult = void 0;
var constants_1 = require("./constants");

@@ -40,2 +41,12 @@ var bs58check = require('bs58check');

exports.isValidPrefix = isValidPrefix;
/**
* @description This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
* Verify if the value has the right prefix or return `NO_PREFIX_MATCHED`,
* decode the value using base58 and return `INVALID_CHECKSUM` if it fails,
* check if the length of the value matches the prefix type or return `INVALID_LENGTH`.
* If all checks pass, return `VALID`.
*
* @param value Value to validate
* @param prefixes prefix the value should have
*/
function validatePrefixedValue(value, prefixes) {

@@ -65,2 +76,17 @@ var match = new RegExp("^(" + prefixes.join('|') + ")").exec(value);

var pkPrefix = [constants_1.Prefix.EDPK, constants_1.Prefix.SPPK, constants_1.Prefix.P2PK];
/**
* @description Used to check if an address or a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateAddress } from '@taquito/utils';
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateAddress(pkh)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateAddress(value) {

@@ -70,2 +96,17 @@ return validatePrefixedValue(value, __spread(implicitPrefix, contractPrefix));

exports.validateAddress = validateAddress;
/**
* @description Used to check if a chain id is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateChain } from '@taquito/utils';
* const chainId = 'NetXdQprcVkpaWU'
* const validation = validateChain(chainId)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateChain(value) {

@@ -75,2 +116,17 @@ return validatePrefixedValue(value, [constants_1.Prefix.NET]);

exports.validateChain = validateChain;
/**
* @description Used to check if a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateContractAddress } from '@taquito/utils';
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
* const validation = validateContractAddress(contractAddress)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateContractAddress(value) {

@@ -80,2 +136,17 @@ return validatePrefixedValue(value, contractPrefix);

exports.validateContractAddress = validateContractAddress;
/**
* @description Used to check if a key hash is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateKeyHash } from '@taquito/utils';
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateKeyHash(keyHashWithoutPrefix)
* console.log(validation)
* // This example return 0 which correspond to NO_PREFIX_MATCHED
* ```
*/
function validateKeyHash(value) {

@@ -85,2 +156,17 @@ return validatePrefixedValue(value, implicitPrefix);

exports.validateKeyHash = validateKeyHash;
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateSignature } from '@taquito/utils';
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validateSignature(signature)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateSignature(value) {

@@ -90,2 +176,17 @@ return validatePrefixedValue(value, signaturePrefix);

exports.validateSignature = validateSignature;
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validatePublicKey } from '@taquito/utils';
* const publicKey = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validatePublicKey(publicKey)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validatePublicKey(value) {

@@ -92,0 +193,0 @@ return validatePrefixedValue(value, pkPrefix);

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

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -141,2 +141,12 @@

}
/**
* @description This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
* Verify if the value has the right prefix or return `NO_PREFIX_MATCHED`,
* decode the value using base58 and return `INVALID_CHECKSUM` if it fails,
* check if the length of the value matches the prefix type or return `INVALID_LENGTH`.
* If all checks pass, return `VALID`.
*
* @param value Value to validate
* @param prefixes prefix the value should have
*/
function validatePrefixedValue(value, prefixes) {

@@ -166,17 +176,107 @@ var match = new RegExp("^(" + prefixes.join('|') + ")").exec(value);

var pkPrefix = [Prefix.EDPK, Prefix.SPPK, Prefix.P2PK];
/**
* @description Used to check if an address or a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateAddress } from '@taquito/utils';
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateAddress(pkh)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateAddress(value) {
return validatePrefixedValue(value, __spread(implicitPrefix, contractPrefix));
}
/**
* @description Used to check if a chain id is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateChain } from '@taquito/utils';
* const chainId = 'NetXdQprcVkpaWU'
* const validation = validateChain(chainId)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateChain(value) {
return validatePrefixedValue(value, [Prefix.NET]);
}
/**
* @description Used to check if a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateContractAddress } from '@taquito/utils';
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
* const validation = validateContractAddress(contractAddress)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateContractAddress(value) {
return validatePrefixedValue(value, contractPrefix);
}
/**
* @description Used to check if a key hash is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateKeyHash } from '@taquito/utils';
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateKeyHash(keyHashWithoutPrefix)
* console.log(validation)
* // This example return 0 which correspond to NO_PREFIX_MATCHED
* ```
*/
function validateKeyHash(value) {
return validatePrefixedValue(value, implicitPrefix);
}
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateSignature } from '@taquito/utils';
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validateSignature(signature)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateSignature(value) {
return validatePrefixedValue(value, signaturePrefix);
}
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validatePublicKey } from '@taquito/utils';
* const publicKey = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validatePublicKey(publicKey)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validatePublicKey(value) {

@@ -193,2 +293,8 @@ return validatePrefixedValue(value, pkPrefix);

var bs58check$1 = require('bs58check');
/**
*
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
*
* @param value Value in hex
*/
function encodeExpr(value) {

@@ -264,2 +370,8 @@ var blakeHash = blake.blake2b(hex2buf(value), null, 32);

}
/**
*
* @description Base58 encode a key according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKey(value) {

@@ -275,2 +387,8 @@ if (value[0] === '0') {

}
/**
*
* @description Base58 encode a key hash according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKeyHash(value) {

@@ -297,16 +415,2 @@ if (value[0] === '0') {

*
* @description Generate a random hex nonce
*
* @param length length of the nonce
*/
var hexNonce = function (length) {
var chars = '0123456789abcedf';
var hex = '';
while (length--) {
hex += chars[(Math.random() * 16) | 0];
}
return hex;
};
/**
*
* @description Merge 2 buffers together

@@ -456,3 +560,3 @@ *

*
* @description Convert a michelson string to it's json representation
* @description Convert a michelson string to its json representation
*

@@ -554,3 +658,3 @@ * @param mi Michelson string to convert to json

export { Prefix, ValidationResult, b58cdecode, b58cencode, b58decode, buf2hex, encodeExpr, encodeKey, encodeKeyHash, encodePubKey, hex2buf, hexNonce, isValidPrefix, mergebuf, mic2arr, ml2mic, prefix, prefixLength, sexp2mic, validateAddress, validateChain, validateContractAddress, validateKeyHash, validatePublicKey, validateSignature };
export { Prefix, ValidationResult, b58cdecode, b58cencode, b58decode, buf2hex, encodeExpr, encodeKey, encodeKeyHash, encodePubKey, hex2buf, isValidPrefix, mergebuf, mic2arr, ml2mic, prefix, prefixLength, sexp2mic, validateAddress, validateChain, validateContractAddress, validateKeyHash, validatePublicKey, validateSignature };
//# sourceMappingURL=taquito-utils.es5.js.map

@@ -92,14 +92,14 @@ (function (global, factory) {

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -143,2 +143,12 @@

}
/**
* @description This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
* Verify if the value has the right prefix or return `NO_PREFIX_MATCHED`,
* decode the value using base58 and return `INVALID_CHECKSUM` if it fails,
* check if the length of the value matches the prefix type or return `INVALID_LENGTH`.
* If all checks pass, return `VALID`.
*
* @param value Value to validate
* @param prefixes prefix the value should have
*/
function validatePrefixedValue(value, prefixes) {

@@ -168,17 +178,107 @@ var match = new RegExp("^(" + prefixes.join('|') + ")").exec(value);

var pkPrefix = [exports.Prefix.EDPK, exports.Prefix.SPPK, exports.Prefix.P2PK];
/**
* @description Used to check if an address or a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateAddress } from '@taquito/utils';
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateAddress(pkh)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateAddress(value) {
return validatePrefixedValue(value, __spread(implicitPrefix, contractPrefix));
}
/**
* @description Used to check if a chain id is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateChain } from '@taquito/utils';
* const chainId = 'NetXdQprcVkpaWU'
* const validation = validateChain(chainId)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateChain(value) {
return validatePrefixedValue(value, [exports.Prefix.NET]);
}
/**
* @description Used to check if a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateContractAddress } from '@taquito/utils';
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
* const validation = validateContractAddress(contractAddress)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateContractAddress(value) {
return validatePrefixedValue(value, contractPrefix);
}
/**
* @description Used to check if a key hash is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateKeyHash } from '@taquito/utils';
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateKeyHash(keyHashWithoutPrefix)
* console.log(validation)
* // This example return 0 which correspond to NO_PREFIX_MATCHED
* ```
*/
function validateKeyHash(value) {
return validatePrefixedValue(value, implicitPrefix);
}
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateSignature } from '@taquito/utils';
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validateSignature(signature)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validateSignature(value) {
return validatePrefixedValue(value, signaturePrefix);
}
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validatePublicKey } from '@taquito/utils';
* const publicKey = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validatePublicKey(publicKey)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
function validatePublicKey(value) {

@@ -195,2 +295,8 @@ return validatePrefixedValue(value, pkPrefix);

var bs58check$1 = require('bs58check');
/**
*
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
*
* @param value Value in hex
*/
function encodeExpr(value) {

@@ -266,2 +372,8 @@ var blakeHash = blake.blake2b(hex2buf(value), null, 32);

}
/**
*
* @description Base58 encode a key according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKey(value) {

@@ -277,2 +389,8 @@ if (value[0] === '0') {

}
/**
*
* @description Base58 encode a key hash according to its prefix
*
* @param value Key to base58 encode
*/
function encodeKeyHash(value) {

@@ -299,16 +417,2 @@ if (value[0] === '0') {

*
* @description Generate a random hex nonce
*
* @param length length of the nonce
*/
var hexNonce = function (length) {
var chars = '0123456789abcedf';
var hex = '';
while (length--) {
hex += chars[(Math.random() * 16) | 0];
}
return hex;
};
/**
*
* @description Merge 2 buffers together

@@ -458,3 +562,3 @@ *

*
* @description Convert a michelson string to it's json representation
* @description Convert a michelson string to its json representation
*

@@ -565,3 +669,2 @@ * @param mi Michelson string to convert to json

exports.hex2buf = hex2buf;
exports.hexNonce = hexNonce;
exports.isValidPrefix = isValidPrefix;

@@ -568,0 +671,0 @@ exports.mergebuf = mergebuf;

@@ -1,4 +0,10 @@

/// <reference types="node" />
import { Buffer } from 'buffer';
export * from './validators';
export { prefix, Prefix, prefixLength } from './constants';
/**
*
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
*
* @param value Value in hex
*/
export declare function encodeExpr(value: string): any;

@@ -35,3 +41,15 @@ /**

export declare function encodePubKey(value: string): any;
/**
*
* @description Base58 encode a key according to its prefix
*
* @param value Key to base58 encode
*/
export declare function encodeKey(value: string): any;
/**
*
* @description Base58 encode a key hash according to its prefix
*
* @param value Key to base58 encode
*/
export declare function encodeKeyHash(value: string): any;

@@ -47,9 +65,2 @@ /**

*
* @description Generate a random hex nonce
*
* @param length length of the nonce
*/
export declare const hexNonce: (length: number) => string;
/**
*
* @description Merge 2 buffers together

@@ -77,3 +88,3 @@ *

*
* @description Convert a michelson string to it's json representation
* @description Convert a michelson string to its json representation
*

@@ -80,0 +91,0 @@ * @param mi Michelson string to convert to json

@@ -9,7 +9,97 @@ import { Prefix } from './constants';

export declare function isValidPrefix(value: any): value is Prefix;
/**
* @description Used to check if an address or a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateAddress } from '@taquito/utils';
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateAddress(pkh)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
export declare function validateAddress(value: any): ValidationResult;
/**
* @description Used to check if a chain id is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateChain } from '@taquito/utils';
* const chainId = 'NetXdQprcVkpaWU'
* const validation = validateChain(chainId)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
export declare function validateChain(value: any): ValidationResult;
/**
* @description Used to check if a contract address is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateContractAddress } from '@taquito/utils';
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
* const validation = validateContractAddress(contractAddress)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
export declare function validateContractAddress(value: any): ValidationResult;
/**
* @description Used to check if a key hash is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateKeyHash } from '@taquito/utils';
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
* const validation = validateKeyHash(keyHashWithoutPrefix)
* console.log(validation)
* // This example return 0 which correspond to NO_PREFIX_MATCHED
* ```
*/
export declare function validateKeyHash(value: any): ValidationResult;
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validateSignature } from '@taquito/utils';
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validateSignature(signature)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
export declare function validateSignature(value: any): ValidationResult;
/**
* @description Used to check if a signature is valid.
*
* @returns
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
*
* @example
* ```
* import { validatePublicKey } from '@taquito/utils';
* const publicKey = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
* const validation = validatePublicKey(publicKey)
* console.log(validation)
* // This example return 3 which correspond to VALID
* ```
*/
export declare function validatePublicKey(value: any): ValidationResult;
{
"name": "@taquito/utils",
"version": "6.3.0-wallet.4",
"version": "6.3.1-beta.0",
"description": "converts michelson data and types into convenient JS/TS objects",

@@ -66,34 +66,32 @@ "keywords": [

"bs58check": "^2.1.2",
"buffer": "^5.2.1"
"buffer": "^5.6.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/node": "^10.14.13",
"colors": "^1.3.2",
"coveralls": "^3.0.2",
"cross-env": "^5.2.0",
"jest": "^24.8.0",
"jest-config": "^24.8.0",
"lint-staged": "^8.0.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.1",
"colors": "^1.4.0",
"coveralls": "^3.1.0",
"cross-env": "^7.0.2",
"jest": "^26.0.1",
"jest-config": "^26.0.1",
"lint-staged": "^10.2.2",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.14.3",
"prettier": "^2.0.5",
"prompt": "^1.0.0",
"replace-in-file": "^3.4.2",
"rimraf": "^2.6.2",
"rollup": "^1.20.1",
"rollup-plugin-commonjs": "^10.1.0",
"replace-in-file": "^6.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.10.2",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.22.1",
"shelljs": "^0.8.3",
"ts-jest": "^23.10.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-standard": "^8.0.1",
"typedoc": "^0.15.0",
"typescript": "~3.8.3"
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-typescript2": "^0.27.1",
"shelljs": "^0.8.4",
"ts-jest": "^26.1.0",
"ts-node": "^8.10.1",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.17.6",
"typescript": "~3.9.5"
},
"gitHead": "91633f37f8877684796d21bc60b2a55d9a2ecd5c"
"gitHead": "e766cd7e48d1b10aa02110dd08b98e88d7336981"
}

@@ -9,39 +9,39 @@ {

"path": "dist/lib/constants.js",
"sha512": "499d060add270a33ba127d1e9055a752c4f9068873bcf1351b516e292616223911aa4304e5d0ddc264f06d3e4c525bbcd77cb086da2b745ea3db63b4644561ea"
"sha512": "f90631a1855f27c26b2d3e9d2e7077b4e4bb3cbcb5c942f1c62b5410e26e9594e50493b958e29dd9a9993efc26b0313e51e82e0ab848042bbd376ef1242d85ac"
},
{
"path": "dist/taquito-utils.es5.js",
"sha512": "cb020d20f3f992464a157c27ad2fb6f8ba59b7df0bdfba84b624e2113d19c0687552387e1f84e5d0d32d17d8075bcf36b97620c28512be215e223e628ffd642b"
"sha512": "8d0897d731d404ea831caa82de6e059a1a5d2250051236c7df4398050e6fee92a41ddf3a857e4814f9927aaa73aad1b4917f60386ffbcd0f6791e2f7849b7171"
},
{
"path": "dist/lib/taquito-utils.js",
"sha512": "bc581da69d70fa33c08a005fb020b10486767d0602c09059f06a487cebde62039f8d490d4e49785378189e9e887b727bd7cf213985276fbde265a653476ecf59"
"sha512": "33eae9f58e747f8e9cd5f3c6163648d385cc6b53c0c3a7bf93214bb396cffd1ec11ee5d573fd3ac6ed8811fe7267e74d7eea5f38d4ea7bf7883774e0deb17f9d"
},
{
"path": "dist/taquito-utils.umd.js",
"sha512": "c76e5f35ae7bc672f0260a9dc605179f753635f226750273f4601d7daab8feb304b95180d859eca33c02f1769795ce47c077b1160433f249f111a1f00d32686a"
"sha512": "562910a647a53e8ea19dd9759251c257fc82d2a3bfe7a1f648f8e142ecdd68dd5f9cbd6617544bbeb0194e02d992e765505c898243ab6b9e6424b7b68915a3a3"
},
{
"path": "dist/lib/validators.js",
"sha512": "989ee14521ea688541ae9d93d9840408ebd59392b3406b1336968465235c61ff1d118563e1bbdc42b4a4288c59f1be1d2a66db972f017d1560130936eb6fcda5"
"sha512": "7a7c491e86b6571b67cc2c4def71b7322f5a09302a434256f0a7c3c9d751bb029b1627079ee4485095ca580582bb79a63b3f88308dc499925c0df1cc9f4d684a"
},
{
"path": "dist/lib/constants.js.map",
"sha512": "6d95f07f88784d2cda42f8522d373075ed9df212ee20627d6a8a646d11eb838e75b6e329906ae7374946a95b3173b8b24f3bed2f316cf94512a22559ba902fb5"
"sha512": "60386bfe60bb0dd477fda291b40cbaf2528fabc0b7d94e87f724715c9e22f202537c675069658e610a928cb450843f40fc4dc18660388d22a1dd34c9c4bc4aab"
},
{
"path": "dist/taquito-utils.es5.js.map",
"sha512": "c0c3fa05c0fc949812193c60fa52ffb69092827bcea556dd89f32ecb75be35950ba02f42055d6784fce0f817c885fa4e2bdbee75e1d614670c540e1988c8d4b0"
"sha512": "35cfaa7cd026b35a9357bbda1bd1dfe8877be5a74cf4b94e93b669f76ee9a89839889a0a0d849b66d46dbe7522695e6e1ae2e7786ab62aad98bde636e675ccd1"
},
{
"path": "dist/lib/taquito-utils.js.map",
"sha512": "86492bbb165590ec8978cd90d3f6af5a0d3a89666efb739708996825798b7755226fb635c33b662998996550c9fae7cbfcfeb4f3bba14c75d2d9959dd55eb861"
"sha512": "505b2f8db7b12a5bea073d9c16764703034e7c8d15d4ad616aba7d4b0d47761fa558749d29683c24734b12667f1b529efceac9e1edb8cb34aa719d26a5a84cc5"
},
{
"path": "dist/taquito-utils.umd.js.map",
"sha512": "8c441f1afcfa6392c94b4df81b79b1783fd9d44a10852868fb6c4cfe94e69e91e93a365276f4a6cbed5f0d47ca3cb0b36acb640a4212023506d3d8e3617d20d3"
"sha512": "934372030d0686fe0ec3942ee6239066e5b6bc25883fd56419f5f0cfaec3d096450249a22f24d2a9c75592c25f1e10710e8ad6740a6706e8b94a1da5e73a9c8c"
},
{
"path": "dist/lib/validators.js.map",
"sha512": "dafc8b7fb3abd7f1126e375ef21c6b2f620b65f3fac59ebca26d7cc03e09beed28a490dbccf167ceec85d1780cbdc8424b00b26a16634da1890aca3b4c567688"
"sha512": "241dfa50909d88042aa3c67f706423ccf76ba76aa609998217eb5c5fd8c15126aa178ac7e1c458bfc2edf3522d7154787d09c3f579f8be5eeb9704faf8015907"
},

@@ -58,7 +58,7 @@ {

"path": "dist/types/taquito-utils.d.ts",
"sha512": "4153f24b8a7dbea4ea2731a99e65246d425548b4b8c1cccc295b78acd638056c123e19f32214b709d2af000a92cb082b92ff43b0f020389101cb17dd0e5218f3"
"sha512": "c54729768cea4b9cd7558b030b58edbae690114c1a599a1b4aa5ef77d531654a747b809a98ba5e3761e01bc7da127e48ff1d4aae77031a35d4fedb8471a0ca6d"
},
{
"path": "dist/types/validators.d.ts",
"sha512": "b888a5fe5b9f1840a244d4d1861a612d385e32d0d483b7e74aff822f204106ba8a6c0d8636f5ff8e5983379b3b0800cce52c79ddf344428cc2422bf75590f1e7"
"sha512": "7a36ebb852c5aef5a12aaf419dd625f065a5f1341e936edd463da2e65b4bb64b7633a815b21309cce624f31ff2e7cd696f1987b92470be160e658d1949be94df"
}

@@ -99,3 +99,3 @@ ]

],
"sha512": "2fb5c41bb4219ac76d1311d5dbe2407407f6f5fde9ce0d679654235dd9ec436a98378e46afaeca8625e9aa3827ad689b2219fa60aaa9d92ccf3064718988621d"
"sha512": "cee38dcfa829416d30ff05c70c948b999454cece58a5b6848b2d56228b36ca60a4d813f9daaec97de2bcbe9582a6ada75c02d7f59e3b3d3d5c4a5f7177173f73"
}

@@ -108,3 +108,3 @@ },

"name": "@taquito/utils",
"version": "6.3.0-wallet.4",
"version": "6.3.1-beta.0",
"description": "converts michelson data and types into convenient JS/TS objects",

@@ -172,32 +172,30 @@ "keywords": [

"bs58check": "^2.1.2",
"buffer": "^5.2.1"
"buffer": "^5.6.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/node": "^10.14.13",
"colors": "^1.3.2",
"coveralls": "^3.0.2",
"cross-env": "^5.2.0",
"jest": "^24.8.0",
"jest-config": "^24.8.0",
"lint-staged": "^8.0.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.1",
"colors": "^1.4.0",
"coveralls": "^3.1.0",
"cross-env": "^7.0.2",
"jest": "^26.0.1",
"jest-config": "^26.0.1",
"lint-staged": "^10.2.2",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.14.3",
"prettier": "^2.0.5",
"prompt": "^1.0.0",
"replace-in-file": "^3.4.2",
"rimraf": "^2.6.2",
"rollup": "^1.20.1",
"rollup-plugin-commonjs": "^10.1.0",
"replace-in-file": "^6.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.10.2",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.22.1",
"shelljs": "^0.8.3",
"ts-jest": "^23.10.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-standard": "^8.0.1",
"typedoc": "^0.15.0",
"typescript": "~3.8.3"
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-typescript2": "^0.27.1",
"shelljs": "^0.8.4",
"ts-jest": "^26.1.0",
"ts-node": "^8.10.1",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.17.6",
"typescript": "~3.9.5"
}

@@ -208,3 +206,3 @@ }

],
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJe1VPhCRAD9Qy5GYHsngAAz8oQAG7vUjD2AuzXA/mN1i8k2Ltn\nwt6jeg0Qv/1qoC6o49x+1Q0FYMNJEJ60MEW3QvVoo25hPduO1MG0z/H2M5npUkzS\npLrfOARbHqXRM0CwFpnt88fKFLb/cxLsU/cO4V3KYApYQcajPZVMWPoGsUjclzED\n16hZPpEWpetNgXOd4LppqByXIaTTtMp7ITSh5lmVXMyG65+73o1eERKlkABYHx4U\n4KinRiiFcr8uQwAHotwE4qj8zAdIdsu1s0ZonO715+ZptdYUZE5uvRRHC5CU5HIb\n6I2VpwI2znrBmJUITjmILmLTRNlse5Vy+P7rb1MKap+ShsVOrZlWNnqzLGTRBrS5\n5MS/+83wnt3iKmzbEXqrmMfBOXyOQwOmO63+4AhM75Baje1qcXpxN9ZcKVMEJfwv\n4KhuLDkuARD3KkIIsiaSBDn5pWkQn9mq0x9/4iS8GDEFq7VMJyw5zxfiQDc/Cquh\nTfbGej2BCD9iu7xr7KMhFuEWMWaEumcIw50bczUAl1PCsjs09V7VVabSo9a8Y/+D\nM7YWR1HBIZnAx2T4yADZnMXmaBGUun8oEKi6mFJ6B6Tt2QnmzoowGpOk9GA7k5Vq\n/6GGFKpF3hSR1tUSDXJUPhIh0rwvQzuQJdEqG8CPe3pK2ZU/D4q/WTKvsn8yLe+Q\naqxRiCjKhncaKzEw9+u7\n=u1cH\n-----END PGP SIGNATURE-----\n"
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJe6NPpCRAD9Qy5GYHsngAA8MwQAJLfb1oxNp8O2GAHQMEFcM2d\nK+ifvbNcg+WFjcUsN9B/KRAFkCMiVQyMaQuDRD9RjhrizMzgLgkO4RCF5XHXAW5r\niP8e+S6w7YZrazonB29OVrYyELbHZw+G8xFOSYLPBfXPmETu/VH3KpnbPdezmdRK\ndexoHLYmDPTIX72Rx/Np0169rGY87N/7mOd7mBmFg2tvvf/tpd5vSOYShQvtMDum\nG/S/v8YpRbELVczOdv2LSpeM8Y7RbPvMUhURw5aRYYoMv7GlznOeA8gnjsVy7/Hc\nnnNo4TRfYmESg/0oQ/zpADwC61QLloJvuWNWo6b4fMR7qE7ql+UrxVRa57hLahMQ\n7gY5iSEprGxSyq4M2eAdea0qq16+AcZzNQ1HtfePLnzrsUPDu9dDbL5vwXKQDBrp\nQ+7uhA+WG/4U/UmRxqQyZjRBHa7J1gpdm7TT6B/9R198PBoClPBg+PtknHV141Fi\noHD5aGffges3G+NuaC5iNRyB3FVJboF1iqhVOoVdDDpZxBgI1b1UJ9SZoQezORC2\njZZRFHGgCpGEpW4uFNn94mUsAUCURu7KAEkZRIWuiuLamOMGufuWJzZYunCy/HnT\n2hTwsQnG7oiUBgpQ1lkTWboZV1iiXdY0LGPt+BLQueFoTSoPPlvMc0VJA2B4ZWGJ\nCOP4rcBd79lXhSvBqQYE\n=9ugm\n-----END PGP SIGNATURE-----\n"
}

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