Comparing version 2.0.0 to 3.0.0
@@ -0,1 +1,6 @@ | ||
3.0.0 / 2018-06-05 | ||
------------------ | ||
- Drop support for Node versions less than v6 | ||
- Add support for ZCash and other coins with multibyte public versions | ||
2.0.0 / 2016-04-27 | ||
@@ -2,0 +7,0 @@ ------------------ |
@@ -26,3 +26,4 @@ var assert = require('assert') | ||
Object.defineProperty(CoinKey.prototype, 'versions', { | ||
enumerable: true, configurable: true, | ||
enumerable: true, | ||
configurable: true, | ||
get: function () { | ||
@@ -44,3 +45,4 @@ return this._versions | ||
get: function () { | ||
return cs.encode(this.pubKeyHash, this.versions.public) | ||
var bufVersion = util.bufferizeVersion(this.versions.public) | ||
return cs.encode(this.pubKeyHash, bufVersion) | ||
} | ||
@@ -47,0 +49,0 @@ }) |
@@ -7,5 +7,5 @@ // poor man's clone | ||
function isArrayish (maybeArray) { | ||
return Array.isArray(maybeArray) | ||
|| (maybeArray instanceof Uint8Array) | ||
|| Buffer.isBuffer(maybeArray) | ||
return Array.isArray(maybeArray) || | ||
(maybeArray instanceof Uint8Array) || | ||
Buffer.isBuffer(maybeArray) | ||
} | ||
@@ -27,6 +27,30 @@ | ||
function bufferizeVersion (version) { | ||
if (typeof version === 'string') return hexStringToBuffer(version) | ||
if (typeof version === 'number') return beUIntToBuffer(version) | ||
throw new Error('invalid version type.') | ||
} | ||
// accepts hex string sequence with or without 0x prefix | ||
function hexStringToBuffer (input) { | ||
var isValidRE = /^(0x)?([\dA-Fa-f]{2})+$/g | ||
if (!isValidRE.test(input)) throw new Error('invalid hex string.') | ||
return Buffer.from(input.slice(input.slice(0, 2) === '0x' ? 2 : 0), 'hex') | ||
} | ||
function beUIntToBuffer (num) { | ||
var length | ||
if (num === 0) length = 1 | ||
else if (num > 0) length = Math.ceil((Math.log(num + 1) / Math.log(2)) / 8) | ||
var buf = Buffer.alloc(length) | ||
buf.writeUIntBE(num, 0, length) | ||
return buf | ||
} | ||
module.exports = { | ||
clone: clone, | ||
isArrayish: isArrayish, | ||
normalizeVersions: normalizeVersions | ||
normalizeVersions: normalizeVersions, | ||
bufferizeVersion: bufferizeVersion | ||
} |
{ | ||
"name": "coinkey", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "JavaScript component for private keys, public keys, and addresess for crypto currencies such as Bitcoin, Litecoin, and Dogecoin", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -19,3 +19,3 @@ coinkey | ||
- license: **MIT** | ||
- versioning: [http://semver-ftw.org](http://semver-ftw.org) | ||
- versioning: **SemVer** | ||
@@ -22,0 +22,0 @@ |
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
13501
114
5
1