Socket
Socket
Sign inDemoInstall

@taquito/utils

Package Overview
Dependencies
31
Maintainers
7
Versions
195
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 17.3.2 to 17.4.0-beta-RC.0

3

dist/lib/constants.js

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

Prefix["SRC1"] = "src1";
})(Prefix = exports.Prefix || (exports.Prefix = {}));
})(Prefix || (exports.Prefix = Prefix = {}));
exports.prefix = {

@@ -133,2 +133,1 @@ [Prefix.TZ1]: new Uint8Array([6, 161, 159]),

};
//# sourceMappingURL=constants.js.map

@@ -50,2 +50,1 @@ "use strict";

exports.ValueConversionError = ValueConversionError;
//# sourceMappingURL=errors.js.map

@@ -28,2 +28,1 @@ "use strict";

exports.format = format;
//# sourceMappingURL=format.js.map

@@ -8,3 +8,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -53,3 +57,3 @@ if (k2 === undefined) k2 = k;

function encodeExpr(value) {
const blakeHash = blakejs_1.default.blake2b(exports.hex2buf(value), undefined, 32);
const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
return b58cencode(blakeHash, constants_1.prefix['expr']);

@@ -64,3 +68,3 @@ }

function encodeOpHash(value) {
const blakeHash = blakejs_1.default.blake2b(exports.hex2buf(value), undefined, 32);
const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
return b58cencode(blakeHash, constants_1.prefix.o);

@@ -113,7 +117,7 @@ }

// tz addresses
const hex = exports.buf2hex(buf.slice(3));
const hex = (0, exports.buf2hex)(buf.slice(3));
return pref + hex;
}
else if (rollupPref) {
const hex = exports.buf2hex(buf.slice(4));
const hex = (0, exports.buf2hex)(buf.slice(4));
return rollupPref + hex + '00';

@@ -123,3 +127,3 @@ }

// other (kt addresses)
return '01' + exports.buf2hex(buf.slice(3, 42)) + '00';
return '01' + (0, exports.buf2hex)(buf.slice(3, 42)) + '00';
}

@@ -137,3 +141,3 @@ }

// tz4 address currently
return exports.buf2hex(buf.slice(3, 42));
return (0, exports.buf2hex)(buf.slice(3, 42));
}

@@ -307,10 +311,9 @@ exports.b58decodeL2Address = b58decodeL2Address;

