@taquito/utils
Advanced tools
Comparing version 17.1.0 to 17.1.1
@@ -209,9 +209,19 @@ "use strict"; | ||
const hex2buf = (hex) => { | ||
const match = hex.match(/[\da-f]{2}/gi); | ||
if (match) { | ||
return new Uint8Array(match.map((h) => parseInt(h, 16))); | ||
if (hex.length % 2 !== 0) { | ||
throw new core_1.InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
} | ||
else { | ||
throw new errors_1.ValueConversionError(hex, 'Uint8Array'); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^([\da-f]{2})*$/gi)) { | ||
throw new core_1.InvalidHexStringError(hex, `: Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'`); | ||
} | ||
const out = new Uint8Array(hexDigits.length / 2); | ||
let j = 0; | ||
for (let i = 0; i < hexDigits.length; i += 2) { | ||
const v = parseInt(hexDigits.slice(i, i + 2), 16); | ||
if (Number.isNaN(v)) { | ||
throw new errors_1.ValueConversionError(hex, 'Uint8Array'); | ||
} | ||
out[j++] = v; | ||
} | ||
return out; | ||
}; | ||
@@ -368,6 +378,7 @@ exports.hex2buf = hex2buf; | ||
function hex2Bytes(hex) { | ||
if (!hex.match(/[\da-f]{2}/gi)) { | ||
throw new core_1.InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^(0x)?([\da-f]{2})*$/gi)) { | ||
throw new core_1.InvalidHexStringError(hex, `: Expecting even number of characters: 0-9, a-z, A-Z, optionally prefixed with 0x`); | ||
} | ||
return buffer_1.Buffer.from(hex, 'hex'); | ||
return buffer_1.Buffer.from(hexDigits, 'hex'); | ||
} | ||
@@ -374,0 +385,0 @@ exports.hex2Bytes = hex2Bytes; |
@@ -6,5 +6,5 @@ "use strict"; | ||
exports.VERSION = { | ||
"commitHash": "a23fb981e79462489c07a1e4656f310390cb1148", | ||
"version": "17.1.0" | ||
"commitHash": "15732f9b7d575aa46427c94501fb8677a754b733", | ||
"version": "17.1.1" | ||
}; | ||
//# sourceMappingURL=version.js.map |
@@ -513,4 +513,4 @@ import { Buffer } from 'buffer'; | ||
const VERSION = { | ||
"commitHash": "a23fb981e79462489c07a1e4656f310390cb1148", | ||
"version": "17.1.0" | ||
"commitHash": "15732f9b7d575aa46427c94501fb8677a754b733", | ||
"version": "17.1.1" | ||
}; | ||
@@ -699,9 +699,19 @@ | ||
const hex2buf = (hex) => { | ||
const match = hex.match(/[\da-f]{2}/gi); | ||
if (match) { | ||
return new Uint8Array(match.map((h) => parseInt(h, 16))); | ||
if (hex.length % 2 !== 0) { | ||
throw new InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
} | ||
else { | ||
throw new ValueConversionError(hex, 'Uint8Array'); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^([\da-f]{2})*$/gi)) { | ||
throw new InvalidHexStringError(hex, `: Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'`); | ||
} | ||
const out = new Uint8Array(hexDigits.length / 2); | ||
let j = 0; | ||
for (let i = 0; i < hexDigits.length; i += 2) { | ||
const v = parseInt(hexDigits.slice(i, i + 2), 16); | ||
if (Number.isNaN(v)) { | ||
throw new ValueConversionError(hex, 'Uint8Array'); | ||
} | ||
out[j++] = v; | ||
} | ||
return out; | ||
}; | ||
@@ -851,6 +861,7 @@ /** | ||
function hex2Bytes(hex) { | ||
if (!hex.match(/[\da-f]{2}/gi)) { | ||
throw new InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^(0x)?([\da-f]{2})*$/gi)) { | ||
throw new InvalidHexStringError(hex, `: Expecting even number of characters: 0-9, a-z, A-Z, optionally prefixed with 0x`); | ||
} | ||
return Buffer.from(hex, 'hex'); | ||
return Buffer.from(hexDigits, 'hex'); | ||
} | ||
@@ -857,0 +868,0 @@ /** |
@@ -516,4 +516,4 @@ (function (global, factory) { | ||
const VERSION = { | ||
"commitHash": "a23fb981e79462489c07a1e4656f310390cb1148", | ||
"version": "17.1.0" | ||
"commitHash": "15732f9b7d575aa46427c94501fb8677a754b733", | ||
"version": "17.1.1" | ||
}; | ||
@@ -702,9 +702,19 @@ | ||
const hex2buf = (hex) => { | ||
const match = hex.match(/[\da-f]{2}/gi); | ||
if (match) { | ||
return new Uint8Array(match.map((h) => parseInt(h, 16))); | ||
if (hex.length % 2 !== 0) { | ||
throw new core.InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
} | ||
else { | ||
throw new ValueConversionError(hex, 'Uint8Array'); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^([\da-f]{2})*$/gi)) { | ||
throw new core.InvalidHexStringError(hex, `: Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'`); | ||
} | ||
const out = new Uint8Array(hexDigits.length / 2); | ||
let j = 0; | ||
for (let i = 0; i < hexDigits.length; i += 2) { | ||
const v = parseInt(hexDigits.slice(i, i + 2), 16); | ||
if (Number.isNaN(v)) { | ||
throw new ValueConversionError(hex, 'Uint8Array'); | ||
} | ||
out[j++] = v; | ||
} | ||
return out; | ||
}; | ||
@@ -854,6 +864,7 @@ /** | ||
function hex2Bytes(hex) { | ||
if (!hex.match(/[\da-f]{2}/gi)) { | ||
throw new core.InvalidHexStringError(hex, `: Expecting even number of characters`); | ||
const hexDigits = stripHexPrefix(hex); | ||
if (!hexDigits.match(/^(0x)?([\da-f]{2})*$/gi)) { | ||
throw new core.InvalidHexStringError(hex, `: Expecting even number of characters: 0-9, a-z, A-Z, optionally prefixed with 0x`); | ||
} | ||
return buffer.Buffer.from(hex, 'hex'); | ||
return buffer.Buffer.from(hexDigits, 'hex'); | ||
} | ||
@@ -860,0 +871,0 @@ /** |
{ | ||
"name": "@taquito/utils", | ||
"version": "17.1.0", | ||
"version": "17.1.1", | ||
"description": "converts michelson data and types into convenient JS/TS objects", | ||
@@ -68,3 +68,3 @@ "keywords": [ | ||
"@stablelib/ed25519": "^1.0.3", | ||
"@taquito/core": "^17.1.0", | ||
"@taquito/core": "^17.1.1", | ||
"@types/bs58check": "^2.1.0", | ||
@@ -107,3 +107,3 @@ "bignumber.js": "^9.1.0", | ||
}, | ||
"gitHead": "8ac541f668bffe24e30a83303aae973c73813adb" | ||
"gitHead": "8f685d3d4fef68a2cfc44f8da7ba866a11478681" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
288811
3635
1
Updated@taquito/core@^17.1.1