@taquito/utils
Advanced tools
Comparing version 12.1.1 to 13.0.0-beta-RC.0
@@ -18,2 +18,3 @@ "use strict"; | ||
Prefix["P2PK"] = "p2pk"; | ||
Prefix["BLPK"] = "BLpk"; | ||
Prefix["EDESK"] = "edesk"; | ||
@@ -62,2 +63,3 @@ Prefix["SPESK"] = "spesk"; | ||
[Prefix.P2PK]: new Uint8Array([3, 178, 139, 127]), | ||
[Prefix.BLPK]: new Uint8Array([6, 149, 135, 204]), | ||
[Prefix.EDESK]: new Uint8Array([7, 90, 60, 179, 41]), | ||
@@ -101,2 +103,4 @@ [Prefix.SPESK]: new Uint8Array([0x09, 0xed, 0xf1, 0xae, 0x96]), | ||
[Prefix.P2PK]: 33, | ||
//working with value in comment for base58.ml line 445 but not consistent with the three above | ||
[Prefix.BLPK]: 48, | ||
[Prefix.EDSIG]: 64, | ||
@@ -103,0 +107,0 @@ [Prefix.SPSIG]: 64, |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bytes2Char = exports.char2Bytes = exports.getPkhfromPk = exports.buf2hex = exports.mic2arr = exports.mergebuf = exports.hex2buf = exports.encodeKeyHash = exports.encodeKey = exports.encodePubKey = exports.b58decode = exports.b58cdecode = exports.b58cencode = exports.encodeOpHash = exports.encodeExpr = exports.validatePkAndExtractPrefix = exports.verifySignature = exports.prefixLength = exports.Prefix = exports.prefix = exports.VERSION = void 0; | ||
exports.bytes2Char = exports.char2Bytes = exports.getPkhfromPk = exports.buf2hex = exports.mic2arr = exports.mergebuf = exports.hex2buf = exports.encodeKeyHash = exports.encodeKey = exports.encodeL2Address = exports.encodePubKey = exports.b58decodeL2Address = exports.b58decode = exports.b58cdecode = exports.b58cencode = exports.encodeOpHash = exports.encodeExpr = exports.validatePkAndExtractPrefix = exports.verifySignature = exports.prefixLength = exports.Prefix = exports.prefix = exports.VERSION = void 0; | ||
/* | ||
@@ -100,3 +100,7 @@ * Some code in this file is originally from sotez and eztz | ||
}; | ||
const rollupPrefMap = { | ||
[constants_1.prefix.txr1.toString()]: '02', | ||
}; | ||
const pref = prefixMap[new Uint8Array(buf.slice(0, 3)).toString()]; | ||
const rollupPref = rollupPrefMap[new Uint8Array(buf.slice(0, 4)).toString()]; | ||
if (pref) { | ||
@@ -107,2 +111,6 @@ // tz addresses | ||
} | ||
else if (rollupPref) { | ||
const hex = exports.buf2hex(buf.slice(4)); | ||
return rollupPref + hex + '00'; | ||
} | ||
else { | ||
@@ -116,2 +124,14 @@ // other (kt addresses) | ||
* | ||
* @description b58 decode a string without predefined prefix | ||
* @param value | ||
* @returns string of bytes | ||
*/ | ||
function b58decodeL2Address(payload) { | ||
const buf = bs58check_1.default.decode(payload); | ||
// tz4 address currently | ||
return exports.buf2hex(buf.slice(3, 42)); | ||
} | ||
exports.b58decodeL2Address = b58decodeL2Address; | ||
/** | ||
* | ||
* @description Base58 encode an address using predefined prefix | ||
@@ -130,2 +150,6 @@ * | ||
} | ||
else if (value.substring(0, 2) === '02') { | ||
// 42 also works but the removes the 00 padding at the end | ||
return b58cencode(value.substring(2, value.length - 2), constants_1.prefix.txr1); | ||
} | ||
return b58cencode(value.substring(2, 42), constants_1.prefix.KT); | ||
@@ -136,2 +160,12 @@ } | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
* @param value Address to base58 encode (tz4) hex dec | ||
* @returns return address | ||
*/ | ||
function encodeL2Address(value) { | ||
return b58cencode(value, constants_1.prefix.tz4); | ||
} | ||
exports.encodeL2Address = encodeL2Address; | ||
/** | ||
* | ||
* @description Base58 encode a key according to its prefix | ||
@@ -205,3 +239,2 @@ * | ||
*/ | ||
// TODO Zainen check use | ||
const mic2arr = function me2(s) { | ||
@@ -300,2 +333,5 @@ let ret = []; | ||
break; | ||
case constants_1.Prefix.BLPK: | ||
encodingPrefix = constants_1.prefix[constants_1.Prefix.TZ4]; | ||
prefixLen = constants_1.prefixLength[constants_1.Prefix.TZ4]; | ||
} | ||
@@ -302,0 +338,0 @@ const hashed = blake2b_1.hash(decoded, prefixLen); |
@@ -58,3 +58,3 @@ "use strict"; | ||
const signaturePrefix = [constants_1.Prefix.EDSIG, constants_1.Prefix.P2SIG, constants_1.Prefix.SPSIG, constants_1.Prefix.SIG]; | ||
const pkPrefix = [constants_1.Prefix.EDPK, constants_1.Prefix.SPPK, constants_1.Prefix.P2PK]; | ||
const pkPrefix = [constants_1.Prefix.EDPK, constants_1.Prefix.SPPK, constants_1.Prefix.P2PK, constants_1.Prefix.BLPK]; | ||
const operationPrefix = [constants_1.Prefix.O]; | ||
@@ -61,0 +61,0 @@ const protocolPrefix = [constants_1.Prefix.P]; |
@@ -6,5 +6,5 @@ "use strict"; | ||
exports.VERSION = { | ||
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25", | ||
"version": "12.1.1" | ||
commitHash: '38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25', | ||
version: '12.1.1', | ||
}; | ||
//# sourceMappingURL=version.js.map |
@@ -23,2 +23,3 @@ import { Buffer } from 'buffer'; | ||
Prefix["P2PK"] = "p2pk"; | ||
Prefix["BLPK"] = "BLpk"; | ||
Prefix["EDESK"] = "edesk"; | ||
@@ -67,2 +68,3 @@ Prefix["SPESK"] = "spesk"; | ||
[Prefix.P2PK]: new Uint8Array([3, 178, 139, 127]), | ||
[Prefix.BLPK]: new Uint8Array([6, 149, 135, 204]), | ||
[Prefix.EDESK]: new Uint8Array([7, 90, 60, 179, 41]), | ||
@@ -106,2 +108,4 @@ [Prefix.SPESK]: new Uint8Array([0x09, 0xed, 0xf1, 0xae, 0x96]), | ||
[Prefix.P2PK]: 33, | ||
//working with value in comment for base58.ml line 445 but not consistent with the three above | ||
[Prefix.BLPK]: 48, | ||
[Prefix.EDSIG]: 64, | ||
@@ -455,3 +459,3 @@ [Prefix.SPSIG]: 64, | ||
const signaturePrefix = [Prefix.EDSIG, Prefix.P2SIG, Prefix.SPSIG, Prefix.SIG]; | ||
const pkPrefix = [Prefix.EDPK, Prefix.SPPK, Prefix.P2PK]; | ||
const pkPrefix = [Prefix.EDPK, Prefix.SPPK, Prefix.P2PK, Prefix.BLPK]; | ||
const operationPrefix = [Prefix.O]; | ||
@@ -625,4 +629,4 @@ const protocolPrefix = [Prefix.P]; | ||
const VERSION = { | ||
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25", | ||
"version": "12.1.1" | ||
commitHash: '38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25', | ||
version: '12.1.1', | ||
}; | ||
@@ -688,3 +692,7 @@ | ||
}; | ||
const rollupPrefMap = { | ||
[prefix.txr1.toString()]: '02', | ||
}; | ||
const pref = prefixMap[new Uint8Array(buf.slice(0, 3)).toString()]; | ||
const rollupPref = rollupPrefMap[new Uint8Array(buf.slice(0, 4)).toString()]; | ||
if (pref) { | ||
@@ -695,2 +703,6 @@ // tz addresses | ||
} | ||
else if (rollupPref) { | ||
const hex = buf2hex(buf.slice(4)); | ||
return rollupPref + hex + '00'; | ||
} | ||
else { | ||
@@ -703,2 +715,13 @@ // other (kt addresses) | ||
* | ||
* @description b58 decode a string without predefined prefix | ||
* @param value | ||
* @returns string of bytes | ||
*/ | ||
function b58decodeL2Address(payload) { | ||
const buf = bs58check.decode(payload); | ||
// tz4 address currently | ||
return buf2hex(buf.slice(3, 42)); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode an address using predefined prefix | ||
@@ -717,2 +740,6 @@ * | ||
} | ||
else if (value.substring(0, 2) === '02') { | ||
// 42 also works but the removes the 00 padding at the end | ||
return b58cencode(value.substring(2, value.length - 2), prefix.txr1); | ||
} | ||
return b58cencode(value.substring(2, 42), prefix.KT); | ||
@@ -722,2 +749,11 @@ } | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
* @param value Address to base58 encode (tz4) hex dec | ||
* @returns return address | ||
*/ | ||
function encodeL2Address(value) { | ||
return b58cencode(value, prefix.tz4); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode a key according to its prefix | ||
@@ -787,3 +823,2 @@ * | ||
*/ | ||
// TODO Zainen check use | ||
const mic2arr = function me2(s) { | ||
@@ -880,2 +915,5 @@ let ret = []; | ||
break; | ||
case Prefix.BLPK: | ||
encodingPrefix = prefix[Prefix.TZ4]; | ||
prefixLen = prefixLength[Prefix.TZ4]; | ||
} | ||
@@ -905,3 +943,3 @@ const hashed = hash(decoded, prefixLen); | ||
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 }; | ||
export { DeprecationError, InvalidAddressError, InvalidBlockHashError, InvalidChainIdError, InvalidContractAddressError, InvalidKeyError, InvalidKeyHashError, InvalidMessageError, InvalidOperationHashError, InvalidOperationKindError, InvalidProtocolHashError, InvalidPublicKeyError, InvalidSignatureError, Prefix, ProhibitedActionError, VERSION, ValidationResult, ValueConversionError, b58cdecode, b58cencode, b58decode, b58decodeL2Address, buf2hex, bytes2Char, char2Bytes, encodeExpr, encodeKey, encodeKeyHash, encodeL2Address, 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 |
@@ -28,2 +28,3 @@ (function (global, factory) { | ||
Prefix["P2PK"] = "p2pk"; | ||
Prefix["BLPK"] = "BLpk"; | ||
Prefix["EDESK"] = "edesk"; | ||
@@ -72,2 +73,3 @@ Prefix["SPESK"] = "spesk"; | ||
[exports.Prefix.P2PK]: new Uint8Array([3, 178, 139, 127]), | ||
[exports.Prefix.BLPK]: new Uint8Array([6, 149, 135, 204]), | ||
[exports.Prefix.EDESK]: new Uint8Array([7, 90, 60, 179, 41]), | ||
@@ -111,2 +113,4 @@ [exports.Prefix.SPESK]: new Uint8Array([0x09, 0xed, 0xf1, 0xae, 0x96]), | ||
[exports.Prefix.P2PK]: 33, | ||
//working with value in comment for base58.ml line 445 but not consistent with the three above | ||
[exports.Prefix.BLPK]: 48, | ||
[exports.Prefix.EDSIG]: 64, | ||
@@ -460,3 +464,3 @@ [exports.Prefix.SPSIG]: 64, | ||
const signaturePrefix = [exports.Prefix.EDSIG, exports.Prefix.P2SIG, exports.Prefix.SPSIG, exports.Prefix.SIG]; | ||
const pkPrefix = [exports.Prefix.EDPK, exports.Prefix.SPPK, exports.Prefix.P2PK]; | ||
const pkPrefix = [exports.Prefix.EDPK, exports.Prefix.SPPK, exports.Prefix.P2PK, exports.Prefix.BLPK]; | ||
const operationPrefix = [exports.Prefix.O]; | ||
@@ -630,4 +634,4 @@ const protocolPrefix = [exports.Prefix.P]; | ||
const VERSION = { | ||
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25", | ||
"version": "12.1.1" | ||
commitHash: '38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25', | ||
version: '12.1.1', | ||
}; | ||
@@ -693,3 +697,7 @@ | ||
}; | ||
const rollupPrefMap = { | ||
[prefix.txr1.toString()]: '02', | ||
}; | ||
const pref = prefixMap[new Uint8Array(buf.slice(0, 3)).toString()]; | ||
const rollupPref = rollupPrefMap[new Uint8Array(buf.slice(0, 4)).toString()]; | ||
if (pref) { | ||
@@ -700,2 +708,6 @@ // tz addresses | ||
} | ||
else if (rollupPref) { | ||
const hex = buf2hex(buf.slice(4)); | ||
return rollupPref + hex + '00'; | ||
} | ||
else { | ||
@@ -708,2 +720,13 @@ // other (kt addresses) | ||
* | ||
* @description b58 decode a string without predefined prefix | ||
* @param value | ||
* @returns string of bytes | ||
*/ | ||
function b58decodeL2Address(payload) { | ||
const buf = bs58check__default["default"].decode(payload); | ||
// tz4 address currently | ||
return buf2hex(buf.slice(3, 42)); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode an address using predefined prefix | ||
@@ -722,2 +745,6 @@ * | ||
} | ||
else if (value.substring(0, 2) === '02') { | ||
// 42 also works but the removes the 00 padding at the end | ||
return b58cencode(value.substring(2, value.length - 2), prefix.txr1); | ||
} | ||
return b58cencode(value.substring(2, 42), prefix.KT); | ||
@@ -727,2 +754,11 @@ } | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
* @param value Address to base58 encode (tz4) hex dec | ||
* @returns return address | ||
*/ | ||
function encodeL2Address(value) { | ||
return b58cencode(value, prefix.tz4); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode a key according to its prefix | ||
@@ -792,3 +828,2 @@ * | ||
*/ | ||
// TODO Zainen check use | ||
const mic2arr = function me2(s) { | ||
@@ -885,2 +920,5 @@ let ret = []; | ||
break; | ||
case exports.Prefix.BLPK: | ||
encodingPrefix = prefix[exports.Prefix.TZ4]; | ||
prefixLen = prefixLength[exports.Prefix.TZ4]; | ||
} | ||
@@ -929,2 +967,3 @@ const hashed = blake2b.hash(decoded, prefixLen); | ||
exports.b58decode = b58decode; | ||
exports.b58decodeL2Address = b58decodeL2Address; | ||
exports.buf2hex = buf2hex; | ||
@@ -936,2 +975,3 @@ exports.bytes2Char = bytes2Char; | ||
exports.encodeKeyHash = encodeKeyHash; | ||
exports.encodeL2Address = encodeL2Address; | ||
exports.encodeOpHash = encodeOpHash; | ||
@@ -938,0 +978,0 @@ exports.encodePubKey = encodePubKey; |
@@ -14,2 +14,3 @@ export declare enum Prefix { | ||
P2PK = "p2pk", | ||
BLPK = "BLpk", | ||
EDESK = "edesk", | ||
@@ -57,2 +58,3 @@ SPESK = "spesk", | ||
p2pk: Uint8Array; | ||
BLpk: Uint8Array; | ||
edesk: Uint8Array; | ||
@@ -59,0 +61,0 @@ spesk: Uint8Array; |
@@ -49,2 +49,9 @@ /** | ||
* | ||
* @description b58 decode a string without predefined prefix | ||
* @param value | ||
* @returns string of bytes | ||
*/ | ||
export declare function b58decodeL2Address(payload: string): string; | ||
/** | ||
* | ||
* @description Base58 encode an address using predefined prefix | ||
@@ -57,2 +64,9 @@ * | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
* @param value Address to base58 encode (tz4) hex dec | ||
* @returns return address | ||
*/ | ||
export declare function encodeL2Address(value: string): string; | ||
/** | ||
* | ||
* @description Base58 encode a key according to its prefix | ||
@@ -59,0 +73,0 @@ * |
import { Prefix } from './taquito-utils'; | ||
declare type PkPrefix = Prefix.EDPK | Prefix.SPPK | Prefix.P2PK; | ||
declare type PkPrefix = Prefix.EDPK | Prefix.SPPK | Prefix.P2PK | Prefix.BLPK; | ||
/** | ||
@@ -4,0 +4,0 @@ * @description Verify signature of a payload |
{ | ||
"name": "@taquito/utils", | ||
"version": "12.1.1", | ||
"version": "13.0.0-beta-RC.0", | ||
"description": "converts michelson data and types into convenient JS/TS objects", | ||
@@ -102,6 +102,5 @@ "keywords": [ | ||
"ts-toolbelt": "^9.6.0", | ||
"typedoc": "^0.20.36", | ||
"typescript": "~4.1.5" | ||
}, | ||
"gitHead": "e97d6f77d990f91b4e407f4e7b7f8f3785edb2ba" | ||
"gitHead": "d9034944abf0efab2478e61f35614b1aef397cec" | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
272759
27
3671
2
1