@onflow/rlp
Advanced tools
Comparing version 1.2.0-alpha.0 to 1.2.0
# @onflow/rlp | ||
## 1.2.0 | ||
### Minor Changes | ||
- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build | ||
- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript | ||
## 1.2.0-alpha.0 | ||
@@ -4,0 +12,0 @@ |
353
dist/rlp.js
@@ -15,23 +15,21 @@ 'use strict'; | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
*/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
**/ | ||
*/ | ||
function encode(input) { | ||
if (Array.isArray(input)) { | ||
var output = []; | ||
for (var i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
var buf = buffer.Buffer.concat(output); | ||
return buffer.Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
if (Array.isArray(input)) { | ||
const output = []; | ||
for (let i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
else { | ||
var inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 | ||
? inputBuf | ||
: buffer.Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
const buf = buffer.Buffer.concat(output); | ||
return buffer.Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
} else { | ||
const inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : buffer.Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
} | ||
/** | ||
@@ -43,18 +41,18 @@ * Parse integers. Check if there is no leading zeros | ||
function safeParseInt(v, base) { | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
return parseInt(v, base); | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
return parseInt(v, base); | ||
} | ||
function encodeLength(len, offset) { | ||
if (len < 56) { | ||
return buffer.Buffer.from([len + offset]); | ||
} | ||
else { | ||
var hexLength = intToHex(len); | ||
var lLength = hexLength.length / 2; | ||
var firstByte = intToHex(offset + 55 + lLength); | ||
return buffer.Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
if (len < 56) { | ||
return buffer.Buffer.from([len + offset]); | ||
} else { | ||
const hexLength = intToHex(len); | ||
const lLength = hexLength.length / 2; | ||
const firstByte = intToHex(offset + 55 + lLength); | ||
return buffer.Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
} | ||
/** | ||
@@ -68,3 +66,4 @@ * Built on top of rlp library, removing the BN dependency for the flow. | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
*/ | ||
/** | ||
@@ -74,20 +73,21 @@ * @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
**/ | ||
*/ | ||
function decode(input, stream) { | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
return decoded.data; | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
const inputBuffer = toBuffer(input); | ||
const decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
return decoded.data; | ||
} | ||
/** | ||
@@ -99,170 +99,157 @@ * Get the length of the RLP input | ||
function getLength(input) { | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} | ||
else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} | ||
else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
var llength = firstByte - 0xf6; | ||
var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
const inputBuffer = toBuffer(input); | ||
if (inputBuffer.length === 0) { | ||
return 0; | ||
} | ||
const firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} else { | ||
// a list over 55 bytes long | ||
const llength = firstByte - 0xf6; | ||
const length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
} | ||
/** Decode an input with RLP */ | ||
function _decode(input) { | ||
var length, llength, data, innerRemainder, d; | ||
var decoded = []; | ||
var firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1), | ||
}; | ||
let length, llength, data, innerRemainder, d; | ||
const decoded = []; | ||
const firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1) | ||
}; | ||
} else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = buffer.Buffer.from([]); | ||
} else { | ||
data = input.slice(1, length); | ||
} | ||
else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = buffer.Buffer.from([]); | ||
} | ||
else { | ||
data = input.slice(1, length); | ||
} | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length), | ||
}; | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength), | ||
}; | ||
return { | ||
data: data, | ||
remainder: input.slice(length) | ||
}; | ||
} else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length), | ||
}; | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength) | ||
}; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
var totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength), | ||
}; | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length) | ||
}; | ||
} else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
const totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength) | ||
}; | ||
} | ||
} | ||
/** Check if a string is prefixed by 0x */ | ||
function isHexPrefixed(str) { | ||
return str.slice(0, 2) === "0x"; | ||
return str.slice(0, 2) === "0x"; | ||
} | ||
/** Removes 0x from a given String */ | ||
function stripHexPrefix(str) { | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
} | ||
/** Transform an integer into its hexadecimal value */ | ||
function intToHex(integer) { | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
var hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
const hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
} | ||
/** Pad a string to be even */ | ||
function padToEven(a) { | ||
return a.length % 2 ? "0" + a : a; | ||
return a.length % 2 ? "0" + a : a; | ||
} | ||
/** Transform an integer into a Buffer */ | ||
function intToBuffer(integer) { | ||
var hex = intToHex(integer); | ||
return buffer.Buffer.from(hex, "hex"); | ||
const hex = intToHex(integer); | ||
return buffer.Buffer.from(hex, "hex"); | ||
} | ||
/** Transform anything into a Buffer */ | ||
function toBuffer(v) { | ||
if (!buffer.Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return buffer.Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} | ||
else { | ||
return buffer.Buffer.from(v); | ||
} | ||
} | ||
else if (typeof v === "number") { | ||
if (!v) { | ||
return buffer.Buffer.from([]); | ||
} | ||
else { | ||
return intToBuffer(v); | ||
} | ||
} | ||
else if (v === null || v === undefined) { | ||
return buffer.Buffer.from([]); | ||
} | ||
else if (v instanceof Uint8Array) { | ||
return buffer.Buffer.from(v); | ||
} | ||
else { | ||
throw new Error("invalid type"); | ||
} | ||
if (!buffer.Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return buffer.Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} else { | ||
return buffer.Buffer.from(v); | ||
} | ||
} else if (typeof v === "number") { | ||
if (!v) { | ||
return buffer.Buffer.from([]); | ||
} else { | ||
return intToBuffer(v); | ||
} | ||
} else if (v === null || v === undefined) { | ||
return buffer.Buffer.from([]); | ||
} else if (v instanceof Uint8Array) { | ||
return buffer.Buffer.from(v); | ||
} else { | ||
throw new Error("invalid type"); | ||
} | ||
return v; | ||
} | ||
return v; | ||
} | ||
Object.defineProperty(exports, 'Buffer', { | ||
enumerable: true, | ||
get: function () { return buffer.Buffer; } | ||
enumerable: true, | ||
get: function () { return buffer.Buffer; } | ||
}); | ||
@@ -269,0 +256,0 @@ exports.decode = decode; |
@@ -12,23 +12,21 @@ import { Buffer } from 'buffer'; | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
*/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
**/ | ||
*/ | ||
function encode(input) { | ||
if (Array.isArray(input)) { | ||
var output = []; | ||
for (var i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
var buf = Buffer.concat(output); | ||
return Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
if (Array.isArray(input)) { | ||
const output = []; | ||
for (let i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
else { | ||
var inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 | ||
? inputBuf | ||
: Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
const buf = Buffer.concat(output); | ||
return Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
} else { | ||
const inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
} | ||
/** | ||
@@ -40,18 +38,18 @@ * Parse integers. Check if there is no leading zeros | ||
function safeParseInt(v, base) { | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
return parseInt(v, base); | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
return parseInt(v, base); | ||
} | ||
function encodeLength(len, offset) { | ||
if (len < 56) { | ||
return Buffer.from([len + offset]); | ||
} | ||
else { | ||
var hexLength = intToHex(len); | ||
var lLength = hexLength.length / 2; | ||
var firstByte = intToHex(offset + 55 + lLength); | ||
return Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
if (len < 56) { | ||
return Buffer.from([len + offset]); | ||
} else { | ||
const hexLength = intToHex(len); | ||
const lLength = hexLength.length / 2; | ||
const firstByte = intToHex(offset + 55 + lLength); | ||
return Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
} | ||
/** | ||
@@ -65,3 +63,4 @@ * Built on top of rlp library, removing the BN dependency for the flow. | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
*/ | ||
/** | ||
@@ -71,20 +70,21 @@ * @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
**/ | ||
*/ | ||
function decode(input, stream) { | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
if (!input || input.length === 0) { | ||
return Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
return decoded.data; | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
if (!input || input.length === 0) { | ||
return Buffer.from([]); | ||
} | ||
const inputBuffer = toBuffer(input); | ||
const decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
return decoded.data; | ||
} | ||
/** | ||
@@ -96,165 +96,152 @@ * Get the length of the RLP input | ||
function getLength(input) { | ||
if (!input || input.length === 0) { | ||
return Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} | ||
else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} | ||
else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
var llength = firstByte - 0xf6; | ||
var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
const inputBuffer = toBuffer(input); | ||
if (inputBuffer.length === 0) { | ||
return 0; | ||
} | ||
const firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} else { | ||
// a list over 55 bytes long | ||
const llength = firstByte - 0xf6; | ||
const length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
} | ||
/** Decode an input with RLP */ | ||
function _decode(input) { | ||
var length, llength, data, innerRemainder, d; | ||
var decoded = []; | ||
var firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1), | ||
}; | ||
let length, llength, data, innerRemainder, d; | ||
const decoded = []; | ||
const firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1) | ||
}; | ||
} else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = Buffer.from([]); | ||
} else { | ||
data = input.slice(1, length); | ||
} | ||
else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = Buffer.from([]); | ||
} | ||
else { | ||
data = input.slice(1, length); | ||
} | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length), | ||
}; | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength), | ||
}; | ||
return { | ||
data: data, | ||
remainder: input.slice(length) | ||
}; | ||
} else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length), | ||
}; | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength) | ||
}; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
var totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength), | ||
}; | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length) | ||
}; | ||
} else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
const totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength) | ||
}; | ||
} | ||
} | ||
/** Check if a string is prefixed by 0x */ | ||
function isHexPrefixed(str) { | ||
return str.slice(0, 2) === "0x"; | ||
return str.slice(0, 2) === "0x"; | ||
} | ||
/** Removes 0x from a given String */ | ||
function stripHexPrefix(str) { | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
} | ||
/** Transform an integer into its hexadecimal value */ | ||
function intToHex(integer) { | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
var hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
const hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
} | ||
/** Pad a string to be even */ | ||
function padToEven(a) { | ||
return a.length % 2 ? "0" + a : a; | ||
return a.length % 2 ? "0" + a : a; | ||
} | ||
/** Transform an integer into a Buffer */ | ||
function intToBuffer(integer) { | ||
var hex = intToHex(integer); | ||
return Buffer.from(hex, "hex"); | ||
const hex = intToHex(integer); | ||
return Buffer.from(hex, "hex"); | ||
} | ||
/** Transform anything into a Buffer */ | ||
function toBuffer(v) { | ||
if (!Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} | ||
else { | ||
return Buffer.from(v); | ||
} | ||
} | ||
else if (typeof v === "number") { | ||
if (!v) { | ||
return Buffer.from([]); | ||
} | ||
else { | ||
return intToBuffer(v); | ||
} | ||
} | ||
else if (v === null || v === undefined) { | ||
return Buffer.from([]); | ||
} | ||
else if (v instanceof Uint8Array) { | ||
return Buffer.from(v); | ||
} | ||
else { | ||
throw new Error("invalid type"); | ||
} | ||
if (!Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} else { | ||
return Buffer.from(v); | ||
} | ||
} else if (typeof v === "number") { | ||
if (!v) { | ||
return Buffer.from([]); | ||
} else { | ||
return intToBuffer(v); | ||
} | ||
} else if (v === null || v === undefined) { | ||
return Buffer.from([]); | ||
} else if (v instanceof Uint8Array) { | ||
return Buffer.from(v); | ||
} else { | ||
throw new Error("invalid type"); | ||
} | ||
return v; | ||
} | ||
return v; | ||
} | ||
@@ -261,0 +248,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('buffer')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'buffer'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.onflowRlp = {}, global.buffer)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('buffer')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'buffer'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.onflowRlp = {}, global.buffer)); | ||
})(this, (function (exports, buffer) { 'use strict'; | ||
/** | ||
* Built on top of rlp library, removing the BN dependency for the flow. | ||
* Package : https://github.com/ethereumjs/rlp | ||
* RLP License : https://github.com/ethereumjs/rlp/blob/master/LICENSE | ||
* | ||
* ethereumjs/rlp is licensed under the | ||
* Mozilla Public License 2.0 | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
**/ | ||
function encode(input) { | ||
if (Array.isArray(input)) { | ||
var output = []; | ||
for (var i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
var buf = buffer.Buffer.concat(output); | ||
return buffer.Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
} | ||
else { | ||
var inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 | ||
? inputBuf | ||
: buffer.Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
/** | ||
* Built on top of rlp library, removing the BN dependency for the flow. | ||
* Package : https://github.com/ethereumjs/rlp | ||
* RLP License : https://github.com/ethereumjs/rlp/blob/master/LICENSE | ||
* | ||
* ethereumjs/rlp is licensed under the | ||
* Mozilla Public License 2.0 | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
*/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @returns returns buffer of encoded data | ||
*/ | ||
function encode(input) { | ||
if (Array.isArray(input)) { | ||
const output = []; | ||
for (let i = 0; i < input.length; i++) { | ||
output.push(encode(input[i])); | ||
} | ||
const buf = buffer.Buffer.concat(output); | ||
return buffer.Buffer.concat([encodeLength(buf.length, 192), buf]); | ||
} else { | ||
const inputBuf = toBuffer(input); | ||
return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : buffer.Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]); | ||
} | ||
/** | ||
* Parse integers. Check if there is no leading zeros | ||
* @param v The value to parse | ||
* @param base The base to parse the integer into | ||
*/ | ||
function safeParseInt(v, base) { | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
return parseInt(v, base); | ||
} | ||
/** | ||
* Parse integers. Check if there is no leading zeros | ||
* @param v The value to parse | ||
* @param base The base to parse the integer into | ||
*/ | ||
function safeParseInt(v, base) { | ||
if (v.slice(0, 2) === "00") { | ||
throw new Error("invalid RLP: extra zeros"); | ||
} | ||
function encodeLength(len, offset) { | ||
if (len < 56) { | ||
return buffer.Buffer.from([len + offset]); | ||
} | ||
else { | ||
var hexLength = intToHex(len); | ||
var lLength = hexLength.length / 2; | ||
var firstByte = intToHex(offset + 55 + lLength); | ||
return buffer.Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
return parseInt(v, base); | ||
} | ||
function encodeLength(len, offset) { | ||
if (len < 56) { | ||
return buffer.Buffer.from([len + offset]); | ||
} else { | ||
const hexLength = intToHex(len); | ||
const lLength = hexLength.length / 2; | ||
const firstByte = intToHex(offset + 55 + lLength); | ||
return buffer.Buffer.from(firstByte + hexLength, "hex"); | ||
} | ||
/** | ||
* Built on top of rlp library, removing the BN dependency for the flow. | ||
* Package : https://github.com/ethereumjs/rlp | ||
* RLP License : https://github.com/ethereumjs/rlp/blob/master/LICENSE | ||
* | ||
* ethereumjs/rlp is licensed under the | ||
* Mozilla Public License 2.0 | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
**/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @param stream Is the input a stream (false by default) | ||
* @returns returns buffer of encoded data | ||
**/ | ||
function decode(input, stream) { | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
return decoded.data; | ||
} | ||
/** | ||
* Built on top of rlp library, removing the BN dependency for the flow. | ||
* Package : https://github.com/ethereumjs/rlp | ||
* RLP License : https://github.com/ethereumjs/rlp/blob/master/LICENSE | ||
* | ||
* ethereumjs/rlp is licensed under the | ||
* Mozilla Public License 2.0 | ||
* Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. | ||
*/ | ||
/** | ||
* @param input - will be converted to buffer | ||
* @param stream Is the input a stream (false by default) | ||
* @returns returns buffer of encoded data | ||
*/ | ||
function decode(input, stream) { | ||
if (stream === void 0) { | ||
stream = false; | ||
} | ||
/** | ||
* Get the length of the RLP input | ||
* @param input | ||
* @returns The length of the input or an empty Buffer if no input | ||
*/ | ||
function getLength(input) { | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
var inputBuffer = toBuffer(input); | ||
var firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} | ||
else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} | ||
else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
var llength = firstByte - 0xf6; | ||
var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
if (!input || input.length === 0) { | ||
return buffer.Buffer.from([]); | ||
} | ||
/** Decode an input with RLP */ | ||
function _decode(input) { | ||
var length, llength, data, innerRemainder, d; | ||
var decoded = []; | ||
var firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1), | ||
}; | ||
} | ||
else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = buffer.Buffer.from([]); | ||
} | ||
else { | ||
data = input.slice(1, length); | ||
} | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length), | ||
}; | ||
} | ||
else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength), | ||
}; | ||
} | ||
else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length), | ||
}; | ||
} | ||
else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
var totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength), | ||
}; | ||
} | ||
const inputBuffer = toBuffer(input); | ||
const decoded = _decode(inputBuffer); | ||
if (stream) { | ||
return decoded; | ||
} | ||
/** Check if a string is prefixed by 0x */ | ||
function isHexPrefixed(str) { | ||
return str.slice(0, 2) === "0x"; | ||
if (decoded.remainder.length !== 0) { | ||
throw new Error("invalid remainder"); | ||
} | ||
/** Removes 0x from a given String */ | ||
function stripHexPrefix(str) { | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
return decoded.data; | ||
} | ||
/** | ||
* Get the length of the RLP input | ||
* @param input | ||
* @returns The length of the input or an empty Buffer if no input | ||
*/ | ||
function getLength(input) { | ||
const inputBuffer = toBuffer(input); | ||
if (inputBuffer.length === 0) { | ||
return 0; | ||
} | ||
/** Transform an integer into its hexadecimal value */ | ||
function intToHex(integer) { | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
var hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
const firstByte = inputBuffer[0]; | ||
if (firstByte <= 0x7f) { | ||
return inputBuffer.length; | ||
} else if (firstByte <= 0xb7) { | ||
return firstByte - 0x7f; | ||
} else if (firstByte <= 0xbf) { | ||
return firstByte - 0xb6; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
return firstByte - 0xbf; | ||
} else { | ||
// a list over 55 bytes long | ||
const llength = firstByte - 0xf6; | ||
const length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16); | ||
return llength + length; | ||
} | ||
/** Pad a string to be even */ | ||
function padToEven(a) { | ||
return a.length % 2 ? "0" + a : a; | ||
} | ||
/** Decode an input with RLP */ | ||
function _decode(input) { | ||
let length, llength, data, innerRemainder, d; | ||
const decoded = []; | ||
const firstByte = input[0]; | ||
if (firstByte <= 0x7f) { | ||
// a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. | ||
return { | ||
data: input.slice(0, 1), | ||
remainder: input.slice(1) | ||
}; | ||
} else if (firstByte <= 0xb7) { | ||
// string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string | ||
// The range of the first byte is [0x80, 0xb7] | ||
length = firstByte - 0x7f; | ||
// set 0x80 null to 0 | ||
if (firstByte === 0x80) { | ||
data = buffer.Buffer.from([]); | ||
} else { | ||
data = input.slice(1, length); | ||
} | ||
if (length === 2 && data[0] < 0x80) { | ||
throw new Error("invalid rlp encoding: byte must be less 0x80"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length) | ||
}; | ||
} else if (firstByte <= 0xbf) { | ||
llength = firstByte - 0xb6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
data = input.slice(llength, length + llength); | ||
if (data.length < length) { | ||
throw new Error("invalid RLP"); | ||
} | ||
return { | ||
data: data, | ||
remainder: input.slice(length + llength) | ||
}; | ||
} else if (firstByte <= 0xf7) { | ||
// a list between 0-55 bytes long | ||
length = firstByte - 0xbf; | ||
innerRemainder = input.slice(1, length); | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(length) | ||
}; | ||
} else { | ||
// a list over 55 bytes long | ||
llength = firstByte - 0xf6; | ||
length = safeParseInt(input.slice(1, llength).toString("hex"), 16); | ||
const totalLength = llength + length; | ||
if (totalLength > input.length) { | ||
throw new Error("invalid rlp: total length is larger than the data"); | ||
} | ||
innerRemainder = input.slice(llength, totalLength); | ||
if (innerRemainder.length === 0) { | ||
throw new Error("invalid rlp, List has a invalid length"); | ||
} | ||
while (innerRemainder.length) { | ||
d = _decode(innerRemainder); | ||
decoded.push(d.data); | ||
innerRemainder = d.remainder; | ||
} | ||
return { | ||
data: decoded, | ||
remainder: input.slice(totalLength) | ||
}; | ||
} | ||
/** Transform an integer into a Buffer */ | ||
function intToBuffer(integer) { | ||
var hex = intToHex(integer); | ||
return buffer.Buffer.from(hex, "hex"); | ||
} | ||
/** Check if a string is prefixed by 0x */ | ||
function isHexPrefixed(str) { | ||
return str.slice(0, 2) === "0x"; | ||
} | ||
/** Removes 0x from a given String */ | ||
function stripHexPrefix(str) { | ||
if (typeof str !== "string") { | ||
return str; | ||
} | ||
/** Transform anything into a Buffer */ | ||
function toBuffer(v) { | ||
if (!buffer.Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return buffer.Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} | ||
else { | ||
return buffer.Buffer.from(v); | ||
} | ||
} | ||
else if (typeof v === "number") { | ||
if (!v) { | ||
return buffer.Buffer.from([]); | ||
} | ||
else { | ||
return intToBuffer(v); | ||
} | ||
} | ||
else if (v === null || v === undefined) { | ||
return buffer.Buffer.from([]); | ||
} | ||
else if (v instanceof Uint8Array) { | ||
return buffer.Buffer.from(v); | ||
} | ||
else { | ||
throw new Error("invalid type"); | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
} | ||
/** Transform an integer into its hexadecimal value */ | ||
function intToHex(integer) { | ||
if (integer < 0) { | ||
throw new Error("Invalid integer as argument, must be unsigned!"); | ||
} | ||
const hex = integer.toString(16); | ||
return hex.length % 2 ? "0" + hex : hex; | ||
} | ||
/** Pad a string to be even */ | ||
function padToEven(a) { | ||
return a.length % 2 ? "0" + a : a; | ||
} | ||
/** Transform an integer into a Buffer */ | ||
function intToBuffer(integer) { | ||
const hex = intToHex(integer); | ||
return buffer.Buffer.from(hex, "hex"); | ||
} | ||
/** Transform anything into a Buffer */ | ||
function toBuffer(v) { | ||
if (!buffer.Buffer.isBuffer(v)) { | ||
if (typeof v === "string") { | ||
if (isHexPrefixed(v)) { | ||
return buffer.Buffer.from(padToEven(stripHexPrefix(v)), "hex"); | ||
} else { | ||
return buffer.Buffer.from(v); | ||
} | ||
return v; | ||
} else if (typeof v === "number") { | ||
if (!v) { | ||
return buffer.Buffer.from([]); | ||
} else { | ||
return intToBuffer(v); | ||
} | ||
} else if (v === null || v === undefined) { | ||
return buffer.Buffer.from([]); | ||
} else if (v instanceof Uint8Array) { | ||
return buffer.Buffer.from(v); | ||
} else { | ||
throw new Error("invalid type"); | ||
} | ||
} | ||
return v; | ||
} | ||
Object.defineProperty(exports, 'Buffer', { | ||
enumerable: true, | ||
get: function () { return buffer.Buffer; } | ||
}); | ||
exports.decode = decode; | ||
exports.encode = encode; | ||
exports.getLength = getLength; | ||
exports.toBuffer = toBuffer; | ||
Object.defineProperty(exports, 'Buffer', { | ||
enumerable: true, | ||
get: function () { return buffer.Buffer; } | ||
}); | ||
exports.decode = decode; | ||
exports.encode = encode; | ||
exports.getLength = getLength; | ||
exports.toBuffer = toBuffer; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=rlp.umd.js.map |
{ | ||
"name": "@onflow/rlp", | ||
"version": "1.2.0-alpha.0", | ||
"version": "1.2.0", | ||
"description": "Port of ethereumjs/rlp", | ||
@@ -16,3 +16,9 @@ "license": "MPL-2.0", | ||
"devDependencies": { | ||
"@onflow/fcl-bundle": "^1.4.0-alpha.0", | ||
"@babel/preset-typescript": "^7.22.5", | ||
"@onflow/fcl-bundle": "^1.4.0", | ||
"@types/jest": "^29.5.3", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "^8.47.0", | ||
"eslint-plugin-jsdoc": "^46.4.6", | ||
"jest": "^29.5.0" | ||
@@ -24,3 +30,3 @@ }, | ||
"unpkg": "dist/rlp.umd.js", | ||
"types": "dist/types/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
@@ -27,0 +33,0 @@ "prepublishOnly": "npm test && npm run build", |
@@ -9,4 +9,4 @@ { | ||
// next to the .js files | ||
"outDir": "types", | ||
"outDir": "types" | ||
} | ||
} | ||
} |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
103175
16
863
0
0
8