*
* @description Convert a buffer to an hex string
* @description Convert a Uint8Array to an hex string
*
* @param buffer Buffer to convert
* @param buffer Uint8Array to convert
*/
const buf2hex = (buffer) => {
const byteArray = new Uint8Array(buffer);
const hexParts = [];
byteArray.forEach((byte) => {
buffer.forEach((byte) => {
const hex = byte.toString(16);

@@ -333,4 +336,4 @@ const paddedHex = `00${hex}`.slice(-2);

let prefixLen;
const keyPrefix = verify_signature_1.validatePkAndExtractPrefix(publicKey);
const decoded = exports.b58cdecode(publicKey, constants_1.prefix[keyPrefix]);
const keyPrefix = (0, verify_signature_1.validatePkAndExtractPrefix)(publicKey);
const decoded = (0, exports.b58cdecode)(publicKey, constants_1.prefix[keyPrefix]);
switch (keyPrefix) {

@@ -353,3 +356,3 @@ case constants_1.Prefix.EDPK:

}
const hashed = blake2b_1.hash(decoded, prefixLen);
const hashed = (0, blake2b_1.hash)(decoded, prefixLen);
const result = b58cencode(hashed, encodingPrefix);

@@ -376,3 +379,3 @@ return result;

function bytes2Char(hex) {
return buffer_1.Buffer.from(exports.hex2buf(hex)).toString('utf8');
return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
}

@@ -415,3 +418,3 @@ exports.bytes2Char = bytes2Char;

const hex = val.toString(16);
// check whether nibble (4 bits) length is higher or lowerthan the current hex string length
// check whether nibble (4 bits) length is higher or lower than the current hex string length
let targetLength = hex.length >= nibbleLength ? hex.length : nibbleLength;

@@ -450,2 +453,1 @@ // make sure the hex string target length is even

exports.stripHexPrefix = stripHexPrefix;
//# sourceMappingURL=taquito-utils.js.map

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

ValidationResult[ValidationResult["VALID"] = 3] = "VALID";
})(ValidationResult = exports.ValidationResult || (exports.ValidationResult = {}));
})(ValidationResult || (exports.ValidationResult = ValidationResult = {}));
function isValidPrefix(value) {

@@ -264,2 +264,1 @@ if (typeof value !== 'string') {

exports.validateSmartRollupAddress = validateSmartRollupAddress;
//# sourceMappingURL=validators.js.map

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

const sigPrefix = validateSigAndExtractPrefix(signature);
const decodedPublicKey = taquito_utils_1.b58cdecode(publicKey, taquito_utils_1.prefix[pkPrefix]);
const decodedSig = taquito_utils_1.b58cdecode(signature, taquito_utils_1.prefix[sigPrefix]);
let messageBuf = taquito_utils_1.hex2buf(validateMessageNotEmpty(messageBytes));
const decodedPublicKey = (0, taquito_utils_1.b58cdecode)(publicKey, taquito_utils_1.prefix[pkPrefix]);
const decodedSig = (0, taquito_utils_1.b58cdecode)(signature, taquito_utils_1.prefix[sigPrefix]);
let messageBuf = (0, taquito_utils_1.hex2buf)(validateMessageNotEmpty(messageBytes));
if (typeof watermark !== 'undefined') {
messageBuf = taquito_utils_1.mergebuf(watermark, messageBuf);
messageBuf = (0, taquito_utils_1.mergebuf)(watermark, messageBuf);
}
const bytesHash = blake2b_1.hash(messageBuf, 32);
const bytesHash = (0, blake2b_1.hash)(messageBuf, 32);
if (pkPrefix === taquito_utils_1.Prefix.EDPK) {

@@ -65,5 +65,5 @@ return verifyEdSignature(decodedSig, bytesHash, decodedPublicKey);

const pkPrefix = publicKey.substring(0, 4);
const publicKeyValidation = taquito_utils_1.validatePublicKey(publicKey);
const publicKeyValidation = (0, taquito_utils_1.validatePublicKey)(publicKey);
if (publicKeyValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new core_1.InvalidPublicKeyError(publicKey, taquito_utils_1.invalidDetail(publicKeyValidation));
throw new core_1.InvalidPublicKeyError(publicKey, (0, taquito_utils_1.invalidDetail)(publicKeyValidation));
}

@@ -77,5 +77,5 @@ return pkPrefix;

: signature.substring(0, 5);
const validation = taquito_utils_1.validateSignature(signature);
const validation = (0, taquito_utils_1.validateSignature)(signature);
if (validation !== taquito_utils_1.ValidationResult.VALID) {
throw new core_1.InvalidSignatureError(signature, taquito_utils_1.invalidDetail(validation));
throw new core_1.InvalidSignatureError(signature, (0, taquito_utils_1.invalidDetail)(validation));
}

@@ -86,3 +86,3 @@ return signaturePrefix;

try {
return ed25519_1.verify(decodedPublicKey, bytesHash, decodedSig);
return (0, ed25519_1.verify)(decodedPublicKey, bytesHash, decodedSig);
}

@@ -102,3 +102,3 @@ catch (e) {

function verifySpOrP2Sig(decodedSig, bytesHash, key) {
const hexSig = taquito_utils_1.buf2hex(typedarray_to_buffer_1.default(decodedSig));
const hexSig = (0, taquito_utils_1.buf2hex)((0, typedarray_to_buffer_1.default)(decodedSig));
const match = hexSig.match(/([a-f\d]{64})/gi);

@@ -116,2 +116,1 @@ if (match) {

}
//# sourceMappingURL=verify-signature.js.map

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

exports.VERSION = {
"commitHash": "a97e506efd61b86e39ae30db588401b8fda46553",
"version": "17.3.2"
"commitHash": "4f44dd73b7659554c167acb80f0c20f222f893a5",
"version": "17.4.0-beta-RC.0"
};
//# sourceMappingURL=version.js.map

@@ -517,4 +517,4 @@ import { Buffer } from 'buffer';

const VERSION = {
"commitHash": "a97e506efd61b86e39ae30db588401b8fda46553",
"version": "17.3.2"
"commitHash": "4f44dd73b7659554c167acb80f0c20f222f893a5",
"version": "17.4.0-beta-RC.0"
};

@@ -549,2 +549,7 @@

*/
/*
* Some code in this file is originally from sotez and eztz
* Copyright (c) 2018 Andrew Kishino
* Copyright (c) 2017 Stephen Andrews
*/
/**

@@ -793,10 +798,9 @@ *

*
* @description Convert a buffer to an hex string
* @description Convert a Uint8Array to an hex string
*
* @param buffer Buffer to convert
* @param buffer Uint8Array to convert
*/
const buf2hex = (buffer) => {
const byteArray = new Uint8Array(buffer);
const hexParts = [];
byteArray.forEach((byte) => {
buffer.forEach((byte) => {
const hex = byte.toString(16);

@@ -892,3 +896,3 @@ const paddedHex = `00${hex}`.slice(-2);

const hex = val.toString(16);
// check whether nibble (4 bits) length is higher or lowerthan the current hex string length
// check whether nibble (4 bits) length is higher or lower than the current hex string length
let targetLength = hex.length >= nibbleLength ? hex.length : nibbleLength;

@@ -895,0 +899,0 @@ // make sure the hex string target length is even

@@ -7,10 +7,2 @@ (function (global, factory) {

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var blake__default = /*#__PURE__*/_interopDefaultLegacy(blake);
var bs58check__default = /*#__PURE__*/_interopDefaultLegacy(bs58check);
var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
var elliptic__default = /*#__PURE__*/_interopDefaultLegacy(elliptic);
var toBuffer__default = /*#__PURE__*/_interopDefaultLegacy(toBuffer);
exports.Prefix = void 0;

@@ -223,11 +215,11 @@ (function (Prefix) {

function verifySpSignature(decodedSig, bytesHash, decodedPublicKey) {
const key = new elliptic__default["default"].ec('secp256k1').keyFromPublic(decodedPublicKey);
const key = new elliptic.ec('secp256k1').keyFromPublic(decodedPublicKey);
return verifySpOrP2Sig(decodedSig, bytesHash, key);
}
function verifyP2Signature(decodedSig, bytesHash, decodedPublicKey) {
const key = new elliptic__default["default"].ec('p256').keyFromPublic(decodedPublicKey);
const key = new elliptic.ec('p256').keyFromPublic(decodedPublicKey);
return verifySpOrP2Sig(decodedSig, bytesHash, key);
}
function verifySpOrP2Sig(decodedSig, bytesHash, key) {
const hexSig = buf2hex(toBuffer__default["default"](decodedSig));
const hexSig = buf2hex(toBuffer(decodedSig));
const match = hexSig.match(/([a-f\d]{64})/gi);

@@ -316,3 +308,3 @@ if (match) {

// decodeUnsafe return undefined if decoding fail
let decoded = bs58check__default["default"].decodeUnsafe(value);
let decoded = bs58check.decodeUnsafe(value);
if (!decoded) {

@@ -523,4 +515,4 @@ return exports.ValidationResult.INVALID_CHECKSUM;

const VERSION = {
"commitHash": "a97e506efd61b86e39ae30db588401b8fda46553",
"version": "17.3.2"
"commitHash": "4f44dd73b7659554c167acb80f0c20f222f893a5",
"version": "17.4.0-beta-RC.0"
};

@@ -542,3 +534,3 @@

function format(from = 'mutez', to = 'mutez', amount) {
const bigNum = new BigNumber__default["default"](amount);
const bigNum = new BigNumber(amount);
if (bigNum.isNaN()) {

@@ -556,2 +548,7 @@ return amount;

*/
/*
* Some code in this file is originally from sotez and eztz
* Copyright (c) 2018 Andrew Kishino
* Copyright (c) 2017 Stephen Andrews
*/
/**

@@ -564,3 +561,3 @@ *

function encodeExpr(value) {
const blakeHash = blake__default["default"].blake2b(hex2buf(value), undefined, 32);
const blakeHash = blake.blake2b(hex2buf(value), undefined, 32);
return b58cencode(blakeHash, prefix['expr']);

@@ -574,3 +571,3 @@ }

function encodeOpHash(value) {
const blakeHash = blake__default["default"].blake2b(hex2buf(value), undefined, 32);
const blakeHash = blake.blake2b(hex2buf(value), undefined, 32);
return b58cencode(blakeHash, prefix.o);

@@ -590,3 +587,3 @@ }

n.set(payloadAr, prefix.length);
return bs58check__default["default"].encode(buffer.Buffer.from(n.buffer));
return bs58check.encode(buffer.Buffer.from(n.buffer));
}

@@ -600,3 +597,3 @@ /**

*/
const b58cdecode = (enc, prefixArg) => bs58check__default["default"].decode(enc).slice(prefixArg.length);
const b58cdecode = (enc, prefixArg) => bs58check.decode(enc).slice(prefixArg.length);
/**

@@ -609,3 +606,3 @@ *

function b58decode(payload) {
const buf = bs58check__default["default"].decode(payload);
const buf = bs58check.decode(payload);
const prefixMap = {

@@ -642,3 +639,3 @@ [prefix.tz1.toString()]: '0000',

function b58decodeL2Address(payload) {
const buf = bs58check__default["default"].decode(payload);
const buf = bs58check.decode(payload);
// tz4 address currently

@@ -806,10 +803,9 @@ return buf2hex(buf.slice(3, 42));

*
* @description Convert a buffer to an hex string
* @description Convert a Uint8Array to an hex string
*
* @param buffer Buffer to convert
* @param buffer Uint8Array to convert
*/
const buf2hex = (buffer) => {
const byteArray = new Uint8Array(buffer);
const hexParts = [];
byteArray.forEach((byte) => {
buffer.forEach((byte) => {
const hex = byte.toString(16);

@@ -902,6 +898,6 @@ const paddedHex = `00${hex}`.slice(-2);

function num2PaddedHex(val, bitLength = 8) {
if (new BigNumber__default["default"](val).isPositive()) {
if (new BigNumber(val).isPositive()) {
const nibbleLength = Math.ceil(bitLength / 4);
const hex = val.toString(16);
// check whether nibble (4 bits) length is higher or lowerthan the current hex string length
// check whether nibble (4 bits) length is higher or lower than the current hex string length
let targetLength = hex.length >= nibbleLength ? hex.length : nibbleLength;

@@ -913,5 +909,5 @@ // make sure the hex string target length is even

else {
const twosCompliment = new BigNumber__default["default"](2)
const twosCompliment = new BigNumber(2)
.pow(bitLength)
.minus(new BigNumber__default["default"](val).abs());
.minus(new BigNumber(val).abs());
return twosCompliment.toString(16);

@@ -1039,5 +1035,3 @@ }

Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=taquito-utils.umd.js.map

@@ -0,0 +0,0 @@ export declare enum Prefix {

@@ -0,0 +0,0 @@ import { ParameterValidationError, UnsupportedActionError } from '@taquito/core';

import BigNumber from 'bignumber.js';
declare type Format = 'tz' | 'mtz' | 'mutez';
type Format = 'tz' | 'mtz' | 'mutez';
export declare function format(from: Format | undefined, to: Format | undefined, amount: number | string | BigNumber): string | number | BigNumber;
export {};

@@ -110,7 +110,7 @@ /**

*
* @description Convert a buffer to an hex string
* @description Convert a Uint8Array to an hex string
*
* @param buffer Buffer to convert
* @param buffer Uint8Array to convert
*/
export declare const buf2hex: (buffer: Buffer) => string;
export declare const buf2hex: (buffer: Uint8Array) => string;
/**

@@ -117,0 +117,0 @@ *

@@ -0,0 +0,0 @@ import { Prefix } from './constants';

import { Prefix } from './taquito-utils';
declare type PkPrefix = Prefix.EDPK | Prefix.SPPK | Prefix.P2PK | Prefix.BLPK;
type PkPrefix = Prefix.EDPK | Prefix.SPPK | Prefix.P2PK | Prefix.BLPK;
/**

@@ -4,0 +4,0 @@ * @description Verify signature of a payload

@@ -0,0 +0,0 @@ export declare const VERSION: {

{
"name": "@taquito/utils",
"version": "17.3.2",
"version": "17.4.0-beta-RC.0",
"description": "converts michelson data and types into convenient JS/TS objects",

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

"engines": {
"node": ">=16"
"node": ">=18"
},

@@ -36,4 +36,4 @@ "scripts": {

"version-stamp": "node ../taquito/version-stamping.js",
"build": "tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts",
"start": "rollup -c rollup.config.ts -w",
"build": "tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts --bundleConfigAsCjs",
"start": "rollup -c rollup.config.ts --bundleConfigAsCjs -w",
"test": "jest"

@@ -44,4 +44,3 @@ },

"prettier --write",
"eslint --fix",
"git add"
"eslint --fix"
]

@@ -71,7 +70,7 @@ },

"@stablelib/ed25519": "^1.0.3",
"@taquito/core": "^17.3.2",
"@taquito/core": "^17.4.0-beta-RC.0",
"@types/bs58check": "^2.1.0",
"bignumber.js": "^9.1.0",
"bignumber.js": "^9.1.2",
"blakejs": "^1.2.1",
"bs58check": "^2.1.2",
"bs58check": "^3.0.1",
"buffer": "^6.0.3",

@@ -82,31 +81,30 @@ "elliptic": "^6.5.4",

"devDependencies": {
"@types/bluebird": "^3.5.36",
"@types/elliptic": "^6.4.14",
"@types/jest": "^26.0.23",
"@types/node": "^16",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"@types/bluebird": "^3.5.40",
"@types/elliptic": "^6.4.15",
"@types/jest": "^29.5.5",
"@types/node": "^20",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"colors": "^1.4.0",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"eslint": "^8.17.0",
"jest": "^26.6.3",
"jest-config": "^26.6.3",
"lint-staged": "^13.0.1",
"eslint": "^8.51.0",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"lint-staged": "^14.0.1",
"lodash.camelcase": "^4.3.0",
"prettier": "^2.7.0",
"prettier": "^3.0.3",
"prompt": "^1.3.0",
"replace-in-file": "^6.3.5",
"rimraf": "^3.0.2",
"rollup": "^2.75.6",
"replace-in-file": "^7.0.1",
"rimraf": "^5.0.5",
"rollup": "^4.1.4",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.32.1",
"rollup-plugin-typescript2": "^0.36.0",
"shelljs": "^0.8.5",
"ts-jest": "^26.4.4",
"ts-node": "^10.4.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-toolbelt": "^9.6.0",
"typescript": "~4.1.5"
"typescript": "~5.2.2"
},
"gitHead": "a8dac9c64a1511b398fb8acb88cc8fb593d5d0f3"
"gitHead": "34103941d52e31a808e051ea19dbecf43f984dca"
}

@@ -131,3 +131,3 @@ {

"engines": {
"node": ">=16"
"node": ">=18"
},

@@ -144,4 +144,3 @@ "scripts": {

"prettier --write",
"tslint --fix",
"git add"
"tslint --fix"
]

@@ -175,3 +174,3 @@ },

"@types/jest": "^26.0.16",
"@types/node": "^16",
"@types/node": "^18",
"colors": "^1.4.0",

@@ -190,3 +189,2 @@ "coveralls": "^3.1.0",

"rollup-plugin-json": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.27.3",

@@ -193,0 +191,0 @@ "shelljs": "^0.8.4",

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc