From 004972af672e8247744aed2db5af0b2825c59c0c Mon Sep 17 00:00:00 2001 From: "tboydston tracey@traceyboyd.me" Date: Mon, 2 Jan 2023 08:50:40 +0800 Subject: [PATCH] Fix dependency security issue. Bump version. --- hdAddressGenerator.js | 12 +- node_modules/base-x/README.md | 2 +- node_modules/base-x/package.json | 2 +- node_modules/base-x/src/index.js | 4 - node_modules/bignumber.js/CHANGELOG.md | 11 + node_modules/bignumber.js/LICENCE | 23 - node_modules/bignumber.js/README.md | 113 +- node_modules/bignumber.js/bignumber.d.ts | 2 +- node_modules/bignumber.js/bignumber.js | 22 +- node_modules/bignumber.js/bignumber.min.js | 1 - .../bignumber.js/bignumber.min.js.map | 1 - node_modules/bignumber.js/bignumber.mjs | 25 +- node_modules/bignumber.js/doc/API.html | 20 +- node_modules/bignumber.js/package.json | 5 +- node_modules/bip174/package.json | 5 +- .../src/lib/converter/global/globalXpub.js | 2 +- .../bip174/src/lib/converter/index.d.ts | 38 + .../bip174/src/lib/converter/index.js | 24 + .../lib/converter/shared/bip32Derivation.d.ts | 3 +- .../lib/converter/shared/bip32Derivation.js | 15 +- node_modules/bip174/src/lib/interfaces.d.ts | 33 + .../bip174/src/lib/parser/fromBuffer.js | 68 + node_modules/bip174/src/lib/typeFields.d.ts | 13 +- node_modules/bip174/src/lib/typeFields.js | 20 + node_modules/bip174/src/lib/utils.js | 2 +- node_modules/bip39/README.md | 5 + node_modules/bip39/package.json | 2 +- node_modules/bip39/src/_wordlists.js | 5 + node_modules/bip39/src/index.js | 2 +- node_modules/bip44-constants/index.js | 45 +- node_modules/bip44-constants/package.json | 2 +- node_modules/bn.js/README.md | 49 +- node_modules/bn.js/lib/bn.js | 366 +- node_modules/bn.js/package.json | 39 +- node_modules/bn.js/util/genCombMulTo.js | 65 - node_modules/bn.js/util/genCombMulTo10.js | 65 - node_modules/chai/README.md | 2 +- node_modules/chai/chai.js | 1489 ++-- node_modules/chai/karma.conf.js | 8 +- node_modules/chai/karma.sauce.js | 2 +- node_modules/chai/lib/chai.js | 2 +- node_modules/chai/lib/chai/assertion.js | 14 +- node_modules/chai/lib/chai/core/assertions.js | 87 +- .../chai/lib/chai/interface/assert.js | 12 +- .../chai/lib/chai/interface/should.js | 3 +- node_modules/chai/lib/chai/utils/index.js | 6 + node_modules/chai/lib/chai/utils/inspect.js | 355 +- node_modules/chai/package.json | 24 +- node_modules/chai/sauce.browsers.js | 4 + node_modules/deep-eql/README.md | 45 +- node_modules/deep-eql/deep-eql.js | 834 +-- node_modules/deep-eql/index.js | 52 +- node_modules/deep-eql/package.json | 69 +- node_modules/nan/CHANGELOG.md | 14 +- node_modules/nan/LICENSE.md | 6 +- node_modules/nan/README.md | 9 +- node_modules/nan/doc/json.md | 2 +- node_modules/nan/doc/script.md | 24 +- node_modules/nan/nan.h | 62 +- node_modules/nan/nan_callbacks.h | 4 + node_modules/nan/package.json | 6 +- node_modules/pbkdf2/lib/async.js | 24 +- node_modules/pbkdf2/lib/default-encoding.js | 4 +- node_modules/pbkdf2/package.json | 2 +- node_modules/tiny-secp256k1/build/config.gypi | 334 +- package-lock.json | 6420 ++--------------- package.json | 6 +- 67 files changed, 2999 insertions(+), 8037 deletions(-) delete mode 100644 node_modules/bignumber.js/LICENCE delete mode 100644 node_modules/bignumber.js/bignumber.min.js delete mode 100644 node_modules/bignumber.js/bignumber.min.js.map delete mode 100644 node_modules/bn.js/util/genCombMulTo.js delete mode 100644 node_modules/bn.js/util/genCombMulTo10.js diff --git a/hdAddressGenerator.js b/hdAddressGenerator.js index 353e197..3e69b3a 100644 --- a/hdAddressGenerator.js +++ b/hdAddressGenerator.js @@ -9,8 +9,9 @@ const bip38 = require("bip38"); const edHd = require("ed25519-hd-key"); const basex = require("base-x"); const bs58 = require("bs58"); +const bs58check = require("bs58check"); + const createHash = require("create-hash"); -const pubConvert = require("pubkeyconverter"); // Coin specific libs const bitcoin = require("bitcoinjs-lib"); @@ -102,7 +103,7 @@ class AddressGenerator { // If a BIP 49 'y' or BIP 141 'z' xpub is submitted it is converted to an 'x' pub it can be processed. this.extPub = extPub; - this.xpub = extPub === false ? false : pubConvert.pubToXpub(extPub); + this.xpub = extPub === false ? false : this.pubToXpub(extPub); if (seed !== false) { this.seed = Buffer.from(seed, "hex"); @@ -892,6 +893,13 @@ class AddressGenerator { }/${index}${this.hardened ? "'" : ""}`; } + pubToXpub(pub) { + let data = bs58check.decode(pub); + data = data.slice(4); + data = Buffer.concat([Buffer.from("0488b21e", "hex"), data]); + return bs58check.encode(data); + } + /** * Checks if a coin has a test in the 'coins' folder. * @param {string} coinName Short name of the coin. diff --git a/node_modules/base-x/README.md b/node_modules/base-x/README.md index a6c3ce0..042647c 100644 --- a/node_modules/base-x/README.md +++ b/node_modules/base-x/README.md @@ -43,7 +43,7 @@ Base | Alphabet 58 | `123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz` 62 | `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` 64 | `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/` -66 | `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~` +67 | `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~` ## How it works diff --git a/node_modules/base-x/package.json b/node_modules/base-x/package.json index 7263d4c..167bca8 100644 --- a/node_modules/base-x/package.json +++ b/node_modules/base-x/package.json @@ -1,6 +1,6 @@ { "name": "base-x", - "version": "3.0.8", + "version": "3.0.9", "description": "Fast base encoding / decoding of any given alphabet", "keywords": [ "base-x", diff --git a/node_modules/base-x/src/index.js b/node_modules/base-x/src/index.js index 9d82be6..5b695f1 100644 --- a/node_modules/base-x/src/index.js +++ b/node_modules/base-x/src/index.js @@ -66,8 +66,6 @@ function base (ALPHABET) { if (typeof source !== 'string') { throw new TypeError('Expected String') } if (source.length === 0) { return _Buffer.alloc(0) } var psz = 0 - // Skip leading spaces. - if (source[psz] === ' ') { return } // Skip and count leading '1's. var zeroes = 0 var length = 0 @@ -94,8 +92,6 @@ function base (ALPHABET) { length = i psz++ } - // Skip trailing spaces. - if (source[psz] === ' ') { return } // Skip leading zeroes in b256. var it4 = size - length while (it4 !== size && b256[it4] === 0) { diff --git a/node_modules/bignumber.js/CHANGELOG.md b/node_modules/bignumber.js/CHANGELOG.md index e288a93..970c229 100644 --- a/node_modules/bignumber.js/CHANGELOG.md +++ b/node_modules/bignumber.js/CHANGELOG.md @@ -1,3 +1,14 @@ +#### 9.0.2 +* 12/12/21 +* #250 [BUGFIX] Allow use of user-defined alphabet for base 10. +* #295 Remove *bignumber.min.js* and amend *README.md*. +* Update *.travis.yml* and *LICENCE.md*. + +#### 9.0.1 +* 28/09/20 +* [BUGFIX] #276 Correct `sqrt` initial estimate. +* Update *.travis.yml*, *LICENCE.md* and *README.md*. + #### 9.0.0 * 27/05/2019 * For compatibility with legacy browsers, remove `Symbol` references. diff --git a/node_modules/bignumber.js/LICENCE b/node_modules/bignumber.js/LICENCE deleted file mode 100644 index 87a9b15..0000000 --- a/node_modules/bignumber.js/LICENCE +++ /dev/null @@ -1,23 +0,0 @@ -The MIT Licence. - -Copyright (c) 2019 Michael Mclaughlin - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/node_modules/bignumber.js/README.md b/node_modules/bignumber.js/README.md index fc3c84c..528cb7c 100644 --- a/node_modules/bignumber.js/README.md +++ b/node_modules/bignumber.js/README.md @@ -2,63 +2,80 @@ A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. -[![Build Status](https://travis-ci.org/MikeMcl/bignumber.js.svg)](https://travis-ci.org/MikeMcl/bignumber.js) +[![npm version](https://img.shields.io/npm/v/bignumber.js.svg)](https://www.npmjs.com/package/bignumber.js) +[![npm downloads](https://img.shields.io/npm/dw/bignumber.js)](https://www.npmjs.com/package/bignumber.js)
## Features - - Integers and decimals - - Simple API but full-featured - - Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal - - 8 KB minified and gzipped - - Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type - - Includes a `toFraction` and a correctly-rounded `squareRoot` method - - Supports cryptographically-secure pseudo-random number generation - - No dependencies - - Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only - - Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set +- Integers and decimals +- Simple API but full-featured +- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal +- 8 KB minified and gzipped +- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type +- Includes a `toFraction` and a correctly-rounded `squareRoot` method +- Supports cryptographically-secure pseudo-random number generation +- No dependencies +- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only +- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set ![API](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/API.png) If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/). It's less than half the size but only works with decimal numbers and only has half the methods. -It also does not allow `NaN` or `Infinity`, or have the configuration options of this library. +It also has fewer configuration options than this library, and does not allow `NaN` or `Infinity`. See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits. ## Load -The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*). +The library is the single JavaScript file *bignumber.js* or ES module *bignumber.mjs*. -Browser: +### Browser ```html ``` -[Node.js](http://nodejs.org): +> ES module + +```html + +``` + +### [Node.js](http://nodejs.org) ```bash -$ npm install bignumber.js +npm install bignumber.js ``` ```javascript const BigNumber = require('bignumber.js'); ``` -ES6 module: +> ES module ```javascript -import BigNumber from "./bignumber.mjs" +import BigNumber from "bignumber.js"; +// or maybe +import { BigNumber } from "bignumber.js"; +// else +import { BigNumber } from "./node_modules/bignumber.js/bignumber.mjs"; ``` -AMD loader libraries such as [requireJS](http://requirejs.org/): +### [Deno](https://deno.land/) ```javascript -require(['bignumber'], function(BigNumber) { - // Use BigNumber here in local scope. No global BigNumber. -}); +import BigNumber from 'https://raw.githubusercontent.com/mikemcl/bignumber.js/v9.0.2/bignumber.mjs'; +import BigNumber from 'https://unpkg.com/bignumber.js@latest/bignumber.mjs'; ``` ## Use @@ -112,7 +129,7 @@ b = new BigNumber('zz.9', 36) // "1295.25" c = a.plus(b) // "1306.25" ``` -Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting. +*Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when you want to limit the number of decimal places of the input value to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.* A BigNumber is immutable in the sense that it is not changed by its methods. @@ -147,7 +164,9 @@ x.toPrecision(5) // "255.50" x.toNumber() // 255.5 ``` - A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting. + A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). + +*Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when you want to limit the number of decimal places of the string to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.* ```javascript x.toString(16) // "ff.8" @@ -203,7 +222,7 @@ x.e // 2 exponent x.s // -1 sign ``` -For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration. +For advanced usage, multiple BigNumber constructors can be created, each with its own independent configuration. ```javascript // Set DECIMAL_PLACES for the original BigNumber constructor @@ -219,6 +238,12 @@ x.div(3) // '0.3333333333' y.div(3) // '0.33333' ``` +To avoid having to call `toString` or `valueOf` on a BigNumber to get its value in the Node.js REPL or when using `console.log` use + +```javascript +BigNumber.prototype[require('util').inspect.custom] = BigNumber.prototype.valueOf; +``` + For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory. ## Test @@ -227,39 +252,35 @@ The *test/modules* directory contains the test scripts for each method. The tests can be run with Node.js or a browser. For Node.js use - $ npm test +```bash +npm test +``` or - $ node test/test +```bash +node test/test +``` To test a single method, use, for example - $ node test/methods/toFraction +```bash +node test/methods/toFraction +``` For the browser, open *test/test.html*. -## Build - -For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed - - npm install uglify-js -g - -then - - npm run build +## Minify -will create *bignumber.min.js*. +To minify using, for example, [terser](https://github.com/terser/terser) -A source map will also be created in the root directory. - -## Feedback - -Open an issue, or email - -Michael +```bash +npm install -g terser +``` -M8ch88l@gmail.com +```bash +terser big.js -c -m -o big.min.js +``` ## Licence diff --git a/node_modules/bignumber.js/bignumber.d.ts b/node_modules/bignumber.js/bignumber.d.ts index ac6a3e4..272bd5b 100644 --- a/node_modules/bignumber.js/bignumber.d.ts +++ b/node_modules/bignumber.js/bignumber.d.ts @@ -1088,7 +1088,7 @@ export declare class BigNumber implements BigNumber.Instance { * 0.1 + 0.2 // 0.30000000000000004 * x = new BigNumber(0.1) * y = x.plus(0.2) // '0.3' - * BigNumber(0.7).plus(x).plus(y) // '1' + * BigNumber(0.7).plus(x).plus(y) // '1.1' * x.plus('0.1', 8) // '0.225' * ``` * diff --git a/node_modules/bignumber.js/bignumber.js b/node_modules/bignumber.js/bignumber.js index f2ea883..54059f3 100644 --- a/node_modules/bignumber.js/bignumber.js +++ b/node_modules/bignumber.js/bignumber.js @@ -2,10 +2,10 @@ 'use strict'; /* - * bignumber.js v9.0.0 + * bignumber.js v9.0.2 * A JavaScript library for arbitrary-precision arithmetic. * https://github.com/MikeMcl/bignumber.js - * Copyright (c) 2019 Michael Mclaughlin + * Copyright (c) 2021 Michael Mclaughlin * MIT Licensed. * * BigNumber.prototype methods | BigNumber methods @@ -145,7 +145,7 @@ // The maximum number of significant digits of the result of the exponentiatedBy operation. // If POW_PRECISION is 0, there will be unlimited significant digits. - POW_PRECISION = 0, // 0 to MAX + POW_PRECISION = 0, // 0 to MAX // The format specification used by the BigNumber.prototype.toFormat method. FORMAT = { @@ -155,14 +155,15 @@ groupSeparator: ',', decimalSeparator: '.', fractionGroupSize: 0, - fractionGroupSeparator: '\xA0', // non-breaking space + fractionGroupSeparator: '\xA0', // non-breaking space suffix: '' }, // The alphabet used for base conversion. It must be at least 2 characters long, with no '+', // '-', '.', whitespace, or repeated character. // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' - ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz', + alphabetHasNormalDecimalDigits = true; //------------------------------------------------------------------------------------------ @@ -252,7 +253,7 @@ // Allow exponential notation to be used with base 10 argument, while // also rounding to DECIMAL_PLACES as with other bases. - if (b == 10) { + if (b == 10 && alphabetHasNormalDecimalDigits) { x = new BigNumber(v); return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); } @@ -541,9 +542,10 @@ if (obj.hasOwnProperty(p = 'ALPHABET')) { v = obj[p]; - // Disallow if only one character, + // Disallow if less than two characters, // or if it contains '+', '-', '.', whitespace, or a repeated character. - if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) { + if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) { + alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789'; ALPHABET = v; } else { throw Error @@ -2396,7 +2398,7 @@ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); if (s == 1 / 0) { - n = '1e' + e; + n = '5e' + e; } else { n = s.toExponential(); n = n.slice(0, n.indexOf('e') + 1) + e; @@ -2718,7 +2720,7 @@ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, '0'); - } else if (b === 10) { + } else if (b === 10 && alphabetHasNormalDecimalDigits) { n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE); str = toFixedPoint(coeffToString(n.c), n.e, '0'); } else { diff --git a/node_modules/bignumber.js/bignumber.min.js b/node_modules/bignumber.js/bignumber.min.js deleted file mode 100644 index 2610072..0000000 --- a/node_modules/bignumber.js/bignumber.min.js +++ /dev/null @@ -1 +0,0 @@ -/* bignumber.js v9.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */!function(e){"use strict";var r,x=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,L=Math.ceil,U=Math.floor,I="[BigNumber Error] ",T=I+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,k=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],F=1e7,q=1e9;function j(e){var r=0|e;return 0o[s]^n?1:-1;return u==l?0:l(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else ry?c.c=c.e=null:e.ey)c.c=c.e=null;else if(oy?e.c=e.e=null:e.c=n=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5y?e.c=e.e=null:e.e>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw b=!1,Error(I+"crypto unavailable");for(r=crypto.randomBytes(i*=7);sn-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,g=e.indexOf("."),p=N,w=O;for(0<=g&&(u=E,E=0,e=e.replace(".",""),c=(h=new B(r)).pow(e.length-g),E=u,h.c=m(X($(c.c),c.e,"0"),10,n,d),h.e=h.c.length),f=u=(a=m(e,r,n,i?(o=S,d):(o=d,S))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(g<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,p,w,n)).c,l=c.r,f=c.e),g=a[s=f+p+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=g||l)&&(0==w||w==(c.s<0?3:2)):un;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(g=0,e="";g<=u;e+=o.charAt(a[g++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%F,c=r/F|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%F)+(t=c*o+(s=e[u]/F|0)*l)%F*F+f)/n|0)+(t/F|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=tr[i]?1:-1;break}return o}function _(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n](E[f]||0)&&s--,b<0)g.push(1),u=!0;else{for(v=E.length,O=A.length,b+=2,1<(l=U(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),O=A.length,v=E.length),m=O,w=(p=E.slice(0,O)).length;w=i/2&&N++;do{if(l=0,(o=R(A,p,O,w))<0){if(d=p[0],O!=w&&(d=d*i+(p[1]||0)),1<(l=U(d/N)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=p.length;1==R(c,p,a,w);)l--,_(c,Oo&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=U(i/2)))break;u=i%2}else if(D(e=e.times(n),e.e+1,1),14o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?D(l,E,O,void 0):l)},t.integerValue=function(e){var r=new B(this);return null==e?e=O:H(e,0,8),D(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new B(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new B(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new B(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=N+4,c=new B("0.5");if(1!==f||!s||!s[0])return new B(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+P(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new B(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new B(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e + * Copyright (c) 2021 Michael Mclaughlin * MIT Licensed. * * BigNumber.prototype methods | BigNumber methods @@ -48,7 +48,6 @@ var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, - mathceil = Math.ceil, mathfloor = Math.floor, @@ -143,7 +142,7 @@ function clone(configObject) { // The maximum number of significant digits of the result of the exponentiatedBy operation. // If POW_PRECISION is 0, there will be unlimited significant digits. - POW_PRECISION = 0, // 0 to MAX + POW_PRECISION = 0, // 0 to MAX // The format specification used by the BigNumber.prototype.toFormat method. FORMAT = { @@ -153,14 +152,15 @@ function clone(configObject) { groupSeparator: ',', decimalSeparator: '.', fractionGroupSize: 0, - fractionGroupSeparator: '\xA0', // non-breaking space + fractionGroupSeparator: '\xA0', // non-breaking space suffix: '' }, // The alphabet used for base conversion. It must be at least 2 characters long, with no '+', // '-', '.', whitespace, or repeated character. // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' - ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'; + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz', + alphabetHasNormalDecimalDigits = true; //------------------------------------------------------------------------------------------ @@ -250,7 +250,7 @@ function clone(configObject) { // Allow exponential notation to be used with base 10 argument, while // also rounding to DECIMAL_PLACES as with other bases. - if (b == 10) { + if (b == 10 && alphabetHasNormalDecimalDigits) { x = new BigNumber(v); return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); } @@ -404,7 +404,7 @@ function clone(configObject) { * MODULO_MODE {number} 0 to 9 * POW_PRECISION {number} 0 to MAX * ALPHABET {string} A string of two or more unique characters which does - * not contain '.'. + * not contain '.'. * FORMAT {object} An object with some of the following properties: * prefix {string} * groupSize {number} @@ -539,9 +539,10 @@ function clone(configObject) { if (obj.hasOwnProperty(p = 'ALPHABET')) { v = obj[p]; - // Disallow if only one character, + // Disallow if less than two characters, // or if it contains '+', '-', '.', whitespace, or a repeated character. - if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) { + if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) { + alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789'; ALPHABET = v; } else { throw Error @@ -2394,7 +2395,7 @@ function clone(configObject) { e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); if (s == 1 / 0) { - n = '1e' + e; + n = '5e' + e; } else { n = s.toExponential(); n = n.slice(0, n.indexOf('e') + 1) + e; @@ -2716,7 +2717,7 @@ function clone(configObject) { str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, '0'); - } else if (b === 10) { + } else if (b === 10 && alphabetHasNormalDecimalDigits) { n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE); str = toFixedPoint(coeffToString(n.c), n.e, '0'); } else { diff --git a/node_modules/bignumber.js/doc/API.html b/node_modules/bignumber.js/doc/API.html index 1ed4a87..0a73900 100644 --- a/node_modules/bignumber.js/doc/API.html +++ b/node_modules/bignumber.js/doc/API.html @@ -58,7 +58,7 @@